/bin/wifi: Add option not to use freq_list with setclient.

When this option is set, --band will still select a radio, but the
actual band will not be strictly enforced with freq_list.

This is useful for testing bandsteering.

Change-Id: I93b41501185c89450739f50d0db2f3b9fb5de83c
diff --git a/wifi/configs.py b/wifi/configs.py
index 572b1c9..240dd63 100644
--- a/wifi/configs.py
+++ b/wifi/configs.py
@@ -370,20 +370,22 @@
   else:
     network_block_lines = wpa_network_lines(ssid, passphrase)
 
-  freq_list = ' '.join(autochannel.get_all_frequencies(opt.band))
+  freq_list = 'freq_list=' + ' '.join(autochannel.get_all_frequencies(opt.band))
+  use_freq_list = not opt.no_band_restriction
 
   network_block_lines.append('\tscan_ssid=1')
   if opt.bssid:
     network_block_lines.append('\tbssid=%s' %
                                utils.validate_and_sanitize_bssid(opt.bssid))
-  network_block_lines.append('\tfreq_list=' + freq_list)
+  if use_freq_list:
+    network_block_lines.append('\t' + freq_list)
   network_block = make_network_block(network_block_lines)
 
   lines = [
       'ctrl_interface=/var/run/wpa_supplicant',
       'ap_scan=1',
       'autoscan=exponential:1:30',
-      'freq_list=' + freq_list,
+      freq_list if use_freq_list else '',
       network_block
   ]
   return '\n'.join(lines)
diff --git a/wifi/configs_test.py b/wifi/configs_test.py
index bd28626..68e7b2a 100755
--- a/wifi/configs_test.py
+++ b/wifi/configs_test.py
@@ -59,6 +59,18 @@
 }}
 """
 
+_WPA_SUPPLICANT_CONFIG_NO_FREQ_LIST = """ctrl_interface=/var/run/wpa_supplicant
+ap_scan=1
+autoscan=exponential:1:30
+
+network={
+\tssid="some ssid"
+\t#psk="some passphrase"
+\tpsk=41821f7ca3ea5d85beea7644ed7e0fefebd654177fa06c26fbdfdc3c599a317f
+\tscan_ssid=1
+}
+"""
+
 
 @wvtest.wvtest
 def generate_wpa_supplicant_config_test():
@@ -92,6 +104,13 @@
         freq_list=_FREQ_LIST[band])
     wvtest.WVPASSEQ(want, got)
 
+    opt.no_band_restriction = True
+    opt.bssid = None
+    got = configs.generate_wpa_supplicant_config(
+        'some ssid', 'some passphrase', opt)
+    want = _WPA_SUPPLICANT_CONFIG_NO_FREQ_LIST
+    wvtest.WVPASSEQ(want, got)
+
 
 _PHY_INFO = """Wiphy phy0
   max # scan SSIDs: 4
@@ -415,6 +434,7 @@
     self.interface_suffix = ''
     self.client_isolation = False
     self.supports_provisioning = False
+    self.no_band_restriction = False
 
 
 def wpa_passphrase(ssid, passphrase):
diff --git a/wifi/wifi.py b/wifi/wifi.py
index 3773f03..81ccfb4 100755
--- a/wifi/wifi.py
+++ b/wifi/wifi.py
@@ -57,6 +57,7 @@
 scan-passive                      (Scan only) do not probe, scan passively
 scan-freq=                        (Scan only) limit scan to specific frequencies.
 supports-provisioning             Indicate via vendor IE that this AP supports provisioning.  Corresponds to feature ID 01 of OUI f4f5e8 at go/alphabet-ie-registry.
+no-band-restriction               For setclient only.  If set, let --band select the wifi radio but do not actually enforce it for multi-band radios.
 """
 
 _FINGERPRINTS_DIRECTORY = '/tmp/wifi/fingerprints'