def coex_test_phone_setup(self, Screen_status, WiFi_status, WiFi_band, BT_status, BLE_status, Cellular_status, Celluar_band): """Setup the phone in desired state for coex tests. Args: Screen_status: 'ON' or 'OFF' WiFi_status: 'ON', 'Connected', 'Disconnected', or 'OFF' WiFi_band: '2g', '5g' or None, the band of AP BT_status: 'ON' or 'OFF' BLE_status: 'ON' or 'OFF' Cellular_status: 'ON' or 'OFF' Celluar_band: 'Verizon', 'Tmobile', or 'ATT' for live network, actual band for callbox setup; 'None' when celluar is OFF """ # Setup WiFi if WiFi_status == 'ON': wutils.wifi_toggle_state(self.dut, True) elif WiFi_status == 'Connected': self.setup_ap_connection(self.main_network[WiFi_band]) elif WiFi_status == 'Disconnected': self.setup_ap_connection(self.main_network[WiFi_band], connect=False) # Setup BT/BLE self.phone_setup_for_BT(BT_status, BLE_status, Screen_status) # Setup Cellular if Cellular_status == 'ON': self.dut.droid.connectivityToggleAirplaneMode(False) utils.set_mobile_data_always_on(self.dut, True)
def get_interference_rssi(self): """Function to read wifi interference RSSI level.""" bssids = [] self.interference_rssi = [] wutils.wifi_toggle_state(self.android_devices[0], True) for item in self.wifi_int_pairs: ssid = item.network['SSID'] bssid = item.ap.get_bssid_from_ssid(ssid, '2g') bssids.append(bssid) interference_rssi_dict = { "ssid": ssid, "bssid": bssid, "chan": item.channel, "rssi": 0 } self.interference_rssi.append(interference_rssi_dict) scaned_rssi = wpeutils.get_scan_rssi(self.android_devices[0], bssids, num_measurements=2) for item in self.interference_rssi: item['rssi'] = scaned_rssi[item['bssid']]['mean'] self.log.info('Interference RSSI at channel {} is {} dBm'.format( item['chan'], item['rssi'])) wutils.wifi_toggle_state(self.android_devices[0], False)
def setup_ap_connection(self, network, bandwidth=80, connect=True, ap=None): """Setup AP and connect DUT to it. Args: network: the network config for the AP to be setup bandwidth: bandwidth of the WiFi network to be setup connect: indicator of if connect dut to the network after setup ap: access point object, default is None to find the main AP Returns: self.brconfigs: dict for bridge interface configs """ wutils.wifi_toggle_state(self.dut, True) if not ap: if hasattr(self, 'access_points'): self.brconfigs = wputils.ap_setup(self.access_point, network, bandwidth=bandwidth) else: self.brconfigs = wputils.ap_setup(ap, network, bandwidth=bandwidth) if connect: wutils.wifi_connect(self.dut, network, num_of_tries=3) if ap or (not ap and hasattr(self, 'access_points')): return self.brconfigs
def verify_lte_data_and_tethering_supported(ad): """Verify if LTE data is enabled and tethering supported""" wutils.wifi_toggle_state(ad, False) ad.droid.telephonyToggleDataConnection(True) wait_for_cell_data_connection(ad.log, ad, True) asserts.assert_true( verify_http_connection(ad.log, ad), "HTTP verification failed on cell data connection") asserts.assert_true( ad.droid.connectivityIsTetheringSupported(), "Tethering is not supported for the provider") wutils.wifi_toggle_state(ad, True)
def setup_ap_connection(dut, network, ap, bandwidth=20): """Setup AP and connect DUT to it. Args: dut: the android device to connect and run traffic network: the network config for the AP to be setup ap: access point object bandwidth: bandwidth of the WiFi network to be setup Returns: self.brconfigs: dict for bridge interface configs """ wutils.wifi_toggle_state(dut, True) brconfigs = wputils.ap_setup(ap, network, bandwidth=bandwidth) wutils.wifi_connect(dut, network, num_of_tries=3) return brconfigs
def setup_test(self): """Set up test specific parameters or configs. """ # Reset result variables self.avg_current = 0 self.samples = [] self.power_result.metric_value = 0 # Set the device into rockbottom state self.dut_rockbottom() wutils.reset_wifi(self.dut) wutils.wifi_toggle_state(self.dut, False) # Wait for extra time if needed for the first test if self.extra_wait: self.more_wait_first_test()
def connect_wlan_profile(pri_ad, network): """Disconnect and Connect to AP. Args: pri_ad: An android device. network: Network to which AP to be connected. Returns: True if successful, False otherwise. """ reset_wifi(pri_ad) wifi_toggle_state(pri_ad, False) wifi_test_device_init(pri_ad) wifi_connect(pri_ad, network) if not wifi_connection_check(pri_ad, network["SSID"]): pri_ad.log.error("Wifi connection does not exist.") return False return True
def setup_test(self): required_params = ( "aware_default_power_mode", "dbs_supported_models", ) self.unpack_userparams(required_params) if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"): wutils.start_cnss_diags(self.android_devices, self.cnss_diag_file, self.pixel_models) self.tcpdump_proc = [] if hasattr(self, "android_devices"): for ad in self.android_devices: proc = nutils.start_tcpdump(ad, self.test_name) self.tcpdump_proc.append((ad, proc)) for ad in self.android_devices: ad.droid.wifiEnableVerboseLogging(1) asserts.skip_if( not ad.droid.doesDeviceSupportWifiAwareFeature(), "Device under test does not support Wi-Fi Aware - skipping test" ) aware_avail = ad.droid.wifiIsAwareAvailable() ad.droid.wifiP2pClose() wutils.wifi_toggle_state(ad, True) utils.set_location_service(ad, True) if not aware_avail: self.log.info('Aware not available. Waiting ...') autils.wait_for_event(ad, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) ad.aware_capabilities = autils.get_aware_capabilities(ad) self.reset_device_parameters(ad) self.reset_device_statistics(ad) self.set_power_mode_parameters(ad) wutils.set_wifi_country_code(ad, wutils.WifiEnums.CountryCode.US) autils.configure_ndp_allow_any_override(ad, True) # set randomization interval to 0 (disable) to reduce likelihood of # interference in tests autils.configure_mac_random_interval(ad, 0) ad.ed.clear_all_events()
def setup_test(self): required_params = ("lci_reference", "lcr_reference", "rtt_reference_distance_mm", "stress_test_min_iteration_count", "stress_test_target_run_time_sec") self.unpack_userparams(required_params) # can be moved to JSON config file self.rtt_reference_distance_margin_mm = 2000 self.rtt_max_failure_rate_two_sided_rtt_percentage = 20 self.rtt_max_failure_rate_one_sided_rtt_percentage = 50 self.rtt_max_margin_exceeded_rate_two_sided_rtt_percentage = 10 self.rtt_max_margin_exceeded_rate_one_sided_rtt_percentage = 50 self.rtt_min_expected_rssi_dbm = -100 if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"): wutils.start_cnss_diags( self.android_devices, self.cnss_diag_file, self.pixel_models) self.tcpdump_proc = [] if hasattr(self, "android_devices"): for ad in self.android_devices: proc = nutils.start_tcpdump(ad, self.test_name) self.tcpdump_proc.append((ad, proc)) for ad in self.android_devices: utils.set_location_service(ad, True) ad.droid.wifiEnableVerboseLogging(1) asserts.skip_if( not ad.droid.doesDeviceSupportWifiRttFeature(), "Device under test does not support Wi-Fi RTT - skipping test") wutils.wifi_toggle_state(ad, True) rtt_avail = ad.droid.wifiIsRttAvailable() if not rtt_avail: self.log.info('RTT not available. Waiting ...') rutils.wait_for_event(ad, rconsts.BROADCAST_WIFI_RTT_AVAILABLE) ad.ed.clear_all_events() rutils.config_privilege_override(ad, False) wutils.set_wifi_country_code(ad, wutils.WifiEnums.CountryCode.US) ad.rtt_capabilities = rutils.get_rtt_capabilities(ad)
def reset_wifi_and_store_results(self): """Resets wifi and store test results.""" reset_wifi(self.pri_ad) wifi_toggle_state(self.pri_ad, False)
def wifi_toggle_state(self, state): awutils.wifi_toggle_state(self.device, state)