def wifi_test_device_init(ad): """Initializes an android device for wifi testing. 0. Make sure SL4A connection is established on the android device. 1. Disable location service's WiFi scan. 2. Turn WiFi on. 3. Clear all saved networks. 4. Set country code to US. 5. Enable WiFi verbose logging. 6. Sync device time with computer time. 7. Turn off cellular data. """ require_sl4a((ad, )) ad.droid.wifiScannerToggleAlwaysAvailable(False) msg = "Failed to turn off location service's scan." assert not ad.droid.wifiScannerIsAlwaysAvailable(), msg msg = "Failed to turn WiFi on %s" % ad.serial assert wifi_toggle_state(ad, True), msg reset_wifi(ad) msg = "Failed to clear configured networks." assert not ad.droid.wifiGetConfiguredNetworks(), msg ad.droid.wifiEnableVerboseLogging(1) msg = "Failed to enable WiFi verbose logging." assert ad.droid.wifiGetVerboseLoggingLevel() == 1, msg ad.droid.wifiScannerToggleAlwaysAvailable(False) # We don't verify the following settings since they are not critical. sync_device_time(ad) ad.droid.telephonyToggleDataConnection(False) # TODO(angli): need to verify the country code was actually set. No generic # way to check right now. ad.adb.shell("halutil -country %s" % WifiEnums.CountryCode.US)
def setup_class(self): """It will setup the required dependencies from config file and configure the devices for softap mode testing. Returns: True if successfully configured the requirements for testing. """ self.dut = self.android_devices[0] self.dut_client = self.android_devices[1] # Do a simple version of init - mainly just sync the time and enable # verbose logging. This test will fail if the DUT has a sim and cell # data is disabled. We would also like to test with phones in less # constrained states (or add variations where we specifically # constrain). utils.require_sl4a((self.dut, self.dut_client)) utils.sync_device_time(self.dut) utils.sync_device_time(self.dut_client) # Enable verbose logging on the duts self.dut.droid.wifiEnableVerboseLogging(1) msg = "Failed to enable WiFi verbose logging on the softap dut." asserts.assert_true(self.dut.droid.wifiGetVerboseLoggingLevel() == 1, msg) self.dut_client.droid.wifiEnableVerboseLogging(1) msg = "Failed to enable WiFi verbose logging on the client dut." asserts.assert_true(self.dut_client.droid.wifiGetVerboseLoggingLevel() == 1, msg)
def setup_class(self): super().setup_class() self.dut = self.android_devices[0] self.dut_client = self.android_devices[1] # Do a simple version of init - mainly just sync the time and enable # verbose logging. This test will fail if the DUT has a sim and cell # data is disabled. We would also like to test with phones in less # constrained states (or add variations where we specifically # constrain). utils.require_sl4a(self.android_devices) for ad in self.android_devices: wutils.wifi_test_device_init(ad) utils.sync_device_time(ad) # Set country code explicitly to "US". wutils.set_wifi_country_code(ad, WifiEnums.CountryCode.US) # Enable verbose logging on the duts. ad.droid.wifiEnableVerboseLogging(1) req_params = [ "dbs_supported_models", "iperf_server_address", "iperf_server_port" ] self.unpack_userparams(req_param_names=req_params, ) asserts.abort_class_if( self.dut.model not in self.dbs_supported_models, "Device %s does not support dual interfaces." % self.dut.model)
def setup_class(self): self.dut = self.android_devices[0] self.dut_client = self.android_devices[1] wutils.wifi_test_device_init(self.dut) wutils.wifi_test_device_init(self.dut_client) utils.require_sl4a((self.dut, self.dut_client)) utils.sync_device_time(self.dut) utils.sync_device_time(self.dut_client) # Set country code explicitly to "US". self.dut.droid.wifiSetCountryCode(wutils.WifiEnums.CountryCode.US) self.dut_client.droid.wifiSetCountryCode(wutils.WifiEnums.CountryCode.US) # Enable verbose logging on the duts self.dut.droid.wifiEnableVerboseLogging(1) asserts.assert_equal(self.dut.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the softap dut.") self.dut_client.droid.wifiEnableVerboseLogging(1) asserts.assert_equal(self.dut_client.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the client dut.") req_params = [] opt_param = ["iperf_server_address", "reference_networks"] self.unpack_userparams( req_param_names=req_params, opt_param_names=opt_param) if "iperf_server_address" in self.user_params: self.iperf_server = self.iperf_servers[0] if hasattr(self, 'iperf_server'): self.iperf_server.start()
def setup_class(self): super().setup_class() self.dut = self.android_devices[0] self.dut_client = self.android_devices[1] wutils.wifi_test_device_init(self.dut) wutils.wifi_test_device_init(self.dut_client) utils.require_sl4a((self.dut, self.dut_client)) utils.sync_device_time(self.dut) utils.sync_device_time(self.dut_client) # Set country code explicitly to "US". wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US) wutils.set_wifi_country_code(self.dut_client, wutils.WifiEnums.CountryCode.US) # Enable verbose logging on the duts self.dut.droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.dut.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the softap dut.") self.dut_client.droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.dut_client.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the client dut.") req_params = [] opt_param = [ "iperf_server_address", "reference_networks", "iperf_server_port" ] self.unpack_userparams(req_param_names=req_params, opt_param_names=opt_param) self.chan_map = { v: k for k, v in hostapd_constants.CHANNEL_MAP.items() } self.pcap_procs = None
def wifi_test_device_init(ad): """Initializes an android device for wifi testing. 0. Make sure SL4A connection is established on the android device. 1. Disable location service's WiFi scan. 2. Turn WiFi on. 3. Clear all saved networks. 4. Set country code to US. 5. Enable WiFi verbose logging. 6. Sync device time with computer time. 7. Turn off cellular data. 8. Turn off ambient display. """ utils.require_sl4a((ad, )) ad.droid.wifiScannerToggleAlwaysAvailable(False) msg = "Failed to turn off location service's scan." asserts.assert_true(not ad.droid.wifiScannerIsAlwaysAvailable(), msg) wifi_toggle_state(ad, True) reset_wifi(ad) ad.droid.wifiEnableVerboseLogging(1) msg = "Failed to enable WiFi verbose logging." 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") ad.log.info("wpa_supplicant log change status: %s", output) utils.sync_device_time(ad) ad.droid.telephonyToggleDataConnection(False) # TODO(angli): need to verify the country code was actually set. No generic # way to check right now. ad.adb.shell("halutil -country %s" % WifiEnums.CountryCode.US) utils.set_ambient_display(ad, False)
def setup_class(self): self.dut = self.android_devices[0] self.dut_client = self.android_devices[1] wutils.wifi_test_device_init(self.dut) wutils.wifi_test_device_init(self.dut_client) # Do a simple version of init - mainly just sync the time and enable # verbose logging. This test will fail if the DUT has a sim and cell # data is disabled. We would also like to test with phones in less # constrained states (or add variations where we specifically # constrain). utils.require_sl4a((self.dut, self.dut_client)) utils.sync_device_time(self.dut) utils.sync_device_time(self.dut_client) # Set country code explicitly to "US". wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US) wutils.set_wifi_country_code(self.dut_client, wutils.WifiEnums.CountryCode.US) # Enable verbose logging on the duts self.dut.droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.dut.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the softap dut.") self.dut_client.droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.dut_client.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the client dut.") req_params = ["AccessPoint", "dbs_supported_models", "stress_count"] opt_param = ["iperf_server_address"] self.unpack_userparams(req_param_names=req_params, opt_param_names=opt_param) if self.dut.model not in self.dbs_supported_models: asserts.skip(("Device %s does not support dual interfaces.") % self.dut.model) if "iperf_server_address" in self.user_params: self.iperf_server = self.iperf_servers[0] if hasattr(self, 'iperf_server'): self.iperf_server.start() # Set the client wifi state to on before the test begins. wutils.wifi_toggle_state(self.dut_client, True) # Init extra devices if len(self.android_devices) > 2: wutils.wifi_test_device_init(self.android_devices[2]) utils.sync_device_time(self.android_devices[2]) wutils.set_wifi_country_code(self.android_devices[2], wutils.WifiEnums.CountryCode.US) self.android_devices[2].droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.android_devices[2].droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the client dut.")
def setup_class(self): """It will setup the required dependencies from config file and configure the devices for softap mode testing. Returns: True if successfully configured the requirements for testing. """ self.dut = self.android_devices[0] self.dut_client = self.android_devices[1] req_params = ["dbs_supported_models"] opt_param = ["open_network"] self.unpack_userparams(req_param_names=req_params, opt_param_names=opt_param) if "AccessPoint" in self.user_params: self.legacy_configure_ap_and_start() self.open_network = self.open_network[0]["2g"] # Do a simple version of init - mainly just sync the time and enable # verbose logging. This test will fail if the DUT has a sim and cell # data is disabled. We would also like to test with phones in less # constrained states (or add variations where we specifically # constrain). utils.require_sl4a((self.dut, self.dut_client)) utils.sync_device_time(self.dut) utils.sync_device_time(self.dut_client) # Set country code explicitly to "US". wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US) wutils.set_wifi_country_code(self.dut_client, wutils.WifiEnums.CountryCode.US) # Enable verbose logging on the duts self.dut.droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.dut.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the softap dut.") self.dut_client.droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.dut_client.droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the client dut.") wutils.wifi_toggle_state(self.dut, True) wutils.wifi_toggle_state(self.dut_client, True) self.AP_IFACE = 'wlan0' if self.dut.model in self.dbs_supported_models: self.AP_IFACE = 'wlan1' if len(self.android_devices) > 2: utils.sync_device_time(self.android_devices[2]) wutils.set_wifi_country_code(self.android_devices[2], wutils.WifiEnums.CountryCode.US) self.android_devices[2].droid.wifiEnableVerboseLogging(1) asserts.assert_equal( self.android_devices[2].droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the client dut.")
def dut_rockbottom(self): """Set the phone into Rock-bottom state. """ self.dut.log.info('Now set the device to Rockbottom State') utils.require_sl4a((self.dut, )) self.dut.droid.connectivityToggleAirplaneMode(False) time.sleep(2) self.dut.droid.connectivityToggleAirplaneMode(True) time.sleep(2) utils.set_ambient_display(self.dut, False) utils.set_auto_rotate(self.dut, False) utils.set_adaptive_brightness(self.dut, False) utils.sync_device_time(self.dut) utils.set_location_service(self.dut, False) utils.set_mobile_data_always_on(self.dut, False) utils.disable_doze_light(self.dut) utils.disable_doze(self.dut) wutils.reset_wifi(self.dut) wutils.wifi_toggle_state(self.dut, False) try: self.dut.droid.nfcDisable() except acts.controllers.sl4a_lib.rpc_client.Sl4aApiError: self.dut.log.info('NFC is not available') self.dut.droid.setScreenBrightness(0) self.dut.adb.shell(AOD_OFF) self.dut.droid.setScreenTimeout(2200) self.dut.droid.wakeUpNow() self.dut.adb.shell(LIFT) self.dut.adb.shell(DOUBLE_TAP) self.dut.adb.shell(JUMP_TO_CAMERA) self.dut.adb.shell(RAISE_TO_CAMERA) self.dut.adb.shell(FLIP_CAMERA) self.dut.adb.shell(ASSIST_GESTURE) self.dut.adb.shell(ASSIST_GESTURE_ALERT) self.dut.adb.shell(ASSIST_GESTURE_WAKE) self.dut.adb.shell(SCREENON_USB_DISABLE) self.dut.adb.shell(UNLOCK_SCREEN) self.dut.adb.shell(SETTINGS_PAGE) self.dut.adb.shell(SCROLL_BOTTOM) self.dut.adb.shell(MUSIC_IQ_OFF) self.dut.adb.shell(AUTO_TIME_OFF) self.dut.adb.shell(AUTO_TIMEZONE_OFF) self.dut.adb.shell(FORCE_YOUTUBE_STOP) self.dut.adb.shell(FORCE_DIALER_STOP) self.dut.droid.wifiSetCountryCode('US') self.dut.droid.wakeUpNow() self.dut.log.info('Device has been set to Rockbottom state') self.dut.log.info('Screen is ON')
def setup_class(self): """ Sets up the required dependencies from the config file and configures the device for WifiService API tests. Returns: True is successfully configured the requirements for testig. """ self.dut = self.android_devices[0] # Do a simple version of init - mainly just sync the time and enable # verbose logging. We would also like to test with phones in less # constrained states (or add variations where we specifically # constrain). utils.require_sl4a((self.dut, )) utils.sync_device_time(self.dut) # Enable verbose logging on the dut self.dut.droid.wifiEnableVerboseLogging(1) if self.dut.droid.wifiGetVerboseLoggingLevel() != 1: raise signals.TestFailure( "Failed to enable WiFi verbose logging on the dut.")
def setup_class(self): self.log = logging.getLogger() self.tests = self.get_existing_test_names() # Obtain test parameters from user_params TEST_PARAMS = self.TAG + '_params' self.test_params = self.user_params.get(TEST_PARAMS, {}) if not self.test_params: self.log.warning(TEST_PARAMS + ' was not found in the user ' 'parameters defined in the config file.') # Override user_param values with test parameters self.user_params.update(self.test_params) # Unpack user_params with default values. All the usages of user_params # as self attributes need to be included either as a required parameter # or as a parameter with a default value. req_params = ['custom_files', 'mon_duration'] self.unpack_userparams(req_params, mon_freq=DEFAULT_MONSOON_FREQUENCY, mon_offset=0, bug_report=False, extra_wait=None, iperf_duration=None, pass_fail_tolerance=THRESHOLD_TOLERANCE_DEFAULT, mon_voltage=PHONE_BATTERY_VOLTAGE_DEFAULT) # Setup the must have controllers, phone and monsoon self.dut = self.android_devices[0] self.mon_data_path = os.path.join(self.log_path, 'Monsoon') os.makedirs(self.mon_data_path, exist_ok=True) # Initialize the power monitor object that will be used to measure self.initialize_power_monitor() # Unpack the thresholds file or fail class setup if it can't be found for file in self.custom_files: if 'pass_fail_threshold_' + self.dut.model in file: self.threshold_file = file break else: raise RuntimeError('Required test pass/fail threshold file is ' 'missing') # Unpack the rockbottom script or fail class setup if it can't be found for file in self.custom_files: if 'rockbottom_' + self.dut.model in file: self.rockbottom_script = file break else: raise RuntimeError('Required rockbottom script is missing.') # Unpack optional custom files for file in self.custom_files: if 'attenuator_setting' in file: self.attenuation_file = file elif 'network_config' in file: self.network_file = file if hasattr(self, 'attenuators'): self.num_atten = self.attenuators[0].instrument.num_atten self.atten_level = self.unpack_custom_file(self.attenuation_file) self.threshold = self.unpack_custom_file(self.threshold_file) self.mon_info = self.create_monsoon_info() # Sync device time, timezone and country code utils.require_sl4a((self.dut, )) utils.sync_device_time(self.dut) wutils.set_wifi_country_code(self.dut, 'US') screen_on_img = self.user_params.get('screen_on_img', []) if screen_on_img: img_src = screen_on_img[0] img_dest = '/sdcard/Pictures/' success = self.dut.push_system_file(img_src, img_dest) if success: self.img_name = os.path.basename(img_src)