def run_disable_rtt(self, disable_mode): """Validate the RTT disabled flows: whether by disabling Wi-Fi or entering doze mode. Args: disable_mode: The particular mechanism in which RTT is disabled. One of the MODE_* constants. """ dut = self.android_devices[0] # validate start-up conditions asserts.assert_true(dut.droid.wifiIsRttAvailable(), "RTT is not available") # scan to get some APs to be used later all_aps = rutils.select_best_scan_results( rutils.scan_networks(dut), select_count=1) asserts.assert_true(len(all_aps) > 0, "Need at least one visible AP!") # disable RTT and validate broadcast & API if disable_mode == self.MODE_DISABLE_WIFI: # disabling Wi-Fi is not sufficient: since scan mode (and hence RTT) will # remain enabled - we need to disable the Wi-Fi chip aka Airplane Mode asserts.assert_true( utils.force_airplane_mode(dut, True), "Can not turn on airplane mode on: %s" % dut.serial) elif disable_mode == self.MODE_ENABLE_DOZE: asserts.assert_true(utils.enable_doze(dut), "Can't enable doze") elif disable_mode == self.MODE_DISABLE_LOCATIONING: utils.set_location_service(dut, False) rutils.wait_for_event(dut, rconsts.BROADCAST_WIFI_RTT_NOT_AVAILABLE) asserts.assert_false(dut.droid.wifiIsRttAvailable(), "RTT is available") # request a range and validate error id = dut.droid.wifiRttStartRangingToAccessPoints(all_aps[0:1]) event = rutils.wait_for_event( dut, rutils.decorate_event(rconsts.EVENT_CB_RANGING_ON_FAIL, id)) asserts.assert_equal( event["data"][rconsts.EVENT_CB_RANGING_KEY_STATUS], rconsts.RANGING_FAIL_CODE_RTT_NOT_AVAILABLE, "Invalid error code") # enable RTT and validate broadcast & API if disable_mode == self.MODE_DISABLE_WIFI: asserts.assert_true( utils.force_airplane_mode(dut, False), "Can not turn off airplane mode on: %s" % dut.serial) elif disable_mode == self.MODE_ENABLE_DOZE: asserts.assert_true(utils.disable_doze(dut), "Can't disable doze") elif disable_mode == self.MODE_DISABLE_LOCATIONING: utils.set_location_service(dut, True) rutils.wait_for_event(dut, rconsts.BROADCAST_WIFI_RTT_AVAILABLE) asserts.assert_true(dut.droid.wifiIsRttAvailable(), "RTT is not available")
def teardown_test(self): self.dut.log.debug("Toggling Airplane mode OFF.") asserts.assert_true( utils.force_airplane_mode(self.dut, False), "Can not turn off airplane mode: %s" % self.dut.serial) if self.dut.droid.wifiIsApEnabled(): wutils.stop_wifi_tethering(self.dut)
def setup_class(self): self.dut = self.android_devices[0] req_params = [ 'RemoteServer', 'RetailAccessPoints', 'rssi_test_params', 'main_network', 'testbed_params' ] self.unpack_userparams(req_params) self.testclass_params = self.rssi_test_params self.num_atten = self.attenuators[0].instrument.num_atten self.iperf_server = self.iperf_servers[0] self.iperf_client = self.iperf_clients[0] self.remote_server = ssh.connection.SshConnection( ssh.settings.from_config(self.RemoteServer[0]['ssh_config'])) self.access_point = retail_ap.create(self.RetailAccessPoints)[0] self.log_path = os.path.join(logging.log_path, 'results') os.makedirs(self.log_path, exist_ok=True) self.log.info('Access Point Configuration: {}'.format( self.access_point.ap_settings)) self.testclass_results = [] # Turn WiFi ON if self.testclass_params.get('airplane_mode', 1): self.log.info('Turning on airplane mode.') asserts.assert_true(utils.force_airplane_mode(self.dut, True), "Can not turn on airplane mode.") wutils.wifi_toggle_state(self.dut, True)
def teardown_class(self): try: ensure_phones_default_state(self.log, self.android_devices) for ad in self.android_devices: ad.droid.telephonyAdjustPreciseCallStateListenLevel( PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND, False) ad.droid.telephonyAdjustPreciseCallStateListenLevel( PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING, False) ad.droid.telephonyAdjustPreciseCallStateListenLevel( PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND, False) if "enable_wifi_verbose_logging" in self.user_params: ad.droid.wifiEnableVerboseLogging( WIFI_VERBOSE_LOGGING_DISABLED) finally: for ad in self.android_devices: try: toggle_airplane_mode(self.log, ad, True, strict_checking=False) except BrokenPipeError: # Broken Pipe, can not call SL4A API to turn on Airplane Mode. # Use adb command to turn on Airplane Mode. if not force_airplane_mode(ad, True): self.log.error( "Can not turn on airplane mode on:{}".format( ad.serial)) return True
def setup_class(self): self.dut = self.android_devices[-1] req_params = [ 'ping_test_params', 'testbed_params', 'main_network', 'RetailAccessPoints', 'RemoteServer' ] opt_params = ['OTASniffer'] self.unpack_userparams(req_params, opt_params) self.testclass_params = self.ping_test_params self.num_atten = self.attenuators[0].instrument.num_atten self.ping_server = ssh.connection.SshConnection( ssh.settings.from_config(self.RemoteServer[0]['ssh_config'])) self.access_point = retail_ap.create(self.RetailAccessPoints)[0] if hasattr(self, 'OTASniffer') and self.testbed_params['sniffer_enable']: self.sniffer = ota_sniffer.create(self.OTASniffer)[0] self.log.info('Access Point Configuration: {}'.format( self.access_point.ap_settings)) self.log_path = os.path.join(logging.log_path, 'results') os.makedirs(self.log_path, exist_ok=True) self.atten_dut_chain_map = {} self.testclass_results = [] # Turn WiFi ON if self.testclass_params.get('airplane_mode', 1): self.log.info('Turning on airplane mode.') asserts.assert_true(utils.force_airplane_mode(self.dut, True), "Can not turn on airplane mode.") wutils.wifi_toggle_state(self.dut, True) # Configure test retries self.user_params['retry_tests'] = [self.__class__.__name__]
def toggle_airplane_mode_on_and_off(ad): """Turn ON and OFF Airplane mode. ad: An AndroidDevice object. Returns: Assert if turning on/off Airplane mode fails. """ 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) 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) time.sleep(DEFAULT_TIMEOUT)
def test_usb_tethering_after_airplane_mode(self): """Enable usb tethering after airplane mode then executing ping test. Steps: 1. Stop SL4A services. 2. Enable usb tethering. 3. Restart SL4A services. 4. Wifi disable and mobile data enable. 5. Enable/disable airplane mode. 6. Run ping test through usb tethering interface. """ self.enable_usb_tethering() wutils.wifi_toggle_state(self.dut, False) self.log.info('Enable airplane mode.') utils.force_airplane_mode(self.dut, True) self.log.info('Disable airplane mode.') utils.force_airplane_mode(self.dut, False) time.sleep(DEFAULT_SETTLE_TIME) self.can_ping_through_usb_interface()
def test_attach_apm_toggle_attach_again(self): """Validates that enabling Airplane mode while Aware is on resets it correctly, and allows it to be re-enabled when Airplane mode is then disabled.""" dut = self.android_devices[0] # enable Aware (attach) dut.droid.wifiAwareAttach() autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED) # enable airplane mode force_airplane_mode(dut, True) autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_NOT_AVAILABLE) # wait a few seconds and disable airplane mode time.sleep(10) force_airplane_mode(dut, False) autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) # try enabling Aware again (attach) dut.droid.wifiAwareAttach() autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED)
def setup_class(self): """Initializes common test hardware and parameters. This function initializes hardwares and compiles parameters that are common to all tests in this class. """ self.dut = self.android_devices[-1] req_params = [ 'RetailAccessPoints', 'rvr_test_params', 'testbed_params', 'RemoteServer', 'main_network' ] opt_params = ['golden_files_list', 'OTASniffer'] self.unpack_userparams(req_params, opt_params) self.testclass_params = self.rvr_test_params self.num_atten = self.attenuators[0].instrument.num_atten self.iperf_server = self.iperf_servers[0] self.remote_server = ssh.connection.SshConnection( ssh.settings.from_config(self.RemoteServer[0]['ssh_config'])) self.iperf_client = self.iperf_clients[0] self.access_point = retail_ap.create(self.RetailAccessPoints)[0] if hasattr(self, 'OTASniffer') and self.testbed_params['sniffer_enable']: self.sniffer = ota_sniffer.create(self.OTASniffer)[0] self.log.info('Access Point Configuration: {}'.format( self.access_point.ap_settings)) self.log_path = os.path.join(logging.log_path, 'results') os.makedirs(self.log_path, exist_ok=True) if not hasattr(self, 'golden_files_list'): if 'golden_results_path' in self.testbed_params: self.golden_files_list = [ os.path.join(self.testbed_params['golden_results_path'], file) for file in os.listdir(self.testbed_params['golden_results_path']) ] else: self.log.warning('No golden files found.') self.golden_files_list = [] self.testclass_results = [] # Turn WiFi ON if self.testclass_params.get('airplane_mode', 1): self.log.info('Turning on airplane mode.') asserts.assert_true(utils.force_airplane_mode(self.dut, True), "Can not turn on airplane mode.") wutils.wifi_toggle_state(self.dut, True)
def test_full_tether_startup_2G_with_airplane_mode_on(self): """Test full startup of wifi tethering in 2G band with airplane mode on. 1. Turn on airplane mode. 2. Report current state. 3. Switch to AP mode. 4. verify SoftAP active. 5. Shutdown wifi tethering. 6. verify back to previous mode. 7. Turn off airplane mode. """ self.dut.log.debug("Toggling Airplane mode ON.") asserts.assert_true( utils.force_airplane_mode(self.dut, True), "Can not turn on airplane mode: %s" % self.dut.serial) wutils.wifi_toggle_state(self.dut, True) self.validate_full_tether_startup(WIFI_CONFIG_APBAND_2G)
def setup_class(self): # Not to call Base class setup_class() # since it removes the bonded devices for ad in self.android_devices: sync_device_time(ad) self.ad = self.android_devices[0] self.mon = self.monsoons[0] self.mon.set_voltage(self.MONSOON_OUTPUT_VOLTAGE) self.mon.set_max_current(self.MONSOON_MAX_CURRENT) # Monsoon phone self.mon.attach_device(self.ad) self.monsoon_log_path = os.path.join(self.log_path, "MonsoonLog") create_dir(self.monsoon_log_path) asserts.assert_true(self.mon.usb("auto"), "Failed to turn USB mode to auto on monsoon.") asserts.assert_true( force_airplane_mode(self.ad, True), "Can not turn on airplane mode on: %s" % self.ad.serial) asserts.assert_true(bluetooth_enabled_check(self.ad), "Failed to set Bluetooth state to enabled") set_location_service(self.ad, False) set_adaptive_brightness(self.ad, False) set_ambient_display(self.ad, False) self.ad.adb.shell("settings put system screen_brightness 0") set_auto_rotate(self.ad, False) set_phone_screen_on(self.log, self.ad, self.SCREEN_TIME_OFF) wutils.wifi_toggle_state(self.ad, False) # Start PMC app. self.log.info("Start PMC app...") self.ad.adb.shell(self.START_PMC_CMD) self.ad.adb.shell(self.PMC_VERBOSE_CMD) self.log.info("Check to see if PMC app started") for _ in range(self.WAIT_TIME): time.sleep(1) try: self.ad.adb.shell('ps -A | grep "S com.android.pmc"') break except adb.AdbError as e: self.log.info("PMC app is NOT started yet")
def setup_class(self): """Initializes common test hardware and parameters. This function initializes hardwares and compiles parameters that are common to all tests in this class. """ self.dut = self.android_devices[-1] req_params = [ 'RetailAccessPoints', 'roaming_test_params', 'testbed_params' ] opt_params = ['main_network', 'RemoteServer'] self.unpack_userparams(req_params, opt_params) self.testclass_params = self.roaming_test_params self.num_atten = self.attenuators[0].instrument.num_atten self.remote_server = ssh.connection.SshConnection( ssh.settings.from_config(self.RemoteServer[0]['ssh_config'])) self.remote_server.setup_master_ssh() self.iperf_server = self.iperf_servers[0] self.iperf_client = self.iperf_clients[0] self.access_point = retail_ap.create(self.RetailAccessPoints)[0] self.log.info('Access Point Configuration: {}'.format( self.access_point.ap_settings)) # Get RF connection map self.log.info("Getting RF connection map.") wutils.wifi_toggle_state(self.dut, True) self.rf_map_by_network, self.rf_map_by_atten = ( wputils.get_full_rf_connection_map(self.attenuators, self.dut, self.remote_server, self.main_network)) self.log.info("RF Map (by Network): {}".format(self.rf_map_by_network)) self.log.info("RF Map (by Atten): {}".format(self.rf_map_by_atten)) #Turn WiFi ON if self.testclass_params.get('airplane_mode', 1): self.log.info('Turning on airplane mode.') asserts.assert_true(utils.force_airplane_mode(self.dut, True), "Can not turn on airplane mode.") wutils.wifi_toggle_state(self.dut, True)
def setup_class(self): self.offset = 5 * 60 self.hz = 5000 self.scan_interval = 15 # Continuosly download self.download_interval = 0 self.mon_data_path = os.path.join(self.log_path, "Monsoon") self.mon = self.monsoons[0] self.mon.set_voltage(4.2) self.mon.set_max_current(7.8) self.dut = self.android_devices[0] self.mon.attach_device(self.dut) asserts.assert_true(self.mon.usb("auto"), "Failed to turn USB mode to auto on monsoon.") asserts.assert_true( force_airplane_mode(self.dut, True), "Can not turn on airplane mode on: %s" % self.dut.serial) set_location_service(self.dut, False) set_adaptive_brightness(self.dut, False) set_ambient_display(self.dut, False) self.dut.adb.shell("settings put system screen_brightness 0") set_auto_rotate(self.dut, False) required_userparam_names = ( # These two params should follow the format of # {"SSID": <SSID>, "password": <Password>} "network_2g", "network_5g", "iperf_server_address") self.unpack_userparams(required_userparam_names, threshold=None) wutils.wifi_test_device_init(self.dut) try: self.attn = self.attenuators[0] self.attn.set_atten(0) except AttributeError: self.log.warning("No attenuator found, some tests will fail.") pass
def setup_class(self): """Initializes common test hardware and parameters. This function initializes hardwares and compiles parameters that are common to all tests in this class. """ self.dut = self.android_devices[-1] req_params = [ 'RetailAccessPoints', 'sensitivity_test_params', 'testbed_params', 'RemoteServer' ] opt_params = ['main_network'] self.unpack_userparams(req_params, opt_params) self.testclass_params = self.sensitivity_test_params self.num_atten = self.attenuators[0].instrument.num_atten self.ping_server = ssh.connection.SshConnection( ssh.settings.from_config(self.RemoteServer[0]['ssh_config'])) self.iperf_server = self.iperf_servers[0] self.iperf_client = self.iperf_clients[0] self.access_point = retail_ap.create(self.RetailAccessPoints)[0] self.log.info('Access Point Configuration: {}'.format( self.access_point.ap_settings)) self.log_path = os.path.join(logging.log_path, 'results') os.makedirs(self.log_path, exist_ok=True) self.atten_dut_chain_map = {} self.testclass_results = [] # Turn WiFi ON if self.testclass_params.get('airplane_mode', 1): self.log.info('Turning on airplane mode.') asserts.assert_true(utils.force_airplane_mode(self.dut, True), "Can not turn on airplane mode.") wutils.wifi_toggle_state(self.dut, True) # Configure test retries self.user_params['retry_tests'] = [self.__class__.__name__]