shill: Makes progressive scan field trial more visible in logs.

The progressive scan field trial used to be shown in the logs only on
instantiation of the WiFi device so feedback would probably not provide
this information.  This CL makes the progressive scan group visible at
the start of every scan greatly increasing the likelihood of having this
data available in feedback logs.

BUG=None
TEST=unittest

Change-Id: I5c6d7b563002339740ae54e919843f218cd1ba8e
Reviewed-on: https://gerrit.chromium.org/gerrit/63360
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
Commit-Queue: Wade Guthrie <wdg@chromium.org>
diff --git a/wifi.cc b/wifi.cc
index e619a27..08f9084 100644
--- a/wifi.cc
+++ b/wifi.cc
@@ -117,6 +117,7 @@
       bgscan_signal_threshold_dbm_(kDefaultBgscanSignalThresholdDbm),
       scan_interval_seconds_(kDefaultScanIntervalSeconds),
       progressive_scan_enabled_(false),
+      scan_configuration_("Full scan"),
       netlink_manager_(NetlinkManager::GetInstance()),
       min_frequencies_to_scan_(kMinumumFrequenciesToScan),
       max_frequencies_to_scan_(std::numeric_limits<int>::max()),
@@ -164,6 +165,10 @@
   if (PathExists(FilePath(kProgressiveScanFlagFile))) {
     // Setup manually-enrolled progressive scan.
     progressive_scan_enabled_ = true;
+    scan_configuration_ = "Progressive scan (manual: min=4/max=MAX, 33%)";
+    min_frequencies_to_scan_ = 4;
+    max_frequencies_to_scan_ = std::numeric_limits<int>::max();
+    fraction_per_scan_ = .34;
   } else {
     // TODO(wdg): Remove after progressive scan field trial is over.
     // Only do the field trial if the user hasn't already enabled progressive
@@ -189,28 +194,39 @@
       max_frequencies_to_scan_ = 4;
       fraction_per_scan_ = .34;
       progressive_scan_enabled_ = true;
+      scan_configuration_ = "Progressive scan (field trial 1: min/max=4, 33%)";
       break;
     case '2':
       min_frequencies_to_scan_ = 4;
       max_frequencies_to_scan_ = 4;
       fraction_per_scan_ = .51;
       progressive_scan_enabled_ = true;
+      scan_configuration_ = "Progressive scan (field trial 2: min/max=4, 50%)";
       break;
     case '3':
       min_frequencies_to_scan_ = 8;
       max_frequencies_to_scan_ = 8;
       fraction_per_scan_ = .51;
       progressive_scan_enabled_ = true;
+      scan_configuration_ = "Progressive scan (field trial 3: min/max=8, 50%)";
       break;
     case '4':
       min_frequencies_to_scan_ = 8;
       max_frequencies_to_scan_ = 8;
       fraction_per_scan_ = 1.1;
       progressive_scan_enabled_ = true;
+      scan_configuration_ = "Progressive scan (field trial 4: min/max=8, 100%)";
       break;
-    case 'c':  // FALLTHROUGH.
-    case 'x':  // FALLTHROUGH.
+    case 'c':
+      progressive_scan_enabled_ = false;
+      scan_configuration_ = "Full scan (field trial c: control group)";
+      break;
+    case 'x':
+      progressive_scan_enabled_ = false;
+      scan_configuration_ = "Full scan (field trial x: default/disabled group)";
+      break;
     default:
+      scan_configuration_ = "Full scan (field trial unknown)";
       progressive_scan_enabled_ = false;
       break;
   }
@@ -306,6 +322,7 @@
   if (progressive_scan_enabled_ && scan_type == kProgressiveScan) {
     LOG(INFO) << __func__ << " [progressive] on " << link_name() << " from "
               << reason;
+    LOG(INFO) << scan_configuration_;
     if (!scan_session_) {
       // TODO(wdg): Perform in-depth testing to determine the best values for
       // the different scans. chromium:235293
@@ -340,6 +357,7 @@
               << " (progressive scan "
               << (progressive_scan_enabled_ ? "ENABLED" : "DISABLED")
               << ") from " << reason;
+    LOG(INFO) << scan_configuration_;
     // Needs to send a D-Bus message, but may be called from D-Bus
     // signal handler context (via Manager::RequestScan). So defer work
     // to event loop.
diff --git a/wifi.h b/wifi.h
index 1ff9a6a..2e307f5 100644
--- a/wifi.h
+++ b/wifi.h
@@ -487,6 +487,7 @@
   uint16 scan_interval_seconds_;
 
   bool progressive_scan_enabled_;
+  std::string scan_configuration_;
   NetlinkManager *netlink_manager_;
   std::set<uint16_t> all_scan_frequencies_;
   scoped_ptr<ScanSession> scan_session_;