Merge "conman:  Don't log false "provisioning failed" messages."
diff --git a/cmds/castcheck b/cmds/castcheck
index 70080ec..40c90cc 100755
--- a/cmds/castcheck
+++ b/cmds/castcheck
@@ -13,7 +13,7 @@
 while IFS=";" read ip; do
   cast_devices="$cast_devices $ip"
 done<<EOT
-$($AVAHI -tpvlr _googlecast._tcp | grep "^=" | cut -d";" -f8 | sort)
+$(timeout 10 $AVAHI -tpvlr _googlecast._tcp | grep "^=" | cut -d";" -f8 | sort)
 EOT
 
 echo "Cast responses from:$cast_devices"
diff --git a/cmds/dialcheck.cc b/cmds/dialcheck.cc
index 17f8fbd..d5ea202 100644
--- a/cmds/dialcheck.cc
+++ b/cmds/dialcheck.cc
@@ -290,7 +290,7 @@
   int s4, s6;
 
   setlinebuf(stdout);
-  alarm(30);
+  alarm(10);
 
   while ((c = getopt(argc, argv, "t:")) != -1) {
     switch(c) {
diff --git a/cmds/soft_rc.py b/cmds/soft_rc.py
index 78bf5bc..685a069 100755
--- a/cmds/soft_rc.py
+++ b/cmds/soft_rc.py
@@ -142,7 +142,8 @@
 LOG_VERB = 3
 LOG_ALL  = 99
 
-SLEEP_BEFORE_RELEASE_TIME = 0.1  # secs
+SLEEP_BEFORE_RELEASE_TIME = 0.1   # secs
+SLEEP_BETWEEN_DIGITS_TIME = 0.25  # secs
 
 optspec = """
 soft_rc.py [options]
@@ -523,6 +524,7 @@
           for d in token:
             tok = "DIGIT_" + d
             self.SendKeyCode(tok, keymap.get(tok))
+            time.sleep(SLEEP_BETWEEN_DIGITS_TIME)
           self.SendKeyCode("OK", keymap.get("OK"))
 
         # regular key
diff --git a/diags/chameleon/sfp.c b/diags/chameleon/sfp.c
index e17e02d..1974d27 100644
--- a/diags/chameleon/sfp.c
+++ b/diags/chameleon/sfp.c
@@ -175,7 +175,7 @@
     temp = value[0] + ((float)value[1]) / 256.0;
   }
   vcc = ((float)((value[2] << 8) + value[3])) / 10000.0;
-  tx_bias = ((float)((value[4] << 8) + value[5])) / 1000.0;
+  tx_bias = (((float)((value[4] << 8) + value[5])) * 2) / 1000.0;
   tx_power = ((float)((value[6] << 8) + value[7])) / 10000.0;
   rx_power = ((float)((value[8] << 8) + value[9])) / 10000.0;
   mod_curr = ((float)((value[12] << 8) + value[13])) / 1000.0;
diff --git a/ginstall/ginstall.py b/ginstall/ginstall.py
index 1fc0976..f03dfa3 100755
--- a/ginstall/ginstall.py
+++ b/ginstall/ginstall.py
@@ -887,7 +887,19 @@
 
   uloader = loader = None
   uloadersig = FileWithSecureHash(StringIO.StringIO(''), 'badsig')
-  loadersig = FileWithSecureHash(StringIO.StringIO(''), 'badsig')
+
+  # TODO(cgibson): Modern ginstall images contain a loadersig. However, some
+  # releases, such as 42.33 for the FiberJack, do not have a loadersig. In 42.33
+  # this was okay since cwmp calls ginstall with the '--skiploadersig' flag.
+  # However, in later versions this flag was removed. Now if a new ginstall
+  # were to be used to downgrade to an older ginstall image, the install would
+  # fail. This seems to only affect the FiberJack platform, which is still
+  # running 42.33. This can safely be removed once all FiberJacks have been
+  # upgraded to gfiber-47 and are not anticipated to need to be downgraded back
+  # to 42.33.
+  loadersig = None
+  if not GetPlatform().startswith('GFLT'):
+    loadersig = FileWithSecureHash(StringIO.StringIO(''), 'badsig')
 
   for ti in tar:
     secure_hash = manifest.get('%s-sha1' % ti.name)
diff --git a/wifi/configs.py b/wifi/configs.py
index 97a27ce..a4f20b8 100644
--- a/wifi/configs.py
+++ b/wifi/configs.py
@@ -22,6 +22,7 @@
     'WifiHostapdDebug',
     'WifiShortAggTimeout',
     'WifiNoAggTimeout',
+    'WifiNoAliveMonitor',
 ]
 for _i in EXPERIMENTS:
   experiment.register(_i)
diff --git a/wifi/quantenna.py b/wifi/quantenna.py
index f3f96ef..bb541f5 100755
--- a/wifi/quantenna.py
+++ b/wifi/quantenna.py
@@ -54,11 +54,11 @@
 
 
 def _set_link_state(hif, state):
-  subprocess.check_output(['if' + state, hif])
+  subprocess.check_call(['if' + state, hif])
 
 
 def _ifplugd_action(hif, state):
-  subprocess.check_output(['/etc/ifplugd/ifplugd.action', hif, state])
+  subprocess.check_call(['/etc/ifplugd/ifplugd.action', hif, state])
 
 
 def _parse_scan_result(line):
diff --git a/wifi/wifi.py b/wifi/wifi.py
index 34bb5e8..644f483 100755
--- a/wifi/wifi.py
+++ b/wifi/wifi.py
@@ -61,6 +61,7 @@
 
 _FINGERPRINTS_DIRECTORY = '/tmp/wifi/fingerprints'
 _LOCKFILE = '/tmp/wifi/wifi'
+_PLATFORM_FILE = '/etc/platform'
 lockfile_taken = False
 
 
@@ -587,6 +588,18 @@
         return None
 
 
+def _is_wind_charger():
+  try:
+    etc_platform = open(_PLATFORM_FILE).read()
+    if etc_platform[:-1] == 'GFMN100':
+      return True
+    else:
+      return False
+  except IOError as e:
+    print('_is_wind_charger: cant open %s: %s' % (_PLATFORM_FILE, e.strerror))
+    return False
+
+
 def _start_hostapd(interface, config_filename, band, ssid):
   """Starts a babysat hostapd.
 
@@ -622,9 +635,15 @@
   alivemonitor_filename = utils.get_filename(
       'hostapd', utils.FILENAME_KIND.alive, interface, tmp=True)
 
+  # Don't use alivemonitor on Windcharger since no waveguide. b/32376077
+  if _is_wind_charger() or experiment.enabled('WifiNoAliveMonitor'):
+    alive_monitor = []
+  else:
+    alive_monitor = ['alivemonitor', alivemonitor_filename, '30', '2', '65']
+
   utils.log('Starting hostapd.')
-  utils.babysit(['alivemonitor', alivemonitor_filename, '30', '2', '65',
-                 'hostapd',
+  utils.babysit(alive_monitor +
+                ['hostapd',
                  '-A', alivemonitor_filename,
                  '-F', _FINGERPRINTS_DIRECTORY] +
                 bandsteering.hostapd_options(band, ssid) +
@@ -898,8 +917,12 @@
           "Couldn't stop hostapd to start wpa_supplicant.")
 
   if already_running:
+    subprocess.check_call(['ifdown', interface])
+    subprocess.check_call(['/etc/ifplugd/ifplugd.action', interface, 'down'])
     if not _reconfigure_wpa_supplicant(interface):
       raise utils.BinWifiException('Failed to reconfigure wpa_supplicant.')
+    subprocess.check_call(['ifup', interface])
+    subprocess.check_call(['/etc/ifplugd/ifplugd.action', interface, 'up'])
   elif not _start_wpa_supplicant(interface, tmp_config_filename):
     raise utils.BinWifiException(
         'wpa_supplicant failed to start.  Look at wpa_supplicant logs for '