def turn_location_off_and_scan_toggle_off(self): """Turns off wifi location scans.""" utils.set_location_service(self.dut, False) self.dut.droid.wifiScannerToggleAlwaysAvailable(False) msg = "Failed to turn off location service's scan." asserts.assert_false(self.dut.droid.wifiScannerIsAlwaysAvailable(), msg)
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 for ad in self.android_devices: utils.set_location_service(ad, True) 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 setup_test(self): # Make sure Bluetooth is on enable_bluetooth(self.phone.droid, self.phone.ed) set_location_service(self.phone, True) factory_reset_bluetooth([self.phone]) self.apollo_act.factory_reset() self.log.info('===== START BLUETOOTH PAIR AND CONNECT TEST =====')
def setup_test(self): required_params = ("aware_default_power_mode", ) self.unpack_userparams(required_params) for ad in self.android_devices: asserts.skip_if( not ad.droid.doesDeviceSupportWifiAwareFeature(), "Device under test does not support Wi-Fi Aware - skipping test" ) wutils.wifi_toggle_state(ad, True) ad.droid.wifiP2pClose() utils.set_location_service(ad, True) aware_avail = ad.droid.wifiIsAwareAvailable() if not aware_avail: self.log.info('Aware not available. Waiting ...') autils.wait_for_event(ad, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) ad.ed.clear_all_events() 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)
def setup_class(self): self.hotspot_device = self.android_devices[0] self.tethered_devices = self.android_devices[1:] req_params = ("ssid", "password", "url") self.unpack_userparams(req_params) self.network = {"SSID": self.ssid, "password": self.password} self.offset = 1 * 60 self.hz = 5000 self.duration = 9 * 60 + self.offset 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.mon.attach_device(self.hotspot_device) asserts.assert_true(self.mon.usb("auto"), "Failed to turn USB mode to auto on monsoon.") set_location_service(self.hotspot_device, False) set_adaptive_brightness(self.hotspot_device, False) set_ambient_display(self.hotspot_device, False) self.hotspot_device.adb.shell( "settings put system screen_brightness 0") set_auto_rotate(self.hotspot_device, False) wutils.wifi_toggle_state(self.hotspot_device, False) self.hotspot_device.droid.telephonyToggleDataConnection(True) tel_utils.wait_for_cell_data_connection(self.log, self.hotspot_device, True) asserts.assert_true( tel_utils.verify_http_connection(self.log, self.hotspot_device), "HTTP verification failed on cell data connection") for ad in self.tethered_devices: wutils.reset_wifi(ad)
def setup_class(self): super(BluetoothBaseTest, self).setup_class() self.scn_ad = self.android_devices[0] self.adv_ad = self.android_devices[1] utils.set_location_service(self.scn_ad, True) utils.set_location_service(self.adv_ad, True) return True
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 setup_class(self): super().setup_class() self.client_ad = self.android_devices[0] self.server_ad = self.android_devices[1] # Note that some tests required a third device. if len(self.android_devices) > 2: self.server2_ad = self.android_devices[2] # The client which is scanning will need location to be enabled in order to # start scan and get scan results. utils.set_location_service(self.client_ad, True) return setup_multiple_devices_for_bt_test(self.android_devices)
def setup_class(self): if "reboot_between_test_class" in self.user_params: threads = [] for a in self.android_devices: thread = threading.Thread(target=self._reboot_device, args=([a])) threads.append(thread) thread.start() for t in threads: t.join() for a in self.android_devices: set_location_service(a, False) sync_device_time(a) return setup_multiple_devices_for_bt_test(self.android_devices)
def setup_test(self): # Make sure Bluetooth is on enable_bluetooth(self.phone.droid, self.phone.ed) set_location_service(self.phone, True) factory_reset_bluetooth([self.phone]) self.apollo_act.factory_reset() # Initial pairing and connection of devices self.phone.droid.bluetoothDiscoverAndBond(self.dut_bt_addr) paired_and_connected = self.apollo_act.wait_for_bluetooth_a2dp_hfp() asserts.assert_true(paired_and_connected, 'Failed to pair and connect devices') time.sleep(20) self.log.info('===== START BLUETOOTH RECONNECT TEST =====')
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 __init__(self, configs): self.tests = [] if not self.TAG: self.TAG = self.__class__.__name__ # Set all the controller objects and params. for name, value in configs.items(): setattr(self, name, value) self.results = records.TestResult() self.current_test_name = None self.log = tracelogger.TraceLogger(self.log) if 'android_devices' in self.__dict__: for ad in self.android_devices: if ad.droid: utils.set_location_service(ad, False) utils.sync_device_time(ad)
def test_attach_with_location_off(self): """Function test case / Attach test cases / attempt to attach with location mode off. Validates that if trying to attach with device location mode off will receive the expected failure callback. As a side-effect also validates that the broadcast for Aware unavailable is received. """ dut = self.android_devices[0] utils.set_location_service(dut, False) autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_NOT_AVAILABLE) dut.droid.wifiAwareAttach() autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACH_FAILED) utils.set_location_service(dut, True) autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE)
def test_gnss_dpoON_measurement(self): utils.set_location_service(self.dut, True) time.sleep(DUT_ACTION_WAIT_TIME) gutil.start_gnss_by_gtw_gpstool(self.dut, state=True, type="gnss", bgdisplay=True) self.dut.send_keycode("SLEEP") time.sleep(DUT_ACTION_WAIT_TIME) self.measure_gnsspower_test_func() diaglog.start_diagmdlog_background(self.dut, maskfile=self.maskfile) self.disconnect_usb(self.dut, MDLOG_RUNNING_TIME) qxdm_log_path = os.path.join(self.log_path, 'QXDM') diaglog.stop_background_diagmdlog(self.dut, qxdm_log_path) gutil.start_gnss_by_gtw_gpstool(self.dut, state=False)
def _configure_dut(self): try: self.log.info("Rebooting DUT") self.ad.reboot() self.log.info("DUT rebooted") set_adaptive_brightness(self.ad, False) set_ambient_display(self.ad, False) set_auto_rotate(self.ad, False) set_location_service(self.ad, False) # This is not needed for AOSP build disable_doze(self.ad) set_phone_screen_on(self.log, self.ad, 15) self.ad.droid.telephonyFactoryReset() except Exception as e: self.ad.log.error(e) return False return True
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): """Setup required dependencies from config file and configure the required networks for testing roaming. Returns: True if successfully configured the requirements for testing. """ super().setup_class() self.simulation_thread_running = False self.atten_roaming_count = 0 self.start_db = 30 self.roaming_cycle_seconds = 20 self.fail_count = 0 self.retry_pass_count = 0 self.ping_count = 0 self.dut = self.android_devices[0] wutils.wifi_test_device_init(self.dut) req_params = ["attenuators", "ifs_params"] opt_param = [] 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(ap_count=2, same_ssid=True) wutils.wifi_toggle_state(self.dut, True) if "ifs_params" in self.user_params: self.attn_start_db = self.ifs_params[0]["start_db"] self.gateway = self.ifs_params[0]["gateway"] self.roaming_cycle_seconds = self.ifs_params[0][ "roaming_cycle_seconds"] self.total_test_hour = self.ifs_params[0]["total_test_hour"] self.log_capture_period_hour = self.ifs_params[0][ "log_capture_period_hour"] self.on_active_port = self.ifs_params[0]["on_active_port"] asserts.assert_true( len(self.on_active_port) == 2, "Need setup 2 port.") self.tcpdump_pid = None utils.set_location_service(self.dut, True)
def _connect_rfcomm(self): """Establishes an RFCOMM connection between two phones. Connects the client device to the server device given the hardware address of the server device. """ set_location_service(self.client_device, True) set_location_service(self.server_device, True) server_address = self.server_device.droid.bluetoothGetLocalAddress() self.log.info('Pairing and connecting devices') asserts.assert_true( self.client_device.droid.bluetoothDiscoverAndBond(server_address), 'Failed to pair and connect devices') # Create RFCOMM connection asserts.assert_true( orchestrate_rfcomm_connection(self.client_device, self.server_device), 'Failed to establish RFCOMM connection')
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_class(self): super().setup_class() self.mon = self.monsoons[0] self.mon.set_voltage(MONSOON_OUTPUT_VOLTAGE) self.mon.set_max_current(MONSOON_MAX_CURRENT) # Monsoon phone self.mon.dut = self.ad = self.android_devices[0] set_adaptive_brightness(self.ad, False) set_ambient_display(self.ad, False) set_auto_rotate(self.ad, False) set_location_service(self.ad, False) # This is not needed for AOSP build disable_doze(self.ad) set_phone_screen_on(self.log, self.ad, 15) self.wifi_network_ssid_2g = self.user_params["wifi_network_ssid_2g"] self.wifi_network_pass_2g = self.user_params["wifi_network_pass_2g"] self.wifi_network_ssid_5g = self.user_params["wifi_network_ssid_5g"] self.wifi_network_pass_5g = self.user_params["wifi_network_pass_5g"] self.monsoon_log_path = os.path.join(self.log_path, "MonsoonLog") create_dir(self.monsoon_log_path) return 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_test(self): #self.dut.droid.bluetoothFactoryReset() #bt_utils.enable_bluetooth(self.dut.droid, self.bt_device.ed) # To prevent default file from being overwritten self.dut.adb.shell('cp {} {}'.format(self.power_file_paths[0], self.power_file_paths[1])) self.sar_file_path = self.power_file_paths[1] self.sar_file_name = os.path.basename(self.power_file_paths[1]) self.bt_sar_df = self.read_sar_table(self.dut) utils.set_location_service(self.bt_device, True) utils.set_location_service(self.dut, True) self.attenuator.set_atten(FIXED_ATTENUATION) self.log.info('Attenuation set to {} dB'.format(FIXED_ATTENUATION)) # BokehFigure object self.plot = wifi_utils.BokehFigure(title='{}'.format( self.current_test_name), x_label='Scenarios', primary_y_label='TX power(dBm)')
def setup_class(self): super(BluetoothBaseTest, self).setup_class() utils.set_location_service(self.scn_ad, True) utils.set_location_service(self.adv_ad, True) return True
def turn_location_on_and_scan_toggle_on(self): """Turns on wifi location scans.""" utils.set_location_service(self.dut, True) self.dut.droid.wifiScannerToggleAlwaysAvailable(True) msg = "Failed to turn on location service's scan." asserts.assert_true(self.dut.droid.wifiScannerIsAlwaysAvailable(), msg)