Update RvR tests for WiFi 6 testing.
This CL update the Netgear RAX120 AP code to support either 11ac or 11ax
testing. The CL also adds 160 MHz support to WiFi RvR tests.
Test: Done
Bug: None
Signed-off-by: Omar El Ayach <oelayach@google.com>
Change-Id: I2040356719f8b526bbad6f120496a085fae2db56
diff --git a/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py b/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py
index b6f5381..a09893e 100755
--- a/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py
@@ -54,42 +54,27 @@
CNSS_DIAG_CONFIG_FILE = "cnss_diag.conf"
ROAMING_ATTN = {
- "AP1_on_AP2_off": [
- 0,
- 0,
- 95,
- 95
- ],
- "AP1_off_AP2_on": [
- 95,
- 95,
- 0,
- 0
- ],
- "default": [
- 0,
- 0,
- 0,
- 0
- ]
- }
+ "AP1_on_AP2_off": [0, 0, 95, 95],
+ "AP1_off_AP2_on": [95, 95, 0, 0],
+ "default": [0, 0, 0, 0]
+}
class WifiEnums():
- SSID_KEY = "SSID" # Used for Wifi & SoftAp
+ SSID_KEY = "SSID" # Used for Wifi & SoftAp
SSID_PATTERN_KEY = "ssidPattern"
NETID_KEY = "network_id"
- BSSID_KEY = "BSSID" # Used for Wifi & SoftAp
+ BSSID_KEY = "BSSID" # Used for Wifi & SoftAp
BSSID_PATTERN_KEY = "bssidPattern"
- PWD_KEY = "password" # Used for Wifi & SoftAp
+ PWD_KEY = "password" # Used for Wifi & SoftAp
frequency_key = "frequency"
- HIDDEN_KEY = "hiddenSSID" # Used for Wifi & SoftAp
+ HIDDEN_KEY = "hiddenSSID" # Used for Wifi & SoftAp
IS_APP_INTERACTION_REQUIRED = "isAppInteractionRequired"
IS_USER_INTERACTION_REQUIRED = "isUserInteractionRequired"
IS_SUGGESTION_METERED = "isMetered"
PRIORITY = "priority"
- SECURITY = "security" # Used for Wifi & SoftAp
+ SECURITY = "security" # Used for Wifi & SoftAp
# Used for SoftAp
AP_BAND_KEY = "apBand"
@@ -181,6 +166,7 @@
FRIENDLY_NAME = "providerFriendlyName"
ROAMING_IDS = "roamingConsortiumIds"
OCSP = "ocsp"
+
# End of Macros for EAP
# Macros for wifi p2p.
@@ -288,12 +274,16 @@
SCAN_TYPE_HIGH_ACCURACY = 2
# US Wifi frequencies
- ALL_2G_FREQUENCIES = [2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452,
- 2457, 2462]
- DFS_5G_FREQUENCIES = [5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580,
- 5600, 5620, 5640, 5660, 5680, 5700, 5720]
- NONE_DFS_5G_FREQUENCIES = [5180, 5200, 5220, 5240, 5745, 5765, 5785, 5805,
- 5825]
+ ALL_2G_FREQUENCIES = [
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462
+ ]
+ DFS_5G_FREQUENCIES = [
+ 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640,
+ 5660, 5680, 5700, 5720
+ ]
+ NONE_DFS_5G_FREQUENCIES = [
+ 5180, 5200, 5220, 5240, 5745, 5765, 5785, 5805, 5825
+ ]
ALL_5G_FREQUENCIES = DFS_5G_FREQUENCIES + NONE_DFS_5G_FREQUENCIES
band_to_frequencies = {
@@ -407,6 +397,7 @@
44: 5220,
46: 5230,
48: 5240,
+ 50: 5250,
52: 5260,
56: 5280,
60: 5300,
@@ -442,10 +433,14 @@
def band_to_freq(self, band):
_band_to_frequencies = {
- WifiEnums.WIFI_BAND_24_GHZ: self.ALL_2G_FREQUENCIES,
- WifiEnums.WIFI_BAND_5_GHZ: self.NONE_DFS_5G_FREQUENCIES,
- WifiEnums.WIFI_BAND_5_GHZ_DFS_ONLY: self.DFS_5G_FREQUENCIES,
- WifiEnums.WIFI_BAND_5_GHZ_WITH_DFS: self.ALL_5G_FREQUENCIES,
+ WifiEnums.WIFI_BAND_24_GHZ:
+ self.ALL_2G_FREQUENCIES,
+ WifiEnums.WIFI_BAND_5_GHZ:
+ self.NONE_DFS_5G_FREQUENCIES,
+ WifiEnums.WIFI_BAND_5_GHZ_DFS_ONLY:
+ self.DFS_5G_FREQUENCIES,
+ WifiEnums.WIFI_BAND_5_GHZ_WITH_DFS:
+ self.ALL_5G_FREQUENCIES,
WifiEnums.WIFI_BAND_BOTH:
self.ALL_2G_FREQUENCIES + self.NONE_DFS_5G_FREQUENCIES,
WifiEnums.WIFI_BAND_BOTH_WITH_DFS:
@@ -456,17 +451,22 @@
class WifiChannelUS(WifiChannelBase):
# US Wifi frequencies
- ALL_2G_FREQUENCIES = [2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452,
- 2457, 2462]
- NONE_DFS_5G_FREQUENCIES = [5180, 5200, 5220, 5240, 5745, 5765, 5785, 5805,
- 5825]
- MIX_CHANNEL_SCAN = [2412, 2437, 2462, 5180, 5200, 5280, 5260, 5300, 5500,
- 5320, 5520, 5560, 5700, 5745, 5805]
+ ALL_2G_FREQUENCIES = [
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462
+ ]
+ NONE_DFS_5G_FREQUENCIES = [
+ 5180, 5200, 5220, 5240, 5745, 5765, 5785, 5805, 5825
+ ]
+ MIX_CHANNEL_SCAN = [
+ 2412, 2437, 2462, 5180, 5200, 5280, 5260, 5300, 5500, 5320, 5520, 5560,
+ 5700, 5745, 5805
+ ]
def __init__(self, model=None):
- self.DFS_5G_FREQUENCIES = [5260, 5280, 5300, 5320, 5500, 5520,
- 5540, 5560, 5580, 5600, 5620, 5640,
- 5660, 5680, 5700, 5720]
+ self.DFS_5G_FREQUENCIES = [
+ 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620,
+ 5640, 5660, 5680, 5700, 5720
+ ]
self.ALL_5G_FREQUENCIES = self.DFS_5G_FREQUENCIES + self.NONE_DFS_5G_FREQUENCIES
@@ -608,8 +608,10 @@
If assert_on_fail is False, function returns True if the device transitions
to the specified state, False otherwise. If assert_on_fail is True, no return value.
"""
- return _assert_on_fail_handler(
- _wait_for_wifi_state, assert_on_fail, ad, state=state)
+ return _assert_on_fail_handler(_wait_for_wifi_state,
+ assert_on_fail,
+ ad,
+ state=state)
def _wait_for_wifi_state(ad, state):
@@ -626,8 +628,8 @@
# state change event by mistake.
return
ad.droid.wifiStartTrackingStateChange()
- fail_msg = "Device did not transition to Wi-Fi state to %s on %s." % (state,
- ad.serial)
+ fail_msg = "Device did not transition to Wi-Fi state to %s on %s." % (
+ state, ad.serial)
try:
ad.ed.wait_for_event(wifi_constants.WIFI_STATE_CHANGED,
lambda x: x["data"]["enabled"] == state,
@@ -651,8 +653,10 @@
If assert_on_fail is False, function returns True if the toggle was
successful, False otherwise. If assert_on_fail is True, no return value.
"""
- return _assert_on_fail_handler(
- _wifi_toggle_state, assert_on_fail, ad, new_state=new_state)
+ return _assert_on_fail_handler(_wifi_toggle_state,
+ assert_on_fail,
+ ad,
+ new_state=new_state)
def _wifi_toggle_state(ad, new_state=None):
@@ -722,14 +726,12 @@
"""
ad.log.debug("Toggling Airplane mode ON.")
- asserts.assert_true(
- utils.force_airplane_mode(ad, True),
- "Can not turn on airplane mode on: %s" % ad.serial)
+ asserts.assert_true(utils.force_airplane_mode(ad, True),
+ "Can not turn on airplane mode on: %s" % ad.serial)
time.sleep(DEFAULT_TIMEOUT)
ad.log.debug("Toggling Airplane mode OFF.")
- asserts.assert_true(
- utils.force_airplane_mode(ad, False),
- "Can not turn on airplane mode on: %s" % ad.serial)
+ asserts.assert_true(utils.force_airplane_mode(ad, False),
+ "Can not turn on airplane mode on: %s" % ad.serial)
time.sleep(DEFAULT_TIMEOUT)
@@ -793,14 +795,17 @@
asserts.assert_equal(ad.droid.wifiGetVerboseLoggingLevel(), 1, msg)
# We don't verify the following settings since they are not critical.
# Set wpa_supplicant log level to EXCESSIVE.
- output = ad.adb.shell("wpa_cli -i wlan0 -p -g@android:wpa_wlan0 IFNAME="
- "wlan0 log_level EXCESSIVE", ignore_status=True)
+ output = ad.adb.shell(
+ "wpa_cli -i wlan0 -p -g@android:wpa_wlan0 IFNAME="
+ "wlan0 log_level EXCESSIVE",
+ ignore_status=True)
ad.log.info("wpa_supplicant log change status: %s", output)
utils.sync_device_time(ad)
ad.droid.telephonyToggleDataConnection(False)
set_wifi_country_code(ad, WifiEnums.CountryCode.US)
utils.set_ambient_display(ad, False)
+
def set_wifi_country_code(ad, country_code):
"""Sets the wifi country code on the device.
@@ -845,8 +850,8 @@
ad.ed.clear_all_events()
ad.droid.wifiStartScan()
try:
- events = ad.ed.pop_events(
- "WifiManagerScan(ResultsAvailable|Failure)", 60)
+ events = ad.ed.pop_events("WifiManagerScan(ResultsAvailable|Failure)",
+ 60)
except Empty:
asserts.fail(
"Wi-Fi scan results/failure did not become available within 60s.")
@@ -859,7 +864,8 @@
return False
-def start_wifi_connection_scan_and_check_for_network(ad, network_ssid,
+def start_wifi_connection_scan_and_check_for_network(ad,
+ network_ssid,
max_tries=3):
"""
Start connectivity scans & checks if the |network_ssid| is seen in
@@ -877,15 +883,15 @@
for num_tries in range(max_tries):
if start_wifi_connection_scan_and_return_status(ad):
scan_results = ad.droid.wifiGetScanResults()
- match_results = match_networks(
- {WifiEnums.SSID_KEY: network_ssid}, scan_results)
+ match_results = match_networks({WifiEnums.SSID_KEY: network_ssid},
+ scan_results)
if len(match_results) > 0:
return True
return False
-def start_wifi_connection_scan_and_ensure_network_found(ad, network_ssid,
- max_tries=3):
+def start_wifi_connection_scan_and_ensure_network_found(
+ ad, network_ssid, max_tries=3):
"""
Start connectivity scans & ensure the |network_ssid| is seen in
scan results. The method performs a max of |max_tries| connectivity scans
@@ -900,12 +906,13 @@
ad.log.info("Starting scans to ensure %s is present", network_ssid)
assert_msg = "Failed to find " + network_ssid + " in scan results" \
" after " + str(max_tries) + " tries"
- asserts.assert_true(start_wifi_connection_scan_and_check_for_network(
- ad, network_ssid, max_tries), assert_msg)
+ asserts.assert_true(
+ start_wifi_connection_scan_and_check_for_network(
+ ad, network_ssid, max_tries), assert_msg)
-def start_wifi_connection_scan_and_ensure_network_not_found(ad, network_ssid,
- max_tries=3):
+def start_wifi_connection_scan_and_ensure_network_not_found(
+ ad, network_ssid, max_tries=3):
"""
Start connectivity scans & ensure the |network_ssid| is not seen in
scan results. The method performs a max of |max_tries| connectivity scans
@@ -920,8 +927,9 @@
ad.log.info("Starting scans to ensure %s is not present", network_ssid)
assert_msg = "Found " + network_ssid + " in scan results" \
" after " + str(max_tries) + " tries"
- asserts.assert_false(start_wifi_connection_scan_and_check_for_network(
- ad, network_ssid, max_tries), assert_msg)
+ asserts.assert_false(
+ start_wifi_connection_scan_and_check_for_network(
+ ad, network_ssid, max_tries), assert_msg)
def start_wifi_background_scan(ad, scan_setting):
@@ -960,10 +968,9 @@
if band:
config[WifiEnums.AP_BAND_KEY] = band
if hidden:
- config[WifiEnums.HIDDEN_KEY] = hidden
- asserts.assert_true(
- ad.droid.wifiSetWifiApConfiguration(config),
- "Failed to update WifiAp Configuration")
+ config[WifiEnums.HIDDEN_KEY] = hidden
+ asserts.assert_true(ad.droid.wifiSetWifiApConfiguration(config),
+ "Failed to update WifiAp Configuration")
ad.droid.wifiStartTrackingTetherStateChange()
ad.droid.connectivityStartTethering(tel_defines.TETHERING_WIFI, False)
try:
@@ -978,13 +985,19 @@
ad.droid.wifiStopTrackingTetherStateChange()
-def save_wifi_soft_ap_config(ad, wifi_config, band=None, hidden=None,
- security=None, password=None,
- channel=None, max_clients=None,
+def save_wifi_soft_ap_config(ad,
+ wifi_config,
+ band=None,
+ hidden=None,
+ security=None,
+ password=None,
+ channel=None,
+ max_clients=None,
shutdown_timeout_enable=None,
shutdown_timeout_millis=None,
client_control_enable=None,
- allowedList=None, blockedList=None):
+ allowedList=None,
+ blockedList=None):
""" Save a soft ap configuration and verified
Args:
ad: android_device to set soft ap configuration.
@@ -1002,8 +1015,8 @@
blockedList: specifies blocked clients list.
"""
if security and password:
- wifi_config[WifiEnums.SECURITY] = security
- wifi_config[WifiEnums.PWD_KEY] = password
+ wifi_config[WifiEnums.SECURITY] = security
+ wifi_config[WifiEnums.PWD_KEY] = password
if band:
wifi_config[WifiEnums.AP_BAND_KEY] = band
if hidden:
@@ -1017,8 +1030,7 @@
wifi_config[
WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY] = shutdown_timeout_enable
if shutdown_timeout_millis:
- wifi_config[
- WifiEnums.AP_SHUTDOWNTIMEOUT_KEY] = shutdown_timeout_millis
+ wifi_config[WifiEnums.AP_SHUTDOWNTIMEOUT_KEY] = shutdown_timeout_millis
if client_control_enable:
wifi_config[WifiEnums.AP_CLIENTCONTROL_KEY] = client_control_enable
if allowedList:
@@ -1027,11 +1039,11 @@
wifi_config[WifiEnums.AP_BLOCKEDLIST_KEY] = blockedList
if WifiEnums.AP_CHANNEL_KEY in wifi_config and wifi_config[
- WifiEnums.AP_CHANNEL_KEY] == 0:
+ WifiEnums.AP_CHANNEL_KEY] == 0:
del wifi_config[WifiEnums.AP_CHANNEL_KEY]
if WifiEnums.SECURITY in wifi_config and wifi_config[
- WifiEnums.SECURITY] == WifiEnums.SoftApSecurityType.OPEN:
+ WifiEnums.SECURITY] == WifiEnums.SoftApSecurityType.OPEN:
del wifi_config[WifiEnums.SECURITY]
del wifi_config[WifiEnums.PWD_KEY]
@@ -1058,42 +1070,44 @@
if WifiEnums.AP_BAND_KEY in wifi_config:
asserts.assert_true(
- wifi_ap[WifiEnums.AP_BAND_KEY] == wifi_config[WifiEnums.AP_BAND_KEY],
- "Hotspot Band doesn't match")
+ wifi_ap[WifiEnums.AP_BAND_KEY] == wifi_config[
+ WifiEnums.AP_BAND_KEY], "Hotspot Band doesn't match")
if WifiEnums.AP_CHANNEL_KEY in wifi_config:
asserts.assert_true(
wifi_ap[WifiEnums.AP_CHANNEL_KEY] == wifi_config[
- WifiEnums.AP_CHANNEL_KEY], "Hotspot Channel doesn't match")
+ WifiEnums.AP_CHANNEL_KEY], "Hotspot Channel doesn't match")
if WifiEnums.AP_MAXCLIENTS_KEY in wifi_config:
asserts.assert_true(
wifi_ap[WifiEnums.AP_MAXCLIENTS_KEY] == wifi_config[
- WifiEnums.AP_MAXCLIENTS_KEY], "Hotspot Max Clients doesn't match")
+ WifiEnums.AP_MAXCLIENTS_KEY],
+ "Hotspot Max Clients doesn't match")
if WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY in wifi_config:
asserts.assert_true(
wifi_ap[WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY] == wifi_config[
- WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY],
+ WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY],
"Hotspot ShutDown feature flag doesn't match")
if WifiEnums.AP_SHUTDOWNTIMEOUT_KEY in wifi_config:
asserts.assert_true(
wifi_ap[WifiEnums.AP_SHUTDOWNTIMEOUT_KEY] == wifi_config[
- WifiEnums.AP_SHUTDOWNTIMEOUT_KEY],
+ WifiEnums.AP_SHUTDOWNTIMEOUT_KEY],
"Hotspot ShutDown timeout setting doesn't match")
if WifiEnums.AP_CLIENTCONTROL_KEY in wifi_config:
asserts.assert_true(
wifi_ap[WifiEnums.AP_CLIENTCONTROL_KEY] == wifi_config[
- WifiEnums.AP_CLIENTCONTROL_KEY],
+ WifiEnums.AP_CLIENTCONTROL_KEY],
"Hotspot Client control flag doesn't match")
if WifiEnums.AP_ALLOWEDLIST_KEY in wifi_config:
asserts.assert_true(
wifi_ap[WifiEnums.AP_ALLOWEDLIST_KEY] == wifi_config[
- WifiEnums.AP_ALLOWEDLIST_KEY],
+ WifiEnums.AP_ALLOWEDLIST_KEY],
"Hotspot Allowed List doesn't match")
if WifiEnums.AP_BLOCKEDLIST_KEY in wifi_config:
asserts.assert_true(
wifi_ap[WifiEnums.AP_BLOCKEDLIST_KEY] == wifi_config[
- WifiEnums.AP_BLOCKEDLIST_KEY],
+ WifiEnums.AP_BLOCKEDLIST_KEY],
"Hotspot Blocked List doesn't match")
+
def start_wifi_tethering_saved_config(ad):
""" Turn on wifi hotspot with a config that is already saved """
ad.droid.wifiStartTrackingTetherStateChange()
@@ -1156,12 +1170,11 @@
If assert_on_fail is False, function returns True if the toggle was
successful, False otherwise. If assert_on_fail is True, no return value.
"""
- return _assert_on_fail_handler(
- _toggle_wifi_and_wait_for_reconnection,
- assert_on_fail,
- ad,
- network,
- num_of_tries=num_of_tries)
+ return _assert_on_fail_handler(_toggle_wifi_and_wait_for_reconnection,
+ assert_on_fail,
+ ad,
+ network,
+ num_of_tries=num_of_tries)
def _toggle_wifi_and_wait_for_reconnection(ad, network, num_of_tries=3):
@@ -1205,23 +1218,26 @@
break
except Empty:
pass
- asserts.assert_true(connect_result,
- "Failed to connect to Wi-Fi network %s on %s" %
- (network, ad.serial))
+ asserts.assert_true(
+ connect_result, "Failed to connect to Wi-Fi network %s on %s" %
+ (network, ad.serial))
logging.debug("Connection result on %s: %s.", ad.serial,
connect_result)
actual_ssid = connect_result['data'][WifiEnums.SSID_KEY]
- asserts.assert_equal(actual_ssid, expected_ssid,
- "Connected to the wrong network on %s."
- "Expected %s, but got %s." %
- (ad.serial, expected_ssid, actual_ssid))
+ asserts.assert_equal(
+ actual_ssid, expected_ssid, "Connected to the wrong network on %s."
+ "Expected %s, but got %s." %
+ (ad.serial, expected_ssid, actual_ssid))
logging.info("Connected to Wi-Fi network %s on %s", actual_ssid,
ad.serial)
finally:
ad.droid.wifiStopTrackingStateChange()
-def wait_for_connect(ad, expected_ssid=None, expected_id=None, tries=2,
+def wait_for_connect(ad,
+ expected_ssid=None,
+ expected_id=None,
+ tries=2,
assert_on_fail=True):
"""Wait for a connect event.
@@ -1239,9 +1255,8 @@
Returns a value only if assert_on_fail is false.
Returns True if the connection was successful, False otherwise.
"""
- return _assert_on_fail_handler(
- _wait_for_connect, assert_on_fail, ad, expected_ssid, expected_id,
- tries)
+ return _assert_on_fail_handler(_wait_for_connect, assert_on_fail, ad,
+ expected_ssid, expected_id, tries)
def _wait_for_connect(ad, expected_ssid=None, expected_id=None, tries=2):
@@ -1255,11 +1270,13 @@
"""
ad.droid.wifiStartTrackingStateChange()
try:
- connect_result = _wait_for_connect_event(
- ad, ssid=expected_ssid, id=expected_id, tries=tries)
- asserts.assert_true(connect_result,
- "Failed to connect to Wi-Fi network %s" %
- expected_ssid)
+ connect_result = _wait_for_connect_event(ad,
+ ssid=expected_ssid,
+ id=expected_id,
+ tries=tries)
+ asserts.assert_true(
+ connect_result,
+ "Failed to connect to Wi-Fi network %s" % expected_ssid)
ad.log.debug("Wi-Fi connection result: %s.", connect_result)
actual_ssid = connect_result['data'][WifiEnums.SSID_KEY]
if expected_ssid:
@@ -1317,15 +1334,17 @@
if id is None and ssid is None:
for i in range(tries):
try:
- conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED, 30)
+ conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED,
+ 30)
break
except Empty:
pass
else:
- # If ssid or network id is specified, wait for specific connect event.
+ # If ssid or network id is specified, wait for specific connect event.
for i in range(tries):
try:
- conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED, 30)
+ conn_result = ad.ed.pop_event(wifi_constants.WIFI_CONNECTED,
+ 30)
if id and conn_result['data'][WifiEnums.NETID_KEY] == id:
break
elif ssid and conn_result['data'][WifiEnums.SSID_KEY] == ssid:
@@ -1371,8 +1390,11 @@
ad.droid.wifiStopTrackingStateChange()
-def connect_to_wifi_network(ad, network, assert_on_fail=True,
- check_connectivity=True, hidden=False):
+def connect_to_wifi_network(ad,
+ network,
+ assert_on_fail=True,
+ check_connectivity=True,
+ hidden=False):
"""Connection logic for open and psk wifi networks.
Args:
@@ -1411,14 +1433,17 @@
connect_data = ad.droid.wifiGetConnectionInfo()
connect_ssid = connect_data[WifiEnums.SSID_KEY]
ad.log.debug("Expected SSID = %s Connected SSID = %s" %
- (network_ssid, connect_ssid))
+ (network_ssid, connect_ssid))
if connect_ssid != network_ssid:
return False
return True
-def wifi_connect(ad, network, num_of_tries=1, assert_on_fail=True,
- check_connectivity=True):
+def wifi_connect(ad,
+ network,
+ num_of_tries=1,
+ assert_on_fail=True,
+ check_connectivity=True):
"""Connect an Android device to a wifi network.
Initiate connection to a wifi network, wait for the "connected" event, then
@@ -1439,9 +1464,12 @@
Returns a value only if assert_on_fail is false.
Returns True if the connection was successful, False otherwise.
"""
- return _assert_on_fail_handler(
- _wifi_connect, assert_on_fail, ad, network, num_of_tries=num_of_tries,
- check_connectivity=check_connectivity)
+ return _assert_on_fail_handler(_wifi_connect,
+ assert_on_fail,
+ ad,
+ network,
+ num_of_tries=num_of_tries,
+ check_connectivity=check_connectivity)
def _wifi_connect(ad, network, num_of_tries=1, check_connectivity=True):
@@ -1459,32 +1487,33 @@
num_of_tries: An integer that is the number of times to try before
delaring failure. Default is 1.
"""
- asserts.assert_true(WifiEnums.SSID_KEY in network,
- "Key '%s' must be present in network definition." %
- WifiEnums.SSID_KEY)
+ asserts.assert_true(
+ WifiEnums.SSID_KEY in network,
+ "Key '%s' must be present in network definition." % WifiEnums.SSID_KEY)
ad.droid.wifiStartTrackingStateChange()
expected_ssid = network[WifiEnums.SSID_KEY]
ad.droid.wifiConnectByConfig(network)
ad.log.info("Starting connection process to %s", expected_ssid)
try:
event = ad.ed.pop_event(wifi_constants.CONNECT_BY_CONFIG_SUCCESS, 30)
- connect_result = _wait_for_connect_event(
- ad, ssid=expected_ssid, tries=num_of_tries)
- asserts.assert_true(connect_result,
- "Failed to connect to Wi-Fi network %s on %s" %
- (network, ad.serial))
+ connect_result = _wait_for_connect_event(ad,
+ ssid=expected_ssid,
+ tries=num_of_tries)
+ asserts.assert_true(
+ connect_result, "Failed to connect to Wi-Fi network %s on %s" %
+ (network, ad.serial))
ad.log.debug("Wi-Fi connection result: %s.", connect_result)
actual_ssid = connect_result['data'][WifiEnums.SSID_KEY]
- asserts.assert_equal(actual_ssid, expected_ssid,
- "Connected to the wrong network on %s." %
- ad.serial)
+ asserts.assert_equal(
+ actual_ssid, expected_ssid,
+ "Connected to the wrong network on %s." % ad.serial)
ad.log.info("Connected to Wi-Fi network %s.", actual_ssid)
if check_connectivity:
internet = validate_connection(ad, DEFAULT_PING_ADDR)
if not internet:
- raise signals.TestFailure("Failed to connect to internet on %s" %
- expected_ssid)
+ raise signals.TestFailure(
+ "Failed to connect to internet on %s" % expected_ssid)
except Empty:
asserts.fail("Failed to start connection process to %s on %s" %
(network, ad.serial))
@@ -1540,19 +1569,21 @@
ad.log.info("Starting connection to network with id %d", network_id)
try:
event = ad.ed.pop_event(wifi_constants.CONNECT_BY_NETID_SUCCESS, 60)
- connect_result = _wait_for_connect_event(
- ad, id=network_id, tries=num_of_tries)
- asserts.assert_true(connect_result,
- "Failed to connect to Wi-Fi network using network id")
+ connect_result = _wait_for_connect_event(ad,
+ id=network_id,
+ tries=num_of_tries)
+ asserts.assert_true(
+ connect_result,
+ "Failed to connect to Wi-Fi network using network id")
ad.log.debug("Wi-Fi connection result: %s", connect_result)
actual_id = connect_result['data'][WifiEnums.NETID_KEY]
- asserts.assert_equal(actual_id, network_id,
- "Connected to the wrong network on %s."
- "Expected network id = %d, but got %d." %
- (ad.serial, network_id, actual_id))
+ asserts.assert_equal(
+ actual_id, network_id, "Connected to the wrong network on %s."
+ "Expected network id = %d, but got %d." %
+ (ad.serial, network_id, actual_id))
expected_ssid = connect_result['data'][WifiEnums.SSID_KEY]
ad.log.info("Connected to Wi-Fi network %s with %d network id.",
- expected_ssid, network_id)
+ expected_ssid, network_id)
internet = validate_connection(ad, DEFAULT_PING_ADDR)
if not internet:
@@ -1560,18 +1591,21 @@
expected_ssid)
except Empty:
asserts.fail("Failed to connect to network with id %d on %s" %
- (network_id, ad.serial))
+ (network_id, ad.serial))
except Exception as error:
ad.log.error("Failed to connect to network with id %d with error %s",
- network_id, error)
+ network_id, error)
raise signals.TestFailure("Failed to connect to network with network"
" id %d" % network_id)
finally:
ad.droid.wifiStopTrackingStateChange()
-def wifi_connect_using_network_request(ad, network, network_specifier,
- num_of_tries=3, assert_on_fail=True):
+def wifi_connect_using_network_request(ad,
+ network,
+ network_specifier,
+ num_of_tries=3,
+ assert_on_fail=True):
"""Connect an Android device to a wifi network using network request.
Trigger a network request with the provided network specifier,
@@ -1597,11 +1631,14 @@
Returns a value only if assert_on_fail is false.
Returns True if the connection was successful, False otherwise.
"""
- _assert_on_fail_handler(_wifi_connect_using_network_request, assert_on_fail,
- ad, network, network_specifier, num_of_tries)
+ _assert_on_fail_handler(_wifi_connect_using_network_request,
+ assert_on_fail, ad, network, network_specifier,
+ num_of_tries)
-def _wifi_connect_using_network_request(ad, network, network_specifier,
+def _wifi_connect_using_network_request(ad,
+ network,
+ network_specifier,
num_of_tries=3):
"""Connect an Android device to a wifi network using network request.
@@ -1628,7 +1665,9 @@
_wait_for_wifi_connect_after_network_request(ad, network, num_of_tries)
-def wait_for_wifi_connect_after_network_request(ad, network, num_of_tries=3,
+def wait_for_wifi_connect_after_network_request(ad,
+ network,
+ num_of_tries=3,
assert_on_fail=True):
"""
Simulate and verify the connection flow after initiating the network
@@ -1673,9 +1712,9 @@
num_of_tries: An integer that is the number of times to try before
delaring failure.
"""
- asserts.assert_true(WifiEnums.SSID_KEY in network,
- "Key '%s' must be present in network definition." %
- WifiEnums.SSID_KEY)
+ asserts.assert_true(
+ WifiEnums.SSID_KEY in network,
+ "Key '%s' must be present in network definition." % WifiEnums.SSID_KEY)
ad.droid.wifiStartTrackingStateChange()
expected_ssid = network[WifiEnums.SSID_KEY]
ad.droid.wifiRegisterNetworkRequestMatchCallback()
@@ -1683,7 +1722,7 @@
# matching the request
try:
matched_network = None
- for _ in [0, num_of_tries]:
+ for _ in [0, num_of_tries]:
on_match_event = ad.ed.pop_event(
wifi_constants.WIFI_NETWORK_REQUEST_MATCH_CB_ON_MATCH, 60)
asserts.assert_true(on_match_event,
@@ -1695,10 +1734,10 @@
{WifiEnums.SSID_KEY: network[WifiEnums.SSID_KEY]},
matched_scan_results)
if matched_network:
- break;
+ break
- asserts.assert_true(
- matched_network, "Target network %s not found" % network)
+ asserts.assert_true(matched_network,
+ "Target network %s not found" % network)
ad.droid.wifiSendUserSelectionForNetworkRequestMatch(network)
ad.log.info("Sent user selection for network request %s",
@@ -1711,11 +1750,10 @@
"Network request on available not received.")
connected_network = on_available_event["data"]
ad.log.info("Connected to network %s", connected_network)
- asserts.assert_equal(connected_network[WifiEnums.SSID_KEY],
- expected_ssid,
- "Connected to the wrong network."
- "Expected %s, but got %s." %
- (network, connected_network))
+ asserts.assert_equal(
+ connected_network[WifiEnums.SSID_KEY], expected_ssid,
+ "Connected to the wrong network."
+ "Expected %s, but got %s." % (network, connected_network))
except Empty:
asserts.fail("Failed to connect to %s" % expected_ssid)
except Exception as error:
@@ -1726,7 +1764,9 @@
ad.droid.wifiStopTrackingStateChange()
-def wifi_passpoint_connect(ad, passpoint_network, num_of_tries=1,
+def wifi_passpoint_connect(ad,
+ passpoint_network,
+ num_of_tries=1,
assert_on_fail=True):
"""Connect an Android device to a wifi network.
@@ -1747,8 +1787,11 @@
If assert_on_fail is False, function returns network id, if the connect was
successful, False otherwise. If assert_on_fail is True, no return value.
"""
- _assert_on_fail_handler(_wifi_passpoint_connect, assert_on_fail, ad,
- passpoint_network, num_of_tries = num_of_tries)
+ _assert_on_fail_handler(_wifi_passpoint_connect,
+ assert_on_fail,
+ ad,
+ passpoint_network,
+ num_of_tries=num_of_tries)
def _wifi_passpoint_connect(ad, passpoint_network, num_of_tries=1):
@@ -1770,15 +1813,16 @@
ad.log.info("Starting connection process to passpoint %s", expected_ssid)
try:
- connect_result = _wait_for_connect_event(
- ad, expected_ssid, num_of_tries)
- asserts.assert_true(connect_result,
- "Failed to connect to WiFi passpoint network %s on"
- " %s" % (expected_ssid, ad.serial))
+ connect_result = _wait_for_connect_event(ad, expected_ssid,
+ num_of_tries)
+ asserts.assert_true(
+ connect_result, "Failed to connect to WiFi passpoint network %s on"
+ " %s" % (expected_ssid, ad.serial))
ad.log.info("Wi-Fi connection result: %s.", connect_result)
actual_ssid = connect_result['data'][WifiEnums.SSID_KEY]
- asserts.assert_equal(actual_ssid, expected_ssid,
- "Connected to the wrong network on %s." % ad.serial)
+ asserts.assert_equal(
+ actual_ssid, expected_ssid,
+ "Connected to the wrong network on %s." % ad.serial)
ad.log.info("Connected to Wi-Fi passpoint network %s.", actual_ssid)
internet = validate_connection(ad, DEFAULT_PING_ADDR)
@@ -1787,9 +1831,9 @@
expected_ssid)
except Exception as error:
ad.log.error("Failed to connect to passpoint network %s with error %s",
- expected_ssid, error)
+ expected_ssid, error)
raise signals.TestFailure("Failed to connect to %s passpoint network" %
- expected_ssid)
+ expected_ssid)
finally:
ad.droid.wifiStopTrackingStateChange()
@@ -1801,8 +1845,9 @@
ad.droid.removePasspointConfig(fqdn)
return True
except Exception as error:
- ad.log.error("Failed to remove passpoint configuration with FQDN=%s "
- "and error=%s" , fqdn, error)
+ ad.log.error(
+ "Failed to remove passpoint configuration with FQDN=%s "
+ "and error=%s", fqdn, error)
return False
@@ -1901,14 +1946,16 @@
filename.
"""
asserts.assert_true(in_file.endswith(".pem"), "Input file has to be .pem.")
- asserts.assert_true(
- out_file.endswith(".der"), "Output file has to be .der.")
+ asserts.assert_true(out_file.endswith(".der"),
+ "Output file has to be .der.")
cmd = ("openssl pkcs8 -inform PEM -in {} -outform DER -out {} -nocrypt"
" -topk8").format(in_file, out_file)
utils.exe_cmd(cmd)
-def validate_connection(ad, ping_addr=DEFAULT_PING_ADDR, wait_time=15,
+def validate_connection(ad,
+ ping_addr=DEFAULT_PING_ADDR,
+ wait_time=15,
ping_gateway=True):
"""Validate internet connection by pinging the address provided.
@@ -1923,7 +1970,7 @@
# wait_time to allow for DHCP to complete.
for i in range(wait_time):
if ad.droid.connectivityNetworkIsConnected(
- ) and ad.droid.connectivityGetIPv4DefaultGateway():
+ ) and ad.droid.connectivityGetIPv4DefaultGateway():
break
time.sleep(1)
ping = False
@@ -1972,7 +2019,8 @@
raise signals.TestFailure(msg)
-def check_autoconnect_to_open_network(ad, conn_timeout=WIFI_CONNECTION_TIMEOUT_DEFAULT):
+def check_autoconnect_to_open_network(
+ ad, conn_timeout=WIFI_CONNECTION_TIMEOUT_DEFAULT):
"""Connects to any open WiFI AP
Args:
timeout value in sec to wait for UE to connect to a WiFi AP
@@ -1986,8 +2034,8 @@
wifi_connection_state = None
timeout = time.time() + conn_timeout
while wifi_connection_state != "completed":
- wifi_connection_state = ad.droid.wifiGetConnectionInfo()[
- 'supplicant_state']
+ wifi_connection_state = ad.droid.wifiGetConnectionInfo(
+ )['supplicant_state']
if time.time() > timeout:
ad.log.warning("Failed to connect to WiFi AP")
return False
@@ -2011,8 +2059,8 @@
phase2_types = [WifiEnums.EapPhase2.GTC, WifiEnums.EapPhase2.MSCHAPV2]
for phase2_type in phase2_types:
# Skip a special case for passpoint TTLS.
- if (WifiEnums.Enterprise.FQDN in config and
- phase2_type == WifiEnums.EapPhase2.GTC):
+ if (WifiEnums.Enterprise.FQDN in config
+ and phase2_type == WifiEnums.EapPhase2.GTC):
continue
c = dict(config)
c[WifiEnums.Enterprise.PHASE2] = phase2_type.value
@@ -2109,9 +2157,10 @@
attenuator[3].set_atten(roaming_attn[attn_val_name][3])
except:
logging.exception("Failed to set attenuation values %s.",
- attn_val_name)
+ attn_val_name)
raise
+
def set_attns_steps(attenuators,
atten_val_name,
roaming_attn=ROAMING_ATTN,
@@ -2130,7 +2179,7 @@
wait_time: Sleep time for each change of attenuator.
"""
logging.info("Set attenuation values to %s in %d step(s)",
- roaming_attn[atten_val_name], steps)
+ roaming_attn[atten_val_name], steps)
start_atten = [attenuator.get_atten() for attenuator in attenuators]
target_atten = roaming_attn[atten_val_name]
for current_step in range(steps):
@@ -2166,7 +2215,8 @@
logging.info("Roamed to %s successfully", expected_bssid)
if not validate_connection(dut):
raise signals.TestFailure("Fail to connect to internet on %s" %
- expected_bssid)
+ expected_bssid)
+
def create_softap_config():
"""Create a softap config with random ssid and password."""
@@ -2179,6 +2229,7 @@
}
return config
+
def start_softap_and_verify(ad, band):
"""Bring-up softap and verify AP mode and in scan results.
@@ -2198,11 +2249,12 @@
config = create_softap_config()
start_wifi_tethering(ad.dut,
config[WifiEnums.SSID_KEY],
- config[WifiEnums.PWD_KEY], band=band)
+ config[WifiEnums.PWD_KEY],
+ band=band)
asserts.assert_true(ad.dut.droid.wifiIsApEnabled(),
- "SoftAp is not reported as running")
- start_wifi_connection_scan_and_ensure_network_found(ad.dut_client,
- config[WifiEnums.SSID_KEY])
+ "SoftAp is not reported as running")
+ start_wifi_connection_scan_and_ensure_network_found(
+ ad.dut_client, config[WifiEnums.SSID_KEY])
# Check softap info can get from callback succeed and assert value should be
# valid.
@@ -2214,24 +2266,30 @@
return config
+
def wait_for_expected_number_of_softap_clients(ad, callbackId,
- expected_num_of_softap_clients):
+ expected_num_of_softap_clients):
"""Wait for the number of softap clients to be updated as expected.
Args:
callbackId: Id of the callback associated with registering.
expected_num_of_softap_clients: expected number of softap clients.
"""
eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str(
- callbackId) + wifi_constants.SOFTAP_NUMBER_CLIENTS_CHANGED
+ callbackId) + wifi_constants.SOFTAP_NUMBER_CLIENTS_CHANGED
clientData = ad.ed.pop_event(eventStr, SHORT_TIMEOUT)['data']
clientCount = clientData[wifi_constants.SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY]
- clientMacAddresses = clientData[wifi_constants.SOFTAP_CLIENTS_MACS_CALLBACK_KEY]
- asserts.assert_equal(clientCount, expected_num_of_softap_clients,
- "The number of softap clients doesn't match the expected number")
- asserts.assert_equal(len(clientMacAddresses), expected_num_of_softap_clients,
- "The number of mac addresses doesn't match the expected number")
+ clientMacAddresses = clientData[
+ wifi_constants.SOFTAP_CLIENTS_MACS_CALLBACK_KEY]
+ asserts.assert_equal(
+ clientCount, expected_num_of_softap_clients,
+ "The number of softap clients doesn't match the expected number")
+ asserts.assert_equal(
+ len(clientMacAddresses), expected_num_of_softap_clients,
+ "The number of mac addresses doesn't match the expected number")
for macAddress in clientMacAddresses:
- asserts.assert_true(checkMacAddress(macAddress), "An invalid mac address was returned")
+ asserts.assert_true(checkMacAddress(macAddress),
+ "An invalid mac address was returned")
+
def checkMacAddress(input):
"""Validate whether a string is a valid mac address or not.
@@ -2246,6 +2304,7 @@
return True
return False
+
def wait_for_expected_softap_state(ad, callbackId, expected_softap_state):
"""Wait for the expected softap state change.
Args:
@@ -2253,12 +2312,13 @@
expected_softap_state: The expected softap state.
"""
eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str(
- callbackId) + wifi_constants.SOFTAP_STATE_CHANGED
- asserts.assert_equal(ad.ed.pop_event(eventStr,
- SHORT_TIMEOUT)['data'][wifi_constants.
- SOFTAP_STATE_CHANGE_CALLBACK_KEY],
- expected_softap_state,
- "Softap state doesn't match with expected state")
+ callbackId) + wifi_constants.SOFTAP_STATE_CHANGED
+ asserts.assert_equal(
+ ad.ed.pop_event(eventStr, SHORT_TIMEOUT)['data'][
+ wifi_constants.SOFTAP_STATE_CHANGE_CALLBACK_KEY],
+ expected_softap_state,
+ "Softap state doesn't match with expected state")
+
def get_current_number_of_softap_clients(ad, callbackId):
"""pop up all of softap client updated event from queue.
@@ -2270,15 +2330,16 @@
Returns None when no any match callback event in queue.
"""
eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str(
- callbackId) + wifi_constants.SOFTAP_NUMBER_CLIENTS_CHANGED
+ callbackId) + wifi_constants.SOFTAP_NUMBER_CLIENTS_CHANGED
events = ad.ed.pop_all(eventStr)
for event in events:
- num_of_clients = event['data'][wifi_constants.
- SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY]
+ num_of_clients = event['data'][
+ wifi_constants.SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY]
if len(events) == 0:
return None
return num_of_clients
+
def get_current_softap_info(ad, callbackId, least_one):
"""pop up all of softap info changed event from queue.
Args:
@@ -2288,32 +2349,30 @@
Returns last updated information of softap.
"""
eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str(
- callbackId) + wifi_constants.SOFTAP_INFO_CHANGED
- ad.log.info("softap info dump from eventStr %s",
- eventStr)
+ callbackId) + wifi_constants.SOFTAP_INFO_CHANGED
+ ad.log.info("softap info dump from eventStr %s", eventStr)
frequency = 0
bandwidth = 0
if (least_one):
event = ad.ed.pop_event(eventStr, SHORT_TIMEOUT)
- frequency = event['data'][wifi_constants.
- SOFTAP_INFO_FREQUENCY_CALLBACK_KEY]
- bandwidth = event['data'][wifi_constants.
- SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY]
+ frequency = event['data'][
+ wifi_constants.SOFTAP_INFO_FREQUENCY_CALLBACK_KEY]
+ bandwidth = event['data'][
+ wifi_constants.SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY]
ad.log.info("softap info updated, frequency is %s, bandwidth is %s",
- frequency, bandwidth)
+ frequency, bandwidth)
events = ad.ed.pop_all(eventStr)
for event in events:
- frequency = event['data'][wifi_constants.
- SOFTAP_INFO_FREQUENCY_CALLBACK_KEY]
- bandwidth = event['data'][wifi_constants.
- SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY]
- ad.log.info("softap info, frequency is %s, bandwidth is %s",
- frequency, bandwidth)
+ frequency = event['data'][
+ wifi_constants.SOFTAP_INFO_FREQUENCY_CALLBACK_KEY]
+ bandwidth = event['data'][
+ wifi_constants.SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY]
+ ad.log.info("softap info, frequency is %s, bandwidth is %s", frequency,
+ bandwidth)
return frequency, bandwidth
-
def get_ssrdumps(ad):
"""Pulls dumps in the ssrdump dir
Args:
@@ -2326,7 +2385,8 @@
os.makedirs(log_path, exist_ok=True)
ad.pull_files(logs, log_path)
ad.adb.shell("find /data/vendor/ssrdump/ -type f -delete",
- ignore_status=True)
+ ignore_status=True)
+
def start_pcap(pcap, wifi_band, test_name):
"""Start packet capture in monitor mode.
@@ -2372,6 +2432,7 @@
if test_status:
shutil.rmtree(os.path.dirname(fname))
+
def verify_mac_not_found_in_pcap(ad, mac, packets):
"""Verify that a mac address is not found in the captured packets.
@@ -2386,6 +2447,7 @@
asserts.fail("Device %s caught Factory MAC: %s in packet sniffer."
"Packet = %s" % (ad.serial, mac, pkt.show()))
+
def verify_mac_is_found_in_pcap(ad, mac, packets):
"""Verify that a mac address is found in the captured packets.
@@ -2400,6 +2462,7 @@
asserts.fail("Did not find MAC = %s in packet sniffer."
"for device %s" % (mac, ad.serial))
+
def start_cnss_diags(ads, cnss_diag_file, pixel_models):
for ad in ads:
start_cnss_diag(ad, cnss_diag_file, pixel_models)
@@ -2421,12 +2484,13 @@
else:
prop = wifi_constants.CNSS_DIAG_PROP
if ad.adb.getprop(prop) != 'true':
- if not int(ad.adb.shell("ls -l %s%s | wc -l" %
- (CNSS_DIAG_CONFIG_PATH,
- CNSS_DIAG_CONFIG_FILE))):
+ if not int(
+ ad.adb.shell("ls -l %s%s | wc -l" %
+ (CNSS_DIAG_CONFIG_PATH, CNSS_DIAG_CONFIG_FILE))):
ad.adb.push("%s %s" % (cnss_diag_file, CNSS_DIAG_CONFIG_PATH))
- ad.adb.shell("find /data/vendor/wifi/cnss_diag/wlan_logs/ -type f -delete",
- ignore_status=True)
+ ad.adb.shell(
+ "find /data/vendor/wifi/cnss_diag/wlan_logs/ -type f -delete",
+ ignore_status=True)
ad.adb.shell("setprop %s true" % prop, ignore_status=True)
@@ -2465,8 +2529,9 @@
ad.pull_files(logs, log_path)
-LinkProbeResult = namedtuple('LinkProbeResult', (
- 'is_success', 'stdout', 'elapsed_time', 'failure_reason'))
+LinkProbeResult = namedtuple(
+ 'LinkProbeResult',
+ ('is_success', 'stdout', 'elapsed_time', 'failure_reason'))
def send_link_probe(ad):
@@ -2495,9 +2560,10 @@
else:
asserts.fail('Unexpected link probe result: ' + stdout)
- return LinkProbeResult(
- is_success=is_success, stdout=stdout,
- elapsed_time=elapsed_time, failure_reason=failure_reason)
+ return LinkProbeResult(is_success=is_success,
+ stdout=stdout,
+ elapsed_time=elapsed_time,
+ failure_reason=failure_reason)
def send_link_probes(ad, num_probes, delay_sec):
@@ -2525,7 +2591,7 @@
def ap_setup(test, index, ap, network, bandwidth=80, channel=6):
- """Set up the AP with provided network info.
+ """Set up the AP with provided network info.
Args:
test: the calling test class object.
@@ -2538,29 +2604,28 @@
Returns:
brconfigs: the bridge interface configs
"""
- bss_settings = []
- ssid = network[WifiEnums.SSID_KEY]
- test.access_points[index].close()
- time.sleep(5)
+ bss_settings = []
+ ssid = network[WifiEnums.SSID_KEY]
+ test.access_points[index].close()
+ time.sleep(5)
- # Configure AP as required.
- if "password" in network.keys():
- password = network["password"]
- security = hostapd_security.Security(
- security_mode="wpa", password=password)
- else:
- security = hostapd_security.Security(security_mode=None, password=None)
- config = hostapd_ap_preset.create_ap_preset(
- channel=channel,
- ssid=ssid,
- security=security,
- bss_settings=bss_settings,
- vht_bandwidth=bandwidth,
- profile_name='whirlwind',
- iface_wlan_2g=ap.wlan_2g,
- iface_wlan_5g=ap.wlan_5g)
- ap.start_ap(config)
- logging.info("AP started on channel {} with SSID {}".format(channel, ssid))
+ # Configure AP as required.
+ if "password" in network.keys():
+ password = network["password"]
+ security = hostapd_security.Security(security_mode="wpa",
+ password=password)
+ else:
+ security = hostapd_security.Security(security_mode=None, password=None)
+ config = hostapd_ap_preset.create_ap_preset(channel=channel,
+ ssid=ssid,
+ security=security,
+ bss_settings=bss_settings,
+ vht_bandwidth=bandwidth,
+ profile_name='whirlwind',
+ iface_wlan_2g=ap.wlan_2g,
+ iface_wlan_5g=ap.wlan_5g)
+ ap.start_ap(config)
+ logging.info("AP started on channel {} with SSID {}".format(channel, ssid))
def turn_ap_off(test, AP):
@@ -2569,11 +2634,11 @@
test: The test class object.
AP: int, indicating which AP to turn OFF.
"""
- hostapd_2g = test.access_points[AP-1]._aps['wlan0'].hostapd
+ hostapd_2g = test.access_points[AP - 1]._aps['wlan0'].hostapd
if hostapd_2g.is_alive():
hostapd_2g.stop()
logging.debug('Turned WLAN0 AP%d off' % AP)
- hostapd_5g = test.access_points[AP-1]._aps['wlan1'].hostapd
+ hostapd_5g = test.access_points[AP - 1]._aps['wlan1'].hostapd
if hostapd_5g.is_alive():
hostapd_5g.stop()
logging.debug('Turned WLAN1 AP%d off' % AP)
@@ -2585,11 +2650,11 @@
test: The test class object.
AP: int, indicating which AP to turn ON.
"""
- hostapd_2g = test.access_points[AP-1]._aps['wlan0'].hostapd
+ hostapd_2g = test.access_points[AP - 1]._aps['wlan0'].hostapd
if not hostapd_2g.is_alive():
hostapd_2g.start(hostapd_2g.config)
logging.debug('Turned WLAN0 AP%d on' % AP)
- hostapd_5g = test.access_points[AP-1]._aps['wlan1'].hostapd
+ hostapd_5g = test.access_points[AP - 1]._aps['wlan1'].hostapd
if not hostapd_5g.is_alive():
hostapd_5g.start(hostapd_5g.config)
logging.debug('Turned WLAN1 AP%d on' % AP)
@@ -2613,14 +2678,12 @@
channel: a wifi channel.
"""
chan_switch_cmd = 'hostapd_cli -i {} chan_switch {} {}'
- chan_switch_cmd_show = chan_switch_cmd.format(ap_iface,cs_count,channel)
+ chan_switch_cmd_show = chan_switch_cmd.format(ap_iface, cs_count, channel)
dut.log.info('adb shell {}'.format(chan_switch_cmd_show))
- chan_switch_result = dut.adb.shell(chan_switch_cmd.format(ap_iface,
- cs_count,
- channel))
+ chan_switch_result = dut.adb.shell(
+ chan_switch_cmd.format(ap_iface, cs_count, channel))
if chan_switch_result == 'OK':
dut.log.info('switch hotspot channel to {}'.format(channel))
return chan_switch_result
asserts.fail("Failed to switch hotspot channel")
-