diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2017-11-17 00:04:15 +0000 |
---|---|---|
committer | android-build-prod (mdb) <android-build-team-robot@google.com> | 2017-11-17 00:04:15 +0000 |
commit | a157be066f79c8607291130ee5c30424daef9afc (patch) | |
tree | 8dc052264d41a30315546c28bb5e49a1ad64e817 | |
parent | b7c0ccaac6e53d2b5683b0fc7d2f5132e3c4c1fe (diff) | |
parent | b2b6c6b41b71cec1e8bfeec2b74faa3fb1cd0d1e (diff) | |
download | platform_tools_test_connectivity-oreo-vts-release.tar.gz platform_tools_test_connectivity-oreo-vts-release.tar.bz2 platform_tools_test_connectivity-oreo-vts-release.zip |
Snap for 4455664 from b2b6c6b41b71cec1e8bfeec2b74faa3fb1cd0d1e to oreo-vts-releaseandroid-vts-8.0_r9android-vts-8.0_r8android-vts-8.0_r7android-vts-8.0_r6android-vts-8.0_r13android-vts-8.0_r12android-vts-8.0_r11android-vts-8.0_r10oreo-vts-release
Change-Id: I1dfb33cf73feaa1c9a493bffb69d5b2aece92399
113 files changed, 5566 insertions, 10365 deletions
diff --git a/acts/framework/acts/base_test.py b/acts/framework/acts/base_test.py index 2fe8e9fbe0..3f59469ca5 100755 --- a/acts/framework/acts/base_test.py +++ b/acts/framework/acts/base_test.py @@ -25,7 +25,6 @@ from acts import records from acts import signals from acts import tracelogger from acts import utils -from acts.test_utils.tel.tel_test_utils import run_multithread_func # Macro strings for test result reporting TEST_CASE_TOKEN = "[Test Case]" @@ -224,10 +223,12 @@ class BaseTestClass(object): record: The records.TestResultRecord object for the failed test case. """ + test_name = record.test_name if record.details: self.log.error(record.details) - self.log.info(RESULT_LINE_TEMPLATE, record.test_name, record.result) - self.on_fail(record.test_name, record.log_begin_time) + begin_time = logger.epoch_to_log_line_timestamp(record.begin_time) + self.log.info(RESULT_LINE_TEMPLATE, test_name, record.result) + self.on_fail(test_name, begin_time) def on_fail(self, test_name, begin_time): """A function that is executed upon a test case failure. @@ -247,11 +248,13 @@ class BaseTestClass(object): record: The records.TestResultRecord object for the passed test case. """ + test_name = record.test_name + begin_time = logger.epoch_to_log_line_timestamp(record.begin_time) msg = record.details if msg: self.log.info(msg) - self.log.info(RESULT_LINE_TEMPLATE, record.test_name, record.result) - self.on_pass(record.test_name, record.log_begin_time) + self.log.info(RESULT_LINE_TEMPLATE, test_name, record.result) + self.on_pass(test_name, begin_time) def on_pass(self, test_name, begin_time): """A function that is executed upon a test case passing. @@ -271,9 +274,11 @@ class BaseTestClass(object): record: The records.TestResultRecord object for the skipped test case. """ - self.log.info(RESULT_LINE_TEMPLATE, record.test_name, record.result) + test_name = record.test_name + begin_time = logger.epoch_to_log_line_timestamp(record.begin_time) + self.log.info(RESULT_LINE_TEMPLATE, test_name, record.result) self.log.info("Reason to skip: %s", record.details) - self.on_skip(record.test_name, record.log_begin_time) + self.on_skip(test_name, begin_time) def on_skip(self, test_name, begin_time): """A function that is executed upon a test case being skipped. @@ -293,9 +298,11 @@ class BaseTestClass(object): record: The records.TestResultRecord object for the blocked test case. """ - self.log.info(RESULT_LINE_TEMPLATE, record.test_name, record.result) + test_name = record.test_name + begin_time = logger.epoch_to_log_line_timestamp(record.begin_time) + self.log.info(RESULT_LINE_TEMPLATE, test_name, record.result) self.log.info("Reason to block: %s", record.details) - self.on_blocked(record.test_name, record.log_begin_time) + self.on_blocked(test_name, begin_time) def on_blocked(self, test_name, begin_time): """A function that is executed upon a test begin skipped. @@ -313,8 +320,10 @@ class BaseTestClass(object): record: The records.TestResultRecord object for the failed test case. """ + test_name = record.test_name self.log.exception(record.details) - self.on_exception(record.test_name, record.log_begin_time) + begin_time = logger.epoch_to_log_line_timestamp(record.begin_time) + self.on_exception(test_name, begin_time) def on_exception(self, test_name, begin_time): """A function that is executed upon an unhandled exception from a test @@ -366,8 +375,6 @@ class BaseTestClass(object): is_generate_trigger = False tr_record = records.TestResultRecord(test_name, self.TAG) tr_record.test_begin() - self.begin_time = tr_record.log_begin_time - self.test_name = tr_record.test_name self.log.info("%s %s", TEST_CASE_TOKEN, test_name) verdict = None try: @@ -376,7 +383,7 @@ class BaseTestClass(object): for ad in self.android_devices: if not ad.is_adb_logcat_on: ad.start_adb_logcat(cont_logcat_file=True) - ret = self._setup_test(self.test_name) + ret = self._setup_test(test_name) asserts.assert_true(ret is not False, "Setup for %s failed." % test_name) if args or kwargs: @@ -385,7 +392,7 @@ class BaseTestClass(object): verdict = test_func() finally: try: - self._teardown_test(self.test_name) + self._teardown_test(test_name) except signals.TestAbortAll: raise except Exception as e: @@ -403,7 +410,6 @@ class BaseTestClass(object): except (signals.TestAbortClass, signals.TestAbortAll) as e: # Abort signals, pass along. tr_record.test_fail(e) - self._exec_procedure_func(self._on_fail, tr_record) raise e except signals.TestPass as e: # Explicit test pass. @@ -677,25 +683,27 @@ class BaseTestClass(object): user. """ - def _ad_take_reports(self, ad, test_name, begin_time): - try: - ad.take_bug_report(test_name, begin_time) - bugreport_path = os.path.join(ad.log_path, test_name) - utils.create_dir(bugreport_path) - ad.check_crash_report(test_name, begin_time, True) - if getattr(ad, "qxdm_always_on", False): - ad.get_qxdm_logs() - except Exception as e: - ad.log.error("Failed to take a bug report for %s with error %s", - test_name, e) - def _take_bug_report(self, test_name, begin_time): if "no_bug_report_on_fail" in self.user_params: return - tasks = [(self._ad_take_reports, (ad, test_name, begin_time)) - for ad in self.android_devices] - run_multithread_func(self.log, tasks) + # magical sleep to ensure the runtime restart or reboot begins + time.sleep(1) + for ad in self.android_devices: + try: + ad.adb.wait_for_device() + ad.take_bug_report(test_name, begin_time) + bugreport_path = os.path.join(ad.log_path, test_name) + utils.create_dir(bugreport_path) + ad.check_crash_report(True, test_name) + if getattr(ad, "qxdm_always_on", False): + ad.log.info("Pull QXDM Logs") + ad.pull_files(["/data/vendor/radio/diag_logs/logs/"], + bugreport_path) + except Exception as e: + ad.log.error( + "Failed to take a bug report for %s with error %s", + test_name, e) def _reboot_device(self, ad): ad.log.info("Rebooting device.") diff --git a/acts/framework/acts/config_parser.py b/acts/framework/acts/config_parser.py index 54d15f56c9..57c3a5c7ae 100755 --- a/acts/framework/acts/config_parser.py +++ b/acts/framework/acts/config_parser.py @@ -68,39 +68,11 @@ def _validate_testbed_name(name): "Char '%s' is not allowed in test bed names." % l) -def _update_file_paths(config, config_path): - """ Checks if the path entries are valid. - - If the file path is invaild, assume it is a relative path and append - that to the config file path. - - Args: - config : the config object to verify. - config_path : The path to the config file, which can be used to - generate absolute paths from relative paths in configs. - - Raises: - If the file path is invalid, ActsConfigError is raised. - """ - # Check the file_path_keys and update if it is a relative path. - for file_path_key in keys.Config.file_path_keys.value: - if file_path_key in config: - config_file = config[file_path_key] - if not os.path.isfile(config_file): - config_file = os.path.join(config_path, config_file) - if not os.path.isfile(config_file): - raise ActsConfigError("Unable to load config %s from test " - "config file.", config_file) - config[file_path_key] = config_file - - -def _validate_testbed_configs(testbed_configs, config_path): +def _validate_testbed_configs(testbed_configs): """Validates the testbed configurations. Args: testbed_configs: A list of testbed configuration json objects. - config_path : The path to the config file, which can be used to - generate absolute paths from relative paths in configs. Raises: If any part of the configuration is invalid, ActsConfigError is raised. @@ -108,7 +80,6 @@ def _validate_testbed_configs(testbed_configs, config_path): seen_names = set() # Cross checks testbed configs for resource conflicts. for config in testbed_configs: - _update_file_paths(config, config_path) # Check for conflicts between multiple concurrent testbed configs. # No need to call it if there's only one testbed config. name = config[keys.Config.key_testbed_name.value] @@ -288,20 +259,19 @@ def load_test_config_file(test_config_path, configs[keys.Config.key_test_paths.value] = os.environ[ _ENV_ACTS_TESTPATHS].split(_PATH_SEPARATOR) - # Add the global paths to the global config. + _validate_test_config(configs) + _validate_testbed_configs(configs[keys.Config.key_testbed.value]) k_log_path = keys.Config.key_log_path.value configs[k_log_path] = utils.abs_path(configs[k_log_path]) - - # TODO: See if there is a better way to do this: b/29836695 config_path, _ = os.path.split(utils.abs_path(test_config_path)) configs[keys.Config.key_config_path] = config_path - _validate_test_config(configs) - _validate_testbed_configs(configs[keys.Config.key_testbed.value], - config_path) + tps = configs[keys.Config.key_test_paths.value] # Unpack testbeds into separate json objects. beds = configs.pop(keys.Config.key_testbed.value) config_jsons = [] - + # TODO: See if there is a better way to do this: b/29836695 + config_path, _ = os.path.split(utils.abs_path(test_config_path)) + configs[keys.Config.key_config_path] = config_path for original_bed_config in beds: new_test_config = dict(configs) new_test_config[keys.Config.key_testbed.value] = original_bed_config diff --git a/acts/framework/acts/controllers/access_point.py b/acts/framework/acts/controllers/access_point.py index fabfd404e7..c91275a8aa 100755 --- a/acts/framework/acts/controllers/access_point.py +++ b/acts/framework/acts/controllers/access_point.py @@ -117,6 +117,9 @@ class AccessPoint(object): # the hostapd instance running against the interface. self._aps = dict() + def __del__(self): + self.close() + def start_ap(self, hostapd_config, additional_parameters=None): """Starts as an ap using a set of configurations. @@ -162,11 +165,15 @@ class AccessPoint(object): # up to 8 different mac addresses. The easiest way to do this # is to set the last byte to 0. While technically this could # cause a duplicate mac address it is unlikely and will allow for - # one radio to have up to 8 APs on the interface. + # one radio to have up to 8 APs on the interface. The check ensures + # backwards compatibility since if someone has set the bssid on purpose + # the bssid will not be changed from what the user set. interface_mac_orig = None - cmd = "ifconfig %s|grep ether|awk -F' ' '{print $2}'" % interface - interface_mac_orig = self.ssh.run(cmd) - hostapd_config.bssid = interface_mac_orig.stdout[:-1] + '0' + if not hostapd_config.bssid: + cmd = "ifconfig %s|grep ether|awk -F' ' '{print $2}'" % interface + interface_mac_orig = self.ssh.run(cmd) + interface_mac = interface_mac_orig.stdout[:-1] + '0' + hostapd_config.bssid = interface_mac if interface in self._aps: raise ValueError('No WiFi interface available for AP on ' @@ -193,10 +200,11 @@ class AccessPoint(object): dhcp_bss = {} counter = 1 for bss in hostapd_config.bss_lookup: - if interface_mac_orig: - hostapd_config.bss_lookup[ - bss].bssid = interface_mac_orig.stdout[:-1] + str( - counter) + if not hostapd_config.bss_lookup[bss].bssid: + if interface_mac_orig: + hostapd_config.bss_lookup[ + bss].bssid = interface_mac_orig.stdout[:-1] + str( + counter) self._route_cmd.clear_routes(net_interface=str(bss)) if interface is _AP_2GHZ_INTERFACE: starting_ip_range = _AP_2GHZ_SUBNET_STR @@ -222,8 +230,8 @@ class AccessPoint(object): # variables represent the interface name, k, and dhcp info, v. for k, v in dhcp_bss.items(): bss_interface_ip = ipaddress.ip_interface( - '%s/%s' % (dhcp_bss[k].router, - dhcp_bss[k].network.netmask)) + '%s/%s' % + (dhcp_bss[k].router, dhcp_bss[k].network.netmask)) self._ip_cmd.set_ipv4_address(str(k), bss_interface_ip) # Restart the DHCP server with our updated list of subnets. @@ -241,26 +249,15 @@ class AccessPoint(object): Args: ssid: An SSID string - Returns: The BSSID if on the AP or None if SSID could not be found. + Returns: The BSSID if on the AP or None is SSID could not be found. """ - interfaces = [_AP_2GHZ_INTERFACE, _AP_5GHZ_INTERFACE, ssid] - # Get the interface name associated with the given ssid. - for interface in interfaces: - cmd = "iw dev %s info|grep ssid|awk -F' ' '{print $2}'" % ( - str(interface)) - iw_output = self.ssh.run(cmd) - if 'command failed: No such device' in iw_output.stderr: - continue - else: - # If the configured ssid is equal to the given ssid, we found - # the right interface. - if iw_output.stdout == ssid: - cmd = "iw dev %s info|grep addr|awk -F' ' '{print $2}'" % ( - str(interface)) - iw_output = self.ssh.run(cmd) - return iw_output.stdout - return None + cmd = "iw dev %s info|grep addr|awk -F' ' '{print $2}'" % str(ssid) + iw_output = self.ssh.run(cmd) + if 'command failed: No such device' in iw_output.stderr: + return None + else: + return iw_output.stdout def stop_ap(self, identifier): """Stops a running ap on this controller. @@ -304,4 +301,6 @@ class AccessPoint(object): if self._aps: self.stop_all_aps() + self._dhcp.stop() + self.ssh.close() diff --git a/acts/framework/acts/controllers/adb.py b/acts/framework/acts/controllers/adb.py index 5524700ee4..2a1b69d439 100644 --- a/acts/framework/acts/controllers/adb.py +++ b/acts/framework/acts/controllers/adb.py @@ -137,19 +137,6 @@ class AdbProxy(object): return self._exec_cmd(' '.join((self.adb_str, name, arg_str)), **kwargs) - def _exec_cmd_nb(self, cmd): - """Executes adb commands in a new shell, non blocking. - - Args: - cmds: A string that is the adb command to execute. - - """ - job.run_async(cmd) - - def _exec_adb_cmd_nb(self, name, arg_str, **kwargs): - return self._exec_cmd_nb(' '.join((self.adb_str, name, arg_str)), - **kwargs) - def tcp_forward(self, host_port, device_port): """Starts tcp forwarding from localhost to this android device. @@ -207,9 +194,6 @@ class AdbProxy(object): ignore_status=ignore_status, timeout=timeout) - def shell_nb(self, command): - return self._exec_adb_cmd_nb('shell', shellescape.quote(command)) - def pull(self, command, ignore_status=False, diff --git a/acts/framework/acts/controllers/android_device.py b/acts/framework/acts/controllers/android_device.py index f0778258ae..114b956b93 100755 --- a/acts/framework/acts/controllers/android_device.py +++ b/acts/framework/acts/controllers/android_device.py @@ -45,10 +45,9 @@ ANDROID_DEVICE_ADB_LOGCAT_PARAM_KEY = "adb_logcat_param" ANDROID_DEVICE_EMPTY_CONFIG_MSG = "Configuration is empty, abort!" ANDROID_DEVICE_NOT_LIST_CONFIG_MSG = "Configuration should be a list, abort!" CRASH_REPORT_PATHS = ("/data/tombstones/", "/data/vendor/ramdump/", - "/data/ramdump/", "/data/vendor/ssrdump", - "/data/vendor/ramdump/bluetooth") -CRASH_REPORT_SKIPS = ("RAMDUMP_RESERVED", "RAMDUMP_STATUS", "bluetooth") -BUG_REPORT_TIMEOUT = 1800 + "/data/ramdump/") +CRASH_REPORT_SKIPS = ("RAMDUMP_RESERVED", "RAMDUMP_STATUS") +BUG_REPORT_TIMEOUT = 1200 PULL_TIMEOUT = 300 PORT_RETRY_COUNT = 3 IPERF_TIMEOUT = 60 @@ -137,17 +136,12 @@ def _start_services_on_ads(ads): running_ads = [] for ad in ads: running_ads.append(ad) - if not ad.ensure_screen_on(): - ad.log.error("User window cannot come up") - destroy(running_ads) - raise AndroidDeviceError("User window cannot come up") if not ad.is_sl4a_installed(): - ad.log.error("sl4a.apk is not installed") + ad.log.info("sl4a.apk is not installed") if not ad.skip_sl4a: ad.log.exception("The required sl4a.apk is not installed") destroy(running_ads) - raise AndroidDeviceError( - "The required sl4a.apk is not installed") + raise try: ad.start_services(skip_sl4a=ad.skip_sl4a) except: @@ -387,7 +381,6 @@ class AndroidDevice: self._ssh_connection = ssh_connection self.skip_sl4a = False self.crash_report = None - self.device_password = None def clean_up(self): """Cleans up the AndroidDevice object and releases any resources it @@ -416,21 +409,13 @@ class AndroidDevice: except: self.log.exception("Failed to start adb logcat!") raise - self.exit_setup_wizard() if not skip_sl4a: try: - droid, ed = self.get_droid() - ed.start() + self.get_droid() + self.ed.start() except: self.log.exception("Failed to start sl4a!") raise - # Enable or Disable Device Password per test bed config - if self.device_password: - self.log.info("Enable device password") - droid.setDevicePassword(self.device_password) - else: - self.log.debug("Disable device password") - droid.disableDevicePassword() def stop_services(self): """Stops long running services on the android device. @@ -558,12 +543,18 @@ class AndroidDevice: """ if self.adb_logcat_process: try: - utils._assert_subprocess_running(self.adb_logcat_process) + ret = self.adb_logcat_process.poll() + except AttributeError as e: + #This happens if the logcat process is not a Popen object as + #would be expected if connected to a real android device. This + #solves the mock test problem. + ret = None + if ret is None: return True - except Exception: + else: if self.droid: self.droid.logI('Logcat died') - self.log.info("Logcat to %s died", self.adb_logcat_file_path) + self.log.error('Logcat died on %s' % self.adb_logcat_file_path) return False return False @@ -579,7 +570,7 @@ class AndroidDevice: """ for k, v in config.items(): # skip_sl4a value can be reset from config file - if hasattr(self, k) and k not in ("skip_sl4a", "device_password"): + if hasattr(self, k) and k != "skip_sl4a": raise AndroidDeviceError( "Attempting to set existing attribute %s on %s" % (k, self.serial)) @@ -634,27 +625,25 @@ class AndroidDevice: last_error = e pass if not forward_success: - self.log.error(last_error) raise last_error - for i in range(PORT_RETRY_COUNT): - try: - if self.is_sl4a_running(): - self.log.info("Stop sl4a apk") - self.stop_sl4a() - time.sleep(15) - self.log.info("Start sl4a apk") - self.start_sl4a() - time.sleep(5) - droid = self.start_new_session() - if handle_event: - ed = self.get_dispatcher(droid) - return droid, ed - return droid - except Exception as e: - self.log.warning("get_droid with exception: %s", e) - if i == PORT_RETRY_COUNT - 1: - raise + # TODO(bpeake) b/33470152 Fixup SL4A connection code + if self.is_sl4a_running(): + self.stop_sl4a() + time.sleep(30) + self.start_sl4a() + try: + droid = self.start_new_session() + except: + self.stop_sl4a() + time.sleep(30) + self.start_sl4a() + droid = self.start_new_session() + + if handle_event: + ed = self.get_dispatcher(droid) + return droid, ed + return droid def get_dispatcher(self, droid): """Return an EventDispatcher for an sl4a session @@ -752,7 +741,7 @@ class AndroidDevice: if cont_logcat_file: if self.droid: self.droid.logI('Restarting logcat') - self.log.info( + self.log.warning( 'Restarting logcat on file %s' % self.adb_logcat_file_path) logcat_file_path = self.adb_logcat_file_path else: @@ -859,7 +848,6 @@ class AndroidDevice: test_name: Name of the test case that triggered this bug report. begin_time: Logline format timestamp taken when the test started. """ - self.adb.wait_for_device() new_br = True try: stdout = self.adb.shell("bugreportz -v") @@ -890,7 +878,6 @@ class AndroidDevice: " > {}".format(full_out_path), timeout=BUG_REPORT_TIMEOUT) self.log.info("Bugreport for %s taken at %s.", test_name, full_out_path) - self.adb.wait_for_device() def get_file_names(self, directory): """Get files names with provided directory.""" @@ -909,41 +896,23 @@ class AndroidDevice: self.adb.pull( "%s %s" % (file_name, remote_path), timeout=PULL_TIMEOUT) - def check_crash_report(self, - test_name=None, - begin_time=None, - log_crash_report=False): + def check_crash_report(self, log_crash_report=False, test_name=None): """check crash report on the device.""" crash_reports = [] for crash_path in CRASH_REPORT_PATHS: for report in self.get_file_names(crash_path): if report in CRASH_REPORT_SKIPS: continue - file_path = os.path.join(crash_path, report) - if begin_time: - file_time = self.adb.shell('stat -c "%%y" %s' % file_path) - if begin_time < file_time.split('-', 1)[1]: - crash_reports.append(file_path) - else: - crash_reports.append(file_path) - if crash_reports and log_crash_report: - test_name = test_name or begin_time or time.strftime( - "%m-%d-%Y-%H-%M-%S") - crash_log_path = os.path.join(self.log_path, test_name, "Crashes") + crash_reports.append(os.path.join(crash_path, report)) + if log_crash_report: + if not test_name: + test_name = time.strftime("%m-%d-%Y-%H-%M-%S") + crash_log_path = os.path.join(self.log_path, test_name, + "CrashReports") utils.create_dir(crash_log_path) self.pull_files(crash_reports, crash_log_path) return crash_reports - def get_qxdm_logs(self): - """Get qxdm logs.""" - ad.log.info("Pull QXDM Logs") - qxdm_logs = self.get_file_names( - "/data/vendor/radio/diag_logs/logs/*.qmdl") - if qxdm_logs: - qxdm_path = os.path.join(ad.log_path, "QXDM_Logs") - utils.create_dir(qxdm_path) - ad.pull_files(qxdm_logs, qxdm_path) - def start_new_session(self): """Start a new session in sl4a. @@ -962,7 +931,6 @@ class AndroidDevice: if droid.uid in self._droid_sessions: raise sl4a_client.Sl4aException( "SL4A returned an existing uid for a new session. Abort.") - self.log.info("Add new sl4a session %s", droid.uid) self._droid_sessions[droid.uid] = [droid] return droid @@ -983,7 +951,6 @@ class AndroidDevice: if session_id not in self._droid_sessions: raise DoesNotExistError("Session %d doesn't exist." % session_id) droid = sl4a_client.Sl4aClient(port=self.h_port, uid=session_id) - self.log.info("Open s4la session %s", session_id) droid.open(cmd=sl4a_client.Sl4aCommand.CONTINUE) return droid @@ -996,17 +963,15 @@ class AndroidDevice: Args: session_id: UID of the sl4a session to terminate. """ - ed_key = self.serial + str(session_id) - if self._event_dispatchers and ed_key in self._event_dispatchers: - self.log.info("Clear event dispatcher session %s", session_id) - self._event_dispatchers[ed_key].clean_up() - del self._event_dispatchers[ed_key] if self._droid_sessions and (session_id in self._droid_sessions): for droid in self._droid_sessions[session_id]: - self.log.info("Close sl4a session %s", session_id) droid.closeSl4aSession(timeout=180) droid.close() del self._droid_sessions[session_id] + ed_key = self.serial + str(session_id) + if self._event_dispatchers and ed_key in self._event_dispatchers: + self._event_dispatchers[ed_key].clean_up() + del self._event_dispatchers[ed_key] def terminate_all_sessions(self): """Terminate all sl4a sessions on the AndroidDevice instance. @@ -1018,9 +983,9 @@ class AndroidDevice: for session_id in session_ids: try: self.terminate_session(session_id) - except Exception as e: - self.log.exception("Failed to terminate session %d: %s", - session_id, e) + except: + self.log.exception("Failed to terminate session %d.", + session_id) if self.h_port: self.adb.remove_tcp_forward(self.h_port) self.h_port = None @@ -1090,69 +1055,42 @@ class AndroidDevice: raise AndroidDeviceError( "Device %s booting process timed out." % self.serial) - def reboot(self, stop_at_lock_screen=False): + def reboot(self): """Reboots the device. Terminate all sl4a sessions, reboot the device, wait for device to - complete booting, and restart an sl4a session if restart_sl4a is True. + complete booting, and restart an sl4a session. - Args: - stop_at_lock_screen: whether to unlock after reboot. Set to False - if want to bring the device to reboot up to password locking - phase. Sl4a checking need the device unlocked after rebooting. + This is a blocking method. + + This is probably going to print some error messages in console. Only + use if there's no other option. + + Example: + droid, ed = ad.reboot() Returns: - None, sl4a session and event_dispatcher. + An sl4a session with an event_dispatcher. + + Raises: + AndroidDeviceError is raised if waiting for completion timed + out. """ if self.is_bootloader: self.fastboot.reboot() return - self.terminate_all_sessions() - self.log.info("Reboot") - self.adb.reboot() - self.wait_for_boot_completion() - self.root_adb() - if self.is_waiting_for_unlock_pin() and stop_at_lock_screen: - return - if not self.ensure_screen_on(): - self.log.error("User window cannot come up") - raise AndroidDeviceError("User window cannot come up") - self.ensure_screen_on() - self.start_services(self.skip_sl4a) - - def fastboot_wipe(self): - """Wipe the device in fastboot mode. - - Pull sl4a apk from device. Terminate all sl4a sessions, - Reboot the device to bootloader, wipe the device by fastboot. - Reboot the device. wait for device to complete booting - Re-intall and start an sl4a session. - - """ - #Pull sl4a apk from device - out = self.adb.shell("pm path com.googlecode.android_scripting") - result = re.search(r"package:(.*)", out) - if not result: - self.log.error("Couldn't find sl4a apk") - else: - sl4a_apk = result.group(1) - self.log.info("Get sl4a apk from %s", sl4a_apk) - self.pull_files([sl4a_apk], "/tmp/") has_adb_log = self.is_adb_logcat_on + if has_adb_log: + self.stop_adb_logcat() self.terminate_all_sessions() - self.log.info("Reboot to bootloader") - self.adb.reboot_bootloader(ignore_status=True) - self.log.info("Wipe in fastboot") - self.fastboot._w() - self.fastboot.reboot() - self.log.info("Reboot") + self.adb.reboot() self.wait_for_boot_completion() self.root_adb() - if result: - self.log.info("Re-install sl4a") - self.adb.install("-r /tmp/base.apk") - time.sleep(10) - self.start_services(self.skip_sl4a) + droid, ed = self.get_droid() + ed.start() + if has_adb_log: + self.start_adb_logcat() + return droid, ed def search_logcat(self, matching_string): """Search logcat message with given string. @@ -1230,129 +1168,6 @@ class AndroidDevice: else: return None - def send_keycode(self, keycode): - self.adb.shell("input keyevent KEYCODE_%s" % keycode) - - def get_my_current_focus_window(self): - """Get the current focus window on screen""" - output = self.adb.shell( - 'dumpsys window windows | grep -E mCurrentFocus') - if not output or "mCurrentFocus=null" in output: - result = '' - else: - result = output.split(' ')[-1].strip("}") - self.log.debug("Current focus window is %s", result) - return result - - def get_my_current_focus_app(self): - """Get the current focus application""" - output = self.adb.shell('dumpsys window windows | grep -E mFocusedApp') - if not output or "mFocusedApp=null" in output: - result = '' - else: - result = output.split(' ')[-2] - self.log.debug("Current focus app is %s", result) - return result - - def is_window_ready(self, window_name=None): - current_window = self.get_my_current_focus_window() - if window_name: - return window_name in current_window - return current_window and "CryptKeeper" not in current_window and ( - "FallbackHome" not in self.get_my_current_focus_app()) - - def wait_for_window_ready(self, - window_name=None, - check_interval=5, - check_duration=60): - elapsed_time = 0 - while elapsed_time < check_duration: - time.sleep(check_interval) - elapsed_time += check_interval - if self.is_window_ready(window_name=window_name): - return True - self.log.info("Current focus window is %s", - self.get_my_current_focus_window()) - return False - - def is_user_setup_complete(self): - return "1" in self.adb.shell("settings get secure user_setup_complete") - - def is_screen_awake(self): - """Check if device screen is in sleep mode""" - output = self.adb.shell("dumpsys power | grep mWakefulness=") - return "Awake" in output - - def is_screen_emergency_dialer(self): - """Check if device screen is in emergency dialer mode""" - return "EmergencyDialer" in self.get_my_current_focus_window() - - def is_screen_in_call_activity(self): - """Check if device screen is in in-call activity notification""" - return "InCallActivity" in self.get_my_current_focus_window() - - def is_setupwizard_on(self): - """Check if device screen is in emergency dialer mode""" - return "setupwizard" in self.get_my_current_focus_app() - - def is_waiting_for_unlock_pin(self): - """Check if device is waiting for unlock pin to boot up""" - if "CryptKeeper" in self.get_my_current_focus_window(): - self.log.info("Device is in CrpytKeeper window") - return True - if "FallbackHome" in self.get_my_current_focus_app(): - self.log.info("Device is locked") - return True - return False - - def ensure_screen_on(self): - """Ensure device screen is powered on""" - if not self.is_screen_awake(): - self.wakeup_screen() - if self.is_screen_emergency_dialer( - ) or self.is_screen_in_call_activity(): - # Send two BACK keycodes to get out notification and dialer - self.send_keycode("BACK") - self.send_keycode("BACK") - time.sleep(2) - if self.is_waiting_for_unlock_pin(): - self.unlock_screen() - time.sleep(2) - if self.is_waiting_for_unlock_pin(): - self.unlock_screen() - return self.wait_for_window_ready() - elif self.device_password and self.get_my_current_focus_window( - ) == "StatusBar": - self.unlock_screen() - return self.is_window_ready() - - def wakeup_screen(self): - self.send_keycode("WAKEUP") - current_window = self.get_my_current_focus_window() - if "NexusLauncherActivity" not in current_window or ( - "StatusBar" not in current_window): - self.send_keycode("MENU") - - def go_to_sleep(self): - self.send_keycode("SLEEP") - - def send_keycode_number_pad(self, number): - self.send_keycode("NUMPAD_%s" % number) - - def unlock_screen(self, password=None): - password = password or self.device_password or "1111" - self.log.info("Unlocking screen with pin %s", password) - self.wakeup_screen() - self.send_keycode("DEL") - for number in password: - self.send_keycode_number_pad(number) - self.send_keycode("ENTER") - - def exit_setup_wizard(self): - self.adb.shell( - "am start -n com.google.android.setupwizard/.SetupWizardExitActivity" - ) - class AndroidDeviceLoggerAdapter(logging.LoggerAdapter): def process(self, msg, kwargs): diff --git a/acts/framework/acts/controllers/ap_lib/hostapd_constants.py b/acts/framework/acts/controllers/ap_lib/hostapd_constants.py index 4e43eab6ae..d0dcce1ec9 100755 --- a/acts/framework/acts/controllers/ap_lib/hostapd_constants.py +++ b/acts/framework/acts/controllers/ap_lib/hostapd_constants.py @@ -16,8 +16,6 @@ import itertools -BAND_2G = '2g' -BAND_5G = '5g' WPA1 = 1 WPA2 = 2 MIXED = 3 diff --git a/acts/framework/acts/controllers/event_dispatcher.py b/acts/framework/acts/controllers/event_dispatcher.py index 9b75537f05..93ec2c5928 100644 --- a/acts/framework/acts/controllers/event_dispatcher.py +++ b/acts/framework/acts/controllers/event_dispatcher.py @@ -15,7 +15,6 @@ # limitations under the License. from concurrent.futures import ThreadPoolExecutor -import logging import queue import re import socket @@ -66,10 +65,10 @@ class EventDispatcher: event_name = None try: event_obj = self.droid.eventWait(50000) - except Exception as e: + except: if self.started: - logging.error("Exception %s happened during polling.", e) - logging.info(traceback.format_exc()) + print("Exception happened during polling.") + print(traceback.format_exc()) raise if not event_obj: continue @@ -116,8 +115,8 @@ class EventDispatcher: self.lock.acquire() try: if event_name in self.handlers: - raise DuplicateError( - 'A handler for {} already exists'.format(event_name)) + raise DuplicateError('A handler for {} already exists'.format( + event_name)) self.handlers[event_name] = (handler, args) finally: self.lock.release() @@ -184,8 +183,8 @@ class EventDispatcher: e_queue = self.get_event_q(event_name) if not e_queue: - raise TypeError( - "Failed to get an event queue for {}".format(event_name)) + raise TypeError("Failed to get an event queue for {}".format( + event_name)) try: # Block for timeout @@ -242,8 +241,9 @@ class EventDispatcher: return event if time.time() > deadline: - raise queue.Empty('Timeout after {}s waiting for event: {}'. - format(timeout, event_name)) + raise queue.Empty( + 'Timeout after {}s waiting for event: {}'.format( + timeout, event_name)) def pop_events(self, regex_pattern, timeout, freq=1): """Pop events whose names match a regex pattern. @@ -317,7 +317,8 @@ class EventDispatcher: passed. """ self.lock.acquire() - if not event_name in self.event_dict or self.event_dict[event_name] is None: + if not event_name in self.event_dict or self.event_dict[ + event_name] is None: self.event_dict[event_name] = queue.Queue() self.lock.release() diff --git a/acts/framework/acts/controllers/monsoon.py b/acts/framework/acts/controllers/monsoon.py index e31261af1b..d573afc66a 100644 --- a/acts/framework/acts/controllers/monsoon.py +++ b/acts/framework/acts/controllers/monsoon.py @@ -196,8 +196,8 @@ class MonsoonProxy(object): logging.warning("Wanted status, dropped type=0x%02x, len=%d", read_bytes[0], len(read_bytes)) continue - status = dict( - zip(STATUS_FIELDS, struct.unpack(STATUS_FORMAT, read_bytes))) + status = dict(zip(STATUS_FIELDS, struct.unpack(STATUS_FORMAT, + read_bytes))) p_type = status["packetType"] if p_type != 0x10: raise MonsoonError("Package type %s is not 0x10." % p_type) @@ -300,10 +300,8 @@ class MonsoonProxy(object): continue seq, _type, x, y = struct.unpack("BBBB", _bytes[:4]) - data = [ - struct.unpack(">hhhh", _bytes[x:x + 8]) - for x in range(4, len(_bytes) - 8, 8) - ] + data = [struct.unpack(">hhhh", _bytes[x:x + 8]) + for x in range(4, len(_bytes) - 8, 8)] if self._last_seq and seq & 0xF != (self._last_seq + 1) & 0xF: logging.warning("Data sequence skipped, lost packet?") @@ -379,8 +377,8 @@ class MonsoonProxy(object): self.ser.flush() flushed = 0 while True: - ready_r, ready_w, ready_x = select.select([self.ser], [], - [self.ser], 0) + ready_r, ready_w, ready_x = select.select( + [self.ser], [], [self.ser], 0) if len(ready_x) > 0: logging.error("Exception from serial port.") return None @@ -422,9 +420,9 @@ class MonsoonData(object): self.offset = offset num_of_data_pt = len(self._data_points) if self.offset >= num_of_data_pt: - raise MonsoonError( - ("Offset number (%d) must be smaller than the " - "number of data points (%d).") % (offset, num_of_data_pt)) + raise MonsoonError(("Offset number (%d) must be smaller than the " + "number of data points (%d).") % + (offset, num_of_data_pt)) self.data_points = self._data_points[self.offset:] self.timestamps = self._timestamps[self.offset:] self.hz = hz @@ -470,26 +468,17 @@ class MonsoonData(object): lines = data_str.strip().split('\n') err_msg = ("Invalid input string format. Is this string generated by " "MonsoonData class?") - conditions = [ - len(lines) <= 4, "Average Current:" not in lines[1], - "Voltage: " not in lines[2], "Total Power: " not in lines[3], - "samples taken at " not in lines[4], - lines[5] != "Time" + ' ' * 7 + "Amp" - ] + conditions = [len(lines) <= 4, "Average Current:" not in lines[1], + "Voltage: " not in lines[2], + "Total Power: " not in lines[3], + "samples taken at " not in lines[4], + lines[5] != "Time" + ' ' * 7 + "Amp"] if any(conditions): raise MonsoonError(err_msg) - """Example string from Monsoon output file, first line is empty. - Line1: - Line2: test_2g_screenoff_dtimx2_marlin_OPD1.170706.006 - Line3: Average Current: 51.87984mA. - Line4: Voltage: 4.2V. - Line5: Total Power: 217.895328mW. - Line6: 150000 samples taken at 500Hz, with an offset of 0 samples. - """ - hz_str = lines[4].split()[4] - hz = int(hz_str[:-3]) + hz_str = lines[4].split()[2] + hz = int(hz_str[:-2]) voltage_str = lines[2].split()[1] - voltage = float(voltage_str[:-2]) + voltage = int(voltage[:-1]) lines = lines[6:] t = [] v = [] @@ -516,7 +505,7 @@ class MonsoonData(object): raise MonsoonError("Attempting to write empty Monsoon data to " "file, abort") utils.create_dir(os.path.dirname(file_path)) - with open(file_path, 'a') as f: + with open(file_path, 'w') as f: for md in monsoon_data: f.write(str(md)) f.write(MonsoonData.delimiter) @@ -536,7 +525,6 @@ class MonsoonData(object): results = [] with open(file_path, 'r') as f: data_strs = f.read().split(MonsoonData.delimiter) - data_strs = data_strs[:-1] for data_str in data_strs: results.append(MonsoonData.from_string(data_str)) return results @@ -602,9 +590,9 @@ class MonsoonData(object): strs.append("Average Current: {}mA.".format(self.average_current)) strs.append("Voltage: {}V.".format(self.voltage)) strs.append("Total Power: {}mW.".format(self.total_power)) - strs.append( - ("{} samples taken at {}Hz, with an offset of {} samples.").format( - len(self._data_points), self.hz, self.offset)) + strs.append(("{} samples taken at {}Hz, with an offset of {} samples." + ).format( + len(self._data_points), self.hz, self.offset)) return "\n".join(strs) def __len__(self): @@ -762,12 +750,11 @@ class Monsoon(object): pass self.mon.StopDataCollection() try: - return MonsoonData( - current_values, - timestamps, - sample_hz, - voltage, - offset=sample_offset) + return MonsoonData(current_values, + timestamps, + sample_hz, + voltage, + offset=sample_offset) except: return None @@ -896,8 +883,8 @@ class Monsoon(object): self._wait_for_device(self.dut) # Wait for device to come back online. time.sleep(10) - self.dut.start_services(skip_sl4a=getattr( - self.dut, "skip_sl4a", False)) + self.dut.start_services(skip_sl4a=getattr(self.dut, + "skip_sl4a", False)) # Release wake lock to put device into sleep. self.dut.droid.goToSleepNow() return results @@ -922,13 +909,14 @@ class Monsoon(object): oset = offset * hz data = None try: + self.usb("auto") + time.sleep(1) self.dut.stop_services() time.sleep(1) - self.usb("off") data = self.take_samples(hz, num, sample_offset=oset) if not data: - raise MonsoonError( - ("No data was collected in measurement %s.") % tag) + raise MonsoonError(( + "No data was collected in measurement %s.") % tag) data.tag = tag self.log.info("Measurement summary: %s", repr(data)) finally: @@ -938,8 +926,8 @@ class Monsoon(object): self._wait_for_device(self.dut) # Wait for device to come back online. time.sleep(10) - self.dut.start_services(skip_sl4a=getattr(self.dut, "skip_sl4a", - False)) + self.dut.start_services(skip_sl4a=getattr(self.dut, + "skip_sl4a", False)) # Release wake lock to put device into sleep. self.dut.droid.goToSleepNow() self.log.info("Dut reconnected.") diff --git a/acts/framework/acts/controllers/relay_lib/relay_rig.py b/acts/framework/acts/controllers/relay_lib/relay_rig.py index a88099d566..6a167a8177 100644 --- a/acts/framework/acts/controllers/relay_lib/relay_rig.py +++ b/acts/framework/acts/controllers/relay_lib/relay_rig.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2017 - The Android Open Source Project +# Copyright 2016 - The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from acts.controllers.relay_lib.helpers import validate_key from acts.controllers.relay_lib.sain_smart_board import SainSmartBoard from acts.controllers.relay_lib.generic_relay_device import GenericRelayDevice from acts.controllers.relay_lib.fugu_remote import FuguRemote -from acts.controllers.relay_lib.sony_xb2_speaker import SonyXB2Speaker class RelayRig: @@ -49,7 +48,6 @@ class RelayRig: _device_constructors = { 'GenericRelayDevice': lambda x, rig: GenericRelayDevice(x, rig), 'FuguRemote': lambda x, rig: FuguRemote(x, rig), - 'SonyXB2Speaker': lambda x, rig: SonyXB2Speaker(x, rig), } def __init__(self, config): diff --git a/acts/framework/acts/controllers/relay_lib/sony_xb2_speaker.py b/acts/framework/acts/controllers/relay_lib/sony_xb2_speaker.py deleted file mode 100644 index 2d01eca384..0000000000 --- a/acts/framework/acts/controllers/relay_lib/sony_xb2_speaker.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import time -import enum -import logging -from acts.controllers.relay_lib.generic_relay_device import GenericRelayDevice -from acts.controllers.relay_lib.relay import SynchronizeRelays -from acts.controllers.relay_lib.errors import RelayConfigError -from acts.controllers.relay_lib.helpers import validate_key - -PAIRING_MODE_WAIT_TIME = 5 -POWER_ON_WAIT_TIME = 2 -POWER_OFF_WAIT_TIME = 6 -MISSING_RELAY_MSG = 'Relay config for Sonxy XB2 "%s" missing relay "%s".' - -log = logging - - -class Buttons(enum.Enum): - POWER = 'Power' - PAIR = 'Pair' - - -class SonyXB2Speaker(GenericRelayDevice): - """A Sony XB2 Bluetooth Speaker. - - Wraps the button presses, as well as the special features like pairing. - """ - - def __init__(self, config, relay_rig): - GenericRelayDevice.__init__(self, config, relay_rig) - - self.mac_address = validate_key('mac_address', config, str, 'sony_xb2') - - for button in Buttons: - self.ensure_config_contains_relay(button.value) - - def ensure_config_contains_relay(self, relay_name): - """Throws an error if the relay does not exist.""" - if relay_name not in self.relays: - raise RelayConfigError(MISSING_RELAY_MSG % (self.name, relay_name)) - - def _hold_button(self, button, seconds): - self.hold_down(button.value) - time.sleep(seconds) - self.release(button.value) - - def power_on(self): - self._hold_button(Buttons.POWER, POWER_ON_WAIT_TIME) - - def power_off(self): - self._hold_button(Buttons.POWER, POWER_OFF_WAIT_TIME) - - def enter_pairing_mode(self): - self._hold_button(Buttons.PAIR, PAIRING_MODE_WAIT_TIME) - - def setup(self): - """Sets all relays to their default state (off).""" - GenericRelayDevice.setup(self) - - def clean_up(self): - """Sets all relays to their default state (off).""" - GenericRelayDevice.clean_up(self) diff --git a/acts/framework/acts/controllers/sl4a_client.py b/acts/framework/acts/controllers/sl4a_client.py index dd9c8f8b4e..c80cd09e30 100644 --- a/acts/framework/acts/controllers/sl4a_client.py +++ b/acts/framework/acts/controllers/sl4a_client.py @@ -254,18 +254,16 @@ class Sl4aClient(object): # Will be error handled to make sure this does not happen. resp = self._cmd(cmd, self.uid) break - except (socket.timeout) as e: - logging.warning( - "Sl4aClient failed to open socket connection: %s", e) + except (socket.timeout): + logging.exception("Failed to create socket connection!") raise - except (socket.error, IOError) as e: + except (socket.error, IOError): # TODO: optimize to only forgive some errors here # error values are OS-specific so this will require # additional tuning to fail faster time_left = get_time_left() if time_left <= 0: - logging.warning( - "Sl4aClient failed to create socket connection: %s", e) + logging.exception("Failed to create socket connection!") raise time.sleep(1) @@ -327,41 +325,18 @@ class Sl4aClient(object): Sl4aApiError: The rpc went through, however executed with errors. """ timeout = kwargs.get("timeout") - retries = kwargs.get("retries", 3) with self._lock: apiid = next(self._counter) if timeout: self.conn.settimeout(timeout) data = {'id': apiid, 'method': method, 'params': args} request = json.dumps(data) - for i in range(1, retries + 1): - try: - self.client.write(request.encode("utf8") + b'\n') - self.client.flush() - response = self.client.readline() - except BrokenPipeError as e: - if i < retries: - logging.warning("RPC method %s on iteration %s error: %s", - method, i, e) - continue - else: - logging.error("RPC method %s fail on iteration %s: %s", - method, i, e) - raise - if not response: - if i < retries: - logging.warning( - "No response for RPC method %s on iteration %s", - method, i) - continue - else: - logging.error( - "No response for RPC method %s on iteration %s", - method, i) - raise Sl4aProtocolError( - Sl4aProtocolError.NO_RESPONSE_FROM_SERVER) - else: - break + self.client.write(request.encode("utf8") + b'\n') + self.client.flush() + response = self.client.readline() + if not response: + logging.error("No response for RPC method %s", method) + raise Sl4aProtocolError(Sl4aProtocolError.NO_RESPONSE_FROM_SERVER) result = json.loads(str(response, encoding="utf8")) if timeout: self.conn.settimeout(self._SOCKET_TIMEOUT) diff --git a/acts/framework/acts/keys.py b/acts/framework/acts/keys.py index be5747029e..7e8132d75c 100644 --- a/acts/framework/acts/keys.py +++ b/acts/framework/acts/keys.py @@ -71,9 +71,6 @@ class Config(enum.Enum): key_sniffer ] - # Keys that are file or folder paths. - file_path_keys = [key_relay_device] - def get_name_by_value(value): for name, member in Config.__members__.items(): diff --git a/acts/framework/acts/records.py b/acts/framework/acts/records.py index 44e1c06c7a..9b9a1c68d0 100644 --- a/acts/framework/acts/records.py +++ b/acts/framework/acts/records.py @@ -20,7 +20,6 @@ import json import logging import pprint -from acts import logger from acts import signals from acts import utils @@ -36,8 +35,6 @@ class TestResultEnums(object): RECORD_CLASS = "Test Class" RECORD_BEGIN_TIME = "Begin Time" RECORD_END_TIME = "End Time" - RECORD_LOG_BEGIN_TIME = "Log Begin Time" - RECORD_LOG_END_TIME = "Log End Time" RECORD_RESULT = "Result" RECORD_UID = "UID" RECORD_EXTRAS = "Extras" @@ -68,8 +65,6 @@ class TestResultRecord(object): self.test_class = t_class self.begin_time = None self.end_time = None - self.log_begin_time = None - self.log_end_time = None self.uid = None self.result = None self.extras = None @@ -82,8 +77,6 @@ class TestResultRecord(object): Sets the begin_time of this record. """ self.begin_time = utils.get_current_epoch_time() - self.log_begin_time = logger.epoch_to_log_line_timestamp( - self.begin_time) def _test_end(self, result, e): """Class internal function to signal the end of a test case execution. @@ -95,7 +88,6 @@ class TestResultRecord(object): acts.signals.TestSignal. """ self.end_time = utils.get_current_epoch_time() - self.log_end_time = logger.epoch_to_log_line_timestamp(self.end_time) self.result = result if self.extra_errors: self.result = TestResultEnums.TEST_RESULT_UNKNOWN @@ -185,8 +177,6 @@ class TestResultRecord(object): d[TestResultEnums.RECORD_CLASS] = self.test_class d[TestResultEnums.RECORD_BEGIN_TIME] = self.begin_time d[TestResultEnums.RECORD_END_TIME] = self.end_time - d[TestResultEnums.RECORD_LOG_BEGIN_TIME] = self.log_begin_time - d[TestResultEnums.RECORD_LOG_END_TIME] = self.log_end_time d[TestResultEnums.RECORD_RESULT] = self.result d[TestResultEnums.RECORD_UID] = self.uid d[TestResultEnums.RECORD_EXTRAS] = self.extras diff --git a/acts/framework/acts/test_utils/bt/BluetoothBaseTest.py b/acts/framework/acts/test_utils/bt/BluetoothBaseTest.py index cded9f56ec..5cb3549c74 100644 --- a/acts/framework/acts/test_utils/bt/BluetoothBaseTest.py +++ b/acts/framework/acts/test_utils/bt/BluetoothBaseTest.py @@ -101,8 +101,6 @@ class BluetoothBaseTest(BaseTestClass): self.timer_list = [] for a in self.android_devices: a.ed.clear_all_events() - a.droid.setScreenTimeout(500) - a.droid.wakeUpNow() return True def teardown_test(self): diff --git a/acts/framework/acts/test_utils/bt/BtFunhausBaseTest.py b/acts/framework/acts/test_utils/bt/BtFunhausBaseTest.py index f22e0b80db..2efeee25a9 100644 --- a/acts/framework/acts/test_utils/bt/BtFunhausBaseTest.py +++ b/acts/framework/acts/test_utils/bt/BtFunhausBaseTest.py @@ -139,8 +139,8 @@ class BtFunhausBaseTest(BtMetricsBaseTest): config_path = os.path.join( self.user_params[Config.key_config_path], config_path) if not os.path.isfile(config_path): - self.log.error("Unable to load bt_config file {}.".format( - config_path)) + self.log.error( + "Unable to load bt_config file {}.".format(config_path)) return False ad.adb.push("{} {}".format(config_path, BT_CONF_PATH)) return True @@ -152,32 +152,25 @@ class BtFunhausBaseTest(BtMetricsBaseTest): :return: True on success, False on failure """ self.log.info("Pushing music to the Android device.") - music_path_str = "bt_music" + music_path_str = "music_path" android_music_path = "/sdcard/Music/" if music_path_str not in self.user_params: self.log.error("Need music for audio testcases...") return False music_path = self.user_params[music_path_str] - if type(music_path) is list: - self.log.info("Media ready to push as is.") - elif not os.path.isdir(music_path): + if not os.path.isdir(music_path): music_path = os.path.join(self.user_params[Config.key_config_path], music_path) if not os.path.isdir(music_path): - self.log.error("Unable to find music directory {}.".format( - music_path)) + self.log.error( + "Unable to find music directory {}.".format(music_path)) return False - if type(music_path) is list: - for item in music_path: - self.music_file_to_play = item - ad.adb.push("{} {}".format(item, android_music_path)) - else: - for dirname, dirnames, filenames in os.walk(music_path): - for filename in filenames: - self.music_file_to_play = filename - file = os.path.join(dirname, filename) - # TODO: Handle file paths with spaces - ad.adb.push("{} {}".format(file, android_music_path)) + for dirname, dirnames, filenames in os.walk(music_path): + for filename in filenames: + self.music_file_to_play = filename + file = os.path.join(dirname, filename) + # TODO: Handle file paths with spaces + ad.adb.push("{} {}".format(file, android_music_path)) ad.reboot() return True @@ -204,11 +197,11 @@ class BtFunhausBaseTest(BtMetricsBaseTest): break else: try: - ad.droid.bluetoothConnectBonded(bt_config_map[serial][ - "peripheral_info"]["address"]) + ad.droid.bluetoothConnectBonded( + bt_config_map[serial]["peripheral_info"]["address"]) except Exception as err: - self.log.error("Failed to connect bonded. Err: {}".format( - err)) + self.log.error( + "Failed to connect bonded. Err: {}".format(err)) if not result: self.log.info("Connected Devices: {}".format(connected_devices)) self.log.info("Bonded Devices: {}".format( @@ -242,11 +235,11 @@ class BtFunhausBaseTest(BtMetricsBaseTest): :return: None """ for ad in self.android_devices: - ad.droid.mediaPlayOpen("file:///sdcard/Music/{}".format( - self.music_file_to_play)) + ad.droid.mediaPlayOpen( + "file:///sdcard/Music/{}".format(self.music_file_to_play)) ad.droid.mediaPlaySetLooping(True) - self.log.info("Music is now playing on device {}".format( - ad.serial)) + self.log.info( + "Music is now playing on device {}".format(ad.serial)) def stop_playing_music_on_all_devices(self): """ diff --git a/acts/framework/acts/test_utils/bt/BtMetricsBaseTest.py b/acts/framework/acts/test_utils/bt/BtMetricsBaseTest.py index 2d16f4474b..2f196e4bb5 100644 --- a/acts/framework/acts/test_utils/bt/BtMetricsBaseTest.py +++ b/acts/framework/acts/test_utils/bt/BtMetricsBaseTest.py @@ -35,7 +35,7 @@ class BtMetricsBaseTest(BluetoothBaseTest): :return: True on success, False on failure """ super(BtMetricsBaseTest, self).setup_class() - self.bluetooth_proto_path = self.user_params["bluetooth_proto_path"][0] + self.bluetooth_proto_path = self.user_params["bluetooth_proto_path"] if not os.path.isfile(self.bluetooth_proto_path): try: self.bluetooth_proto_path = "{}/bluetooth.proto".format( diff --git a/acts/framework/acts/test_utils/bt/GattConnectedBaseTest.py b/acts/framework/acts/test_utils/bt/GattConnectedBaseTest.py index 1b51f57930..9f8785e501 100644 --- a/acts/framework/acts/test_utils/bt/GattConnectedBaseTest.py +++ b/acts/framework/acts/test_utils/bt/GattConnectedBaseTest.py @@ -21,22 +21,21 @@ Setup/Teardown methods take care of establishing connection, and doing GATT DB i from queue import Empty from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_err -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_mtu_size +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattService +from acts.test_utils.bt.GattEnum import GattEvent +from acts.test_utils.bt.GattEnum import GattCbErr +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import MtuSize from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection from acts.test_utils.bt.bt_gatt_utils import orchestrate_gatt_connection from acts.test_utils.bt.bt_gatt_utils import setup_gatt_characteristics from acts.test_utils.bt.bt_gatt_utils import setup_gatt_descriptors -from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids -from acts.test_utils.bt.bt_constants import bt_default_timeout class GattConnectedBaseTest(BluetoothBaseTest): + DEFAULT_TIMEOUT = 10 TEST_SERVICE_UUID = "3846D7A0-69C8-11E4-BA00-0002A5D5C51B" READABLE_CHAR_UUID = "21c0a0bf-ad51-4a2d-8124-b74003e4e8c8" @@ -44,6 +43,8 @@ class GattConnectedBaseTest(BluetoothBaseTest): WRITABLE_CHAR_UUID = "aa7edd5a-4d1d-4f0e-883a-d145616a1630" WRITABLE_DESC_UUID = "76d5ed92-ca81-4edb-bb6b-9f019665fb32" NOTIFIABLE_CHAR_UUID = "b2c83efa-34ca-11e6-ac61-9e71128cae77" + # CCC == Client Characteristic Configuration + CCC_DESC_UUID = "00002902-0000-1000-8000-00805f9b34fb" def __init__(self, controllers): BluetoothBaseTest.__init__(self, controllers) @@ -62,10 +63,10 @@ class GattConnectedBaseTest(BluetoothBaseTest): orchestrate_gatt_connection(self.cen_ad, self.per_ad)) self.per_ad.droid.bleStopBleAdvertising(self.adv_callback) - self.mtu = gatt_mtu_size['min'] + self.mtu = MtuSize.MIN if self.cen_ad.droid.gattClientDiscoverServices(self.bluetooth_gatt): - event = self._client_wait(gatt_event['gatt_serv_disc']) + event = self._client_wait(GattEvent.GATT_SERV_DISC) self.discovered_services_index = event['data']['ServicesIndex'] services_count = self.cen_ad.droid.gattClientGetDiscoveredServicesCount( self.discovered_services_index) @@ -110,45 +111,48 @@ class GattConnectedBaseTest(BluetoothBaseTest): return self._timed_pop(gatt_event, self.cen_ad, self.gatt_callback) def _timed_pop(self, gatt_event, droid, gatt_callback): - expected_event = gatt_event["evt"].format(gatt_callback) + expected_event = gatt_event.value["evt"].format(gatt_callback) try: - return droid.ed.pop_event(expected_event, bt_default_timeout) + return droid.ed.pop_event(expected_event, self.DEFAULT_TIMEOUT) except Empty as emp: - raise AssertionError(gatt_event["err"].format(expected_event)) + raise AssertionError(gatt_event.value["err"].format( + expected_event)) def _setup_characteristics_and_descriptors(self, droid): characteristic_input = [ { 'uuid': self.WRITABLE_CHAR_UUID, - 'property': gatt_characteristic['property_write'] | - gatt_characteristic['property_write_no_response'], - 'permission': gatt_characteristic['permission_write'] + 'property': GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_WRITE_NO_RESPONSE.value, + 'permission': GattCharacteristic.PERMISSION_WRITE.value }, { 'uuid': self.READABLE_CHAR_UUID, - 'property': gatt_characteristic['property_read'], - 'permission': gatt_characteristic['permission_read'] + 'property': GattCharacteristic.PROPERTY_READ.value, + 'permission': GattCharacteristic.PERMISSION_READ.value }, { 'uuid': self.NOTIFIABLE_CHAR_UUID, - 'property': gatt_characteristic['property_notify'] | - gatt_characteristic['property_indicate'], - 'permission': gatt_characteristic['permission_read'] + 'property': GattCharacteristic.PROPERTY_NOTIFY.value | + GattCharacteristic.PROPERTY_INDICATE.value, + 'permission': GattCharacteristic.PERMISSION_READ.value }, ] - descriptor_input = [{ - 'uuid': self.WRITABLE_DESC_UUID, - 'property': gatt_descriptor['permission_read'] | - gatt_characteristic['permission_write'], - }, { - 'uuid': self.READABLE_DESC_UUID, - 'property': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], - }, { - 'uuid': gatt_char_desc_uuids['client_char_cfg'], - 'property': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], - }] + descriptor_input = [ + { + 'uuid': self.WRITABLE_DESC_UUID, + 'property': GattDescriptor.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + }, { + 'uuid': self.READABLE_DESC_UUID, + 'property': GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, + }, { + 'uuid': self.CCC_DESC_UUID, + 'property': GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, + } + ] characteristic_list = setup_gatt_characteristics(droid, characteristic_input) self.notifiable_char_index = characteristic_list[2] @@ -167,14 +171,14 @@ class GattConnectedBaseTest(BluetoothBaseTest): return True def _find_service_added_event(self, gatt_server_callback, uuid): - expected_event = gatt_cb_strings['serv_added'].format( + expected_event = GattCbStrings.SERV_ADDED.value.format( gatt_server_callback) try: event = self.per_ad.ed.pop_event(expected_event, - bt_default_timeout) + self.DEFAULT_TIMEOUT) except Empty: - self.log.error(gatt_cb_err['serv_added_err'].format( - expected_event)) + self.log.error( + GattCbErr.SERV_ADDED_ERR.value.format(expected_event)) return False if event['data']['serviceUuid'].lower() != uuid.lower(): self.log.error("Uuid mismatch. Found: {}, Expected {}.".format( @@ -196,7 +200,7 @@ class GattConnectedBaseTest(BluetoothBaseTest): self.per_ad.droid.gattServerCharacteristicAddDescriptor( characteristic_list[2], descriptor_list[2]) gatt_service3 = self.per_ad.droid.gattServerCreateService( - self.TEST_SERVICE_UUID, gatt_service_types['primary']) + self.TEST_SERVICE_UUID, GattService.SERVICE_TYPE_PRIMARY.value) for characteristic in characteristic_list: self.per_ad.droid.gattServerAddCharacteristicToService( gatt_service3, characteristic) diff --git a/acts/framework/acts/test_utils/bt/PowerBaseTest.py b/acts/framework/acts/test_utils/bt/PowerBaseTest.py index 525317e0a2..33802086ef 100644 --- a/acts/framework/acts/test_utils/bt/PowerBaseTest.py +++ b/acts/framework/acts/test_utils/bt/PowerBaseTest.py @@ -46,11 +46,9 @@ class PowerBaseTest(BluetoothBaseTest): MONSOON_MAX_CURRENT = 7.8 # Power mesaurement sampling rate in Hz POWER_SAMPLING_RATE = 10 - SCREEN_TIME_OFF = 5 + SCREEN_TIME_OFF = 10 # Wait time for PMC to start in seconds - WAIT_TIME = 60 - # Wait time for PMC to write AlarmTimes - ALARM_WAIT_TIME = 600 + WAIT_TIME = 10 START_PMC_CMD = ("am start -n com.android.pmc/com.android.pmc." "PMCMainActivity") @@ -86,7 +84,6 @@ class PowerBaseTest(BluetoothBaseTest): 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) - self.ad.go_to_sleep() wutils.wifi_toggle_state(self.ad, False) @@ -125,7 +122,6 @@ class PowerBaseTest(BluetoothBaseTest): if -1 != out.find(label): result = True break - time.sleep(1) if not result: self.log.error(status_msg) @@ -144,23 +140,12 @@ class PowerBaseTest(BluetoothBaseTest): """ start_time = time.time() - alarm_written = False - while time.time() < start_time + self.ALARM_WAIT_TIME: + while time.time() < start_time + self.WAIT_TIME: out = self.ad.adb.shell("cat /mnt/sdcard/Download/" + log_file) self.log.info("READ file: " + out) - if -1 != out.find("READY"): - # AlarmTimes has not been written, wait - self.log.info("AlarmTimes has not been written, wait") - else: - alarm_written = True - break - time.sleep(1) - - if alarm_written is False: - self.log.info("PMC never wrote alarm file") - json_data = json.loads(out) - if json_data["AlarmTimes"]: - return json_data["AlarmTimes"] + json_data = json.loads(out) + if json_data["AlarmTimes"]: + return json_data["AlarmTimes"] def save_logs_for_power_test(self, monsoon_result, @@ -198,10 +183,8 @@ class PowerBaseTest(BluetoothBaseTest): bt_monsoon_result = BtMonsoonDataWithPmcTimes( monsoon_result, time1, time2, self.log) - bt_monsoon_result.save_to_text_file(bt_monsoon_result, - os.path.join( - self.monsoon_log_path, - file_name)) + bt_monsoon_result.save_to_text_file( + bt_monsoon_result, os.path.join(self.monsoon_log_path, file_name)) self.ad.take_bug_report(self.current_test_name, current_time) @@ -354,9 +337,10 @@ class BtMonsoonData(monsoon.MonsoonData): strs.append("\t\tSTD DEV Current: {} mA.".format(stdev)) strs.append("\t\tVoltage: {} V.".format(self.voltage)) strs.append("\t\tTotal Power: {} mW.".format(total_power)) - strs.append( - ("\t\t{} samples taken at {}Hz, with an offset of {} samples." - ).format(len(self.data_points), self.hz, self.offset)) + strs.append(( + "\t\t{} samples taken at {}Hz, with an offset of {} samples." + ).format( + len(self.data_points), self.hz, self.offset)) return "\n".join(strs) def _format_data_point(self): @@ -421,8 +405,8 @@ class BtMonsoonDataWithPmcTimes(BtMonsoonData): end_times: A list of epoch timestamps (int). log: log object to log info messages. """ - super(BtMonsoonDataWithPmcTimes, self).__init__( - bt_monsoon_data, 0, 0, log) + super(BtMonsoonDataWithPmcTimes, self).__init__(bt_monsoon_data, 0, 0, + log) self.start_times = start_times self.end_times = end_times @@ -438,8 +422,8 @@ class BtMonsoonDataWithPmcTimes(BtMonsoonData): self.log.info( "Start times: {} End times: {} Total Data Points: {}".format( - len(self.start_times), - len(self.end_times), len(self.data_points))) + len(self.start_times), len(self.end_times), len( + self.data_points))) # Index for measure and idle cycle index measure_cycle_index = 0 @@ -505,8 +489,8 @@ class BtMonsoonDataWithPmcTimes(BtMonsoonData): average_for_a_cycle.append(current_sum / data_point_count) total_measured_data_point_count += data_point_count - self.log.info( - "Total Number of Cycles: {}".format(len(average_for_a_cycle))) + self.log.info("Total Number of Cycles: {}".format(len( + average_for_a_cycle))) # Calculate the average current and convert it into mA current_avg = round( diff --git a/acts/framework/acts/test_utils/bt/bt_constants.py b/acts/framework/acts/test_utils/bt/bt_constants.py deleted file mode 100644 index 7a55aa47ce..0000000000 --- a/acts/framework/acts/test_utils/bt/bt_constants.py +++ /dev/null @@ -1,513 +0,0 @@ -#/usr/bin/env python3.4 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -### Generic Constants Begin ### - -bt_default_timeout = 15 -default_rfcomm_timeout_ms = 10000 -pan_connect_timeout = 5 -bt_discovery_timeout = 3 -small_timeout = 0.0001 - -java_integer = {"min": -2147483648, "max": 2147483647} - -btsnoop_log_path_on_device = "/data/misc/bluetooth/logs/btsnoop_hci.log" -btsnoop_last_log_path_on_device = \ - "/data/misc/bluetooth/logs/btsnoop_hci.log.last" -pairing_variant_passkey_confirmation = 2 - -# Callback strings -scan_result = "BleScan{}onScanResults" -scan_failed = "BleScan{}onScanFailed" -batch_scan_result = "BleScan{}onBatchScanResult" -adv_fail = "BleAdvertise{}onFailure" -adv_succ = "BleAdvertise{}onSuccess" -bluetooth_off = "BluetoothStateChangedOff" -bluetooth_on = "BluetoothStateChangedOn" -mtu_changed = "GattConnect{}onMtuChanged" -advertising_set_started = "AdvertisingSet{}onAdvertisingSetStarted" -advertising_set_stopped = "AdvertisingSet{}onAdvertisingSetStopped" -advertising_set_on_own_address_read = "AdvertisingSet{}onOwnAddressRead" -advertising_set_stopped = "AdvertisingSet{}onAdvertisingSetStopped" -advertising_set_enabled = "AdvertisingSet{}onAdvertisingEnabled" -advertising_set_data_set = "AdvertisingSet{}onAdvertisingDataSet" -advertising_set_scan_response_set = "AdvertisingSet{}onScanResponseDataSet" -advertising_set_parameters_update = \ - "AdvertisingSet{}onAdvertisingParametersUpdated" -advertising_set_periodic_parameters_updated = \ - "AdvertisingSet{}onPeriodicAdvertisingParametersUpdated" -advertising_set_periodic_data_set = \ - "AdvertisingSet{}onPeriodicAdvertisingDataSet" -advertising_set_periodic_enable = "AdvertisingSet{}onPeriodicAdvertisingEnable" -bluetooth_profile_connection_state_changed = \ - "BluetoothProfileConnectionStateChanged" -bluetooth_le_on = "BleStateChangedOn" -bluetooth_le_off = "BleStateChangedOff" -# End Callback Strings - -batch_scan_not_supported_list = [ - "Nexus 4", - "Nexus 5", - "Nexus 7", -] - -### Generic Constants End ### - -### Bluetooth Constants Begin ### - -# rfcomm test uuids -rfcomm_secure_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66" -rfcomm_insecure_uuid = "8ce255c0-200a-11e0-ac64-0800200c9a66" - -# Bluetooth Adapter Scan Mode Types -bt_scan_mode_types = { - "state_off": -1, - "none": 0, - "connectable": 1, - "connectable_discoverable": 3 -} - -# Bluetooth Adapter State Constants -bt_adapter_states = { - "off": 10, - "turning_on": 11, - "on": 12, - "turning_off": 13, - "ble_turning_on": 14, - "ble_on": 15, - "ble_turning_off": 16 -} - -# Should be kept in sync with BluetoothProfile.java -bt_profile_constants = { - "headset": 1, - "a2dp": 2, - "health": 3, - "input_device": 4, - "pan": 5, - "pbap_server": 6, - "gatt": 7, - "gatt_server": 8, - "map": 9, - "sap": 10, - "a2dp_sink": 11, - "avrcp_controller": 12, - "headset_client": 16, - "pbap_client": 17, - "map_mce": 18 -} - -# Bluetooth RFCOMM UUIDs as defined by the SIG -bt_rfcomm_uuids = { - "default_uuid": "457807c0-4897-11df-9879-0800200c9a66", - "base_uuid": "00000000-0000-1000-8000-00805F9B34FB", - "sdp": "00000001-0000-1000-8000-00805F9B34FB", - "udp": "00000002-0000-1000-8000-00805F9B34FB", - "rfcomm": "00000003-0000-1000-8000-00805F9B34FB", - "tcp": "00000004-0000-1000-8000-00805F9B34FB", - "tcs_bin": "00000005-0000-1000-8000-00805F9B34FB", - "tcs_at": "00000006-0000-1000-8000-00805F9B34FB", - "att": "00000007-0000-1000-8000-00805F9B34FB", - "obex": "00000008-0000-1000-8000-00805F9B34FB", - "ip": "00000009-0000-1000-8000-00805F9B34FB", - "ftp": "0000000A-0000-1000-8000-00805F9B34FB", - "http": "0000000C-0000-1000-8000-00805F9B34FB", - "wsp": "0000000E-0000-1000-8000-00805F9B34FB", - "bnep": "0000000F-0000-1000-8000-00805F9B34FB", - "upnp": "00000010-0000-1000-8000-00805F9B34FB", - "hidp": "00000011-0000-1000-8000-00805F9B34FB", - "hardcopy_control_channel": "00000012-0000-1000-8000-00805F9B34FB", - "hardcopy_data_channel": "00000014-0000-1000-8000-00805F9B34FB", - "hardcopy_notification": "00000016-0000-1000-8000-00805F9B34FB", - "avctp": "00000017-0000-1000-8000-00805F9B34FB", - "avdtp": "00000019-0000-1000-8000-00805F9B34FB", - "cmtp": "0000001B-0000-1000-8000-00805F9B34FB", - "mcap_control_channel": "0000001E-0000-1000-8000-00805F9B34FB", - "mcap_data_channel": "0000001F-0000-1000-8000-00805F9B34FB", - "l2cap": "00000100-0000-1000-8000-00805F9B34FB" -} - -# Should be kept in sync with BluetoothProfile#STATE_* constants. -bt_profile_states = { - "disconnected": 0, - "connecting": 1, - "connected": 2, - "disconnecting": 3 -} - -# Access Levels from BluetoothDevice. -bt_access_levels = {"access_allowed": 1, "access_denied": 2} - -# Priority levels as defined in BluetoothProfile.java. -bt_priority_levels = { - "auto_connect": 1000, - "on": 100, - "off": 0, - "undefined": -1 -} - -### Bluetooth Constants End ### - -### Bluetooth Low Energy Constants Begin ### - -# Bluetooth Low Energy scan callback types -ble_scan_settings_callback_types = { - "all_matches": 1, - "first_match": 2, - "match_lost": 4, - "found_and_lost": 6 -} - -# Bluetooth Low Energy scan settings match mode -ble_scan_settings_match_modes = {"aggresive": 1, "sticky": 2} - -# Bluetooth Low Energy scan settings match nums -ble_scan_settings_match_nums = {"one": 1, "few": 2, "max": 3} - -# Bluetooth Low Energy scan settings result types -ble_scan_settings_result_types = {"full": 0, "abbreviated": 1} - -# Bluetooth Low Energy scan settings mode -ble_scan_settings_modes = { - "opportunistic": -1, - "low_power": 0, - "balanced": 1, - "low_latency": 2 -} - -# Bluetooth Low Energy scan settings report delay millis -ble_scan_settings_report_delay_milli_seconds = { - "min": 0, - "max": 9223372036854775807 -} - -# Bluetooth Low Energy scan settings phy -ble_scan_settings_phys = {"1m": 1, "coded": 3, "all_supported": 255} - -# Bluetooth Low Energy advertise settings types -ble_advertise_settings_types = {"non_connectable": 0, "connectable": 1} - -# Bluetooth Low Energy advertise settings modes -ble_advertise_settings_modes = { - "low_power": 0, - "balanced": 1, - "low_latency": 2 -} - -# Bluetooth Low Energy advertise settings tx power -ble_advertise_settings_tx_powers = { - "ultra_low": 0, - "low": 1, - "medium": 2, - "high": 3 -} - -# Bluetooth Low Energy service uuids for specific devices -ble_uuids = { - "p_service": "0000feef-0000-1000-8000-00805f9b34fb", - "hr_service": "0000180d-0000-1000-8000-00805f9b34fb" -} - -# Bluetooth Low Energy advertising error codes -ble_advertise_error_code = { - "data_too_large": 1, - "too_many_advertisers": 2, - "advertisement_already_started": 3, - "bluetooth_internal_failure": 4, - "feature_not_supported": 5 -} - -### Bluetooth Low Energy Constants End ### - -### Bluetooth GATT Constants Begin ### - -# Gatt Callback error messages -gatt_cb_err = { - "char_write_req_err": - "Characteristic Write Request event not found. Expected {}", - "char_write_err": "Characteristic Write event not found. Expected {}", - "desc_write_req_err": - "Descriptor Write Request event not found. Expected {}", - "desc_write_err": "Descriptor Write event not found. Expected {}", - "char_read_err": "Characteristic Read event not found. Expected {}", - "char_read_req_err": "Characteristic Read Request not found. Expected {}", - "desc_read_err": "Descriptor Read event not found. Expected {}", - "desc_read_req_err": - "Descriptor Read Request event not found. Expected {}", - "rd_remote_rssi_err": "Read Remote RSSI event not found. Expected {}", - "gatt_serv_disc_err": - "GATT Services Discovered event not found. Expected {}", - "serv_added_err": "Service Added event not found. Expected {}", - "mtu_changed_err": "MTU Changed event not found. Expected {}", - "mtu_serv_changed_err": "MTU Server Changed event not found. Expected {}", - "gatt_conn_changed_err": - "GATT Connection Changed event not found. Expected {}", - "char_change_err": - "GATT Characteristic Changed event not fond. Expected {}", - "phy_read_err": "Phy Read event not fond. Expected {}", - "phy_update_err": "Phy Update event not fond. Expected {}", - "exec_write_err": "GATT Execute Write event not found. Expected {}" -} - -# GATT callback strings as defined in GattClientFacade.java and -# GattServerFacade.java implemented callbacks. -gatt_cb_strings = { - "char_write_req": "GattServer{}onCharacteristicWriteRequest", - "exec_write": "GattServer{}onExecuteWrite", - "char_write": "GattConnect{}onCharacteristicWrite", - "desc_write_req": "GattServer{}onDescriptorWriteRequest", - "desc_write": "GattConnect{}onDescriptorWrite", - "char_read": "GattConnect{}onCharacteristicRead", - "char_read_req": "GattServer{}onCharacteristicReadRequest", - "desc_read": "GattConnect{}onDescriptorRead", - "desc_read_req": "GattServer{}onDescriptorReadRequest", - "rd_remote_rssi": "GattConnect{}onReadRemoteRssi", - "gatt_serv_disc": "GattConnect{}onServicesDiscovered", - "serv_added": "GattServer{}onServiceAdded", - "mtu_changed": "GattConnect{}onMtuChanged", - "mtu_serv_changed": "GattServer{}onMtuChanged", - "gatt_conn_change": "GattConnect{}onConnectionStateChange", - "char_change": "GattConnect{}onCharacteristicChanged", - "phy_read": "GattConnect{}onPhyRead", - "phy_update": "GattConnect{}onPhyUpdate", - "serv_phy_read": "GattServer{}onPhyRead", - "serv_phy_update": "GattServer{}onPhyUpdate", -} - -# GATT event dictionary of expected callbacks and errors. -gatt_event = { - "char_write_req": { - "evt": gatt_cb_strings["char_write_req"], - "err": gatt_cb_err["char_write_req_err"] - }, - "exec_write": { - "evt": gatt_cb_strings["exec_write"], - "err": gatt_cb_err["exec_write_err"] - }, - "char_write": { - "evt": gatt_cb_strings["char_write"], - "err": gatt_cb_err["char_write_err"] - }, - "desc_write_req": { - "evt": gatt_cb_strings["desc_write_req"], - "err": gatt_cb_err["desc_write_req_err"] - }, - "desc_write": { - "evt": gatt_cb_strings["desc_write"], - "err": gatt_cb_err["desc_write_err"] - }, - "char_read": { - "evt": gatt_cb_strings["char_read"], - "err": gatt_cb_err["char_read_err"] - }, - "char_read_req": { - "evt": gatt_cb_strings["char_read_req"], - "err": gatt_cb_err["char_read_req_err"] - }, - "desc_read": { - "evt": gatt_cb_strings["desc_read"], - "err": gatt_cb_err["desc_read_err"] - }, - "desc_read_req": { - "evt": gatt_cb_strings["desc_read_req"], - "err": gatt_cb_err["desc_read_req_err"] - }, - "rd_remote_rssi": { - "evt": gatt_cb_strings["rd_remote_rssi"], - "err": gatt_cb_err["rd_remote_rssi_err"] - }, - "gatt_serv_disc": { - "evt": gatt_cb_strings["gatt_serv_disc"], - "err": gatt_cb_err["gatt_serv_disc_err"] - }, - "serv_added": { - "evt": gatt_cb_strings["serv_added"], - "err": gatt_cb_err["serv_added_err"] - }, - "mtu_changed": { - "evt": gatt_cb_strings["mtu_changed"], - "err": gatt_cb_err["mtu_changed_err"] - }, - "gatt_conn_change": { - "evt": gatt_cb_strings["gatt_conn_change"], - "err": gatt_cb_err["gatt_conn_changed_err"] - }, - "char_change": { - "evt": gatt_cb_strings["char_change"], - "err": gatt_cb_err["char_change_err"] - }, - "phy_read": { - "evt": gatt_cb_strings["phy_read"], - "err": gatt_cb_err["phy_read_err"] - }, - "phy_update": { - "evt": gatt_cb_strings["phy_update"], - "err": gatt_cb_err["phy_update_err"] - }, - "serv_phy_read": { - "evt": gatt_cb_strings["serv_phy_read"], - "err": gatt_cb_err["phy_read_err"] - }, - "serv_phy_update": { - "evt": gatt_cb_strings["serv_phy_update"], - "err": gatt_cb_err["phy_update_err"] - } -} - -# Matches constants of connection states defined in BluetoothGatt.java -gatt_connection_state = { - "disconnected": 0, - "connecting": 1, - "connected": 2, - "disconnecting": 3, - "closed": 4 -} - -# Matches constants of Bluetooth GATT Characteristic values as defined -# in BluetoothGattCharacteristic.java -gatt_characteristic = { - "property_broadcast": 0x01, - "property_read": 0x02, - "property_write_no_response": 0x04, - "property_write": 0x08, - "property_notify": 0x10, - "property_indicate": 0x20, - "property_signed_write": 0x40, - "property_extended_props": 0x80, - "permission_read": 0x01, - "permission_read_encrypted": 0x02, - "permission_read_encrypted_mitm": 0x04, - "permission_write": 0x10, - "permission_write_encrypted": 0x20, - "permission_write_encrypted_mitm": 0x40, - "permission_write_signed": 0x80, - "permission_write_signed_mitm": 0x100, - "write_type_default": 0x02, - "write_type_no_response": 0x01, - "write_type_signed": 0x04, -} - -# Matches constants of Bluetooth GATT Characteristic values as defined -# in BluetoothGattDescriptor.java -gatt_descriptor = { - "enable_notification_value": [0x01, 0x00], - "enable_indication_value": [0x02, 0x00], - "disable_notification_value": [0x00, 0x00], - "permission_read": 0x01, - "permission_read_encrypted": 0x02, - "permission_read_encrypted_mitm": 0x04, - "permission_write": 0x10, - "permission_write_encrypted": 0x20, - "permission_write_encrypted_mitm": 0x40, - "permission_write_signed": 0x80, - "permission_write_signed_mitm": 0x100 -} - -# https://www.bluetooth.com/specifications/gatt/descriptors -gatt_char_desc_uuids = { - "char_ext_props": '00002900-0000-1000-8000-00805f9b34fb', - "char_user_desc": '00002901-0000-1000-8000-00805f9b34fb', - "client_char_cfg": '00002902-0000-1000-8000-00805f9b34fb', - "server_char_cfg": '00002903-0000-1000-8000-00805f9b34fb', - "char_fmt_uuid": '00002904-0000-1000-8000-00805f9b34fb', - "char_agreg_fmt": '00002905-0000-1000-8000-00805f9b34fb', - "char_valid_range": '00002906-0000-1000-8000-00805f9b34fb', - "external_report_reference": '00002907-0000-1000-8000-00805f9b34fb', - "report_reference": '00002908-0000-1000-8000-00805f9b34fb' -} - -# https://www.bluetooth.com/specifications/gatt/characteristics -gatt_char_types = { - "device_name": '00002a00-0000-1000-8000-00805f9b34fb', - "appearance": '00002a01-0000-1000-8000-00805f9b34fb', - "peripheral_priv_flag": '00002a02-0000-1000-8000-00805f9b34fb', - "reconnection_address": '00002a03-0000-1000-8000-00805f9b34fb', - "peripheral_pref_conn": '00002a04-0000-1000-8000-00805f9b34fb', - "service_changed": '00002a05-0000-1000-8000-00805f9b34fb', - "system_id": '00002a23-0000-1000-8000-00805f9b34fb', - "model_number_string": '00002a24-0000-1000-8000-00805f9b34fb', - "serial_number_string": '00002a25-0000-1000-8000-00805f9b34fb', - "firmware_revision_string": '00002a26-0000-1000-8000-00805f9b34fb', - "hardware_revision_string": '00002a27-0000-1000-8000-00805f9b34fb', - "software_revision_string": '00002a28-0000-1000-8000-00805f9b34fb', - "manufacturer_name_string": '00002a29-0000-1000-8000-00805f9b34fb', - "pnp_id": '00002a50-0000-1000-8000-00805f9b34fb', -} - -# Matches constants of Bluetooth GATT Characteristic values as defined -# in BluetoothGattCharacteristic.java -gatt_characteristic_value_format = { - "string": 0x1, - "byte": 0x2, - "sint8": 0x21, - "uint8": 0x11, - "sint16": 0x22, - "unit16": 0x12, - "sint32": 0x24, - "uint32": 0x14 -} - -# Matches constants of Bluetooth Gatt Service types as defined in -# BluetoothGattService.java -gatt_service_types = {"primary": 0, "secondary": 1} - -# Matches constants of Bluetooth Gatt Connection Priority values as defined in -# BluetoothGatt.java -gatt_connection_priority = {"balanced": 0, "high": 1, "low_power": 2} - -# Min and max MTU values -gatt_mtu_size = {"min": 23, "max": 217} - -# Gatt Characteristic attribute lengths -gatt_characteristic_attr_length = {"attr_1": 1, "attr_2": 3, "attr_3": 15} - -# Matches constants of Bluetooth Gatt operations status as defined in -# BluetoothGatt.java -gatt_status = {"success": 0, "failure": 0x101} - -# Matches constants of Bluetooth transport values as defined in -# BluetoothDevice.java -gatt_transport = {"auto": 0x00, "bredr": 0x01, "le": 0x02} - -# Matches constants of Bluetooth physical channeling values as defined in -# BluetoothDevice.java -gatt_phy = {"1m": 1, "2m": 2, "le_coded": 3} - -# Matches constants of Bluetooth physical channeling bitmask values as defined -# in BluetoothDevice.java -gatt_phy_mask = {"1m_mask": 1, "2m_mask": 2, "coded_mask": 4} - -# Values as defiend in the Bluetooth GATT specification -gatt_server_responses = { - "GATT_SUCCESS": 0x0, - "GATT_FAILURE": 0x1, - "GATT_READ_NOT_PERMITTED": 0x2, - "GATT_WRITE_NOT_PERMITTED": 0x3, - "GATT_INVALID_PDU": 0x4, - "GATT_INSUFFICIENT_AUTHENTICATION": 0x5, - "GATT_REQUEST_NOT_SUPPORTED": 0x6, - "GATT_INVALID_OFFSET": 0x7, - "GATT_INSUFFICIENT_AUTHORIZATION": 0x8, - "GATT_INVALID_ATTRIBUTE_LENGTH": 0xd, - "GATT_INSUFFICIENT_ENCRYPTION": 0xf, - "GATT_CONNECTION_CONGESTED": 0x8f, - "GATT_13_ERR": 0x13, - "GATT_12_ERR": 0x12, - "GATT_0C_ERR": 0x0C, - "GATT_16": 0x16 -} - -### Bluetooth GATT Constants End ### diff --git a/acts/framework/acts/test_utils/bt/bt_gatt_utils.py b/acts/framework/acts/test_utils/bt/bt_gatt_utils.py index a6d5b81812..da0eb6f328 100644 --- a/acts/framework/acts/test_utils/bt/bt_gatt_utils.py +++ b/acts/framework/acts/test_utils/bt/bt_gatt_utils.py @@ -18,14 +18,14 @@ import logging from acts.test_utils.bt.bt_test_utils import BtTestUtilsError from acts.test_utils.bt.bt_test_utils import get_mac_address_of_generic_advertisement -from acts.test_utils.bt.bt_constants import gatt_cb_err -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_connection_state -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_phy_mask -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import gatt_transport +from acts.test_utils.bt.GattEnum import GattCbErr +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattConnectionState +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattPhyMask +from acts.test_utils.bt.GattEnum import GattService +from acts.test_utils.bt.GattEnum import GattTransport import pprint from queue import Empty @@ -40,22 +40,16 @@ class GattTestUtilsError(Exception): def setup_gatt_connection(cen_ad, mac_address, autoconnect, - transport=gatt_transport['auto']): + transport=GattTransport.TRANSPORT_AUTO.value): gatt_callback = cen_ad.droid.gattCreateGattCallback() log.info("Gatt Connect to mac address {}.".format(mac_address)) bluetooth_gatt = cen_ad.droid.gattClientConnectGatt( gatt_callback, mac_address, autoconnect, transport, - gatt_phy_mask['1m_mask']) - expected_event = gatt_cb_strings['gatt_conn_change'].format(gatt_callback) + GattPhyMask.PHY_LE_1M_MASK) + expected_event = GattCbStrings.GATT_CONN_CHANGE.value.format(gatt_callback) try: event = cen_ad.ed.pop_event(expected_event, default_timeout) except Empty: - close_gatt_client(cen_ad, bluetooth_gatt) - raise GattTestUtilsError("Could not establish a connection to " - "peripheral. Expected event: {}".format( - expected_event)) - if event['data']['State'] != gatt_connection_state['connected']: - close_gatt_client(cen_ad, bluetooth_gatt) try: cen_ad.droid.gattClientClose(bluetooth_gatt) except Exception: @@ -63,24 +57,27 @@ def setup_gatt_connection(cen_ad, raise GattTestUtilsError( "Could not establish a connection to " "peripheral. Expected event: {}".format(expected_event)) + if event['data']['State'] != GattConnectionState.STATE_CONNECTED.value: + try: + cen_ad.droid.gattClientClose(bluetooth_gatt) + except Exception: + self.log.debug("Failed to close gatt client.") + raise GattTestUtilsError( + "Could not establish a connection to " + "peripheral. Event Details: {}".format(pprint.pformat(event))) return bluetooth_gatt, gatt_callback def disconnect_gatt_connection(cen_ad, bluetooth_gatt, gatt_callback): cen_ad.droid.gattClientDisconnect(bluetooth_gatt) - wait_for_gatt_disconnect_event(cen_ad, gatt_callback) - return - - -def wait_for_gatt_disconnect_event(cen_ad, gatt_callback): - expected_event = gatt_cb_strings['gatt_conn_change'].format(gatt_callback) + expected_event = GattCbStrings.GATT_CONN_CHANGE.value.format(gatt_callback) try: event = cen_ad.ed.pop_event(expected_event, default_timeout) except Empty: - raise GattTestUtilsError(gatt_cb_err['gatt_conn_change_err'].format( - expected_event)) + raise GattTestUtilsError( + GattCbErr.GATT_CONN_CHANGE_ERR.value.format(expected_event)) found_state = event['data']['State'] - expected_state = gatt_connection_state['disconnected'] + expected_state = GattConnectionState.STATE_DISCONNECTED.value if found_state != expected_state: raise GattTestUtilsError( "GATT connection state change expected {}, found {}".format( @@ -90,12 +87,12 @@ def wait_for_gatt_disconnect_event(cen_ad, gatt_callback): def orchestrate_gatt_connection(cen_ad, per_ad, - transport=gatt_transport['le'], + transport=GattTransport.TRANSPORT_LE.value, mac_address=None, autoconnect=False): adv_callback = None if mac_address is None: - if transport == gatt_transport['le']: + if transport == GattTransport.TRANSPORT_LE.value: try: mac_address, adv_callback = ( get_mac_address_of_generic_advertisement(cen_ad, per_ad)) @@ -133,22 +130,23 @@ def run_continuous_write_descriptor(cen_droid, cen_ed, per_droid, per_ed, discovered_services_index, i, characteristic)) log.info(descriptor_uuids) for descriptor in descriptor_uuids: - log.info("descriptor to be written {}".format( - descriptor)) + log.info( + "descriptor to be written {}".format(descriptor)) cen_droid.gattClientDescriptorSetValue( bluetooth_gatt, discovered_services_index, i, characteristic, descriptor, test_value) cen_droid.gattClientWriteDescriptor( bluetooth_gatt, discovered_services_index, i, characteristic, descriptor) - expected_event = gatt_cb_strings[ - 'desc_write_req'].format(gatt_server_callback) + expected_event = GattCbStrings.DESC_WRITE_REQ.value.format( + gatt_server_callback) try: event = per_ed.pop_event(expected_event, default_timeout) except Empty: - log.error(gatt_cb_err['desc_write_req_err'].format( - expected_event)) + log.error( + GattCbErr.DESC_WRITE_REQ_ERR.value.format( + expected_event)) return False request_id = event['data']['requestId'] found_value = event['data']['value'] @@ -159,13 +157,14 @@ def run_continuous_write_descriptor(cen_droid, cen_ed, per_droid, per_ed, per_droid.gattServerSendResponse( gatt_server, bt_device_id, request_id, status, offset, test_value_return) - expected_event = gatt_cb_strings['desc_write'].format( + expected_event = GattCbStrings.DESC_WRITE.value.format( bluetooth_gatt) try: cen_ed.pop_event(expected_event, default_timeout) except Empty: - log.error(gatt_cb_strings['desc_write_err'].format( - expected_event)) + log.error( + GattCbErr.DESC_WRITE_ERR.value.format( + expected_event)) return False except Exception as err: log.error("Continuing but found exception: {}".format(err)) @@ -174,32 +173,45 @@ def run_continuous_write_descriptor(cen_droid, cen_ed, per_droid, per_ed, def setup_characteristics_and_descriptors(droid): characteristic_input = [ { - 'uuid': "aa7edd5a-4d1d-4f0e-883a-d145616a1630", - 'property': gatt_characteristic['property_write'] | - gatt_characteristic['property_write_no_response'], - 'permission': gatt_characteristic['permission_write'] + 'uuid': + "aa7edd5a-4d1d-4f0e-883a-d145616a1630", + 'property': + GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_WRITE_NO_RESPONSE.value, + 'permission': + GattCharacteristic.PROPERTY_WRITE.value }, { - 'uuid': "21c0a0bf-ad51-4a2d-8124-b74003e4e8c8", - 'property': gatt_characteristic['property_notify'] | - gatt_characteristic['property_read'], - 'permission': gatt_characteristic['permission_read'] + 'uuid': + "21c0a0bf-ad51-4a2d-8124-b74003e4e8c8", + 'property': + GattCharacteristic.PROPERTY_NOTIFY.value | + GattCharacteristic.PROPERTY_READ.value, + 'permission': + GattCharacteristic.PERMISSION_READ.value }, { - 'uuid': "6774191f-6ec3-4aa2-b8a8-cf830e41fda6", - 'property': gatt_characteristic['property_notify'] | - gatt_characteristic['property_read'], - 'permission': gatt_characteristic['permission_read'] + 'uuid': + "6774191f-6ec3-4aa2-b8a8-cf830e41fda6", + 'property': + GattCharacteristic.PROPERTY_NOTIFY.value | + GattCharacteristic.PROPERTY_READ.value, + 'permission': + GattCharacteristic.PERMISSION_READ.value }, ] descriptor_input = [{ - 'uuid': "aa7edd5a-4d1d-4f0e-883a-d145616a1630", - 'property': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + "aa7edd5a-4d1d-4f0e-883a-d145616a1630", + 'property': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, }, { - 'uuid': "76d5ed92-ca81-4edb-bb6b-9f019665fb32", - 'property': gatt_descriptor['permission_read'] | - gatt_characteristic['permission_write'], + 'uuid': + "76d5ed92-ca81-4edb-bb6b-9f019665fb32", + 'property': + GattDescriptor.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, }] characteristic_list = setup_gatt_characteristics(droid, characteristic_input) @@ -218,22 +230,26 @@ def setup_multiple_services(per_ad): per_droid.gattServerCharacteristicAddDescriptor(characteristic_list[2], descriptor_list[1]) gattService = per_droid.gattServerCreateService( - "00000000-0000-1000-8000-00805f9b34fb", gatt_service_types['primary']) + "00000000-0000-1000-8000-00805f9b34fb", + GattService.SERVICE_TYPE_PRIMARY.value) gattService2 = per_droid.gattServerCreateService( - "FFFFFFFF-0000-1000-8000-00805f9b34fb", gatt_service_types['primary']) + "FFFFFFFF-0000-1000-8000-00805f9b34fb", + GattService.SERVICE_TYPE_PRIMARY.value) gattService3 = per_droid.gattServerCreateService( - "3846D7A0-69C8-11E4-BA00-0002A5D5C51B", gatt_service_types['primary']) + "3846D7A0-69C8-11E4-BA00-0002A5D5C51B", + GattService.SERVICE_TYPE_PRIMARY.value) for characteristic in characteristic_list: per_droid.gattServerAddCharacteristicToService(gattService, characteristic) per_droid.gattServerAddService(gatt_server, gattService) - expected_event = gatt_cb_strings['serv_added'].format(gatt_server_callback) + expected_event = GattCbStrings.SERV_ADDED.value.format( + gatt_server_callback) try: per_ed.pop_event(expected_event, default_timeout) except Empty: per_ad.droid.gattServerClose(gatt_server) - raise GattTestUtilsError(gatt_cb_strings['serv_added_err'].format( - expected_event)) + raise GattTestUtilsError( + GattCbErr.SERV_ADDED_ERR.value.format(expected_event)) for characteristic in characteristic_list: per_droid.gattServerAddCharacteristicToService(gattService2, characteristic) @@ -242,8 +258,8 @@ def setup_multiple_services(per_ad): per_ed.pop_event(expected_event, default_timeout) except Empty: per_ad.droid.gattServerClose(gatt_server) - raise GattTestUtilsError(gatt_cb_strings['serv_added_err'].format( - expected_event)) + raise GattTestUtilsError( + GattCbErr.SERV_ADDED_ERR.value.format(expected_event)) for characteristic in characteristic_list: per_droid.gattServerAddCharacteristicToService(gattService3, characteristic) @@ -252,40 +268,53 @@ def setup_multiple_services(per_ad): per_ed.pop_event(expected_event, default_timeout) except Empty: per_ad.droid.gattServerClose(gatt_server) - raise GattTestUtilsError(gatt_cb_strings['serv_added_err'].format( - expected_event)) + raise GattTestUtilsError( + GattCbErr.SERV_ADDED_ERR.value.format(expected_event)) return gatt_server_callback, gatt_server def setup_characteristics_and_descriptors(droid): characteristic_input = [ { - 'uuid': "aa7edd5a-4d1d-4f0e-883a-d145616a1630", - 'property': gatt_characteristic['property_write'] | - gatt_characteristic['property_write_no_response'], - 'permission': gatt_characteristic['property_write'] + 'uuid': + "aa7edd5a-4d1d-4f0e-883a-d145616a1630", + 'property': + GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_WRITE_NO_RESPONSE.value, + 'permission': + GattCharacteristic.PROPERTY_WRITE.value }, { - 'uuid': "21c0a0bf-ad51-4a2d-8124-b74003e4e8c8", - 'property': gatt_characteristic['property_notify'] | - gatt_characteristic['property_read'], - 'permission': gatt_characteristic['permission_read'] + 'uuid': + "21c0a0bf-ad51-4a2d-8124-b74003e4e8c8", + 'property': + GattCharacteristic.PROPERTY_NOTIFY.value | + GattCharacteristic.PROPERTY_READ.value, + 'permission': + GattCharacteristic.PERMISSION_READ.value }, { - 'uuid': "6774191f-6ec3-4aa2-b8a8-cf830e41fda6", - 'property': gatt_characteristic['property_notify'] | - gatt_characteristic['property_read'], - 'permission': gatt_characteristic['permission_read'] + 'uuid': + "6774191f-6ec3-4aa2-b8a8-cf830e41fda6", + 'property': + GattCharacteristic.PROPERTY_NOTIFY.value | + GattCharacteristic.PROPERTY_READ.value, + 'permission': + GattCharacteristic.PERMISSION_READ.value }, ] descriptor_input = [{ - 'uuid': "aa7edd5a-4d1d-4f0e-883a-d145616a1630", - 'property': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + "aa7edd5a-4d1d-4f0e-883a-d145616a1630", + 'property': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, }, { - 'uuid': "76d5ed92-ca81-4edb-bb6b-9f019665fb32", - 'property': gatt_descriptor['permission_read'] | - gatt_characteristic['permission_write'], + 'uuid': + "76d5ed92-ca81-4edb-bb6b-9f019665fb32", + 'property': + GattDescriptor.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, }] characteristic_list = setup_gatt_characteristics(droid, characteristic_input) @@ -330,16 +359,16 @@ def setup_gatt_mtu(cen_ad, bluetooth_gatt, gatt_callback, mtu): if fail, return False """ cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, mtu) - expected_event = gatt_cb_strings['mtu_changed'].format(gatt_callback) + expected_event = GattCbStrings.MTU_CHANGED.value.format(gatt_callback) try: mtu_event = cen_ad.ed.pop_event(expected_event, default_timeout) mtu_size_found = mtu_event['data']['MTU'] if mtu_size_found != mtu: - log.error("MTU size found: {}, expected: {}".format(mtu_size_found, - mtu)) + log.error( + "MTU size found: {}, expected: {}".format(mtu_size_found, mtu)) return False except Empty: - log.error(gatt_cb_err['mtu_changed_err'].format(expected_event)) + log.error(GattCbErr.MTU_CHANGED_ERR.value.format(expected_event)) return False return True diff --git a/acts/framework/acts/test_utils/bt/bt_test_utils.py b/acts/framework/acts/test_utils/bt/bt_test_utils.py index 73d4dbaf4a..da0bfe73be 100644 --- a/acts/framework/acts/test_utils/bt/bt_test_utils.py +++ b/acts/framework/acts/test_utils/bt/bt_test_utils.py @@ -26,51 +26,79 @@ from acts import utils from subprocess import call -from acts.test_utils.bt.bt_constants import adv_fail -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_constants import advertising_set_started -from acts.test_utils.bt.bt_constants import advertising_set_stopped -from acts.test_utils.bt.bt_constants import advertising_set_on_own_address_read -from acts.test_utils.bt.bt_constants import advertising_set_stopped -from acts.test_utils.bt.bt_constants import advertising_set_enabled -from acts.test_utils.bt.bt_constants import advertising_set_data_set -from acts.test_utils.bt.bt_constants import advertising_set_scan_response_set -from acts.test_utils.bt.bt_constants import advertising_set_parameters_update -from acts.test_utils.bt.bt_constants import \ - advertising_set_periodic_parameters_updated -from acts.test_utils.bt.bt_constants import advertising_set_periodic_data_set -from acts.test_utils.bt.bt_constants import advertising_set_periodic_enable -from acts.test_utils.bt.bt_constants import batch_scan_not_supported_list -from acts.test_utils.bt.bt_constants import batch_scan_result -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers -from acts.test_utils.bt.bt_constants import bluetooth_off -from acts.test_utils.bt.bt_constants import bluetooth_on -from acts.test_utils.bt.bt_constants import \ - bluetooth_profile_connection_state_changed -from acts.test_utils.bt.bt_constants import bt_default_timeout -from acts.test_utils.bt.bt_constants import bt_discovery_timeout -from acts.test_utils.bt.bt_constants import bt_profile_states -from acts.test_utils.bt.bt_constants import bt_rfcomm_uuids -from acts.test_utils.bt.bt_constants import bt_scan_mode_types -from acts.test_utils.bt.bt_constants import btsnoop_last_log_path_on_device -from acts.test_utils.bt.bt_constants import btsnoop_log_path_on_device -from acts.test_utils.bt.bt_constants import default_rfcomm_timeout_ms -from acts.test_utils.bt.bt_constants import mtu_changed -from acts.test_utils.bt.bt_constants import pairing_variant_passkey_confirmation -from acts.test_utils.bt.bt_constants import pan_connect_timeout -from acts.test_utils.bt.bt_constants import small_timeout -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_constants import scan_failed +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import ScanSettingsCallbackType +from acts.test_utils.bt.BleEnum import ScanSettingsMatchMode +from acts.test_utils.bt.BleEnum import ScanSettingsMatchNum +from acts.test_utils.bt.BleEnum import ScanSettingsScanResultType +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.BleEnum import ScanSettingsReportDelaySeconds +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseType +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseTxPower +from acts.test_utils.bt.BleEnum import ScanSettingsMatchNum +from acts.test_utils.bt.BleEnum import ScanSettingsScanResultType +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.BtEnum import BluetoothProfile +from acts.test_utils.bt.BtEnum import BluetoothProfileState +from acts.test_utils.bt.BtEnum import BluetoothScanModeType +from acts.test_utils.bt.BtEnum import RfcommUuid from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode_by_adb from acts.test_utils.tel.tel_test_utils import verify_http_connection from acts.utils import exe_cmd from acts.utils import create_dir +DEFAULT_TIMEOUT = 15 +DEFAULT_RFCOMM_TIMEOUT = 10000 +MAGIC_PAN_CONNECT_TIMEOUT = 5 +DEFAULT_DISCOVERY_TIMEOUT = 3 +TIMEOUT_SMALL = 0.0001 + +PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2 + +BTSNOOP_LOG_PATH_ON_DEVICE = "/data/misc/bluetooth/logs/btsnoop_hci.log" +BTSNOOP_LAST_LOG_PATH_ON_DEVICE = \ + "/data/misc/bluetooth/logs/btsnoop_hci.log.last" + log = logging +# Callback strings +scan_result = "BleScan{}onScanResults" +scan_failed = "BleScan{}onScanFailed" +batch_scan_result = "BleScan{}onBatchScanResult" +adv_fail = "BleAdvertise{}onFailure" +adv_succ = "BleAdvertise{}onSuccess" +bluetooth_off = "BluetoothStateChangedOff" +bluetooth_on = "BluetoothStateChangedOn" +mtu_changed = "GattConnect{}onMtuChanged" +bluetooth_profile_connection_state_changed = \ + "BluetoothProfileConnectionStateChanged" +advertising_set_started = "AdvertisingSet{}onAdvertisingSetStarted" +advertising_set_stopped = "AdvertisingSet{}onAdvertisingSetStopped" +advertising_set_on_own_address_read = "AdvertisingSet{}onOwnAddressRead" +advertising_set_stopped = "AdvertisingSet{}onAdvertisingSetStopped" +advertising_set_enabled = "AdvertisingSet{}onAdvertisingEnabled" +advertising_set_data_set = "AdvertisingSet{}onAdvertisingDataSet" +advertising_set_scan_response_set = "AdvertisingSet{}onScanResponseDataSet" +advertising_set_parameters_update = \ + "AdvertisingSet{}onAdvertisingParametersUpdated" +advertising_set_periodic_parameters_updated = \ + "AdvertisingSet{}onPeriodicAdvertisingParametersUpdated" +advertising_set_periodic_data_set = \ + "AdvertisingSet{}onPeriodicAdvertisingDataSet" +advertising_set_periodic_enable = "AdvertisingSet{}onPeriodicAdvertisingEnable" + +# rfcomm test uuids +rfcomm_secure_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66" +rfcomm_insecure_uuid = "8ce255c0-200a-11e0-ac64-0800200c9a66" + advertisements_to_devices = {} +batch_scan_not_supported_list = [ + "Nexus 4", + "Nexus 5", + "Nexus 7", +] + class BtTestUtilsError(Exception): pass @@ -96,11 +124,11 @@ def scan_and_verify_n_advertisements(scn_ad, max_advertisements): scan_callback = scn_ad.droid.bleGenScanCallback() scn_ad.droid.bleStartBleScan(filter_list, scan_settings, scan_callback) start_time = time.time() - while (start_time + bt_default_timeout) > time.time(): + while (start_time + DEFAULT_TIMEOUT) > time.time(): event = None try: event = scn_ad.ed.pop_event( - scan_result.format(scan_callback), bt_default_timeout) + scan_result.format(scan_callback), DEFAULT_TIMEOUT) except Empty as error: raise BtTestUtilsError("Failed to find scan event: {}".format( error)) @@ -125,7 +153,7 @@ def setup_n_advertisements(adv_ad, num_advertisements): advertise_callback_list: List of advertisement callback ids. """ adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) advertise_data = adv_ad.droid.bleBuildAdvertiseData() advertise_settings = adv_ad.droid.bleBuildAdvertiseSettings() advertise_callback_list = [] @@ -136,7 +164,7 @@ def setup_n_advertisements(adv_ad, num_advertisements): advertise_settings) try: adv_ad.ed.pop_event( - adv_succ.format(advertise_callback), bt_default_timeout) + adv_succ.format(advertise_callback), DEFAULT_TIMEOUT) adv_ad.log.info("Advertisement {} started.".format(i + 1)) except Empty as error: adv_ad.log.error("Advertisement {} failed to start.".format(i + 1)) @@ -261,8 +289,7 @@ def bluetooth_enabled_check(ad): ad.droid.bluetoothToggleState(True) expected_bluetooth_on_event_name = bluetooth_on try: - ad.ed.pop_event(expected_bluetooth_on_event_name, - bt_default_timeout) + ad.ed.pop_event(expected_bluetooth_on_event_name, DEFAULT_TIMEOUT) except Empty: ad.log.info( "Failed to toggle Bluetooth on(no broadcast received).") @@ -292,7 +319,7 @@ def reset_bluetooth(android_devices): expected_bluetooth_off_event_name = bluetooth_off try: ed.pop_event(expected_bluetooth_off_event_name, - bt_default_timeout) + DEFAULT_TIMEOUT) except Exception: a.log.error("Failed to toggle Bluetooth off.") return False @@ -321,7 +348,7 @@ def determine_max_advertisements(android_device): android_device.droid.bluetoothToggleState(True) try: android_device.ed.pop_event(expected_bluetooth_on_event_name, - bt_default_timeout) + DEFAULT_TIMEOUT) except Exception: android_device.log.info( "Failed to toggle Bluetooth on(no broadcast received).") @@ -348,8 +375,8 @@ def determine_max_advertisements(android_device): advertise_callback) + "|" + adv_fail.format( advertise_callback) + ")" # wait for either success or failure event - evt = android_device.ed.pop_events(regex, bt_default_timeout, - small_timeout) + evt = android_device.ed.pop_events(regex, DEFAULT_TIMEOUT, + TIMEOUT_SMALL) if evt[0]["name"] == adv_succ.format(advertise_callback): advertisement_count += 1 android_device.log.info("Advertisement {} started.".format( @@ -479,17 +506,17 @@ def get_mac_address_of_generic_advertisement(scan_ad, adv_ad): """ adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) adv_ad.droid.bleSetAdvertiseSettingsIsConnectable(True) adv_ad.droid.bleSetAdvertiseSettingsTxPowerLevel( - ble_advertise_settings_tx_powers['high']) + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(adv_ad.droid)) adv_ad.droid.bleStartBleAdvertising(advertise_callback, advertise_data, advertise_settings) try: adv_ad.ed.pop_event( - adv_succ.format(advertise_callback), bt_default_timeout) + adv_succ.format(advertise_callback), DEFAULT_TIMEOUT) except Empty as err: raise BtTestUtilsError( "Advertiser did not start successfully {}".format(err)) @@ -502,7 +529,7 @@ def get_mac_address_of_generic_advertisement(scan_ad, adv_ad): scan_ad.droid.bleStartBleScan(filter_list, scan_settings, scan_callback) try: event = scan_ad.ed.pop_event( - "BleScan{}onScanResults".format(scan_callback), bt_default_timeout) + "BleScan{}onScanResults".format(scan_callback), DEFAULT_TIMEOUT) except Empty as err: raise BtTestUtilsError("Scanner did not find advertisement {}".format( err)) @@ -518,7 +545,7 @@ def enable_bluetooth(droid, ed): droid.bluetoothToggleState(True) expected_bluetooth_on_event_name = bluetooth_on try: - ed.pop_event(expected_bluetooth_on_event_name, bt_default_timeout) + ed.pop_event(expected_bluetooth_on_event_name, DEFAULT_TIMEOUT) except Exception: log.info("Failed to toggle Bluetooth on (no broadcast received)") if droid.bluetoothCheckState() is True: @@ -557,24 +584,25 @@ def set_bt_scan_mode(ad, scan_mode_value): True if successful, false if unsuccessful. """ droid, ed = ad.droid, ad.ed - if scan_mode_value == bt_scan_mode_types['state_off']: + if scan_mode_value == BluetoothScanModeType.STATE_OFF.value: disable_bluetooth(droid) scan_mode = droid.bluetoothGetScanMode() reset_bluetooth([ad]) if scan_mode != scan_mode_value: return False - elif scan_mode_value == bt_scan_mode_types['none']: + elif scan_mode_value == BluetoothScanModeType.SCAN_MODE_NONE.value: droid.bluetoothMakeUndiscoverable() scan_mode = droid.bluetoothGetScanMode() if scan_mode != scan_mode_value: return False - elif scan_mode_value == bt_scan_mode_types['connectable']: + elif scan_mode_value == BluetoothScanModeType.SCAN_MODE_CONNECTABLE.value: droid.bluetoothMakeUndiscoverable() droid.bluetoothMakeConnectable() scan_mode = droid.bluetoothGetScanMode() if scan_mode != scan_mode_value: return False - elif (scan_mode_value == bt_scan_mode_types['connectable_discoverable']): + elif (scan_mode_value == + BluetoothScanModeType.SCAN_MODE_CONNECTABLE_DISCOVERABLE.value): droid.bluetoothMakeDiscoverable() scan_mode = droid.bluetoothGetScanMode() if scan_mode != scan_mode_value: @@ -645,13 +673,13 @@ def set_profile_priority(host_ad, client_ad, profiles, priority): profile, host_ad.droid.bluetoothGetLocalName(), client_ad.droid.bluetoothGetLocalAddress(), priority.value)) - if bt_profile_constants['a2dp_sink'] == profile: + if BluetoothProfile.A2DP_SINK.value == profile: host_ad.droid.bluetoothA2dpSinkSetPriority( client_ad.droid.bluetoothGetLocalAddress(), priority.value) - elif bt_profile_constants['headset_client'] == profile: + elif BluetoothProfile.HEADSET_CLIENT.value == profile: host_ad.droid.bluetoothHfpClientSetPriority( client_ad.droid.bluetoothGetLocalAddress(), priority.value) - elif bt_profile_constants['pbap_client'] == profile: + elif BluetoothProfile.PBAP_CLIENT.value == profile: host_ad.droid.bluetoothPbapClientSetPriority( client_ad.droid.bluetoothGetLocalAddress(), priority.value) else: @@ -704,14 +732,14 @@ def _wait_for_passkey_match(pri_ad, sec_ad): try: pri_pairing_req = pri_ad.ed.pop_event( event_name="BluetoothActionPairingRequest", - timeout=bt_default_timeout) + timeout=DEFAULT_TIMEOUT) pri_variant = pri_pairing_req["data"]["PairingVariant"] pri_pin = pri_pairing_req["data"]["Pin"] pri_ad.log.info("Primary device received Pin: {}, Variant: {}" .format(pri_pin, pri_variant)) sec_pairing_req = sec_ad.ed.pop_event( event_name="BluetoothActionPairingRequest", - timeout=bt_default_timeout) + timeout=DEFAULT_TIMEOUT) sec_variant = sec_pairing_req["data"]["PairingVariant"] sec_pin = sec_pairing_req["data"]["Pin"] sec_ad.log.info("Secondary device received Pin: {}, Variant: {}" @@ -721,7 +749,7 @@ def _wait_for_passkey_match(pri_ad, sec_ad): log.error("Pairing request state, Primary: {}, Secondary: {}" .format(pri_pairing_req, sec_pairing_req)) return False - if pri_variant == sec_variant == pairing_variant_passkey_confirmation: + if pri_variant == sec_variant == PAIRING_VARIANT_PASSKEY_CONFIRMATION: confirmation = pri_pin == sec_pin if confirmation: log.info("Pairing code matched, accepting connection") @@ -750,7 +778,7 @@ def _pair_pri_to_sec(pri_ad, sec_ad, auto_confirm): log.info("Bonding device {} to {}".format( pri_droid.bluetoothGetLocalAddress(), sec_droid.bluetoothGetLocalAddress())) - sec_droid.bluetoothMakeDiscoverable(bt_default_timeout) + sec_droid.bluetoothMakeDiscoverable(DEFAULT_TIMEOUT) target_address = sec_droid.bluetoothGetLocalAddress() log.debug("Starting paring helper on each device") pri_droid.bluetoothStartPairingHelper(auto_confirm) @@ -761,7 +789,7 @@ def _pair_pri_to_sec(pri_ad, sec_ad, auto_confirm): if not _wait_for_passkey_match(pri_ad, sec_ad): return False # Loop until we have bonded successfully or timeout. - end_time = time.time() + bt_default_timeout + end_time = time.time() + DEFAULT_TIMEOUT pri_ad.log.info("Verifying devices are bonded") while time.time() < end_time: bonded_devices = pri_droid.bluetoothGetBondedDevices() @@ -847,33 +875,33 @@ def _connect_pri_to_sec(pri_ad, sec_ad, profiles_set): # First use APIs to check profile connection state while (time.time() < end_time and not profile_connected.issuperset(profiles_set)): - if (bt_profile_constants['headset_client'] not in profile_connected and - bt_profile_constants['headset_client'] in profiles_set): + if (BluetoothProfile.HEADSET_CLIENT.value not in profile_connected and + BluetoothProfile.HEADSET_CLIENT.value in profiles_set): if is_hfp_client_device_connected(pri_ad, sec_addr): - profile_connected.add(bt_profile_constants['headset_client']) - if (bt_profile_constants['a2dp'] not in profile_connected and - bt_profile_constants['a2dp'] in profiles_set): + profile_connected.add(BluetoothProfile.HEADSET_CLIENT.value) + if (BluetoothProfile.A2DP.value not in profile_connected and + BluetoothProfile.A2DP.value in profiles_set): if is_a2dp_src_device_connected(pri_ad, sec_addr): - profile_connected.add(bt_profile_constants['a2dp']) - if (bt_profile_constants['a2dp_sink'] not in profile_connected and - bt_profile_constants['a2dp_sink'] in profiles_set): + profile_connected.add(BluetoothProfile.A2DP.value) + if (BluetoothProfile.A2DP_SINK.value not in profile_connected and + BluetoothProfile.A2DP_SINK.value in profiles_set): if is_a2dp_snk_device_connected(pri_ad, sec_addr): - profile_connected.add(bt_profile_constants['a2dp_sink']) - if (bt_profile_constants['map_mce'] not in profile_connected and - bt_profile_constants['map_mce'] in profiles_set): + profile_connected.add(BluetoothProfile.A2DP_SINK.value) + if (BluetoothProfile.MAP_MCE.value not in profile_connected and + BluetoothProfile.MAP_MCE.value in profiles_set): if is_map_mce_device_connected(pri_ad, sec_addr): - profile_connected.add(bt_profile_constants['map_mce']) - if (bt_profile_constants['map'] not in profile_connected and - bt_profile_constants['map'] in profiles_set): + profile_connected.add(BluetoothProfile.MAP_MCE.value) + if (BluetoothProfile.MAP.value not in profile_connected and + BluetoothProfile.MAP.value in profiles_set): if is_map_mse_device_connected(pri_ad, sec_addr): - profile_connected.add(bt_profile_constants['map']) + profile_connected.add(BluetoothProfile.MAP.value) time.sleep(0.1) # If APIs fail, try to find the connection broadcast receiver. while not profile_connected.issuperset(profiles_set): try: profile_event = pri_ad.ed.pop_event( bluetooth_profile_connection_state_changed, - bt_default_timeout + 10) + DEFAULT_TIMEOUT + 10) pri_ad.log.info("Got event {}".format(profile_event)) except Exception: pri_ad.log.error("Did not get {} profiles left {}".format( @@ -884,7 +912,7 @@ def _connect_pri_to_sec(pri_ad, sec_ad, profiles_set): state = profile_event['data']['state'] device_addr = profile_event['data']['addr'] - if state == bt_profile_states['connected'] and \ + if state == BluetoothProfileState.STATE_CONNECTED.value and \ device_addr == sec_ad.droid.bluetoothGetLocalAddress(): profile_connected.add(profile) pri_ad.log.info("Profiles connected until now {}".format( @@ -943,7 +971,7 @@ def disconnect_pri_from_sec(pri_ad, sec_ad, profiles_list): state = profile_event['data']['state'] device_addr = profile_event['data']['addr'] - if state == bt_profile_states['disconnected'] and \ + if state == BluetoothProfileState.STATE_DISCONNECTED.value and \ device_addr == sec_ad.droid.bluetoothGetLocalAddress(): profile_disconnected.add(profile) pri_ad.log.info("Profiles disconnected so far {}".format( @@ -984,17 +1012,17 @@ def take_btsnoop_log(ad, testcase, testname): out_name = ','.join((testname, device_model, serial)) snoop_path = ad.log_path + "/BluetoothSnoopLogs" utils.create_dir(snoop_path) - cmd = ''.join(("adb -s ", serial, " pull ", btsnoop_log_path_on_device, + cmd = ''.join(("adb -s ", serial, " pull ", BTSNOOP_LOG_PATH_ON_DEVICE, " ", snoop_path + '/' + out_name, ".btsnoop_hci.log")) exe_cmd(cmd) try: cmd = ''.join( - ("adb -s ", serial, " pull ", btsnoop_last_log_path_on_device, " ", + ("adb -s ", serial, " pull ", BTSNOOP_LAST_LOG_PATH_ON_DEVICE, " ", snoop_path + '/' + out_name, ".btsnoop_hci.log.last")) exe_cmd(cmd) except Exception as err: testcase.log.info("File does not exist {}".format( - btsnoop_last_log_path_on_device)) + BTSNOOP_LAST_LOG_PATH_ON_DEVICE)) def kill_bluetooth_process(ad): @@ -1011,7 +1039,7 @@ def kill_bluetooth_process(ad): def orchestrate_rfcomm_connection(client_ad, server_ad, - accept_timeout_ms=default_rfcomm_timeout_ms, + accept_timeout_ms=DEFAULT_RFCOMM_TIMEOUT, uuid=None): """Sets up the RFCOMM connection between two Android devices. @@ -1025,16 +1053,16 @@ def orchestrate_rfcomm_connection(client_ad, client_ad.droid.bluetoothStartPairingHelper() if not uuid: server_ad.droid.bluetoothRfcommBeginAcceptThread( - bt_rfcomm_uuids['default_uuid'], accept_timeout_ms) + RfcommUuid.DEFAULT_UUID.value, accept_timeout_ms) client_ad.droid.bluetoothRfcommBeginConnectThread( server_ad.droid.bluetoothGetLocalAddress(), - bt_rfcomm_uuids['default_uuid']) + RfcommUuid.DEFAULT_UUID.value) else: server_ad.droid.bluetoothRfcommBeginAcceptThread(uuid, accept_timeout_ms) client_ad.droid.bluetoothRfcommBeginConnectThread( server_ad.droid.bluetoothGetLocalAddress(), uuid) - end_time = time.time() + bt_default_timeout + end_time = time.time() + DEFAULT_TIMEOUT result = False test_result = True while time.time() < end_time: @@ -1149,8 +1177,6 @@ def orchestrate_and_verify_pan_connection(pan_dut, panu_dut): return False if not bluetooth_enabled_check(panu_dut): return False - if not bluetooth_enabled_check(pan_dut): - return False pan_dut.droid.bluetoothPanSetBluetoothTethering(True) if not (pair_pri_to_sec(pan_dut, panu_dut)): return False @@ -1159,7 +1185,7 @@ def orchestrate_and_verify_pan_connection(pan_dut, panu_dut): return False # Magic sleep needed to give the stack time in between bonding and # connecting the PAN profile. - time.sleep(pan_connect_timeout) + time.sleep(MAGIC_PAN_CONNECT_TIMEOUT) panu_dut.droid.bluetoothConnectBonded( pan_dut.droid.bluetoothGetLocalAddress()) if not verify_http_connection(log, panu_dut): diff --git a/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py b/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py index 5f3fe9de21..3f059c1dc9 100644 --- a/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py +++ b/acts/framework/acts/test_utils/tel/TelephonyBaseTest.py @@ -68,7 +68,6 @@ class TelephonyBaseTest(BaseTestClass): set_qxdm_logger_always_on(ad, mask) else: ad.log.info("qxdm always on is already set") - #The puk and pin should be provided in testbed config file. #"AndroidDevice": [{"serial": "84B5T15A29018214", # "adb_logcat_param": "-b all", @@ -92,22 +91,34 @@ class TelephonyBaseTest(BaseTestClass): @staticmethod def tel_test_wrap(fn): def _safe_wrap_test_case(self, *args, **kwargs): - test_id = "%s:%s:%s" % (self.__class__.__name__, self.test_name, - self.begin_time.replace(' ', '-')) + current_time = time.strftime("%m-%d-%Y-%H-%M-%S") + func_name = fn.__name__ + test_id = "%s:%s:%s" % (self.__class__.__name__, func_name, + current_time) self.test_id = test_id + self.begin_time = current_time + self.test_name = func_name log_string = "[Test ID] %s" % test_id self.log.info(log_string) try: for ad in self.android_devices: ad.droid.logI("Started %s" % log_string) + ad.crash_report = ad.check_crash_report( + log_crash_report=False) + if ad.crash_report: + ad.log.info("Found crash reports %s before test start", + ad.crash_report) + # TODO: b/19002120 start QXDM Logging result = fn(self, *args, **kwargs) for ad in self.android_devices: ad.droid.logI("Finished %s" % log_string) - new_crash = ad.check_crash_report(self.test_name, - self.begin_time, result) - if new_crash: - ad.log.error("Find new crash reports %s", new_crash) + new_crash = ad.check_crash_report() + crash_diff = set(new_crash).difference( + set(ad.crash_report)) + if crash_diff: + ad.log.error("Find new crash reports %s", + list(crash_diff)) if not result and self.user_params.get("telephony_auto_rerun"): self.teardown_test() # re-run only once, if re-run pass, mark as pass @@ -132,6 +143,7 @@ class TelephonyBaseTest(BaseTestClass): except (TestSignal, TestAbortClass, TestAbortAll): raise except Exception as e: + self.log.error(traceback.format_exc()) self.log.error(str(e)) return False finally: @@ -162,11 +174,9 @@ class TelephonyBaseTest(BaseTestClass): setattr(self, "diag_logger", self.register_controller( acts.controllers.diag_logger, required=False)) - - if not self.user_params.get("Attenuator"): + is_mobility_setup = self.user_params.get("Attenuator") + if not is_mobility_setup: ensure_phones_default_state(self.log, self.android_devices) - else: - ensure_phones_idle(self.log, self.android_devices) for ad in self.android_devices: setup_droid_properties(self.log, ad, sim_conf_file) @@ -180,36 +190,12 @@ class TelephonyBaseTest(BaseTestClass): ad.adb.shell("am start --ei EXTRA_LAUNCH_CARRIER_APP 0 -n " "\"com.google.android.wfcactivation/" ".VzwEmergencyAddressActivity\"") - # Start telephony monitor if not ad.is_apk_running("com.google.telephonymonitor"): ad.log.info("TelephonyMonitor is not running, start it now") ad.adb.shell( 'am broadcast -a ' 'com.google.gservices.intent.action.GSERVICES_OVERRIDE -e ' '"ce.telephony_monitor_enable" "true"') - # Sub ID setup - initial_set_up_for_subid_infomation(self.log, ad) - if "enable_wifi_verbose_logging" in self.user_params: - ad.droid.wifiEnableVerboseLogging(WIFI_VERBOSE_LOGGING_ENABLED) - # If device is setup already, skip the following setup procedures - if getattr(ad, "telephony_test_setup", None): - continue - # Disable Emergency alerts - # Set chrome browser start with no-first-run verification and - # disable-fre. Give permission to read from and write to storage. - for cmd in ( - "am start -n com.google.android.setupwizard/." - "SetupWizardExitActivity", - "pm disable com.android.cellbroadcastreceiver", - "pm grant com.android.chrome " - "android.permission.READ_EXTERNAL_STORAGE", - "pm grant com.android.chrome " - "android.permission.WRITE_EXTERNAL_STORAGE", - "rm /data/local/chrome-command-line", - "am set-debug-app --persistent com.android.chrome", - 'echo "chrome --no-default-browser-check --no-first-run ' - '--disable-fre" > /data/local/tmp/chrome-command-line'): - ad.adb.shell(cmd) # Ensure that a test class starts from a consistent state that # improves chances of valid network selection and facilitates @@ -221,21 +207,35 @@ class TelephonyBaseTest(BaseTestClass): if not set_phone_silent_mode(self.log, ad): self.log.error("Failed to set phone silent mode.") return False + ad.droid.telephonyAdjustPreciseCallStateListenLevel( PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND, True) ad.droid.telephonyAdjustPreciseCallStateListenLevel( PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING, True) ad.droid.telephonyAdjustPreciseCallStateListenLevel( PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND, True) + + if "enable_wifi_verbose_logging" in self.user_params: + ad.droid.wifiEnableVerboseLogging( + WIFI_VERBOSE_LOGGING_ENABLED) except Exception as e: self.log.error("Failure with %s", e) - setattr(ad, "telephony_test_setup", True) - + # Sub ID setup + for ad in self.android_devices: + initial_set_up_for_subid_infomation(self.log, ad) return 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) @@ -250,8 +250,8 @@ class TelephonyBaseTest(BaseTestClass): self.logger_sessions.append((logger, logger.start())) if self.skip_reset_between_cases: - ensure_phones_idle(self.log, self.android_devices) - ensure_phones_default_state(self.log, self.android_devices) + return ensure_phones_idle(self.log, self.android_devices) + return ensure_phones_default_state(self.log, self.android_devices) def teardown_test(self): return True diff --git a/acts/framework/acts/test_utils/tel/tel_data_utils.py b/acts/framework/acts/test_utils/tel/tel_data_utils.py index ddb57ca243..ac0bfd43c9 100644 --- a/acts/framework/acts/test_utils/tel/tel_data_utils.py +++ b/acts/framework/acts/test_utils/tel/tel_data_utils.py @@ -296,7 +296,7 @@ def wifi_cell_switching(log, ad, wifi_network_ssid, wifi_network_pass, nw_gen): wifi_toggle_state(log, ad, False) -def airplane_mode_test(log, ad, retries=3): +def airplane_mode_test(log, ad): """ Test airplane mode basic on Phone and Live SIM. Ensure phone attach, data on, WiFi off and verify Internet. @@ -323,16 +323,9 @@ def airplane_mode_test(log, ad, retries=3): if not toggle_airplane_mode(log, ad, False): ad.log.error("Failed initial attach") return False - for i in range(retries): - if verify_internet_connection(log, ad): - ad.log.info("Data available on cell.") - break - elif i == retries - 1: - ad.log.error("Data not available on cell.") - return False - else: - ad.log.warning("Attempt %d Data not available on cell" % - (i + 1)) + if not verify_internet_connection(log, ad): + ad.log.error("Data not available on cell.") + return False log.info("Step2: enable airplane mode and ensure detach") if not toggle_airplane_mode(log, ad, True): @@ -357,17 +350,7 @@ def airplane_mode_test(log, ad, retries=3): time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) log.info("Step4 verify internet") - for i in range(retries): - if verify_internet_connection(log, ad): - ad.log.info("Data available on cell.") - break - elif i == retries - 1: - ad.log.error("Data not available on cell.") - return False - else: - ad.log.warning("Attempt %d Data not available on cell" % - (i + 1)) - return True + return verify_internet_connection(log, ad) finally: toggle_airplane_mode(log, ad, False) diff --git a/acts/framework/acts/test_utils/tel/tel_defines.py b/acts/framework/acts/test_utils/tel/tel_defines.py index 5863e81896..f19737d591 100644 --- a/acts/framework/acts/test_utils/tel/tel_defines.py +++ b/acts/framework/acts/test_utils/tel/tel_defines.py @@ -51,10 +51,7 @@ MAX_WAIT_TIME_ACCEPT_CALL_TO_OFFHOOK_EVENT = 30 MAX_WAIT_TIME_CALL_IDLE_EVENT = 60 # Max time to wait after initiating a call for telecom to report in-call -MAX_WAIT_TIME_CALL_INITIATION = 90 - -# Time to wait after change Mode Pref for Stress Test -WAIT_TIME_AFTER_MODE_CHANGE = 60 +MAX_WAIT_TIME_CALL_INITIATION = 25 # Max time to wait after toggle airplane mode and before # get expected event @@ -154,9 +151,6 @@ WAIT_TIME_VOICE_MAIL_SERVER_RESPONSE = 10 # Time to wait for radio to up and running after reboot WAIT_TIME_AFTER_REBOOT = 10 -# Time to wait for radio to up and running after force crash -WAIT_TIME_AFTER_CRASH = 30 - # Time to wait for tethering test after reboot WAIT_TIME_TETHERING_AFTER_REBOOT = 10 diff --git a/acts/framework/acts/test_utils/tel/tel_test_utils.py b/acts/framework/acts/test_utils/tel/tel_test_utils.py index 5732351d83..88c7831285 100644 --- a/acts/framework/acts/test_utils/tel/tel_test_utils.py +++ b/acts/framework/acts/test_utils/tel/tel_test_utils.py @@ -140,19 +140,12 @@ from acts.test_utils.wifi import wifi_test_utils from acts.test_utils.wifi import wifi_constants from acts.utils import adb_shell_ping from acts.utils import load_config -from acts.utils import create_dir -from acts.utils import start_standing_subprocess -from acts.utils import stop_standing_subprocess -from acts.logger import epoch_to_log_line_timestamp -from acts.logger import normalize_log_line_timestamp -from acts.utils import get_current_epoch_time WIFI_SSID_KEY = wifi_test_utils.WifiEnums.SSID_KEY WIFI_PWD_KEY = wifi_test_utils.WifiEnums.PWD_KEY WIFI_CONFIG_APBAND_2G = wifi_test_utils.WifiEnums.WIFI_CONFIG_APBAND_2G WIFI_CONFIG_APBAND_5G = wifi_test_utils.WifiEnums.WIFI_CONFIG_APBAND_5G log = logging -STORY_LINE = "+19523521350" class _CallSequenceException(Exception): @@ -260,17 +253,13 @@ def setup_droid_properties(log, ad, sim_filename=None): sim_data[iccid]["phone_num"], sim_filename, sub_info["phone_num"]) sub_info["phone_num"] = sim_data[iccid]["phone_num"] - if not hasattr(ad, 'roaming') and sub_info["sim_plmn"] != sub_info[ - "network_plmn"] and ( - sub_info["sim_operator_name"].strip() not in sub_info[ - "network_operator_name"].strip()): - ad.log.info("roaming is not enabled, enable it") + if sub_info["sim_operator_name"] != sub_info["network_operator_name"]: setattr(ad, 'roaming', True) - data_roaming = getattr(ad, 'roaming', False) - if get_cell_data_roaming_state_by_adb(ad) != data_roaming: - set_cell_data_roaming_state_by_adb(ad, data_roaming) + if getattr(ad, 'roaming', False): + ad.log.info("Enable cell data roaming") + toggle_cell_data_roaming(ad, True) - ad.log.debug("cfg = %s", ad.cfg) + ad.log.info("cfg = %s", ad.cfg) def refresh_droid_config(log, ad): @@ -719,8 +708,7 @@ def wait_for_ringing_call_for_subscription( incoming_number=None, caller=None, event_tracking_started=False, - timeout=MAX_WAIT_TIME_CALLEE_RINGING, - retries=1): + timeout=MAX_WAIT_TIME_CALLEE_RINGING): """Wait for an incoming call on specified subscription. Args: @@ -738,32 +726,24 @@ def wait_for_ringing_call_for_subscription( if not event_tracking_started: ad.ed.clear_all_events() ad.droid.telephonyStartTrackingCallStateForSubscription(sub_id) - event_ringing = None - for i in range(retries): - event_ringing = _wait_for_ringing_event(log, ad, timeout) - if event_ringing: - ad.log.info("callee received ring event") - break - if ad.droid.telephonyGetCallStateForSubscription( - sub_id - ) == TELEPHONY_STATE_RINGING or ad.droid.telecomIsRinging(): - ad.log.info("callee in ringing state") - break - if i == retries - 1: - ad.log.error( - "callee didn't receive ring event or got into ringing state") - return False + event_ringing = _wait_for_ringing_event(log, ad, timeout) if not event_tracking_started: ad.droid.telephonyStopTrackingCallStateChangeForSubscription(sub_id) if caller and not caller.droid.telecomIsInCall(): caller.log.error("Caller not in call state") raise _CallSequenceException("Caller not in call state") + if not event_ringing and not ( + ad.droid.telephonyGetCallStateForSubscription(sub_id) == + TELEPHONY_STATE_RINGING or ad.droid.telecomIsRinging()): + ad.log.info("Not in call ringing state") + return False if not incoming_number: return True - if event_ringing and not check_phone_number_match( - event_ringing['data'][CallStateContainer.INCOMING_NUMBER], - incoming_number): + result = check_phone_number_match( + event_ringing['data'][CallStateContainer.INCOMING_NUMBER], + incoming_number) + if not result: ad.log.error( "Incoming Number not match. Expected number:%s, actual number:%s", incoming_number, @@ -979,7 +959,7 @@ def hangup_call(log, ad): return True ad.ed.clear_all_events() ad.droid.telephonyStartTrackingCallState() - ad.log.info("Hangup call.") + log.info("Hangup call.") ad.droid.telecomEndCall() try: @@ -1114,7 +1094,7 @@ def initiate_call(log, ) or wait_for_call_offhook_event(log, ad, sub_id, True, checking_interval): return True - ad.log.info( + ad.log.error( "Make call to %s fail. telecomIsInCall:%s, Telecom State:%s," " Telephony State:%s", callee_number, ad.droid.telecomIsInCall(), @@ -1124,124 +1104,6 @@ def initiate_call(log, ad.droid.telephonyStopTrackingCallStateChangeForSubscription(sub_id) -def dial_phone_number(ad, callee_number): - for number in str(callee_number): - if number == "#": - ad.send_keycode("POUND") - elif number == "*": - ad.send_keycode("STAR") - elif number in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]: - ad.send_keycode("%s" % number) - - -def get_call_state_by_adb(ad): - return ad.adb.shell("dumpsys telephony.registry | grep mCallState") - - -def check_call_state_connected_by_adb(ad): - return "2" in get_call_state_by_adb(ad) - - -def check_call_state_idle_by_adb(ad): - return "0" in get_call_state_by_adb(ad) - - -def check_call_state_ring_by_adb(ad): - return "1" in get_call_state_by_adb(ad) - - -def get_incoming_call_number_by_adb(ad): - output = ad.adb.shell( - "dumpsys telephony.registry | grep mCallIncomingNumber") - return re.search(r"mCallIncomingNumber=(.*)", output).group(1) - - -def emergency_dialer_call_by_keyevent(ad, callee_number): - for i in range(3): - if "EmergencyDialer" in ad.get_my_current_focus_window(): - ad.log.info("EmergencyDialer is the current focus window") - break - elif i <= 2: - ad.adb.shell("am start -a com.android.phone.EmergencyDialer.DIAL") - time.sleep(1) - else: - ad.log.error("Unable to bring up EmergencyDialer") - return False - ad.log.info("Make a phone call to %s", callee_number) - dial_phone_number(ad, callee_number) - ad.send_keycode("CALL") - - -def initiate_emergency_dialer_call_by_adb( - log, - ad, - callee_number, - timeout=MAX_WAIT_TIME_CALL_INITIATION, - checking_interval=5): - """Make emergency call by EmergencyDialer. - - Args: - ad: Caller android device object. - callee_number: Callee phone number. - emergency : specify the call is emergency. - Optional. Default value is False. - - Returns: - result: if phone call is placed successfully. - """ - try: - # Make a Call - ad.wakeup_screen() - ad.log.info("Call %s", callee_number) - ad.adb.shell("am start -a com.android.phone.EmergencyDialer.DIAL") - ad.adb.shell( - "am start -a android.intent.action.CALL_EMERGENCY -d tel:%s" % - callee_number) - ad.log.info("Check call state") - # Verify Call State - elapsed_time = 0 - while elapsed_time < timeout: - time.sleep(checking_interval) - elapsed_time += checking_interval - if check_call_state_connected_by_adb(ad): - ad.log.info("Call to %s is connected", callee_number) - return True - ad.log.info("Make call to %s failed", callee_number) - return False - except Exception as e: - ad.log.error("initiate emergency call failed with error %s", e) - - -def hung_up_call_by_adb(ad): - """Make emergency call by EmergencyDialer. - - Args: - ad: Caller android device object. - callee_number: Callee phone number. - """ - ad.log.info("End call by adb") - ad.send_keycode("ENDCALL") - - -def dumpsys_telecom_call_info(ad): - """ Get call information by dumpsys telecom. """ - output = ad.adb.shell("dumpsys telecom") - calls = re.findall("Call TC@\d+: {(.*?)}", output, re.DOTALL) - calls_info = [] - for call in calls: - call_info = {} - for attr in ("startTime", "endTime", "direction", "isInterrupted", - "callTechnologies", "callTerminationsReason", - "connectionService", "isVedeoCall", "callProperties"): - match = re.search(r"%s: (.*)" % attr, call) - if match: - call_info[attr] = match.group(1) - call_info["inCallServices"] = re.findall(r"name: (.*)", call) - calls_info.append(call_info) - ad.log.debug("calls_info = %s", calls_info) - return calls_info - - def call_reject(log, ad_caller, ad_callee, reject=True): """Caller call Callee, then reject on callee. @@ -1589,25 +1451,17 @@ def call_setup_teardown_for_subscription( False if error happened. """ - CHECK_INTERVAL = 5 + CHECK_INTERVAL = 3 result = True caller_number = ad_caller.cfg['subscription'][subid_caller]['phone_num'] callee_number = ad_callee.cfg['subscription'][subid_callee]['phone_num'] - if not verify_caller_func: - verify_caller_func = is_phone_in_call - if not verify_callee_func: - verify_callee_func = is_phone_in_call - result = True - ad_caller.log.info("Call from %s to %s with duration %s", caller_number, - callee_number, wait_time_in_call) + ad_caller.log.info("Call from %s to %s", caller_number, callee_number) try: if not initiate_call(log, ad_caller, callee_number): - ad_caller.log.error("Initiate call failed.") - result = False - return False + raise _CallSequenceException("Initiate call failed.") else: ad_caller.log.info("Caller initate call successfully") if not wait_and_answer_call_for_subscription( @@ -1617,11 +1471,16 @@ def call_setup_teardown_for_subscription( incoming_number=caller_number, caller=ad_caller, incall_ui_display=incall_ui_display): - ad_callee.log.error("Answer call fail.") - result = False - return False + raise _CallSequenceException("Answer call fail.") else: ad_callee.log.info("Callee answered the call successfully") + # ensure that all internal states are updated in telecom + time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) + + if verify_caller_func and not verify_caller_func(log, ad_caller): + raise _CallSequenceException("Caller not in correct state!") + if verify_callee_func and not verify_callee_func(log, ad_callee): + raise _CallSequenceException("Callee not in correct state!") elapsed_time = 0 while (elapsed_time < wait_time_in_call): @@ -1631,28 +1490,44 @@ def call_setup_teardown_for_subscription( elapsed_time += CHECK_INTERVAL time_message = "at <%s>/<%s> second." % (elapsed_time, wait_time_in_call) - if not verify_caller_func(log, ad_caller): - ad_caller.log.error("Caller is NOT in correct %s state at %s", - verify_caller_func.__name__, time_message) - result = False + if not verify_caller_func: + if not ad_caller.droid.telecomIsInCall(): + ad_caller.log.error("Caller not in call state %s", + time_message) + raise _CallSequenceException( + "Caller not in correct state %s.".format(time_message)) else: - ad_caller.log.info("Caller is in correct %s state at %s", - verify_caller_func.__name__, time_message) - if not verify_callee_func(log, ad_callee): - ad_callee.log.error("Callee is NOT in correct %s state at %s", - verify_callee_func.__name__, time_message) - result = False + if not verify_caller_func(log, ad_caller): + ad_caller.log.error("Caller %s return False", + verify_caller_func.__name__) + raise _CallSequenceException( + "Caller not in correct state %s.".format(time_message)) + if not verify_callee_func: + if not ad_callee.droid.telecomIsInCall(): + ad_callee.log.error("Callee not in call state %s", + time_message) + raise _CallSequenceException( + "Callee not in correct state %s.".format(time_message)) else: - ad_callee.log.info("Callee is in correct %s state at %s", - verify_callee_func.__name__, time_message) - if not result: - return result - return result - finally: - if result and ad_hangup and not hangup_call(log, ad_hangup): + if not verify_callee_func(log, ad_callee): + ad_callee.log.error("Callee %s return False", + verify_callee_func.__name__) + raise _CallSequenceException( + "Callee not in correct state %s.".format(time_message)) + + if not ad_hangup: + return True + if not hangup_call(log, ad_hangup): ad_hangup.log.info("Failed to hang up the call") - result = False - if not result: + raise _CallSequenceException("Error in Hanging-Up Call") + return True + + except _CallSequenceException as e: + log.error(e) + result = False + return False + finally: + if ad_hangup or not result: for ad in [ad_caller, ad_callee]: try: if ad.droid.telecomIsInCall(): @@ -1759,78 +1634,73 @@ def verify_http_connection(log, return False -def _generate_file_directory_and_file_name(url, out_path): +def _generate_file_name_and_out_path(url, out_path): file_name = url.split("/")[-1] if not out_path: - file_directory = "/sdcard/Download/" - elif not out_path.endswith("/"): - file_directory, file_name = os.path.split(out_path) + out_path = "/sdcard/Download/%s" % file_name + elif out_path.endswith("/"): + out_path = os.path.join(out_path, file_name) else: - file_directory = out_path - return file_directory, file_name + file_name = out_path.split("/")[-1] + return file_name, out_path -def _check_file_existance(ad, file_path, expected_file_size=None): - """Check file existance by file_path. If expected_file_size +def _check_file_existance(ad, file_name, out_path, expected_file_size=None): + """Check file existance by file_name and out_path. If expected_file_size is provided, then also check if the file meet the file size requirement. """ - out = None - try: - out = ad.adb.shell('stat -c "%%s" %s' % file_path) - except AdbError: - pass + if out_path.endswith("/"): + out_path = os.path.join(out_path, file_name) + out = ad.adb.shell("ls -l %s" % out_path, ignore_status=True) # Handle some old version adb returns error message "No such" into std_out - if out and "No such" not in out: + if out and "No such" not in out and file_name in out: if expected_file_size: - file_size = int(out) + file_size = int(out.split(" ")[4]) if file_size >= expected_file_size: - ad.log.info("File %s of size %s exists", file_path, file_size) + ad.log.info("File %s of size %s is in %s", file_name, + file_size, out_path) return True else: - ad.log.info("File %s is of size %s, does not meet expected %s", - file_path, file_size, expected_file_size) + ad.log.info( + "File size for %s in %s is %s does not meet expected %s", + file_name, out_path, file_size, expected_file_size) return False else: - ad.log.info("File %s exists", file_path) + ad.log.info("File %s is in %s", file_name, out_path) return True else: - ad.log.info("File %s does not exist.", file_path) + ad.log.info("File %s does not exist in %s.", file_name, out_path) return False def active_file_download_task(log, ad, file_name="5MB"): - if not hasattr(ad, "curl_capable"): - try: - out = ad.adb.shell("curl --version") - if not out or "not found" in out: - setattr(ad, "curl_capable", False) - ad.log.info("curl is unavailable, use chrome to download file") - else: - setattr(ad, "curl_capable", True) - except Exception: - setattr(ad, "curl_capable", False) - ad.log.info("curl is unavailable, use chrome to download file") - + curl_capable = True + try: + out = ad.adb.shell("curl --version") + if "not found" in out: + curl_capable = False + except AdbError: + curl_capable = False # files available for download on the same website: # 1GB.zip, 512MB.zip, 200MB.zip, 50MB.zip, 20MB.zip, 10MB.zip, 5MB.zip # download file by adb command, as phone call will use sl4a - url = "http://146.148.91.8/download/" + file_name + ".zip" + url = "http://download.thinkbroadband.com/" + file_name + ".zip" file_map_dict = { '5MB': 5000000, '10MB': 10000000, '20MB': 20000000, '50MB': 50000000, - '100MB': 100000000, '200MB': 200000000, - '512MB': 512000000 + '512MB': 512000000, + '1GB': 1000000000 } file_size = file_map_dict.get(file_name) if not file_size: log.warning("file_name %s for download is not available", file_name) return False - timeout = min(max(file_size / 100000, 300), 3600) + timeout = min(max(file_size / 100000, 60), 3600) output_path = "/sdcard/Download/" + file_name + ".zip" - if not ad.curl_capable: + if not curl_capable: return (http_file_download_by_chrome, (ad, url, file_size, True, timeout)) else: @@ -1908,7 +1778,7 @@ def http_file_download_by_curl(ad, out_path=None, expected_file_size=None, remove_file_after_check=True, - timeout=3600, + timeout=900, limit_rate=None, retry=3): """Download http file by adb curl. @@ -1926,43 +1796,39 @@ def http_file_download_by_curl(ad, limit_rate: download rate in bps. None, if do not apply rate limit. retry: the retry request times provided in curl command. """ - file_directory, file_name = _generate_file_directory_and_file_name( - url, out_path) - file_path = os.path.join(file_directory, file_name) + file_name, out_path = _generate_file_name_and_out_path(url, out_path) curl_cmd = "curl" if limit_rate: curl_cmd += " --limit-rate %s" % limit_rate if retry: curl_cmd += " --retry %s" % retry - curl_cmd += " --url %s > %s" % (url, file_path) + curl_cmd += " --url %s > %s" % (url, out_path) try: - ad.log.info("Download %s to %s by adb shell command %s", url, - file_path, curl_cmd) + ad.log.info("Download file from %s to %s by adb shell command %s", url, + out_path, curl_cmd) ad.adb.shell(curl_cmd, timeout=timeout) - if _check_file_existance(ad, file_path, expected_file_size): - ad.log.info("%s is downloaded to %s successfully", url, file_path) + if _check_file_existance(ad, file_name, out_path, expected_file_size): + ad.log.info("File %s is downloaded from %s successfully", + file_name, url) return True else: - ad.log.warning("Fail to download %s", url) + ad.log.warning("Fail to download file from %s", url) return False except Exception as e: - ad.log.warning("Download %s failed with exception %s", url, e) + ad.log.warning("Download file from %s failed with exception %s", url, + e) return False finally: if remove_file_after_check: - ad.log.info("Remove the downloaded file %s", file_path) - ad.adb.shell("rm %s" % file_path, ignore_status=True) - - -def open_url_by_adb(ad, url): - ad.adb.shell('am start -a android.intent.action.VIEW -d "%s"' % url) + ad.log.info("Remove the downloaded file %s", out_path) + ad.adb.shell("rm %s" % out_path, ignore_status=True) def http_file_download_by_chrome(ad, url, expected_file_size=None, remove_file_after_check=True, - timeout=3600): + timeout=900): """Download http file by chrome. Args: @@ -1974,38 +1840,32 @@ def http_file_download_by_chrome(ad, check. timeout: timeout for file download to complete. """ - file_directory, file_name = _generate_file_directory_and_file_name( + file_name, out_path = _generate_file_name_and_out_path( url, "/sdcard/Download/") - file_path = os.path.join(file_directory, file_name) - # Remove pre-existing file - ad.force_stop_apk("com.android.chrome") - ad.adb.shell("rm %s" % file_path, ignore_status=True) - ad.adb.shell("rm %s.crdownload" % file_path, ignore_status=True) - ad.ensure_screen_on() - ad.log.info("Download %s with timeout %s", url, timeout) - open_url_by_adb(ad, url) + for cmd in ("am set-debug-app --persistent com.android.chrome", + 'echo "chrome --no-default-browser-check --no-first-run ' + '--disable-fre > /data/local/chrome-command-line"', + "pm grant com.android.chrome " + "android.permission.READ_EXTERNAL_STORAGE", + "pm grant com.android.chrome " + "android.permission.WRITE_EXTERNAL_STORAGE", + 'am start -a android.intent.action.VIEW -d "%s"' % url): + ad.adb.shell(cmd) + ad.log.info("Download %s from %s with timeout %s", file_name, url, timeout) elapse_time = 0 while elapse_time < timeout: time.sleep(30) - if _check_file_existance(ad, file_path, expected_file_size): - ad.log.info("%s is downloaded successfully", url) + if _check_file_existance(ad, file_name, out_path, expected_file_size): + ad.log.info("File %s is downloaded from %s successfully", + file_name, url) if remove_file_after_check: - ad.log.info("Remove the downloaded file %s", file_path) - ad.adb.shell("rm %s" % file_path, ignore_status=True) + ad.log.info("Remove the downloaded file %s", out_path) + ad.adb.shell("rm %s" % out_path, ignore_status=True) return True - elif _check_file_existance(ad, "%s.crdownload" % file_path): - ad.log.info("Chrome is downloading %s", url) - elif elapse_time < 60: - # download not started, retry download wit chrome again - open_url_by_adb(ad, url) else: - ad.log.error("Unable to download file from %s", url) - break - elapse_time += 30 - ad.log.error("Fail to download file from %s", url) - ad.force_stop_apk("com.android.chrome") - ad.adb.shell("rm %s" % file_path, ignore_status=True) - ad.adb.shell("rm %s.crdownload" % file_path, ignore_status=True) + elapse_time += 30 + ad.log.warning("Fail to download file from %s", url) + ad.adb.shell("rm %s" % out_path, ignore_status=True) return False @@ -2030,27 +1890,25 @@ def http_file_download_by_sl4a(log, check. timeout: timeout for file download to complete. """ - file_folder, file_name = _generate_file_directory_and_file_name(url, - out_path) - file_path = os.path.join(file_folder, file_name) + file_name, out_path = _generate_file_name_and_out_path(url, out_path) try: ad.log.info("Download file from %s to %s by sl4a RPC call", url, - file_path) - ad.droid.httpDownloadFile(url, file_path, timeout=timeout) - if _check_file_existance(ad, file_path, expected_file_size): - ad.log.info("%s is downloaded successfully", url) + out_path) + ad.droid.httpDownloadFile(url, out_path, timeout=timeout) + if _check_file_existance(ad, file_name, out_path, expected_file_size): + ad.log.info("File %s is downloaded from %s successfully", + file_name, url) return True else: - ad.log.warning("Fail to download %s", url) + ad.log.warning("Fail to download file from %s", url) return False except Exception as e: - ad.log.error("Download %s failed with exception %s", url, e) + ad.log.error("Download file from %s failed with exception %s", url, e) raise finally: if remove_file_after_check: - ad.log.info("Remove the downloaded file %s", file_path) - ad.adb.shell("rm %s" % file_path, ignore_status=True) - + ad.log.info("Remove the downloaded file %s", out_path) + ad.adb.shell("rm %s" % out_path, ignore_status=True) def trigger_modem_crash(log, ad, timeout=10): cmd = "echo restart > /sys/kernel/debug/msm_subsys/modem" @@ -2058,7 +1916,6 @@ def trigger_modem_crash(log, ad, timeout=10): ad.adb.shell(cmd, timeout=timeout) return True - def _connection_state_change(_event, target_state, connection_type): if connection_type: if 'TypeName' not in _event['data']: @@ -2072,8 +1929,7 @@ def _connection_state_change(_event, target_state, connection_type): connection_type, connection_type_string_in_event, cur_type) return False - if 'isConnected' in _event['data'] and _event['data'][ - 'isConnected'] == target_state: + if 'isConnected' in _event['data'] and _event['data']['isConnected'] == target_state: return True return False @@ -2100,8 +1956,8 @@ def wait_for_cell_data_connection( False if failed. """ sub_id = get_default_data_sub_id(ad) - return wait_for_cell_data_connection_for_subscription(log, ad, sub_id, - state, timeout_value) + return wait_for_cell_data_connection_for_subscription( + log, ad, sub_id, state, timeout_value) def _is_data_connection_state_match(log, ad, expected_data_connection_state): @@ -2325,26 +2181,6 @@ def _wait_for_nw_data_connection( ad.droid.connectivityStopTrackingConnectivityStateChange() -def get_cell_data_roaming_state_by_adb(ad): - """Get Cell Data Roaming state. True for enabled, False for disabled""" - adb_str = {"1": True, "0": False} - out = ad.adb.shell("settings get global data_roaming") - return adb_str[out] - - -def get_cell_data_roaming_state_by_adb(ad): - """Get Cell Data Roaming state. True for enabled, False for disabled""" - state_mapping = {"1": True, "0": False} - return state_mapping[ad.adb.shell("settings get global data_roaming")] - - -def set_cell_data_roaming_state_by_adb(ad, state): - """Set Cell Data Roaming state.""" - state_mapping = {True: "1", False: "0"} - ad.log.info("Set data roaming to %s", state) - ad.adb.shell("settings put global data_roaming %s" % state_mapping[state]) - - def toggle_cell_data_roaming(ad, state): """Enable cell data roaming for default data subscription. @@ -2654,7 +2490,7 @@ def _is_attached(log, ad, voice_or_data): def _is_attached_for_subscription(log, ad, sub_id, voice_or_data): rat = get_network_rat_for_subscription(log, ad, sub_id, voice_or_data) - ad.log.info("Sub_id %s network RAT is %s for %s", sub_id, rat, + ad.log.info("Sub_id %s network rate is %s for %s", sub_id, rat, voice_or_data) return rat != RAT_UNKNOWN @@ -3851,30 +3687,20 @@ def ensure_phone_subscription(log, ad): """Ensure Phone Subscription. """ #check for sim and service - duration = 0 - while duration < MAX_WAIT_TIME_NW_SELECTION: - subInfo = ad.droid.subscriptionGetAllSubInfoList() - if subInfo and len(subInfo) >= 1: - ad.log.info("Find valid subcription %s", subInfo) - break - else: - ad.log.info("Did not find a valid subscription") - time.sleep(5) - duration += 5 - else: + subInfo = ad.droid.subscriptionGetAllSubInfoList() + if not subInfo or len(subInfo) < 1: ad.log.error("Unable to find A valid subscription!") return False - if ad.droid.subscriptionGetDefaultDataSubId() <= INVALID_SUB_ID and ( - ad.droid.subscriptionGetDefaultVoiceSubId() <= INVALID_SUB_ID): - ad.log.error("No Valid Voice or Data Sub ID") + if ad.droid.subscriptionGetDefaultDataSubId() <= INVALID_SUB_ID: + ad.log.error("No Default Data Sub ID") + return False + elif ad.droid.subscriptionGetDefaultVoiceSubId() <= INVALID_SUB_ID: + ad.log.error("No Valid Voice Sub ID") return False - voice_sub_id = ad.droid.subscriptionGetDefaultVoiceSubId() - data_sub_id = ad.droid.subscriptionGetDefaultVoiceSubId() - if not wait_for_voice_attach_for_subscription( - log, ad, voice_sub_id, MAX_WAIT_TIME_NW_SELECTION - - duration) and not wait_for_data_attach_for_subscription( - log, ad, data_sub_id, MAX_WAIT_TIME_NW_SELECTION - duration): - ad.log.error("Did Not Attach For Voice or Data Services") + sub_id = ad.droid.subscriptionGetDefaultVoiceSubId() + if not wait_for_voice_attach_for_subscription(log, ad, sub_id, + MAX_WAIT_TIME_NW_SELECTION): + ad.log.error("Did Not Attach For Voice Services") return False return True @@ -3897,9 +3723,6 @@ def ensure_phone_default_state(log, ad, check_subscription=True): ad.log.error("Failed to end call") ad.droid.telephonyFactoryReset() ad.droid.imsFactoryReset() - data_roaming = getattr(ad, 'roaming', False) - if get_cell_data_roaming_state_by_adb(ad) != data_roaming: - set_cell_data_roaming_state_by_adb(ad, data_roaming) except Exception as e: ad.log.error("%s failure, toggle APM instead", e) toggle_airplane_mode(log, ad, True, False) @@ -3907,11 +3730,16 @@ def ensure_phone_default_state(log, ad, check_subscription=True): ad.droid.telephonyToggleDataConnection(True) set_wfc_mode(log, ad, WFC_MODE_DISABLED) + get_telephony_signal_strength(ad) + if not wait_for_not_network_rat( log, ad, RAT_FAMILY_WLAN, voice_or_data=NETWORK_SERVICE_DATA): ad.log.error("%s still in %s", NETWORK_SERVICE_DATA, RAT_FAMILY_WLAN) result = False + if getattr(ad, 'data_roaming', False): + ad.log.info("Enable cell data roaming") + toggle_cell_data_roaming(ad, True) if check_subscription and not ensure_phone_subscription(log, ad): ad.log.error("Unable to find a valid subscription!") result = False @@ -3952,8 +3780,7 @@ def check_is_wifi_connected(log, ad, wifi_ssid): False if wifi is not connected to wifi_ssid """ wifi_info = ad.droid.wifiGetConnectionInfo() - if wifi_info["supplicant_state"] == "completed" and wifi_info[ - "SSID"] == wifi_ssid: + if wifi_info["supplicant_state"] == "completed" and wifi_info["SSID"] == wifi_ssid: ad.log.info("Wifi is connected to %s", wifi_ssid) return True else: @@ -4163,11 +3990,7 @@ def run_multithread_func(log, tasks): number_of_workers = min(MAX_NUMBER_OF_WORKERS, len(tasks)) executor = concurrent.futures.ThreadPoolExecutor( max_workers=number_of_workers) - try: - results = list(executor.map(task_wrapper, tasks)) - except Exception as e: - log.error("Exception error %s", e) - raise + results = list(executor.map(task_wrapper, tasks)) executor.shutdown() log.info("multithread_func %s result: %s", [task[0].__name__ for task in tasks], results) @@ -4246,41 +4069,10 @@ def set_phone_silent_mode(log, ad, silent_mode=True): ad.droid.setMediaVolume(0) ad.droid.setVoiceCallVolume(0) ad.droid.setAlarmVolume(0) - out = ad.adb.shell("settings list system | grep volume") - for attr in re.findall(r"(volume_.*)=\d+", out): - ad.adb.shell("settings put system %s 0" % attr) - try: - if not ad.droid.telecomIsInCall(): - ad.droid.telecomCallNumber(STORY_LINE) - for _ in range(10): - ad.send_keycode("VOLUME_DOWN") - time.sleep(1) - ad.droid.telecomEndCall() - time.sleep(1) - except Exception as e: - ad.log.info("fail to turn down voice call volume %s", e) return silent_mode == ad.droid.checkRingerSilentMode() -def set_preferred_network_mode_pref(log, ad, sub_id, network_preference): - """Set Preferred Network Mode for Sub_id - Args: - log: Log object. - ad: Android device object. - sub_id: Subscription ID. - network_preference: Network Mode Type - """ - ad.log.info("Setting ModePref to %s for Sub %s", network_preference, - sub_id) - if not ad.droid.telephonySetPreferredNetworkTypesForSubscription( - network_preference, sub_id): - ad.log.error("Set sub_id %s PreferredNetworkType %s failed", sub_id, - network_preference) - return False - return True - - def set_preferred_subid_for_sms(log, ad, sub_id): """set subscription id for SMS @@ -4431,8 +4223,8 @@ def is_network_call_back_event_match(event, network_callback_id, try: return ( (network_callback_id == event['data'][NetworkCallbackContainer.ID]) - and (network_callback_event == event['data'][ - NetworkCallbackContainer.NETWORK_CALLBACK_EVENT])) + and (network_callback_event == event['data'] + [NetworkCallbackContainer.NETWORK_CALLBACK_EVENT])) except KeyError: return False @@ -4564,49 +4356,3 @@ def check_qxdm_logger_always_on(ad, mask_file="Radio-general.cfg"): "cat /data/vendor/radio/diag_logs/diag.conf", ignore_status=True): return False return True - - -def start_adb_tcpdump(ad, test_name, mask="ims"): - """Start tcpdump on any iface - - Args: - ad: android device object. - test_name: tcpdump file name will have this - - """ - ad.log.debug("Ensuring no tcpdump is running in background") - ad.adb.shell("killall -9 tcpdump") - begin_time = epoch_to_log_line_timestamp(get_current_epoch_time()) - begin_time = normalize_log_line_timestamp(begin_time) - file_name = "/sdcard/tcpdump{}{}{}.pcap".format(ad.serial, test_name, - begin_time) - ad.log.info("tcpdump file is %s", file_name) - if mask == "all": - cmd = "adb -s {} shell tcpdump -i any -s0 -w {}" . \ - format(ad.serial, file_name) - else: - cmd = "adb -s {} shell tcpdump -i any -s0 -n -p udp port 500 or \ - udp port 4500 -w {}".format(ad.serial, file_name) - ad.log.debug("%s" % cmd) - tcpdump_pid = start_standing_subprocess(cmd, 5) - return (tcpdump_pid, file_name) - - -def stop_adb_tcpdump(ad, tcpdump_pid, tcpdump_file, pull_tcpdump=False): - """Stops tcpdump on any iface - Pulls the tcpdump file in the tcpdump dir - - Args: - ad: android device object. - tcpdump_pid: need to know which pid to stop - tcpdump_file: filename needed to pull out - - """ - ad.log.debug("Stopping and pulling tcpdump if failed") - stop_standing_subprocess(tcpdump_pid) - if pull_tcpdump: - tcpdump_path = os.path.join(ad.log_path, "tcpdump") - create_dir(tcpdump_path) - ad.adb.pull("{} {}".format(tcpdump_file, tcpdump_path)) - ad.adb.shell("rm -rf {}".format(tcpdump_file)) - return True diff --git a/acts/framework/acts/test_utils/tel/tel_video_utils.py b/acts/framework/acts/test_utils/tel/tel_video_utils.py index 48ab6eef0f..e670bd3e66 100644 --- a/acts/framework/acts/test_utils/tel/tel_video_utils.py +++ b/acts/framework/acts/test_utils/tel/tel_video_utils.py @@ -511,7 +511,6 @@ def video_call_setup_teardown(log, verify_caller_func, verify_callee_func, wait_time_in_call, incall_ui_display) - # TODO: b/26337151 Might be able to re-factor call_setup_teardown and add. # Minimal changes. def video_call_setup_teardown_for_subscription( @@ -594,6 +593,14 @@ def video_call_setup_teardown_for_subscription( if verify_caller_func and not verify_caller_func(log, ad_caller): raise _CallSequenceException("Caller not in correct state!") + time.sleep(5) + ad_caller.adb.shell("input keyevent 22",timeout=3) + ad_callee.adb.shell("input keyevent 22",timeout=3) + ad_caller.adb.shell("input keyevent 22",timeout=3) + ad_callee.adb.shell("input keyevent 22",timeout=3) + ad_caller.adb.shell("input keyevent 66",timeout=3) + ad_callee.adb.shell("input keyevent 66",timeout=3) + # TODO: b/26291165 Replace with reducing the volume as we want # to test route switching ad_caller.droid.telecomCallSetAudioRoute(AUDIO_ROUTE_EARPIECE) @@ -645,7 +652,6 @@ def video_call_setup_teardown_for_subscription( except Exception as e: log.error(str(e)) - def video_call_setup(log, ad_caller, ad_callee, @@ -674,8 +680,8 @@ def video_call_setup(log, return video_call_setup_for_subscription( log, ad_caller, ad_callee, get_outgoing_voice_sub_id(ad_caller), - get_incoming_voice_sub_id(ad_callee), video_state, incall_ui_display) - + get_incoming_voice_sub_id(ad_callee), + video_state, incall_ui_display) def video_call_setup_for_subscription( log, @@ -734,6 +740,15 @@ def video_call_setup_for_subscription( # ensure that all internal states are updated in telecom time.sleep(WAIT_TIME_ACCEPT_VIDEO_CALL_TO_CHECK_STATE) + # Below step is needed for allow camera pop-up + time.sleep(5) + ad_caller.adb.shell("input keyevent 22",timeout=3) + ad_callee.adb.shell("input keyevent 22",timeout=3) + ad_caller.adb.shell("input keyevent 22",timeout=3) + ad_callee.adb.shell("input keyevent 22",timeout=3) + ad_caller.adb.shell("input keyevent 66",timeout=3) + ad_callee.adb.shell("input keyevent 66",timeout=3) + # TODO: b/26291165 Replace with reducing the volume as we want # to test route switching ad_caller.droid.telecomCallSetAudioRoute(AUDIO_ROUTE_EARPIECE) @@ -745,7 +760,6 @@ def video_call_setup_for_subscription( log.error(e) return False - def video_call_modify_video(log, ad_requester, call_id_requester, diff --git a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py index 8de6a6e82e..f38e1a7fb5 100755 --- a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py +++ b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py @@ -17,12 +17,6 @@ Base Class for Defining Common WiFi Test Functionality """ -import copy -import itertools -import time - -import acts.controllers.access_point as ap - from acts import asserts from acts import utils from acts.base_test import BaseTestClass @@ -37,9 +31,7 @@ from acts.controllers.ap_lib import hostapd_security class WifiBaseTest(BaseTestClass): def __init__(self, controllers): BaseTestClass.__init__(self, controllers) - if self.attenuators: - for attenuator in self.attenuators: - attenuator.set_atten(0) + def get_wpa2_network( self, @@ -48,6 +40,7 @@ class WifiBaseTest(BaseTestClass): ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G, passphrase_length_2g=hostapd_constants.AP_PASSPHRASE_LENGTH_2G, passphrase_length_5g=hostapd_constants.AP_PASSPHRASE_LENGTH_5G): + """Generates SSID and passphrase for a WPA2 network using random generator. @@ -88,18 +81,19 @@ class WifiBaseTest(BaseTestClass): for ap in range(ap_count): self.user_params["reference_networks"].append({ - "2g": - network_dict_2g, - "5g": - network_dict_5g + "2g": network_dict_2g, + "5g": network_dict_5g }) self.reference_networks = self.user_params["reference_networks"] return {"2g": network_dict_2g, "5g": network_dict_5g} - def get_open_network(self, - ap_count=1, - ssid_length_2g=hostapd_constants.AP_SSID_LENGTH_2G, - ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G): + + def get_open_network( + self, + ap_count=1, + ssid_length_2g=hostapd_constants.AP_SSID_LENGTH_2G, + ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G): + """Generates SSIDs for a open network using a random generator. Args: @@ -123,39 +117,9 @@ class WifiBaseTest(BaseTestClass): "2g": network_dict_2g, "5g": network_dict_5g }) - self.open_network = self.user_params["open_network"] + self.open_networks = self.user_params["open_network"] return {"2g": network_dict_2g, "5g": network_dict_5g} - def populate_bssid(self, ap, networks_5g, networks_2g): - """Get bssid for a given SSID and add it to the network dictionary. - - Args: - networks_5g: List of 5g networks configured on the APs. - networks_2g: List of 2g networks configured on the APs. - - """ - - if not (networks_5g or networks_2g): - return - - for network in itertools.chain(networks_5g, networks_2g): - if 'channel' in network: - continue - bssid = ap.get_bssid_from_ssid(network["SSID"]) - if network["security"] == hostapd_constants.WPA2_STRING: - # TODO:(bamahadev) Change all occurances of reference_networks - # in to wpa_networks. - network_list = self.reference_networks - else: - network_list = self.open_network - if '2g' in network["SSID"]: - band = hostapd_constants.BAND_2G - else: - band = hostapd_constants.BAND_5G - # For each network update BSSID if it doesn't already exist. - for ref_network in network_list: - if not 'bssid' in ref_network[band]: - ref_network[band]["bssid"] = bssid def legacy_configure_ap_and_start( self, @@ -171,7 +135,7 @@ class WifiBaseTest(BaseTestClass): asserts.assert_true( len(self.user_params["AccessPoint"]) == 2, "Exactly two access points must be specified. \ - Each access point has 2 radios, one each for 2.4GHZ \ + Each accesspoint has 2 radios, one each for 2.4GHZ \ and 5GHz. A test can choose to use one or both APs.") network_list_2g = [] network_list_5g = [] @@ -192,27 +156,19 @@ class WifiBaseTest(BaseTestClass): network_list_2g.append(networks_dict["2g"]) network_list_5g.append(networks_dict["5g"]) - orig_network_list_5g = copy.copy(network_list_5g) - orig_network_list_2g = copy.copy(network_list_2g) - if len(network_list_5g) > 1: - self.config_5g = self._generate_legacy_ap_config(network_list_5g) + self.config_5g = self._generate_legacy_ap_config(network_list_5g) if len(network_list_2g) > 1: - self.config_2g = self._generate_legacy_ap_config(network_list_2g) + self.config_2g = self._generate_legacy_ap_config(network_list_2g) for ap in range(ap_count): self.access_points[ap].start_ap(self.config_2g) self.access_points[ap].start_ap(self.config_5g) - self.populate_bssid(self.access_points[ap], orig_network_list_5g, - orig_network_list_2g) + def _generate_legacy_ap_config(self, network_list): bss_settings = [] ap_settings = network_list.pop(0) - # TODO:(bmahadev) This is a bug. We should not have to pop the first - # network in the list and treat it as a separate case. Instead, - # create_ap_preset() should be able to take NULL ssid and security and - # build config based on the bss_Settings alone. hostapd_config_settings = network_list.pop(0) for network in network_list: if "password" in network: @@ -242,4 +198,5 @@ class WifiBaseTest(BaseTestClass): ssid=hostapd_config_settings["SSID"], bss_settings=bss_settings, profile_name='whirlwind') + return config diff --git a/acts/framework/acts/test_utils/wifi/wifi_constants.py b/acts/framework/acts/test_utils/wifi/wifi_constants.py index 8c9f9788e6..f51c336d99 100644 --- a/acts/framework/acts/test_utils/wifi/wifi_constants.py +++ b/acts/framework/acts/test_utils/wifi/wifi_constants.py @@ -22,8 +22,3 @@ WIFI_FORGET_NW_SUCCESS = "WifiManagerForgetNetworkOnSuccess" # These constants will be used by the ACTS wifi tests. CONNECT_BY_CONFIG_SUCCESS = 'WifiManagerConnectByConfigOnSuccess' CONNECT_BY_NETID_SUCCESS = 'WifiManagerConnectByNetIdOnSuccess' - -# AP related constants -AP_MAIN = "main_AP" -AP_AUX = "aux_AP" -SSID = "SSID" diff --git a/acts/framework/acts/test_utils/wifi/wifi_power_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_power_test_utils.py deleted file mode 100644 index a2a256c8ec..0000000000 --- a/acts/framework/acts/test_utils/wifi/wifi_power_test_utils.py +++ /dev/null @@ -1,468 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 Google, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging -import os -import time -from acts import asserts -from acts import utils -from acts.controllers import monsoon -from acts.test_utils.wifi import wifi_test_utils as wutils -from bokeh.layouts import layout -from bokeh.models import CustomJS, ColumnDataSource -from bokeh.models.widgets import DataTable, TableColumn -from bokeh.plotting import figure, output_file, save -from acts.controllers.ap_lib import hostapd_security -from acts.controllers.ap_lib import hostapd_ap_preset - -SETTINGS_PAGE = "am start -n com.android.settings/.Settings" -SCROLL_BOTTOM = "input swipe 0 2000 0 0" -UNLOCK_SCREEN = "input keyevent 82" -SCREENON_USB_DISABLE = "dumpsys battery unplug" -RESET_BATTERY_STATS = "dumpsys batterystats --reset" -AOD_OFF = "settings put secure doze_always_on 0" -MUSIC_IQ_OFF = "pm disable-user com.google.intelligence.sense" -# Command to disable gestures -LIFT = "settings put secure doze_pulse_on_pick_up 0" -DOUBLE_TAP = "settings put secure doze_pulse_on_double_tap 0" -JUMP_TO_CAMERA = "settings put secure camera_double_tap_power_gesture_disabled 1" -RAISE_TO_CAMERA = "settings put secure camera_lift_trigger_enabled 0" -FLIP_CAMERA = "settings put secure camera_double_twist_to_flip_enabled 0" -ASSIST_GESTURE = "settings put secure assist_gesture_enabled 0" -ASSIST_GESTURE_ALERT = "settings put secure assist_gesture_silence_alerts_enabled 0" -ASSIST_GESTURE_WAKE = "settings put secure assist_gesture_wake_enabled 0" -SYSTEM_NAVI = "settings put secure system_navigation_keys_enabled 0" -# End of command to disable gestures -AUTO_TIME_OFF = "settings put global auto_time 0" -AUTO_TIMEZONE_OFF = "settings put global auto_time_zone 0" -FORCE_YOUTUBE_STOP = "am force-stop com.google.android.youtube" -FORCE_DIALER_STOP = "am force-stop com.google.android.dialer" -IPERF_TIMEOUT = 180 -THRESHOLD_TOLERANCE = 0.05 - - -def dut_rockbottom(ad): - """Set the phone into Rock-bottom state. - - Args: - ad: the target android device, AndroidDevice object - - """ - ad.log.info("Now set the device to Rockbottom State") - utils.require_sl4a((ad, )) - utils.set_ambient_display(ad, False) - utils.set_auto_rotate(ad, False) - utils.set_adaptive_brightness(ad, False) - utils.sync_device_time(ad) - utils.set_location_service(ad, False) - utils.set_mobile_data_always_on(ad, False) - utils.disable_doze_light(ad) - utils.disable_doze(ad) - wutils.reset_wifi(ad) - wutils.wifi_toggle_state(ad, False) - ad.droid.connectivityToggleAirplaneMode(True) - ad.droid.nfcDisable() - ad.droid.setScreenBrightness(0) - ad.adb.shell(AOD_OFF) - ad.droid.setScreenTimeout(2200) - ad.droid.wakeUpNow() - ad.adb.shell(LIFT) - ad.adb.shell(DOUBLE_TAP) - ad.adb.shell(JUMP_TO_CAMERA) - ad.adb.shell(RAISE_TO_CAMERA) - ad.adb.shell(FLIP_CAMERA) - ad.adb.shell(ASSIST_GESTURE) - ad.adb.shell(ASSIST_GESTURE_ALERT) - ad.adb.shell(ASSIST_GESTURE_WAKE) - ad.adb.shell(SCREENON_USB_DISABLE) - ad.adb.shell(UNLOCK_SCREEN) - ad.adb.shell(SETTINGS_PAGE) - ad.adb.shell(SCROLL_BOTTOM) - ad.adb.shell(MUSIC_IQ_OFF) - ad.adb.shell(AUTO_TIME_OFF) - ad.adb.shell(AUTO_TIMEZONE_OFF) - ad.adb.shell(FORCE_YOUTUBE_STOP) - ad.adb.shell(FORCE_DIALER_STOP) - ad.droid.wakeUpNow() - ad.log.info('Device has been set to Rockbottom state') - - -def pass_fail_check(test_class, test_result): - """Check the test result and decide if it passed or failed. - The threshold is provided in the config file - - Args: - test_class: the specific test class where test is running - avg_current: the average current as the test result - """ - test_name = test_class.current_test_name - current_threshold = test_class.threshold[test_name] - asserts.assert_true( - abs(test_result - current_threshold) / current_threshold < - THRESHOLD_TOLERANCE, - ("Measured average current in [%s]: %s, which is " - "more than %d percent off than acceptable threshold %.2fmA") % - (test_name, test_result, THRESHOLD_TOLERANCE * 100, current_threshold)) - asserts.explicit_pass("Measurement finished for %s." % test_name) - - -def monsoon_data_collect_save(ad, mon_info, test_name, bug_report): - """Current measurement and save the log file. - - Collect current data using Monsoon box and return the path of the - log file. Take bug report if requested. - - Args: - ad: the android device under test - mon_info: dict with information of monsoon measurement, including - monsoon device object, measurement frequency, duration and - offset etc. - test_name: current test name, used to contruct the result file name - bug_report: indicator to take bug report or not, 0 or 1 - Returns: - data_path: the absolute path to the log file of monsoon current - measurement - avg_current: the average current of the test - """ - log = logging.getLogger() - log.info("Starting power measurement with monsoon box") - tag = (test_name + '_' + ad.model + '_' + ad.build_info['build_id']) - #Resets the battery status right before the test started - ad.adb.shell(RESET_BATTERY_STATS) - begin_time = utils.get_current_human_time() - #Start the power measurement using monsoon - result = mon_info['dut'].measure_power( - mon_info['freq'], - mon_info['duration'], - tag=tag, - offset=mon_info['offset']) - data_path = os.path.join(mon_info['data_path'], "%s.txt" % tag) - avg_current = result.average_current - monsoon.MonsoonData.save_to_text_file([result], data_path) - log.info("Power measurement done") - if bool(bug_report) == True: - ad.take_bug_report(test_name, begin_time) - return data_path, avg_current - - -def monsoon_data_plot(mon_info, file_path, tag=""): - """Plot the monsoon current data using bokeh interactive plotting tool. - - Plotting power measurement data with bokeh to generate interactive plots. - You can do interactive data analysis on the plot after generating with the - provided widgets, which make the debugging much easier. To realize that, - bokeh callback java scripting is used. View a sample html output file: - https://drive.google.com/open?id=0Bwp8Cq841VnpT2dGUUxLYWZvVjA - - Args: - mon_info: dict with information of monsoon measurement, including - monsoon device object, measurement frequency, duration and - offset etc. - file_path: the path to the monsoon log file with current data - - Returns: - plot: the plotting object of bokeh, optional, will be needed if multiple - plots will be combined to one html file. - dt: the datatable object of bokeh, optional, will be needed if multiple - datatables will be combined to one html file. - """ - - log = logging.getLogger() - log.info("Plot the power measurement data") - #Get results as monsoon data object from the input file - results = monsoon.MonsoonData.from_text_file(file_path) - #Decouple current and timestamp data from the monsoon object - current_data = [] - timestamps = [] - voltage = results[0].voltage - [current_data.extend(x.data_points) for x in results] - [timestamps.extend(x.timestamps) for x in results] - period = 1 / float(mon_info['freq']) - time_relative = [x * period for x in range(len(current_data))] - #Calculate the average current for the test - current_data = [x * 1000 for x in current_data] - avg_current = sum(current_data) / len(current_data) - color = ['navy'] * len(current_data) - - #Preparing the data and source link for bokehn java callback - source = ColumnDataSource(data=dict( - x0=time_relative, y0=current_data, color=color)) - s2 = ColumnDataSource(data=dict( - z0=[mon_info['duration']], - y0=[round(avg_current, 2)], - x0=[round(avg_current * voltage, 2)], - z1=[round(avg_current * voltage * mon_info['duration'], 2)], - z2=[round(avg_current * mon_info['duration'], 2)])) - #Setting up data table for the output - columns = [ - TableColumn(field='z0', title='Total Duration (s)'), - TableColumn(field='y0', title='Average Current (mA)'), - TableColumn(field='x0', title='Average Power (4.2v) (mW)'), - TableColumn(field='z1', title='Average Energy (mW*s)'), - TableColumn(field='z2', title='Normalized Average Energy (mA*s)') - ] - dt = DataTable( - source=s2, columns=columns, width=1300, height=60, editable=True) - - plot_title = file_path[file_path.rfind('/') + 1:-4] + tag - output_file("%s/%s.html" % (mon_info['data_path'], plot_title)) - TOOLS = ('box_zoom,box_select,pan,crosshair,redo,undo,resize,reset,' - 'hover,xwheel_zoom,ywheel_zoom,save') - # Create a new plot with the datatable above - plot = figure( - plot_width=1300, - plot_height=700, - title=plot_title, - tools=TOOLS, - webgl=True) - plot.line('x0', 'y0', source=source, line_width=2) - plot.circle('x0', 'y0', source=source, size=0.5, fill_color='color') - plot.xaxis.axis_label = 'Time (s)' - plot.yaxis.axis_label = 'Current (mA)' - plot.title.text_font_size = {'value': '15pt'} - - #Callback Java scripting - source.callback = CustomJS( - args=dict(mytable=dt), - code=""" - var inds = cb_obj.get('selected')['1d'].indices; - var d1 = cb_obj.get('data'); - var d2 = mytable.get('source').get('data'); - ym = 0 - ts = 0 - d2['x0'] = [] - d2['y0'] = [] - d2['z1'] = [] - d2['z2'] = [] - d2['z0'] = [] - min=max=d1['x0'][inds[0]] - if (inds.length==0) {return;} - for (i = 0; i < inds.length; i++) { - ym += d1['y0'][inds[i]] - d1['color'][inds[i]] = "red" - if (d1['x0'][inds[i]] < min) { - min = d1['x0'][inds[i]]} - if (d1['x0'][inds[i]] > max) { - max = d1['x0'][inds[i]]} - } - ym /= inds.length - ts = max - min - dx0 = Math.round(ym*4.2*100.0)/100.0 - dy0 = Math.round(ym*100.0)/100.0 - dz1 = Math.round(ym*4.2*ts*100.0)/100.0 - dz2 = Math.round(ym*ts*100.0)/100.0 - dz0 = Math.round(ts*1000.0)/1000.0 - d2['z0'].push(dz0) - d2['x0'].push(dx0) - d2['y0'].push(dy0) - d2['z1'].push(dz1) - d2['z2'].push(dz2) - mytable.trigger('change'); - """) - - #Layout the plot and the datatable bar - l = layout([[dt], [plot]]) - save(l) - return [plot, dt] - - -def change_dtim(ad, gEnableModulatedDTIM, gMaxLIModulatedDTIM=6): - """Function to change the DTIM setting in the phone. - - Args: - ad: the target android device, AndroidDevice object - gEnableModulatedDTIM: Modulated DTIM, int - gMaxLIModulatedDTIM: Maximum modulated DTIM, int - """ - serial = ad.serial - ini_file_phone = 'vendor/firmware/wlan/qca_cld/WCNSS_qcom_cfg.ini' - ini_file_local = 'local_ini_file.ini' - ini_pull_cmd = 'adb -s %s pull %s %s' % (serial, ini_file_phone, - ini_file_local) - ini_push_cmd = 'adb -s %s push %s %s' % (serial, ini_file_local, - ini_file_phone) - utils.exe_cmd(ini_pull_cmd) - - with open(ini_file_local, 'r') as fin: - for line in fin: - if 'gEnableModulatedDTIM=' in line: - gEDTIM_old = line.strip('gEnableModulatedDTIM=').strip('\n') - if 'gMaxLIModulatedDTIM=' in line: - gMDTIM_old = line.strip('gMaxLIModulatedDTIM=').strip('\n') - if int(gEDTIM_old) == gEnableModulatedDTIM: - ad.log.info('Current DTIM is already the desired value,' - 'no need to reset it') - return - - gE_old = 'gEnableModulatedDTIM=' + gEDTIM_old - gM_old = 'gMaxLIModulatedDTIM=' + gMDTIM_old - gE_new = 'gEnableModulatedDTIM=' + str(gEnableModulatedDTIM) - gM_new = 'gMaxLIModulatedDTIM=' + str(gMaxLIModulatedDTIM) - - sed_gE = 'sed -i \'s/%s/%s/g\' %s' % (gE_old, gE_new, ini_file_local) - sed_gM = 'sed -i \'s/%s/%s/g\' %s' % (gM_old, gM_new, ini_file_local) - utils.exe_cmd(sed_gE) - utils.exe_cmd(sed_gM) - - utils.exe_cmd('adb -s {} root'.format(serial)) - cmd_out = utils.exe_cmd('adb -s {} remount'.format(serial)) - if ("Permission denied").encode() in cmd_out: - ad.log.info('Need to disable verity first and reboot') - utils.exe_cmd('adb -s {} disable-verity'.format(serial)) - time.sleep(1) - ad.reboot() - ad.log.info('Verity disabled and device back from reboot') - utils.exe_cmd('adb -s {} root'.format(serial)) - utils.exe_cmd('adb -s {} remount'.format(serial)) - time.sleep(1) - utils.exe_cmd(ini_push_cmd) - ad.log.info('ini file changes checked in and rebooting...') - ad.reboot() - ad.log.info('DTIM updated and device back from reboot') - - -def ap_setup(ap, network): - """Set up the whirlwind AP with provided network info. - - Args: - ap: access_point object of the AP - network: dict with information of the network, including ssid, password - bssid, channel etc. - """ - - log = logging.getLogger() - bss_settings = [] - ssid = network[wutils.WifiEnums.SSID_KEY] - password = network["password"] - channel = network["channel"] - security = hostapd_security.Security( - security_mode="wpa", password=password) - config = hostapd_ap_preset.create_ap_preset( - channel=channel, - ssid=ssid, - security=security, - bss_settings=bss_settings, - profile_name='whirlwind') - ap.start_ap(config) - log.info("AP started on channel {} with SSID {}".format(channel, ssid)) - - -def bokeh_plot(data_sets, legends, fig_property): - """Plot bokeh figs. - Args: - data_sets: data sets including lists of x_data and lists of y_data - ex: [[[x_data1], [x_data2]], [[y_data1],[y_data2]]] - legends: list of legend for each curve - fig_property: dict containing the plot property, including title, - lables, linewidth, circle size, etc. - Returns: - plot: bokeh plot figure object - """ - TOOLS = ('box_zoom,box_select,pan,crosshair,redo,undo,resize,reset,' - 'hover,xwheel_zoom,ywheel_zoom,save') - plot = figure( - plot_width=1300, - plot_height=700, - title=fig_property['title'], - tools=TOOLS, - webgl=True) - colors = [ - 'red', 'green', 'blue', 'olive', 'orange', 'salmon', 'black', 'navy', - 'yellow', 'darkred', 'goldenrod' - ] - for x_data, y_data, legend in zip(data_sets[0], data_sets[1], legends): - index_now = legends.index(legend) - color = colors[index_now % len(colors)] - plot.line( - x_data, y_data, legend=str(legend), line_width=3, color=color) - plot.circle( - x_data, y_data, size=10, legend=str(legend), fill_color=color) - #Plot properties - plot.xaxis.axis_label = fig_property['x_label'] - plot.yaxis.axis_label = fig_property['y_label'] - plot.legend.location = "top_right" - plot.legend.click_policy = "hide" - plot.title.text_font_size = {'value': '15pt'} - return plot - - -def run_iperf_client_nonblocking(ad, server_host, extra_args=""): - """Start iperf client on the device with nohup. - - Return status as true if iperf client start successfully. - And data flow information as results. - - Args: - ad: the android device under test - server_host: Address of the iperf server. - extra_args: A string representing extra arguments for iperf client, - e.g. "-i 1 -t 30". - - """ - log = logging.getLogger() - ad.adb.shell_nb("nohup iperf3 -c {} {} &".format(server_host, extra_args)) - log.info("IPerf client started") - - -def get_wifi_rssi(ad): - """Get the RSSI of the device. - - Args: - ad: the android device under test - Returns: - RSSI: the rssi level of the device - """ - RSSI = ad.droid.wifiGetConnectionInfo()['rssi'] - return RSSI - - -def get_phone_ip(ad): - """Get the WiFi IP address of the phone. - - Args: - ad: the android device under test - Returns: - IP: IP address of the phone for WiFi, as a string - """ - IP = ad.droid.connectivityGetIPv4Addresses('wlan0')[0] - - return IP - - -def get_phone_mac(ad): - """Get the WiFi MAC address of the phone. - - Args: - ad: the android device under test - Returns: - mac: MAC address of the phone for WiFi, as a string - """ - mac = ad.droid.wifiGetConnectionInfo()["mac_address"] - - return mac - - -def get_phone_ipv6(ad): - """Get the WiFi IPV6 address of the phone. - - Args: - ad: the android device under test - Returns: - IPv6: IPv6 address of the phone for WiFi, as a string - """ - IPv6 = ad.droid.connectivityGetLinkLocalIpv6Address('wlan0')[:-6] - - return IPv6 diff --git a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py index 263fabee31..2e121afb93 100755 --- a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py +++ b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py @@ -36,6 +36,13 @@ DEFAULT_TIMEOUT = 10 # change. SHORT_TIMEOUT = 30 +# The currently supported devices that existed before release +#TODO: (navtejsingh) Need to clean up the below lists going forward +K_DEVICES = ["hammerhead", "razor", "razorg"] +L_DEVICES = ["shamu", "ryu"] +L_TAP_DEVICES = ["volantis", "volantisg"] +M_DEVICES = ["angler"] + # Speed of light in m/s. SPEED_OF_LIGHT = 299792458 @@ -384,10 +391,30 @@ class WifiChannelUS(WifiChannelBase): 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.ALL_5G_FREQUENCIES = self.DFS_5G_FREQUENCIES + self.NONE_DFS_5G_FREQUENCIES + if model and utils.trim_model_name(model) in K_DEVICES: + self.DFS_5G_FREQUENCIES = [] + self.ALL_5G_FREQUENCIES = self.NONE_DFS_5G_FREQUENCIES + self.MIX_CHANNEL_SCAN = [2412, 2437, 2462, 5180, 5200, 5240, 5745, + 5765] + elif model and utils.trim_model_name(model) in L_DEVICES: + self.DFS_5G_FREQUENCIES = [5260, 5280, 5300, 5320, 5500, 5520, + 5540, 5560, 5580, 5660, 5680, 5700] + self.ALL_5G_FREQUENCIES = self.DFS_5G_FREQUENCIES + self.NONE_DFS_5G_FREQUENCIES + elif model and utils.trim_model_name(model) in L_TAP_DEVICES: + self.DFS_5G_FREQUENCIES = [5260, 5280, 5300, 5320, 5500, 5520, + 5540, 5560, 5580, 5660, 5680, 5700, + 5720] + self.ALL_5G_FREQUENCIES = self.DFS_5G_FREQUENCIES + self.NONE_DFS_5G_FREQUENCIES + elif model and utils.trim_model_name(model) in M_DEVICES: + self.DFS_5G_FREQUENCIES = [5260, 5280, 5300, 5320, 5500, 5520, + 5540, 5560, 5580, 5600, 5620, 5640, + 5660, 5680, 5700] + self.ALL_5G_FREQUENCIES = self.DFS_5G_FREQUENCIES + self.NONE_DFS_5G_FREQUENCIES + else: + 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 class WifiReferenceNetworks: """ Class to parse and return networks of different band and @@ -576,6 +603,9 @@ def reset_wifi(ad): ad: An AndroidDevice object. """ + # TODO(gmoturu): need to remove wifi_toggle_state() in reset_wifi() when + # bug: 32809235 is fixed + wifi_toggle_state(ad, True) networks = ad.droid.wifiGetConfiguredNetworks() if not networks: return @@ -634,6 +664,7 @@ def wifi_forget_network(ad, net_ssid): net_ssid: ssid of network to be forget """ + ad.droid.wifiToggleState(True) networks = ad.droid.wifiGetConfiguredNetworks() if not networks: return diff --git a/acts/framework/acts/utils.py b/acts/framework/acts/utils.py index c5d401baa4..c8d7ba545e 100755 --- a/acts/framework/acts/utils.py +++ b/acts/framework/acts/utils.py @@ -218,11 +218,7 @@ def load_config(file_full_path): A JSON object. """ with open(file_full_path, 'r') as f: - try: - conf = json.load(f) - except Exception as e: - logging.error("Exception error to load %s: %s", f, e) - raise + conf = json.load(f) return conf @@ -588,7 +584,8 @@ def enable_doze(ad): ad.adb.shell("dumpsys deviceidle force-idle") ad.droid.goToSleepNow() time.sleep(5) - adb_shell_result = ad.adb.shell("dumpsys deviceidle get deep") + adb_shell_result = ad.adb.shell("dumpsys deviceidle get deep").decode( + 'utf-8') if not adb_shell_result.startswith(DozeModeStatus.IDLE): info = ("dumpsys deviceidle get deep: {}".format(adb_shell_result)) print(info) @@ -608,7 +605,8 @@ def disable_doze(ad): """ ad.adb.shell("dumpsys deviceidle disable") ad.adb.shell("dumpsys battery reset") - adb_shell_result = ad.adb.shell("dumpsys deviceidle get deep") + adb_shell_result = ad.adb.shell("dumpsys deviceidle get deep").decode( + 'utf-8') if not adb_shell_result.startswith(DozeModeStatus.ACTIVE): info = ("dumpsys deviceidle get deep: {}".format(adb_shell_result)) print(info) @@ -631,7 +629,8 @@ def enable_doze_light(ad): time.sleep(5) ad.adb.shell("cmd deviceidle enable light") ad.adb.shell("cmd deviceidle step light") - adb_shell_result = ad.adb.shell("dumpsys deviceidle get light") + adb_shell_result = ad.adb.shell("dumpsys deviceidle get light").decode( + 'utf-8') if not adb_shell_result.startswith(DozeModeStatus.IDLE): info = ("dumpsys deviceidle get light: {}".format(adb_shell_result)) print(info) @@ -651,7 +650,8 @@ def disable_doze_light(ad): """ ad.adb.shell("dumpsys battery reset") ad.adb.shell("cmd deviceidle disable light") - adb_shell_result = ad.adb.shell("dumpsys deviceidle get light") + adb_shell_result = ad.adb.shell("dumpsys deviceidle get light").decode( + 'utf-8') if not adb_shell_result.startswith(DozeModeStatus.ACTIVE): info = ("dumpsys deviceidle get light: {}".format(adb_shell_result)) print(info) @@ -803,7 +803,7 @@ def adb_shell_ping(ad, count=120, dest_ip="www.google.com", timeout=200, return False return True except Exception as e: - ad.log.warning("Ping Test to %s failed with exception %s", dest_ip, e) + ad.log.warn("Ping Test to %s failed with exception %s", dest_ip, e) return False finally: ad.adb.shell("rm /data/ping.txt", timeout=10, ignore_status=True) diff --git a/acts/framework/tests/acts_android_device_test.py b/acts/framework/tests/acts_android_device_test.py index c326b4bf89..d5b7908b37 100755 --- a/acts/framework/tests/acts_android_device_test.py +++ b/acts/framework/tests/acts_android_device_test.py @@ -53,7 +53,6 @@ def get_mock_ads(num): ads = [] for i in range(num): ad = mock.MagicMock(name="AndroidDevice", serial=i, h_port=None) - ad.ensure_screen_on = mock.MagicMock(return_value=True) ads.append(ad) return ads @@ -328,10 +327,9 @@ class ActsAndroidDeviceTest(unittest.TestCase): @mock.patch('acts.utils.create_dir') @mock.patch('acts.utils.start_standing_subprocess', return_value="process") @mock.patch('acts.utils.stop_standing_subprocess') - @mock.patch('acts.utils._assert_subprocess_running') - def test_AndroidDevice_take_logcat(self, check_proc_mock, stop_proc_mock, - start_proc_mock, creat_dir_mock, - FastbootProxy, MockAdbProxy): + def test_AndroidDevice_take_logcat(self, stop_proc_mock, start_proc_mock, + creat_dir_mock, FastbootProxy, + MockAdbProxy): """Verifies the steps of collecting adb logcat on an AndroidDevice object, including various function calls and the expected behaviors of the calls. @@ -374,10 +372,9 @@ class ActsAndroidDeviceTest(unittest.TestCase): @mock.patch('acts.utils.create_dir') @mock.patch('acts.utils.start_standing_subprocess', return_value="process") @mock.patch('acts.utils.stop_standing_subprocess') - @mock.patch('acts.utils._assert_subprocess_running') def test_AndroidDevice_take_logcat_with_user_param( - self, check_proc_mock, stop_proc_mock, start_proc_mock, - creat_dir_mock, FastbootProxy, MockAdbProxy): + self, stop_proc_mock, start_proc_mock, creat_dir_mock, + FastbootProxy, MockAdbProxy): """Verifies the steps of collecting adb logcat on an AndroidDevice object, including various function calls and the expected behaviors of the calls. @@ -412,10 +409,9 @@ class ActsAndroidDeviceTest(unittest.TestCase): @mock.patch( 'acts.logger.get_log_line_timestamp', return_value=MOCK_ADB_LOGCAT_END_TIME) - @mock.patch('acts.utils._assert_subprocess_running') - def test_AndroidDevice_cat_adb_log( - self, check_proc_mock, mock_timestamp_getter, stop_proc_mock, - start_proc_mock, FastbootProxy, MockAdbProxy): + def test_AndroidDevice_cat_adb_log(self, mock_timestamp_getter, + stop_proc_mock, start_proc_mock, + FastbootProxy, MockAdbProxy): """Verifies that AndroidDevice.cat_adb_log loads the correct adb log file, locates the correct adb log lines within the given time range, and writes the lines to the correct output file. diff --git a/acts/framework/tests/acts_records_test.py b/acts/framework/tests/acts_records_test.py index bc0a250675..24ba65651d 100755 --- a/acts/framework/tests/acts_records_test.py +++ b/acts/framework/tests/acts_records_test.py @@ -48,8 +48,6 @@ class ActsRecordsTest(unittest.TestCase): d[records.TestResultEnums.RECORD_EXTRAS] = extras d[records.TestResultEnums.RECORD_BEGIN_TIME] = record.begin_time d[records.TestResultEnums.RECORD_END_TIME] = record.end_time - d[records.TestResultEnums.RECORD_LOG_BEGIN_TIME] = record.log_begin_time - d[records.TestResultEnums.RECORD_LOG_END_TIME] = record.log_end_time d[records.TestResultEnums.RECORD_UID] = None d[records.TestResultEnums.RECORD_CLASS] = None d[records.TestResultEnums.RECORD_EXTRA_ERRORS] = {} @@ -221,4 +219,4 @@ class ActsRecordsTest(unittest.TestCase): if __name__ == "__main__": - unittest.main() + unittest.main()
\ No newline at end of file diff --git a/acts/framework/tests/acts_test_runner_test.py b/acts/framework/tests/acts_test_runner_test.py index 2e2809e237..8ed27248b9 100755 --- a/acts/framework/tests/acts_test_runner_test.py +++ b/acts/framework/tests/acts_test_runner_test.py @@ -60,7 +60,8 @@ class ActsTestRunnerTest(unittest.TestCase): tr = test_runner.TestRunner(self.base_mock_test_config, self.mock_run_list) self.assertIsNone( - tr.register_controller(mock_controller, required=False)) + tr.register_controller( + mock_controller, required=False)) def test_register_controller_third_party_dup_register(self): """Verifies correctness of registration, internal tally of controllers @@ -110,9 +111,8 @@ class ActsTestRunnerTest(unittest.TestCase): mock_ref_name) try: mock_ctrlr_ref_name = mock_controller.ACTS_CONTROLLER_REFERENCE_NAME - mock_test_config[tb_key][mock_ctrlr_config_name] = [ - "magic1", "magic2" - ] + mock_test_config[tb_key][mock_ctrlr_config_name] = ["magic1", + "magic2"] tr = test_runner.TestRunner(mock_test_config, self.mock_run_list) tr.register_controller(mock_controller) self.assertTrue(mock_ref_name in tr.test_run_info) @@ -136,9 +136,8 @@ class ActsTestRunnerTest(unittest.TestCase): get_info = getattr(mock_controller, "get_info") delattr(mock_controller, "get_info") try: - mock_test_config[tb_key][mock_ctrlr_config_name] = [ - "magic1", "magic2" - ] + mock_test_config[tb_key][mock_ctrlr_config_name] = ["magic1", + "magic2"] tr = test_runner.TestRunner(mock_test_config, self.mock_run_list) tr.register_controller(mock_controller) self.assertEqual(tr.results.controller_info, {}) @@ -164,13 +163,9 @@ class ActsTestRunnerTest(unittest.TestCase): mock_test_config = dict(self.base_mock_test_config) tb_key = keys.Config.key_testbed.value mock_ctrlr_config_name = mock_controller.ACTS_CONTROLLER_CONFIG_NAME - my_config = [{ - "serial": "xxxx", - "magic": "Magic1" - }, { - "serial": "xxxx", - "magic": "Magic2" - }] + my_config = [{"serial": "xxxx", + "magic": "Magic1"}, {"serial": "xxxx", + "magic": "Magic2"}] mock_test_config[tb_key][mock_ctrlr_config_name] = my_config tr = test_runner.TestRunner(mock_test_config, [('IntegrationTest', None)]) @@ -186,17 +181,8 @@ class ActsTestRunnerTest(unittest.TestCase): self.assertEqual(results["Requested"], 2) self.assertEqual(results["Executed"], 2) self.assertEqual(results["Passed"], 2) - expected_info = { - 'MagicDevice': [{ - 'MyMagic': { - 'magic': 'Magic1' - } - }, { - 'MyMagic': { - 'magic': 'Magic2' - } - }] - } + expected_info = {'MagicDevice': [{'MyMagic': {'magic': 'Magic1'}}, + {'MyMagic': {'magic': 'Magic2'}}]} self.assertEqual(tr.results.controller_info, expected_info) @mock.patch( @@ -210,11 +196,11 @@ class ActsTestRunnerTest(unittest.TestCase): @mock.patch( 'acts.controllers.android_device.get_all_instances', return_value=acts_android_device_test.get_mock_ads(1)) - @mock.patch( - 'acts.controllers.android_device.AndroidDevice.ensure_screen_on', - return_value=True) - def test_run_two_test_classes(self, mock_ensure_screen_on, mock_get_all, - mock_list_adb, mock_fastboot, mock_adb): + def test_run_two_test_classes(self, + mock_get_all, + mock_list_adb, + mock_fastboot, + mock_adb, ): """Verifies that runing more than one test class in one test run works proerly. @@ -224,20 +210,14 @@ class ActsTestRunnerTest(unittest.TestCase): mock_test_config = dict(self.base_mock_test_config) tb_key = keys.Config.key_testbed.value mock_ctrlr_config_name = mock_controller.ACTS_CONTROLLER_CONFIG_NAME - my_config = [{ - "serial": "xxxx", - "magic": "Magic1" - }, { - "serial": "xxxx", - "magic": "Magic2" - }] + my_config = [{"serial": "xxxx", + "magic": "Magic1"}, {"serial": "xxxx", + "magic": "Magic2"}] mock_test_config[tb_key][mock_ctrlr_config_name] = my_config - mock_test_config[tb_key]["AndroidDevice"] = [{ - "serial": "1", - "skip_sl4a": True - }] - tr = test_runner.TestRunner(mock_test_config, [( - 'IntegrationTest', None), ('IntegrationTest', None)]) + mock_test_config[tb_key]["AndroidDevice"] = [ + {"serial": "1", "skip_sl4a": True}] + tr = test_runner.TestRunner(mock_test_config, + [('IntegrationTest', None), ('IntegrationTest', None)]) tr.run() tr.stop() self.assertFalse(tr.controller_registry) diff --git a/acts/tests/google/ble/api/BleAdvertiseApiTest.py b/acts/tests/google/ble/api/BleAdvertiseApiTest.py index 0eefa1c40e..3ba906f1dd 100644 --- a/acts/tests/google/ble/api/BleAdvertiseApiTest.py +++ b/acts/tests/google/ble/api/BleAdvertiseApiTest.py @@ -25,9 +25,9 @@ from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.bt_test_utils import adv_fail from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers -from acts.test_utils.bt.bt_constants import java_integer +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseTxPower +from acts.test_utils.bt.BleEnum import JavaInteger class BleAdvertiseVerificationError(Exception): @@ -71,8 +71,8 @@ class BleAdvertiseApiTest(BluetoothBaseTest): is_connectable = droid.bleGetAdvertiseSettingsIsConnectable( adv_settings) - exp_adv_mode = ble_advertise_settings_modes['low_power'] - exp_tx_power_level = ble_advertise_settings_tx_powers['medium'] + exp_adv_mode = AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_POWER.value + exp_tx_power_level = AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value exp_is_connectable = True if adv_mode != exp_adv_mode: test_result = False @@ -176,7 +176,7 @@ class BleAdvertiseApiTest(BluetoothBaseTest): """ self.log.debug("Step 1: Setup environment.") droid = self.ad_dut.droid - exp_adv_mode = ble_advertise_settings_modes['balanced'] + exp_adv_mode = AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value self.log.debug( "Step 2: Set the filtering settings object's value to {}".format( exp_adv_mode)) @@ -208,7 +208,7 @@ class BleAdvertiseApiTest(BluetoothBaseTest): """ self.log.debug("Step 1: Setup environment.") droid = self.ad_dut.droid - exp_adv_mode = ble_advertise_settings_modes['low_power'] + exp_adv_mode = AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_POWER.value self.log.debug( "Step 2: Set the filtering settings object's value to {}".format( exp_adv_mode)) @@ -240,7 +240,7 @@ class BleAdvertiseApiTest(BluetoothBaseTest): """ self.log.debug("Step 1: Setup environment.") droid = self.ad_dut.droid - exp_adv_mode = ble_advertise_settings_modes['low_latency'] + exp_adv_mode = AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value self.log.debug( "Step 2: Set the filtering settings object's value to {}".format( exp_adv_mode)) @@ -300,7 +300,8 @@ class BleAdvertiseApiTest(BluetoothBaseTest): """ self.log.debug("Step 1: Setup environment.") droid = self.ad_dut.droid - exp_adv_tx_power = ble_advertise_settings_tx_powers['high'] + exp_adv_tx_power = ( + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value) self.log.debug( "Step 2: Set the filtering settings object's value to {}".format( exp_adv_tx_power)) @@ -333,7 +334,8 @@ class BleAdvertiseApiTest(BluetoothBaseTest): self.log.debug("Step 1: Setup environment.") test_result = True droid = self.ad_dut.droid - exp_adv_tx_power = ble_advertise_settings_tx_powers['medium'] + exp_adv_tx_power = ( + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value) self.log.debug( "Step 2: Set the filtering settings object's value to {}".format( exp_adv_tx_power)) @@ -365,7 +367,8 @@ class BleAdvertiseApiTest(BluetoothBaseTest): """ self.log.debug("Step 1: Setup environment.") droid = self.ad_dut.droid - exp_adv_tx_power = (ble_advertise_settings_tx_powers['low']) + exp_adv_tx_power = ( + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value) self.log.debug("Step 2: Set the filtering settings object's value to ". format(exp_adv_tx_power)) return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) @@ -396,7 +399,8 @@ class BleAdvertiseApiTest(BluetoothBaseTest): """ self.log.debug("Step 1: Setup environment.") droid = self.ad_dut.droid - exp_adv_tx_power = ble_advertise_settings_tx_powers['ultra_low'] + exp_adv_tx_power = (AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value) self.log.debug("Step 2: Set the filtering settings object's value to ". format(exp_adv_tx_power)) return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) @@ -852,7 +856,7 @@ class BleAdvertiseApiTest(BluetoothBaseTest): """ self.log.debug("Step 1: Setup environment.") droid = self.ad_dut.droid - exp_manu_id = java_integer['max'] + exp_manu_id = JavaInteger.MAX.value exp_manu_specific_data = [1, 2, 3] self.log.debug( "Step 2: Set the filtering data object's service data manu id: {}" diff --git a/acts/tests/google/ble/api/BleScanApiTest.py b/acts/tests/google/ble/api/BleScanApiTest.py index f7bece345b..4c43a76c56 100644 --- a/acts/tests/google/ble/api/BleScanApiTest.py +++ b/acts/tests/google/ble/api/BleScanApiTest.py @@ -23,11 +23,11 @@ then other test suites utilising Ble Scanner will also fail. from acts.controllers import sl4a_client from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_result_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_report_delay_milli_seconds -from acts.test_utils.bt.bt_constants import ble_uuids +from acts.test_utils.bt.BleEnum import ScanSettingsCallbackType +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.BleEnum import ScanSettingsScanResultType +from acts.test_utils.bt.BleEnum import ScanSettingsReportDelaySeconds +from acts.test_utils.bt.BleEnum import Uuids class BleScanResultsError(Exception): @@ -58,9 +58,9 @@ class BleScanApiTest(BluetoothBaseTest): """ if 'ScanSettings' not in input.keys(): input['ScanSettings'] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) if 'ScanFilterManufacturerDataId' not in input.keys(): input['ScanFilterManufacturerDataId'] = -1 if 'ScanFilterDeviceName' not in input.keys(): @@ -299,9 +299,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -327,9 +327,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['first_match'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_FIRST_MATCH.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) test_result = self.validate_scan_settings_helper(input, self.ad_dut.droid) return test_result @@ -357,9 +357,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['match_lost'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_MATCH_LOST.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) test_result = self.validate_scan_settings_helper(input, self.ad_dut.droid) return test_result @@ -385,8 +385,9 @@ class BleScanApiTest(BluetoothBaseTest): Priority: 2 """ input = {} - input["ScanSettings"] = (-1, 0, ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + input["ScanSettings"] = ( + -1, 0, ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) test_result = self.validate_scan_settings_helper(input, self.ad_dut.droid) return not test_result @@ -414,9 +415,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) test_result = self.validate_scan_settings_helper(input, self.ad_dut.droid) return test_result @@ -444,9 +445,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['balanced'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -472,9 +473,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_latency'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -497,8 +498,8 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, -2, - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, -2, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return not self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -524,10 +525,10 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['min'], - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, + ScanSettingsReportDelaySeconds.MIN.value, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -553,10 +554,10 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['min'] + 1, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, + ScanSettingsReportDelaySeconds.MIN.value + 1, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -582,10 +583,10 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['max'], - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, + ScanSettingsReportDelaySeconds.MAX.value, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -611,10 +612,10 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['max'] - 1, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, + ScanSettingsReportDelaySeconds.MAX.value - 1, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -641,10 +642,10 @@ class BleScanApiTest(BluetoothBaseTest): droid = self.ad_dut.droid input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['min'] - 1, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, + ScanSettingsReportDelaySeconds.MIN.value - 1, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return not self.validate_scan_settings_helper(input, droid) @BluetoothBaseTest.bt_test_wrap @@ -670,9 +671,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_FULL.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -698,9 +699,9 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['abbreviated']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + ScanSettingsScanResultType.SCAN_RESULT_TYPE_ABBREVIATED.value) return self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -726,8 +727,8 @@ class BleScanApiTest(BluetoothBaseTest): """ input = {} input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], -1) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value, 0, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, -1) return not self.validate_scan_settings_helper(input, self.ad_dut.droid) @BluetoothBaseTest.bt_test_wrap @@ -1152,7 +1153,7 @@ class BleScanApiTest(BluetoothBaseTest): TAGS: LE, Scanning Priority: 2 """ - expected_service_uuid = ble_uuids['p_service'] + expected_service_uuid = Uuids.P_Service.value expected_service_mask = "00000000-0000-1000-8000-00805F9B34FB" self.log.debug("Step 1: Setup environment.") @@ -1186,7 +1187,7 @@ class BleScanApiTest(BluetoothBaseTest): """ droid = self.ad_dut.droid - service_uuid_list = [ble_uuids['p_service']] + service_uuid_list = [Uuids.P_Service.value] scan_callback = droid.bleGenLeScanCallback() return self.verify_classic_ble_scan_with_service_uuids( droid, scan_callback, service_uuid_list) @@ -1215,7 +1216,7 @@ class BleScanApiTest(BluetoothBaseTest): Priority: 1 """ droid = self.ad_dut.droid - service_uuid_list = [ble_uuids['hr_service']] + service_uuid_list = [Uuids.HR_SERVICE.value] scan_callback = droid.bleGenLeScanCallback() return self.verify_classic_ble_scan_with_service_uuids( droid, scan_callback, service_uuid_list) @@ -1273,7 +1274,7 @@ class BleScanApiTest(BluetoothBaseTest): Priority: 1 """ droid = self.ad_dut.droid - service_uuid_list = [ble_uuids['hr_service'], ble_uuids['p_service']] + service_uuid_list = [Uuids.HR_SERVICE.value, Uuids.P_Service.value] scan_callback = droid.bleGenLeScanCallback() return self.verify_classic_ble_scan_with_service_uuids( droid, scan_callback, service_uuid_list) diff --git a/acts/tests/google/ble/bt5/AdvertisingSetTest.py b/acts/tests/google/ble/bt5/AdvertisingSetTest.py index 4427bb530b..d6ac904eef 100644 --- a/acts/tests/google/ble/bt5/AdvertisingSetTest.py +++ b/acts/tests/google/ble/bt5/AdvertisingSetTest.py @@ -27,7 +27,8 @@ from acts.asserts import assert_equal from acts.asserts import assert_true from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.BleEnum import ScanSettingsPhy +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.bt_test_utils import advertising_set_started from acts.test_utils.bt.bt_test_utils import advertising_set_stopped from acts.test_utils.bt.bt_test_utils import advertising_set_enabled diff --git a/acts/tests/google/ble/bt5/Bt5ScanTest.py b/acts/tests/google/ble/bt5/Bt5ScanTest.py index 7f7b7dcd0d..22a546172f 100644 --- a/acts/tests/google/ble/bt5/Bt5ScanTest.py +++ b/acts/tests/google/ble/bt5/Bt5ScanTest.py @@ -26,14 +26,14 @@ from queue import Empty from acts import asserts from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_phys -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.BleEnum import ScanSettingsPhy +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.bt_test_utils import batch_scan_result from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result from acts.test_utils.bt.bt_test_utils import advertising_set_on_own_address_read from acts.test_utils.bt.bt_test_utils import advertising_set_started from acts import signals @@ -163,7 +163,8 @@ class Bt5ScanTest(BluetoothBaseTest): }, self.big_adv_data, None, None, None, 0, 0, adv_callback) self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + self.scn_ad.droid.bleSetScanSettingsPhy( + ScanSettingsPhy.PHY_LE_1M.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -220,7 +221,8 @@ class Bt5ScanTest(BluetoothBaseTest): }, self.big_adv_data, None, None, None, 0, 0, adv_callback) self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + self.scn_ad.droid.bleSetScanSettingsPhy( + ScanSettingsPhy.PHY_LE_1M.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -276,7 +278,8 @@ class Bt5ScanTest(BluetoothBaseTest): }, {"includeDeviceName": True}, None, None, None, 0, 0, adv_callback) self.scn_ad.droid.bleSetScanSettingsLegacy(True) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + self.scn_ad.droid.bleSetScanSettingsPhy( + ScanSettingsPhy.PHY_LE_1M.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -334,7 +337,8 @@ class Bt5ScanTest(BluetoothBaseTest): }, self.big_adv_data, None, None, None, 0, 0, adv_callback) self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + self.scn_ad.droid.bleSetScanSettingsPhy( + ScanSettingsPhy.PHY_LE_1M.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -392,7 +396,8 @@ class Bt5ScanTest(BluetoothBaseTest): }, self.big_adv_data, None, None, None, 0, 0, adv_callback) self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + self.scn_ad.droid.bleSetScanSettingsPhy( + ScanSettingsPhy.PHY_LE_1M.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) diff --git a/acts/tests/google/ble/bt5/PhyTest.py b/acts/tests/google/ble/bt5/PhyTest.py index 5af778d1d9..b1bb21f2ce 100644 --- a/acts/tests/google/ble/bt5/PhyTest.py +++ b/acts/tests/google/ble/bt5/PhyTest.py @@ -22,20 +22,22 @@ from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_connection_priority -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_phy +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattConnectionPriority +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import MtuSize +from acts.test_utils.bt.GattEnum import GattEvent +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattPhy from acts import signals -CONNECTION_PRIORITY_HIGH = gatt_connection_priority['high'] -PHY_LE_1M = gatt_phy['1m'] -PHY_LE_2M = gatt_phy['2m'] +CONNECTION_PRIORITY_HIGH = GattConnectionPriority.CONNECTION_PRIORITY_HIGH.value +PHY_LE_1M = GattPhy.PHY_LE_1M.value +PHY_LE_2M = GattPhy.PHY_LE_2M.value def lfmt(txPhy, rxPhy): - return '(' + list(gatt_phy.keys())[list(gatt_phy.values()).index( - txPhy)] + ', ' + list(gatt_phy.keys())[list(gatt_phy.values()).index( - rxPhy)] + ')' + return '(' + GattPhy(txPhy).name + ', ' + GattPhy(rxPhy).name + ')' class PhyTest(GattConnectedBaseTest): @@ -54,14 +56,14 @@ class PhyTest(GattConnectedBaseTest): # must pop it from queue. def pop_initial_phy_update(self): try: - maybe_event = gatt_event['phy_update']['evt'].format( + maybe_event = GattEvent.PHY_UPDATE.value["evt"].format( self.gatt_callback) self.cen_ad.ed.pop_event(maybe_event, 0) except Empty: pass try: - maybe_event = gatt_event['serv_phy_update']['evt'].format( + maybe_event = GattEvent.SERV_PHY_UPDATE.value["evt"].format( self.gatt_server_callback) self.per_ad.ed.pop_event(maybe_event, 0) except Empty: @@ -70,7 +72,7 @@ class PhyTest(GattConnectedBaseTest): # this helper method checks wether both client and server received PHY # update event with proper txPhy and rxPhy def ensure_both_updated_phy(self, clientTxPhy, clientRxPhy): - event = self._client_wait(gatt_event['phy_update']) + event = self._client_wait(GattEvent.PHY_UPDATE) txPhy = event['data']['TxPhy'] rxPhy = event['data']['RxPhy'] self.log.info("\tClient PHY updated: " + lfmt(txPhy, rxPhy)) @@ -79,7 +81,7 @@ class PhyTest(GattConnectedBaseTest): self.assertEqual(clientRxPhy, event['data']['RxPhy']) bt_device_id = 0 - event = self._server_wait(gatt_event['serv_phy_update']) + event = self._server_wait(GattEvent.SERV_PHY_UPDATE) txPhy = event['data']['TxPhy'] rxPhy = event['data']['RxPhy'] self.log.info("\tServer PHY updated: " + lfmt(txPhy, rxPhy)) @@ -90,7 +92,7 @@ class PhyTest(GattConnectedBaseTest): # read the client phy, return (txPhy, rxPhy) def read_client_phy(self): self.cen_ad.droid.gattClientReadPhy(self.bluetooth_gatt) - event = self._client_wait(gatt_event['phy_read']) + event = self._client_wait(GattEvent.PHY_READ) self.assertEqual(0, event['data']['Status'], "Status should be 0") return (event['data']['TxPhy'], event['data']['RxPhy']) @@ -98,7 +100,7 @@ class PhyTest(GattConnectedBaseTest): def read_server_phy(self): bt_device_id = 0 self.per_ad.droid.gattServerReadPhy(self.gatt_server, bt_device_id) - event = self._server_wait(gatt_event['serv_phy_read']) + event = self._server_wait(GattEvent.SERV_PHY_READ) self.assertEqual(0, event['data']['Status'], "Status should be 0") return (event['data']['TxPhy'], event['data']['RxPhy']) diff --git a/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisementDiscoveryTest.py b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisementDiscoveryTest.py index 94f4a7ea74..e8cccc2193 100644 --- a/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisementDiscoveryTest.py +++ b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisementDiscoveryTest.py @@ -23,18 +23,17 @@ import os import time from queue import Empty -from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import ScanSettingsCallbackType +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.bt_test_utils import BtTestUtilsError +from acts.test_utils.bt.bt_test_utils import adv_succ from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects from acts.test_utils.bt.bt_test_utils import get_advanced_droid_list from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_test_utils import scan_result from acts.test_utils.bt.bt_test_utils import setup_n_advertisements from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs from acts.test_utils.bt.bt_test_utils import teardown_n_advertisements @@ -75,7 +74,6 @@ class ConcurrentBleAdvertisementDiscoveryTest(BluetoothBaseTest): return True @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e02d6ca6-4db3-4a1d-adaf-98db7c7c2c7a') def test_max_advertisements_defaults(self): """Test scan integrity after BT state is reset @@ -102,12 +100,11 @@ class ConcurrentBleAdvertisementDiscoveryTest(BluetoothBaseTest): TAGS: LE, Advertising, Concurrency, Scanning Priority: 2 """ - filter_list = self.scn_ad.droid.bleGenFilterList() self.scn_ad.droid.bleBuildScanFilter(filter_list) self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) iterations = 20 for _ in range(iterations): self.log.info("Verify all advertisements found") diff --git a/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisingTest.py b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisingTest.py index de81bacdc0..df75cd98b4 100644 --- a/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisingTest.py +++ b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisingTest.py @@ -26,16 +26,16 @@ from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.bt_test_utils import BtTestUtilsError -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import ScanSettingsCallbackType +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.bt_test_utils import adv_succ from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects from acts.test_utils.bt.bt_test_utils import get_advanced_droid_list from acts.test_utils.bt.bt_test_utils import reset_bluetooth from acts.test_utils.bt.bt_test_utils import scan_and_verify_n_advertisements -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result from acts.test_utils.bt.bt_test_utils import setup_n_advertisements from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs from acts.test_utils.bt.bt_test_utils import teardown_n_advertisements diff --git a/acts/tests/google/ble/concurrency/ConcurrentBleScanningTest.py b/acts/tests/google/ble/concurrency/ConcurrentBleScanningTest.py index 24e078afdc..f3b6b9a94e 100644 --- a/acts/tests/google/ble/concurrency/ConcurrentBleScanningTest.py +++ b/acts/tests/google/ble/concurrency/ConcurrentBleScanningTest.py @@ -24,14 +24,14 @@ import time from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import ScanSettingsCallbackType +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.bt_test_utils import adv_succ from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import reset_bluetooth from acts.test_utils.bt.bt_test_utils import scan_failed -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs @@ -83,11 +83,11 @@ class ConcurrentBleScanningTest(BluetoothBaseTest): test_result = True self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.adv_ad.droid)) self.adv_ad.droid.bleSetAdvertiseSettingsIsConnectable(False) @@ -169,11 +169,11 @@ class ConcurrentBleScanningTest(BluetoothBaseTest): """ self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.adv_ad.droid)) filter_list = self.scn_ad.droid.bleGenFilterList() @@ -245,9 +245,9 @@ class ConcurrentBleScanningTest(BluetoothBaseTest): """ test_result = True self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list = self.scn_ad.droid.bleGenFilterList() self.scn_ad.droid.bleBuildScanFilter(filter_list) scan_settings = self.scn_ad.droid.bleBuildScanSetting() @@ -305,11 +305,11 @@ class ConcurrentBleScanningTest(BluetoothBaseTest): """ self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + ScanSettingsCallbackType.CALLBACK_TYPE_ALL_MATCHES.value) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.adv_ad.droid)) filter_list = self.scn_ad.droid.bleGenFilterList() diff --git a/acts/tests/google/ble/examples/BleExamplesTest.py b/acts/tests/google/ble/examples/BleExamplesTest.py index 605608689d..8e4aef1a0f 100644 --- a/acts/tests/google/ble/examples/BleExamplesTest.py +++ b/acts/tests/google/ble/examples/BleExamplesTest.py @@ -21,8 +21,8 @@ import pprint from acts.controllers import android_devices from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import adv_succ +from acts.test_utils.bt.bt_test_utils import scan_result from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers from acts.test_utils.bt.bt_test_utils import reset_bluetooth @@ -52,8 +52,9 @@ class BleExamplesTest(BluetoothBaseTest): # on_exception in base_test. If the test throws an # unexpected exception, you can customise it. def on_exception(self, test_name, begin_time): - self.log.debug("Test {} failed. Gathering bugreport and btsnoop logs". - format(test_name)) + self.log.debug( + "Test {} failed. Gathering bugreport and btsnoop logs".format( + test_name)) android_devices.take_bug_reports(self.android_devices, test_name, begin_time) @@ -101,8 +102,8 @@ class BleExamplesTest(BluetoothBaseTest): event_name = scan_result.format(scan_callback) try: event = self.scn_ed.pop_event(event_name, self.default_timeout) - self.log.info("Found scan result: {}".format( - pprint.pformat(event))) + self.log.info("Found scan result: {}".format(pprint.pformat( + event))) except Exception: self.log.info("Didn't find any scan results.") return True diff --git a/acts/tests/google/ble/filtering/FilteringTest.py b/acts/tests/google/ble/filtering/FilteringTest.py index ee1621c496..0cfa3edbd3 100644 --- a/acts/tests/google/ble/filtering/FilteringTest.py +++ b/acts/tests/google/ble/filtering/FilteringTest.py @@ -21,17 +21,17 @@ import time from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers -from acts.test_utils.bt.bt_constants import java_integer -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import small_timeout -from acts.test_utils.bt.bt_constants import adv_fail -from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseTxPower +from acts.test_utils.bt.BleEnum import JavaInteger +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.bt_test_utils import TIMEOUT_SMALL +from acts.test_utils.bt.bt_test_utils import adv_fail +from acts.test_utils.bt.bt_test_utils import adv_succ from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result class FilteringTest(BluetoothBaseTest): @@ -107,7 +107,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -145,7 +146,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -183,7 +185,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -221,7 +224,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -259,7 +263,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -297,7 +302,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -335,7 +341,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -373,7 +380,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -411,7 +419,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -449,7 +458,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -487,7 +497,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -525,7 +536,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -563,7 +575,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -601,7 +614,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -639,7 +653,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -677,7 +692,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -715,7 +731,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -753,7 +770,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -791,7 +809,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -829,7 +848,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -867,7 +887,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -905,7 +926,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -943,7 +965,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -981,7 +1004,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1019,7 +1043,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1057,7 +1082,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1095,7 +1121,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1133,7 +1160,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1171,7 +1199,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1209,7 +1238,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1247,7 +1277,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1285,7 +1316,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1323,7 +1355,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1361,7 +1394,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1399,7 +1433,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1437,7 +1472,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1475,7 +1511,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1513,7 +1550,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1551,7 +1589,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1589,7 +1628,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1627,7 +1667,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1665,7 +1706,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1703,7 +1745,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1741,7 +1784,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1779,7 +1823,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1817,7 +1862,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1855,7 +1901,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1893,7 +1940,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1931,7 +1979,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -1969,7 +2018,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2007,7 +2057,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2045,7 +2096,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2083,7 +2135,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2121,7 +2174,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2159,7 +2213,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2197,7 +2252,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2235,7 +2291,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2273,7 +2330,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2311,7 +2369,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2349,7 +2408,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2387,7 +2447,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2425,7 +2486,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2463,7 +2525,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2501,7 +2564,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2539,7 +2603,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2577,7 +2642,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2615,7 +2681,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2653,7 +2720,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2691,7 +2759,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2729,7 +2798,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2767,7 +2837,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2805,7 +2876,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2843,7 +2915,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2881,7 +2954,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2919,7 +2993,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2957,7 +3032,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -2995,7 +3071,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3033,7 +3110,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3071,7 +3149,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3109,7 +3188,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3147,7 +3227,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3185,7 +3266,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3223,7 +3305,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3261,7 +3344,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3299,7 +3383,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3337,7 +3422,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3375,7 +3461,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3413,7 +3500,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3451,7 +3539,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3489,7 +3578,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3527,7 +3617,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3565,7 +3656,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3603,7 +3695,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3641,7 +3734,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3679,7 +3773,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3717,7 +3812,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3755,7 +3851,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3793,7 +3890,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3831,7 +3929,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3869,7 +3968,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3907,7 +4007,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3945,7 +4046,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -3983,7 +4085,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4021,7 +4124,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4059,7 +4163,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4097,7 +4202,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4135,7 +4241,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4173,7 +4280,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4211,8 +4319,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4250,8 +4359,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4289,8 +4399,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4328,8 +4439,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4367,8 +4479,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4406,8 +4519,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4445,8 +4559,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4484,8 +4599,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4523,8 +4639,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4562,8 +4679,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4601,8 +4719,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4640,8 +4759,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4679,8 +4799,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4718,8 +4839,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4757,8 +4879,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4796,8 +4919,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4835,8 +4959,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4874,8 +4999,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4913,8 +5039,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4952,8 +5079,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -4991,8 +5119,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5030,8 +5159,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5069,8 +5199,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5108,8 +5239,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5147,8 +5279,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5186,8 +5319,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5225,8 +5359,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5264,8 +5399,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5303,8 +5439,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5342,8 +5479,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5381,8 +5519,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5420,8 +5559,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5459,8 +5599,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5498,8 +5639,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5537,8 +5679,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5576,8 +5719,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5615,8 +5759,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5654,8 +5799,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5693,8 +5839,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5732,8 +5879,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5771,8 +5919,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5810,8 +5959,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5849,8 +5999,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5888,8 +6039,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5927,8 +6079,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -5966,8 +6119,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6005,8 +6159,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6044,8 +6199,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6083,8 +6239,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6122,8 +6279,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6161,8 +6319,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6200,8 +6359,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6239,8 +6399,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6278,8 +6439,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6317,8 +6479,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6356,8 +6519,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6395,8 +6559,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6434,8 +6599,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6473,8 +6639,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6512,8 +6679,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6551,8 +6719,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6590,8 +6759,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6629,8 +6799,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6668,8 +6839,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6707,8 +6879,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6746,8 +6919,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6785,8 +6959,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6824,8 +6999,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6863,8 +7039,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6902,8 +7079,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6941,8 +7119,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -6980,8 +7159,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7019,8 +7199,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7058,8 +7239,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7097,8 +7279,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7136,8 +7319,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7175,8 +7359,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7214,8 +7399,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7253,8 +7439,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7292,8 +7479,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7331,8 +7519,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7370,8 +7559,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7409,8 +7599,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7448,8 +7639,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7487,8 +7679,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7526,8 +7719,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7565,8 +7759,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7604,8 +7799,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7643,8 +7839,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7682,8 +7879,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7721,8 +7919,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7760,8 +7959,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7799,8 +7999,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7838,8 +8039,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7877,8 +8079,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7916,8 +8119,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7955,8 +8159,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -7994,8 +8199,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8033,8 +8239,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8072,8 +8279,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8111,8 +8319,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8150,8 +8359,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8189,8 +8399,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8228,8 +8439,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8267,8 +8479,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8306,8 +8519,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_medium } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8345,8 +8559,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8384,8 +8599,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_small_2 } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8416,10 +8632,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8450,10 +8668,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8484,10 +8704,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8518,10 +8740,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8552,10 +8776,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8586,10 +8812,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8620,10 +8848,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8654,10 +8884,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8688,10 +8920,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8722,10 +8956,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8756,10 +8992,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8790,10 +9028,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8824,10 +9064,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8858,10 +9100,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8892,10 +9136,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8926,10 +9172,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -8960,10 +9208,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -8994,10 +9244,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9028,10 +9280,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9062,10 +9316,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9096,10 +9352,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9130,10 +9388,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9164,10 +9424,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9198,10 +9460,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9232,10 +9496,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9266,10 +9532,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9300,10 +9568,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9334,10 +9604,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9368,10 +9640,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9402,10 +9676,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9436,10 +9712,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9470,10 +9748,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -9504,10 +9784,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9538,10 +9820,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9572,10 +9856,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9606,10 +9892,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9640,10 +9928,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9674,10 +9964,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9708,10 +10000,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9742,10 +10036,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9776,10 +10072,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9810,10 +10108,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9844,10 +10144,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9878,10 +10180,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9912,10 +10216,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9946,10 +10252,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -9980,10 +10288,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -10014,10 +10324,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_BALANCED.value } return self._magic((filters, settings_in_effect)) @@ -10048,10 +10360,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10082,10 +10396,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10116,10 +10432,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10150,10 +10468,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10184,10 +10504,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10218,10 +10540,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10252,10 +10576,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10286,10 +10612,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10320,10 +10648,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10354,10 +10684,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10388,10 +10720,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10422,10 +10756,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_BALANCED.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10456,10 +10792,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_HIGH.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10490,10 +10828,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10524,10 +10864,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'mode': AdvertiseSettingsAdvertiseTxPower. + ADVERTISE_TX_POWER_ULTRA_LOW.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10558,10 +10900,12 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], + 'mode': + AdvertiseSettingsAdvertiseTxPower.ADVERTISE_TX_POWER_MEDIUM.value, 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10592,7 +10936,8 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_tx_power_level': True} settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10623,7 +10968,8 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'filter_device_address': True} settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10657,7 +11003,8 @@ class FilteringTest(BluetoothBaseTest): 'manufacturer_specific_data': self.manu_sepecific_data_small } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10691,7 +11038,8 @@ class FilteringTest(BluetoothBaseTest): 'manufacturer_specific_data': self.manu_sepecific_data_large } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10726,7 +11074,8 @@ class FilteringTest(BluetoothBaseTest): 'manufacturer_specific_data_mask': [1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10760,7 +11109,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_large } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10794,7 +11144,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [13] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10828,7 +11179,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [11, 14, 50] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10862,7 +11214,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [16, 22, 11] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10896,7 +11249,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [2, 9, 54] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10930,7 +11284,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [69, 11, 50] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10964,7 +11319,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [12, 11, 21] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -10998,7 +11354,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [12, 12, 44] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11032,7 +11389,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [4, 54, 1] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11066,7 +11424,8 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [33, 22, 44] } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11100,7 +11459,8 @@ class FilteringTest(BluetoothBaseTest): 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11134,7 +11494,8 @@ class FilteringTest(BluetoothBaseTest): 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11168,7 +11529,8 @@ class FilteringTest(BluetoothBaseTest): 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' } settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11199,7 +11561,8 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11230,8 +11593,9 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_tx_power_level': True} settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11262,8 +11626,9 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'filter_device_address': True} settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11297,8 +11662,9 @@ class FilteringTest(BluetoothBaseTest): 'manufacturer_specific_data': self.manu_sepecific_data_small } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11332,8 +11698,9 @@ class FilteringTest(BluetoothBaseTest): 'manufacturer_specific_data': self.manu_sepecific_data_large } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11368,8 +11735,9 @@ class FilteringTest(BluetoothBaseTest): 'manufacturer_specific_data_mask': [1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11403,8 +11771,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': self.service_data_large } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11438,8 +11807,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [13] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11473,8 +11843,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [11, 14, 50] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11508,8 +11879,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [16, 22, 11] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11543,8 +11915,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [2, 9, 54] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11578,8 +11951,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [69, 11, 50] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11613,8 +11987,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [12, 11, 21] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11648,8 +12023,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [12, 12, 44] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11683,8 +12059,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [4, 54, 1] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11718,8 +12095,9 @@ class FilteringTest(BluetoothBaseTest): 'service_data': [33, 22, 44] } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11753,8 +12131,9 @@ class FilteringTest(BluetoothBaseTest): 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11788,8 +12167,9 @@ class FilteringTest(BluetoothBaseTest): 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11823,8 +12203,9 @@ class FilteringTest(BluetoothBaseTest): 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' } settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11855,8 +12236,9 @@ class FilteringTest(BluetoothBaseTest): """ filters = {'include_device_name': True} settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] + 'scan_mode': ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + 'mode': + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value } return self._magic((filters, settings_in_effect)) @@ -11933,9 +12315,9 @@ class FilteringTest(BluetoothBaseTest): test_result = False if 'tx_power_level' in settings_in_effect.keys(): if (event['data']['SettingsInEffect']['txPowerLevel'] == - java_integer['min']): + JavaInteger.MIN.value): self.log.error("Expected tx power level was not meant to be: " - "{}".format(java_integer['min'])) + "{}".format(JavaInteger.MIN.value)) test_result = False elif (event['data']['SettingsInEffect']['txPowerLevel'] != self.default_tx_power_level): @@ -12030,12 +12412,12 @@ class FilteringTest(BluetoothBaseTest): generate_ble_advertise_objects(self.adv_ad.droid)) if ('scan_mode' in settings_in_effect and settings_in_effect['scan_mode'] != - ble_scan_settings_modes['opportunistic']): + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value): self.scn_ad.droid.bleSetScanSettingsScanMode(settings_in_effect[ 'scan_mode']) else: self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) scan_settings = self.scn_ad.droid.bleBuildScanSetting() scan_callback = self.scn_ad.droid.bleGenScanCallback() self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, @@ -12044,14 +12426,14 @@ class FilteringTest(BluetoothBaseTest): scan_settings2, scan_callback2 = None, None if ('scan_mode' in settings_in_effect and settings_in_effect['scan_mode'] == - ble_scan_settings_modes['opportunistic']): + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value): opportunistic = True scan_settings2 = self.scn_ad.droid.bleBuildScanSetting() scan_callback2 = self.scn_ad.droid.bleGenScanCallback() self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings2, scan_callback2) self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['opportunistic']) + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) self.adv_ad.droid.bleStartBleAdvertising( advertise_callback, advertise_data, advertise_settings) regex = "(" + adv_succ.format( @@ -12060,7 +12442,7 @@ class FilteringTest(BluetoothBaseTest): self.log.debug(regex) try: event = self.adv_ad.ed.pop_events(regex, self.default_timeout, - small_timeout) + TIMEOUT_SMALL) except Empty: self.adv_ad.log.error("Failed to get success or failed event.") return False diff --git a/acts/tests/google/ble/filtering/UniqueFilteringTest.py b/acts/tests/google/ble/filtering/UniqueFilteringTest.py index bb7b00f516..44d2629067 100644 --- a/acts/tests/google/ble/filtering/UniqueFilteringTest.py +++ b/acts/tests/google/ble/filtering/UniqueFilteringTest.py @@ -26,13 +26,13 @@ import time from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_test_utils import adv_succ from acts.test_utils.bt.bt_test_utils import batch_scan_result -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result class UniqueFilteringTest(BluetoothBaseTest): @@ -110,7 +110,7 @@ class UniqueFilteringTest(BluetoothBaseTest): """ test_result = True self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) expected_event_name = scan_result.format(scan_callback) @@ -326,7 +326,7 @@ class UniqueFilteringTest(BluetoothBaseTest): self.scn_ad.droid.bleSetScanFilterServiceUuid(service_uuid, service_mask) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) self.scn_ad.droid.bleBuildScanFilter(filter_list) @@ -383,12 +383,12 @@ class UniqueFilteringTest(BluetoothBaseTest): """ test_result = True self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(117, [1, 2, 3]) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.adv_ad.droid)) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( 117, [1, 2, 3, 4, 5, 6, 7, 8]) advertise_callback1, advertise_data1, advertise_settings1 = ( @@ -399,8 +399,8 @@ class UniqueFilteringTest(BluetoothBaseTest): advertise_callback1, advertise_data1, advertise_settings1) filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) scan_settings = self.scn_ad.droid.bleBuildScanSetting() scan_callback = self.scn_ad.droid.bleGenScanCallback() self.scn_ad.droid.bleSetScanFilterManufacturerData(117, [1, 2, 3], @@ -439,13 +439,13 @@ class UniqueFilteringTest(BluetoothBaseTest): Priority: 1 """ test_result = True - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) expected_event_name = scan_result.format(scan_callback) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.adv_ad.droid)) self.adv_ad.droid.bleStartBleAdvertising( @@ -458,8 +458,8 @@ class UniqueFilteringTest(BluetoothBaseTest): self.log.info("Filter advertisement with address {}".format( mac_address)) self.scn_ad.droid.bleStopBleScan(scan_callback) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanFilterDeviceAddress(mac_address) filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) @@ -509,7 +509,7 @@ class UniqueFilteringTest(BluetoothBaseTest): self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(manufacturer_id, [0x01]) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.adv_ad.droid)) self.adv_ad.droid.bleStartBleAdvertising( @@ -521,8 +521,8 @@ class UniqueFilteringTest(BluetoothBaseTest): self.log.info("Failed to start advertisement.") return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanFilterManufacturerData(manufacturer_id, [0x01]) filter_list = self.scn_ad.droid.bleGenFilterList() @@ -587,7 +587,8 @@ class UniqueFilteringTest(BluetoothBaseTest): self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( manufacturer_id, [0x01]) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY. + value) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.adv_ad.droid)) self.adv_ad.droid.bleStartBleAdvertising( @@ -600,7 +601,7 @@ class UniqueFilteringTest(BluetoothBaseTest): return False self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanFilterManufacturerData(manufacturer_id, [0x01]) filter_list = self.scn_ad.droid.bleGenFilterList() diff --git a/acts/tests/google/ble/gatt/GattConnectTest.py b/acts/tests/google/ble/gatt/GattConnectTest.py index 374becddbb..9834ea93b0 100644 --- a/acts/tests/google/ble/gatt/GattConnectTest.py +++ b/acts/tests/google/ble/gatt/GattConnectTest.py @@ -23,15 +23,15 @@ import time from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import bt_profile_constants -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import gatt_cb_err -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_mtu_size -from acts.test_utils.bt.bt_constants import gatt_phy_mask -from acts.test_utils.bt.bt_constants import gatt_transport +from acts.test_utils.bt.BtEnum import BluetoothProfile +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattService +from acts.test_utils.bt.GattEnum import MtuSize +from acts.test_utils.bt.GattEnum import GattCbErr +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattPhyMask +from acts.test_utils.bt.GattEnum import GattTransport from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids @@ -83,13 +83,13 @@ class GattConnectTest(BluetoothBaseTest): return True def _find_service_added_event(self, gatt_server_cb, uuid): - expected_event = gatt_cb_strings['serv_added'].format(gatt_server_cb) + expected_event = GattCbStrings.SERV_ADDED.value.format(gatt_server_cb) try: event = self.per_ad.ed.pop_event(expected_event, self.default_timeout) except Empty: - self.log.error(gatt_cb_strings['serv_added_err'].format( - expected_event)) + self.log.error( + GattCbErr.SERV_ADDED_ERR.value.format(expected_event)) return False if event['data']['serviceUuid'].lower() != uuid.lower(): self.log.error("Uuid mismatch. Found: {}, Expected {}.".format( @@ -99,7 +99,7 @@ class GattConnectTest(BluetoothBaseTest): def _verify_mtu_changed_on_client_and_server( self, expected_mtu, gatt_callback, gatt_server_callback): - expected_event = gatt_cb_strings['mtu_changed'].format(gatt_callback) + expected_event = GattCbStrings.MTU_CHANGED.value.format(gatt_callback) try: mtu_event = self.cen_ad.ed.pop_event(expected_event, self.default_timeout) @@ -109,11 +109,11 @@ class GattConnectTest(BluetoothBaseTest): mtu_size_found, expected_mtu)) return False except Empty: - self.log.error(gatt_cb_err['mtu_changed_err'].format( - expected_event)) + self.log.error( + GattCbErr.MTU_CHANGED_ERR.value.format(expected_event)) return False - expected_event = gatt_cb_strings['mtu_serv_changed'].format( + expected_event = GattCbStrings.MTU_SERV_CHANGED.value.format( gatt_server_callback) try: mtu_event = self.per_ad.ed.pop_event(expected_event, @@ -124,8 +124,8 @@ class GattConnectTest(BluetoothBaseTest): mtu_size_found, expected_mtu)) return False except Empty: - self.log.error(gatt_cb_err['mtu_serv_changed_err'].format( - expected_event)) + self.log.error( + GattCbErr.MTU_SERV_CHANGED_ERR.value.format(expected_event)) return False return True @@ -213,9 +213,9 @@ class GattConnectTest(BluetoothBaseTest): return False self.per_ad.droid.bleStopBleAdvertising(adv_callback) try: - event = self.cen_ad.ed.pop_event(gatt_cb_strings[ - 'gatt_conn_change'].format(gatt_callback, - self.default_timeout)) + event = self.cen_ad.ed.pop_event( + GattCbStrings.GATT_CONN_CHANGE.value.format( + gatt_callback, self.default_timeout)) self.log.error( "Connection event found when not expected: {}".format(event)) return False @@ -282,20 +282,19 @@ class GattConnectTest(BluetoothBaseTest): autoconnect = True bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( gatt_callback, mac_address, autoconnect, - gatt_transport['auto'], - gatt_phy_mask['1m_mask']) + GattTransport.TRANSPORT_AUTO.value, + GattPhyMask.PHY_LE_1M_MASK) self.bluetooth_gatt_list.append(bluetooth_gatt) - expected_event = gatt_cb_strings['gatt_conn_change'].format( + expected_event = GattCbStrings.GATT_CONN_CHANGE.value.format( gatt_callback) try: event = self.cen_ad.ed.pop_event(expected_event, self.default_timeout) except Empty: - self.log.error(gatt_cb_err['gatt_conn_change_err'].format( - expected_event)) + self.log.error( + GattCbErr.GATT_CONN_CHANGE_ERR.value.format(expected_event)) test_result = False - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) + return True @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='1e01838e-c4de-4720-9adf-9e0419378226') @@ -339,7 +338,7 @@ class GattConnectTest(BluetoothBaseTest): self.log.error(err) return False self.adv_instances.append(adv_callback) - expected_mtu = gatt_mtu_size['min'] + expected_mtu = MtuSize.MIN.value self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, expected_mtu) if not self._verify_mtu_changed_on_client_and_server( expected_mtu, gatt_callback, gatt_server_cb): @@ -389,7 +388,7 @@ class GattConnectTest(BluetoothBaseTest): self.log.error(err) return False self.adv_instances.append(adv_callback) - expected_mtu = gatt_mtu_size['max'] + expected_mtu = MtuSize.MAX.value self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, expected_mtu) if not self._verify_mtu_changed_on_client_and_server( expected_mtu, gatt_callback, gatt_server_cb): @@ -440,7 +439,7 @@ class GattConnectTest(BluetoothBaseTest): self.log.error(err) return False self.adv_instances.append(adv_callback) - unexpected_mtu = gatt_mtu_size['min'] - 1 + unexpected_mtu = MtuSize.MIN.value - 1 self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, unexpected_mtu) if self._verify_mtu_changed_on_client_and_server( unexpected_mtu, gatt_callback, gatt_server_cb): @@ -488,14 +487,14 @@ class GattConnectTest(BluetoothBaseTest): self.log.error(err) return False self.adv_instances.append(adv_callback) - expected_event = gatt_cb_strings['rd_remote_rssi'].format( + expected_event = GattCbStrings.RD_REMOTE_RSSI.value.format( gatt_callback) if self.cen_ad.droid.gattClientReadRSSI(bluetooth_gatt): try: self.cen_ad.ed.pop_event(expected_event, self.default_timeout) except Empty: - self.log.error(gatt_cb_err['rd_remote_rssi_err'].format( - expected_event)) + self.log.error( + GattCbErr.RD_REMOTE_RSSI_ERR.value.format(expected_event)) return self._orchestrate_gatt_disconnection(bluetooth_gatt, gatt_callback) @@ -540,14 +539,14 @@ class GattConnectTest(BluetoothBaseTest): return False self.adv_instances.append(adv_callback) if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( + expected_event = GattCbStrings.GATT_SERV_DISC.value.format( gatt_callback) try: event = self.cen_ad.ed.pop_event(expected_event, self.default_timeout) except Empty: - self.log.error(gatt_cb_err['gatt_serv_disc'].format( - expected_event)) + self.log.error( + GattCbErr.GATT_SERV_DISC_ERR.value.format(expected_event)) return False return self._orchestrate_gatt_disconnection(bluetooth_gatt, gatt_callback) @@ -599,15 +598,15 @@ class GattConnectTest(BluetoothBaseTest): return False self.adv_instances.append(adv_callback) if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( + expected_event = GattCbStrings.GATT_SERV_DISC.value.format( gatt_callback) try: event = self.cen_ad.ed.pop_event(expected_event, self.default_timeout) discovered_services_index = event['data']['ServicesIndex'] except Empty: - self.log.error(gatt_cb_err['gatt_serv_disc'].format( - expected_event)) + self.log.error( + GattCbErr.GATT_SERV_DISC_ERR.value.format(expected_event)) return False log_gatt_server_uuids(self.cen_ad, discovered_services_index) return self._orchestrate_gatt_disconnection(bluetooth_gatt, @@ -657,14 +656,14 @@ class GattConnectTest(BluetoothBaseTest): return False self.adv_instances.append(adv_callback) if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( + expected_event = GattCbStrings.GATT_SERV_DISC.value.format( gatt_callback) try: event = self.cen_ad.ed.pop_event(expected_event, self.default_timeout) except Empty: - self.log.error(gatt_cb_err['gatt_serv_disc'].format( - expected_event)) + self.log.error( + GattCbErr.GATT_SERV_DISC_ERR.value.format(expected_event)) return False discovered_services_index = event['data']['ServicesIndex'] log_gatt_server_uuids(self.cen_ad, discovered_services_index) @@ -738,8 +737,8 @@ class GattConnectTest(BluetoothBaseTest): 1. Create a GATT server and server callback on the peripheral device. 2. Create a unique service and characteristic uuid on the peripheral. 3. Create a characteristic on the peripheral with these properties: - gatt_characteristic['property_write'], - gatt_characteristic['permission_write_encrypted_mitm'] + GattCharacteristic.PROPERTY_WRITE.value, + GattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM.value 4. Create a GATT service on the peripheral. 5. Add the characteristic to the GATT service. 6. Create a GATT connection between your central and peripheral device. @@ -773,10 +772,10 @@ class GattConnectTest(BluetoothBaseTest): test_uuid = "aa7edd5a-4d1d-4f0e-883a-d145616a1630" bonded = False characteristic = self.per_ad.droid.gattServerCreateBluetoothGattCharacteristic( - test_uuid, gatt_characteristic['property_write'], - gatt_characteristic['permission_write_encrypted_mitm']) + test_uuid, GattCharacteristic.PROPERTY_WRITE.value, + GattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM.value) gatt_service = self.per_ad.droid.gattServerCreateService( - service_uuid, gatt_service_types['primary']) + service_uuid, GattService.SERVICE_TYPE_PRIMARY.value) self.per_ad.droid.gattServerAddCharacteristicToService(gatt_service, characteristic) self.per_ad.droid.gattServerAddService(gatt_server, gatt_service) @@ -788,14 +787,14 @@ class GattConnectTest(BluetoothBaseTest): self.bluetooth_gatt_list.append(bluetooth_gatt) self.adv_instances.append(adv_callback) if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( + expected_event = GattCbStrings.GATT_SERV_DISC.value.format( gatt_callback) try: event = self.cen_ad.ed.pop_event(expected_event, self.default_timeout) except Empty: - self.log.error(gatt_cb_err['gatt_serv_disc'].format( - expected_event)) + self.log.error( + GattCbErr.GATT_SERV_DISC_ERR.value.format(expected_event)) return False discovered_services_index = event['data']['ServicesIndex'] else: @@ -828,16 +827,6 @@ class GattConnectTest(BluetoothBaseTest): device['name'] == target_name): bonded = True break - for ad in [self.cen_ad, self.per_ad]: - if not clear_bonded_devices(ad): - return False - # Necessary sleep time for entries to update unbonded state - time.sleep(2) - bonded_devices = ad.droid.bluetoothGetBondedDevices() - if len(bonded_devices) > 0: - self.log.error("Failed to unbond devices: {}".format( - bonded_devices)) - return False return self._orchestrate_gatt_disconnection(bluetooth_gatt, gatt_callback) @@ -884,9 +873,9 @@ class GattConnectTest(BluetoothBaseTest): self.log.error(err) return False conn_cen_devices = self.cen_ad.droid.bluetoothGetConnectedLeDevices( - bt_profile_constants['gatt']) + BluetoothProfile.GATT.value) conn_per_devices = self.per_ad.droid.bluetoothGetConnectedLeDevices( - bt_profile_constants['gatt_server']) + BluetoothProfile.GATT_SERVER.value) target_name = self.per_ad.droid.bluetoothGetLocalName() error_message = ("Connected device {} not found in list of connected " "devices {}") diff --git a/acts/tests/google/ble/gatt/GattNotifyTest.py b/acts/tests/google/ble/gatt/GattNotifyTest.py index 5415cae404..cf7d069c4c 100644 --- a/acts/tests/google/ble/gatt/GattNotifyTest.py +++ b/acts/tests/google/ble/gatt/GattNotifyTest.py @@ -20,11 +20,11 @@ This test script exercises GATT notify/indicate procedures. from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import MtuSize +from acts.test_utils.bt.GattEnum import GattEvent +from acts.test_utils.bt.GattEnum import GattCbStrings from math import ceil @@ -57,20 +57,19 @@ class GattNotifyTest(GattConnectedBaseTest): self.cen_ad.droid.gattClientDescriptorSetValue( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.NOTIFIABLE_CHAR_UUID, - gatt_char_desc_uuids['client_char_cfg'], - gatt_descriptor['enable_notification_value']) + self.CCC_DESC_UUID, GattDescriptor.ENABLE_NOTIFICATION_VALUE.value) self.cen_ad.droid.gattClientWriteDescriptor( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.NOTIFIABLE_CHAR_UUID, - gatt_char_desc_uuids['client_char_cfg']) + self.CCC_DESC_UUID) #enable notifications in app self.cen_ad.droid.gattClientSetCharacteristicNotification( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.NOTIFIABLE_CHAR_UUID, True) - event = self._server_wait(gatt_event['desc_write_req']) + event = self._server_wait(GattEvent.DESC_WRITE_REQ) request_id = event['data']['requestId'] bt_device_id = 0 @@ -79,7 +78,7 @@ class GattNotifyTest(GattConnectedBaseTest): self.per_ad.droid.gattServerSendResponse( self.gatt_server, bt_device_id, request_id, status, 0, []) #wait for client to get response - event = self._client_wait(gatt_event['desc_write']) + event = self._client_wait(GattEvent.DESC_WRITE) #set notified value notified_value = [1, 5, 9, 7, 5, 3, 6, 4, 8, 2] @@ -91,7 +90,7 @@ class GattNotifyTest(GattConnectedBaseTest): self.gatt_server, bt_device_id, self.notifiable_char_index, False) #wait for client to receive the notification - event = self._client_wait(gatt_event['char_change']) + event = self._client_wait(GattEvent.CHAR_CHANGE) self.assertEqual(notified_value, event["data"]["CharacteristicValue"]) return True diff --git a/acts/tests/google/ble/gatt/GattReadTest.py b/acts/tests/google/ble/gatt/GattReadTest.py index 6b377709d2..6faf783779 100644 --- a/acts/tests/google/ble/gatt/GattReadTest.py +++ b/acts/tests/google/ble/gatt/GattReadTest.py @@ -20,10 +20,11 @@ This test script exercises different GATT read procedures. from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import MtuSize +from acts.test_utils.bt.GattEnum import GattEvent +from acts.test_utils.bt.GattEnum import GattCbStrings from math import ceil @@ -57,7 +58,7 @@ class GattReadTest(GattConnectedBaseTest): self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.READABLE_CHAR_UUID) - event = self._server_wait(gatt_event['char_read_req']) + event = self._server_wait(GattEvent.CHAR_READ_REQ) request_id = event['data']['requestId'] self.assertEqual(0, event['data']['offset'], "offset should be 0") @@ -70,7 +71,7 @@ class GattReadTest(GattConnectedBaseTest): bt_device_id, request_id, status, offset, char_value) - event = self._client_wait(gatt_event['char_read']) + event = self._client_wait(GattEvent.CHAR_READ) self.assertEqual(status, event["data"]["Status"], "Write status should be 0") self.assertEqual(char_value, event["data"]["CharacteristicValue"], @@ -126,7 +127,7 @@ class GattReadTest(GattConnectedBaseTest): for i in range(num_packets): startOffset = i * (self.mtu - 1) - event = self._server_wait(gatt_event['char_read_req']) + event = self._server_wait(GattEvent.CHAR_READ_REQ) request_id = event['data']['requestId'] self.assertEqual(startOffset, event['data']['offset'], @@ -139,7 +140,7 @@ class GattReadTest(GattConnectedBaseTest): self.gatt_server, bt_device_id, request_id, status, offset, char_value[startOffset:startOffset + self.mtu - 1]) - event = self._client_wait(gatt_event['char_read']) + event = self._client_wait(GattEvent.CHAR_READ) self.assertEqual(status, event["data"]["Status"], "Write status should be 0") @@ -176,7 +177,7 @@ class GattReadTest(GattConnectedBaseTest): self.cen_ad.droid.gattClientReadUsingCharacteristicUuid( self.bluetooth_gatt, self.READABLE_CHAR_UUID, 0x0001, 0xFFFF) - event = self._server_wait(gatt_event['char_read_req']) + event = self._server_wait(GattEvent.CHAR_READ_REQ) request_id = event['data']['requestId'] self.assertEqual(0, event['data']['offset'], "offset should be 0") @@ -189,7 +190,7 @@ class GattReadTest(GattConnectedBaseTest): bt_device_id, request_id, status, offset, char_value) - event = self._client_wait(gatt_event['char_read']) + event = self._client_wait(GattEvent.CHAR_READ) self.assertEqual(status, event["data"]["Status"], "Write status should be 0") self.assertEqual(char_value, event["data"]["CharacteristicValue"], diff --git a/acts/tests/google/ble/gatt/GattToolTest.py b/acts/tests/google/ble/gatt/GattToolTest.py index d9921b4940..47af8c312d 100644 --- a/acts/tests/google/ble/gatt/GattToolTest.py +++ b/acts/tests/google/ble/gatt/GattToolTest.py @@ -27,19 +27,19 @@ import pprint from queue import Empty import time -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import gatt_cb_err -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_transport +from acts.test_utils.bt.GattEnum import GattCbErr +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattTransport from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result class GattToolTest(BluetoothBaseTest): @@ -84,8 +84,8 @@ class GattToolTest(BluetoothBaseTest): def _is_peripheral_advertising(self): self.cen_ad.droid.bleSetScanFilterDeviceAddress(self.ble_mac_address) - self.cen_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.cen_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.cen_ad.droid) self.cen_ad.droid.bleBuildScanFilter(filter_list) @@ -145,9 +145,9 @@ class GattToolTest(BluetoothBaseTest): self.AUTOCONNECT = False start_time = self._get_time_in_milliseconds() try: - bluetooth_gatt, gatt_callback = ( - setup_gatt_connection(self.cen_ad, self.ble_mac_address, - self.AUTOCONNECT, gatt_transport['le'])) + bluetooth_gatt, gatt_callback = (setup_gatt_connection( + self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, + GattTransport.TRANSPORT_LE.value)) except GattTestUtilsError as err: self.log.error(err) return False @@ -203,7 +203,7 @@ class GattToolTest(BluetoothBaseTest): try: bluetooth_gatt, gatt_callback = (setup_gatt_connection( self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, - gatt_transport['le'])) + GattTransport.TRANSPORT_LE.value)) except GattTestUtilsError as err: self.log.error(err) return False @@ -247,22 +247,22 @@ class GattToolTest(BluetoothBaseTest): Priority: 2 """ try: - bluetooth_gatt, gatt_callback = ( - setup_gatt_connection(self.cen_ad, self.ble_mac_address, - self.AUTOCONNECT, gatt_transport['le'])) + bluetooth_gatt, gatt_callback = (setup_gatt_connection( + self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, + GattTransport.TRANSPORT_LE.value)) except GattTestUtilsError as err: self.log.error(err) return False if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( + expected_event = GattCbStrings.GATT_SERV_DISC.value.format( gatt_callback) try: event = self.cen_ad.ed.pop_event(expected_event, self.DEFAULT_TIMEOUT) discovered_services_index = event['data']['ServicesIndex'] except Empty: - self.log.error(gatt_cb_err['gatt_serv_disc'].format( - expected_event)) + self.log.error( + GattCbErr.GATT_SERV_DISC_ERR.value.format(expected_event)) return False log_gatt_server_uuids(self.cen_ad, discovered_services_index) try: @@ -382,22 +382,22 @@ class GattToolTest(BluetoothBaseTest): if not self._pair_with_peripheral(): return False try: - bluetooth_gatt, gatt_callback = ( - setup_gatt_connection(self.cen_ad, self.ble_mac_address, - self.AUTOCONNECT, gatt_transport['le'])) + bluetooth_gatt, gatt_callback = (setup_gatt_connection( + self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, + GattTransport.TRANSPORT_LE.value)) except GattTestUtilsError as err: self.log.error(err) return False if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( + expected_event = GattCbStrings.GATT_SERV_DISC.value.format( gatt_callback) try: event = self.cen_ad.ed.pop_event(expected_event, self.DEFAULT_TIMEOUT) discovered_services_index = event['data']['ServicesIndex'] except Empty: - self.log.error(gatt_cb_err['gatt_serv_disc'].format( - expected_event)) + self.log.error( + GattCbErr.GATT_SERV_DISC_ERR.value.format(expected_event)) return False # TODO: in setup save service_cound and discovered_services_index # programatically @@ -418,7 +418,7 @@ class GattToolTest(BluetoothBaseTest): self.cen_ad.droid.gattClientDescriptorSetValue( bluetooth_gatt, discovered_services_index, test_service_index, self.NOTIFIABLE_CHAR_UUID, self.CCC_DESC_UUID, - gatt_descriptor['enable_notification_value']) + GattDescriptor.ENABLE_NOTIFICATION_VALUE.value) self.cen_ad.droid.gattClientWriteDescriptor( bluetooth_gatt, discovered_services_index, test_service_index, @@ -435,7 +435,7 @@ class GattToolTest(BluetoothBaseTest): while time.time() < end_time: try: event = self.cen_ad.ed.pop_event(expected_event, - self.DEFAULT_TIMEOUT) + self.DEFAULT_TIMEOUT) self.log.info(event) except Empty as err: print(err) diff --git a/acts/tests/google/ble/gatt/GattWriteTest.py b/acts/tests/google/ble/gatt/GattWriteTest.py index 47e5b0ea25..2f3c896023 100644 --- a/acts/tests/google/ble/gatt/GattWriteTest.py +++ b/acts/tests/google/ble/gatt/GattWriteTest.py @@ -20,13 +20,13 @@ This test script exercises different GATT write procedures. from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_connection_priority -from acts.test_utils.bt.bt_constants import gatt_characteristic_attr_length -from acts.test_utils.bt.bt_constants import gatt_mtu_size +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattEvent +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattConnectionPriority +from acts.test_utils.bt.GattEnum import GattCharacteristicAttrLength +from acts.test_utils.bt.GattEnum import MtuSize from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu @@ -62,13 +62,13 @@ class GattWriteTest(GattConnectedBaseTest): self.cen_ad.droid.gattClientCharacteristicSetWriteType( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_default']) + GattCharacteristic.WRITE_TYPE_DEFAULT.value) self.cen_ad.droid.gattClientWriteCharacteristic( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID) - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) request_id = event['data']['requestId'] self.assertEqual(True, event['data']['responseNeeded'], @@ -84,7 +84,7 @@ class GattWriteTest(GattConnectedBaseTest): self.per_ad.droid.gattServerSendResponse( self.gatt_server, bt_device_id, request_id, status, offset, []) - event = self._client_wait(gatt_event['char_write']) + event = self._client_wait(GattEvent.CHAR_WRITE) self.assertEqual(status, event["data"]["Status"], "Write status should be 0") # Write response doesn't carry any data expcept status @@ -123,7 +123,7 @@ class GattWriteTest(GattConnectedBaseTest): self.test_service_index, self.WRITABLE_CHAR_UUID, self.WRITABLE_DESC_UUID) - event = self._server_wait(gatt_event['desc_write_req']) + event = self._server_wait(GattEvent.DESC_WRITE_REQ) request_id = event['data']['requestId'] self.assertEqual(True, event['data']['responseNeeded'], @@ -139,7 +139,7 @@ class GattWriteTest(GattConnectedBaseTest): self.per_ad.droid.gattServerSendResponse( self.gatt_server, bt_device_id, request_id, status, offset, []) - event = self._client_wait(gatt_event['desc_write']) + event = self._client_wait(GattEvent.DESC_WRITE) self.assertEqual(status, event["data"]["Status"], "Write status should be 0") # Write response doesn't carry any data except status @@ -175,18 +175,18 @@ class GattWriteTest(GattConnectedBaseTest): self.cen_ad.droid.gattClientCharacteristicSetWriteType( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) + GattCharacteristic.WRITE_TYPE_NO_RESPONSE.value) self.cen_ad.droid.gattClientWriteCharacteristic( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID) - event = self._client_wait(gatt_event['char_write']) + event = self._client_wait(GattEvent.CHAR_WRITE) if event["data"]["Status"] != 0: self.log.error("Write status should be 0") return False - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) request_id = event['data']['requestId'] self.assertEqual(False, event['data']['responseNeeded'], @@ -229,13 +229,13 @@ class GattWriteTest(GattConnectedBaseTest): self.cen_ad.droid.gattClientCharacteristicSetWriteType( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) + GattCharacteristic.WRITE_TYPE_NO_RESPONSE.value) self.cen_ad.droid.gattClientWriteCharacteristic( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID) - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) request_id = event['data']['requestId'] self.assertEqual(False, event['data']['responseNeeded']) @@ -246,7 +246,7 @@ class GattWriteTest(GattConnectedBaseTest): trimmed_value, event['data']['value'], "Received value should be sent value trimmed to MTU-3") - event = self._client_wait(gatt_event['char_write']) + event = self._client_wait(GattEvent.CHAR_WRITE) if event["data"]["Status"] != 0: self.log.error("Write status should be 0") return False @@ -260,8 +260,8 @@ class GattWriteTest(GattConnectedBaseTest): Test establishing a gatt connection between a GATT Peripheral and GATT Client. Request mtu size equal to the max MTU. The max number of bytes can be sent within a characteristic is - (MTU - gatt_characteristic_attr_length['attr_2']) since - the gatt_characteristic_attr_length['attr_2'] (3 bytes) are + (MTU - GattCharacteristicAttrLength.MTU_ATTR_2) since + the GattCharacteristicAttrLength.MTU_ATTR_2 (3 bytes) are used for its attribute of the command code and its handle. Then reduce mtu by 1 and re-send the same characteristic. Make sure the characteristic value received by the remote side is @@ -273,11 +273,11 @@ class GattWriteTest(GattConnectedBaseTest): 2. Client: request new mtu size change to max MTU. 3. Client: write a characteristic with char_value of max MTU bytes. 4. Peripheral: receive the written data. Check it was properly - truncated to (max MTU - gatt_characteristic_attr_length['attr_2']). + truncated to (max MTU - GattCharacteristicAttrLength.MTU_ATTR_2). 5. Client: request mtu size change to (max MTU - 1). 6. Client: write the same characteristic again. 7. Peripheral: receive the written data. Check it was properly - truncated to (max MTU - 1 - gatt_characteristic_attr_length['attr_2']) + truncated to (max MTU - 1 - GattCharacteristicAttrLength.MTU_ATTR_2) Expected Result: Verify that data received by the Peripheral side is properly truncated @@ -290,7 +290,7 @@ class GattWriteTest(GattConnectedBaseTest): TAGS: LE, GATT, Characteristic, MTU Priority: 2 """ - self.mtu = gatt_mtu_size['max'] + self.mtu = MtuSize.MAX.value self.log.info("Set mtu to max MTU: {}".format(self.mtu)) # set new MTU to the middle point of min and max of MTU if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, @@ -299,7 +299,7 @@ class GattWriteTest(GattConnectedBaseTest): # create a characteristic with max MTU (217) bytes char_value = [] - for i in range(gatt_mtu_size['max']): + for i in range(MtuSize.MAX.value): char_value.append(i) self.cen_ad.droid.gattClientCharacteristicSetValue( @@ -309,29 +309,29 @@ class GattWriteTest(GattConnectedBaseTest): self.cen_ad.droid.gattClientCharacteristicSetWriteType( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) + GattCharacteristic.WRITE_TYPE_NO_RESPONSE.value) # write data to the characteristic of the Peripheral self.cen_ad.droid.gattClientWriteCharacteristic( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID) - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) self.log.info("Received value with mtu = max MTU: {}".format(event[ 'data']['value'])) # check the data received by Peripheral shall be truncated to - # (mtu - gatt_characteristic_attr_length['attr_2']) bytes - data_length = self.mtu - gatt_characteristic_attr_length['attr_2'] + # (mtu - GattCharacteristicAttrLength.MTU_ATTR_2) bytes + data_length = self.mtu - GattCharacteristicAttrLength.MTU_ATTR_2 expected_value = char_value[:data_length] self.assertEqual( expected_value, event['data']['value'], "Received value should have {} bytes".format(data_length)) # set the mtu to max MTU-1 - self.mtu = gatt_mtu_size['max'] - 1 + self.mtu = MtuSize.MAX.value - 1 self.log.info("Set mtu to max MTU - 1 : {}".format(self.mtu)) - data_length = self.mtu - gatt_characteristic_attr_length['attr_2'] + data_length = self.mtu - GattCharacteristicAttrLength.MTU_ATTR_2 if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, self.gatt_callback, self.mtu): return False @@ -341,12 +341,12 @@ class GattWriteTest(GattConnectedBaseTest): self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID) - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) self.log.info("Data received when mtu = max MTU - 1: {}".format(event[ 'data']['value'])) # check the data received by Peripheral shall be truncated to - # (mtu - gatt_characteristic_attr_length['attr_2']) bytes + # (mtu - GattCharacteristicAttrLength.MTU_ATTR_2) bytes # when mtu is reduced expected_value = char_value[:data_length] self.assertEqual( @@ -379,14 +379,15 @@ class GattWriteTest(GattConnectedBaseTest): Priority: 0 """ self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) + self.bluetooth_gatt, + GattConnectionPriority.CONNECTION_PRIORITY_HIGH.value) bt_device_id = 0 self.cen_ad.droid.gattClientCharacteristicSetWriteType( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_default']) + GattCharacteristic.WRITE_TYPE_DEFAULT.value) for i in range(100): @@ -402,11 +403,11 @@ class GattWriteTest(GattConnectedBaseTest): self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID) - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) + self.log.info("{} event found: {}".format( + GattCbStrings.CHAR_WRITE_REQ.value.format( + self.gatt_server_callback), event['data']['value'])) request_id = event['data']['requestId'] found_value = event['data']['value'] if found_value != char_value: @@ -422,7 +423,7 @@ class GattWriteTest(GattConnectedBaseTest): self.gatt_server, bt_device_id, request_id, status, offset, char_value_return) - event = self._client_wait(gatt_event['char_write']) + event = self._client_wait(GattEvent.CHAR_WRITE) if event["data"]["Status"] != status: self.log.error("Write status should be 0") return False @@ -453,7 +454,8 @@ class GattWriteTest(GattConnectedBaseTest): Priority: 0 """ self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) + self.bluetooth_gatt, + GattConnectionPriority.CONNECTION_PRIORITY_HIGH.value) for i in range(100): @@ -471,11 +473,11 @@ class GattWriteTest(GattConnectedBaseTest): self.test_service_index, self.WRITABLE_CHAR_UUID, self.WRITABLE_DESC_UUID) - event = self._server_wait(gatt_event['desc_write_req']) + event = self._server_wait(GattEvent.DESC_WRITE_REQ) - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) + self.log.info("{} event found: {}".format( + GattCbStrings.CHAR_WRITE_REQ.value.format( + self.gatt_server_callback), event['data']['value'])) request_id = event['data']['requestId'] self.assertEqual(True, event['data']['responseNeeded'], @@ -491,7 +493,7 @@ class GattWriteTest(GattConnectedBaseTest): self.per_ad.droid.gattServerSendResponse( self.gatt_server, bt_device_id, request_id, status, offset, []) - event = self._client_wait(gatt_event['desc_write']) + event = self._client_wait(GattEvent.DESC_WRITE) self.assertEqual(status, event["data"]["Status"], "Write status should be 0") # Write response doesn't carry any data except status @@ -521,14 +523,15 @@ class GattWriteTest(GattConnectedBaseTest): Priority: 0 """ self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) + self.bluetooth_gatt, + GattConnectionPriority.CONNECTION_PRIORITY_HIGH.value) bt_device_id = 0 self.cen_ad.droid.gattClientCharacteristicSetWriteType( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) + GattCharacteristic.WRITE_TYPE_NO_RESPONSE.value) for i in range(100): char_value = [] @@ -544,16 +547,16 @@ class GattWriteTest(GattConnectedBaseTest): self.test_service_index, self.WRITABLE_CHAR_UUID) # client shall not wait for server, get complete event right away - event = self._client_wait(gatt_event['char_write']) + event = self._client_wait(GattEvent.CHAR_WRITE) if event["data"]["Status"] != 0: self.log.error("Write status should be 0") return False - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) + self.log.info("{} event found: {}".format( + GattCbStrings.CHAR_WRITE_REQ.value.format( + self.gatt_server_callback), event['data']['value'])) request_id = event['data']['requestId'] found_value = event['data']['value'] if found_value != char_value: diff --git a/acts/tests/google/ble/power/BleScanPowerTest.py b/acts/tests/google/ble/power/BleScanPowerTest.py index b88515d2ef..a423219a79 100644 --- a/acts/tests/google/ble/power/BleScanPowerTest.py +++ b/acts/tests/google/ble/power/BleScanPowerTest.py @@ -22,9 +22,8 @@ Shield box one: Android Device and Monsoon tool box import json import os -from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.bt_test_utils import bluetooth_enabled_check from acts.test_utils.bt.bt_test_utils import disable_bluetooth from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects @@ -86,9 +85,8 @@ class BleScanPowerTest(PowerBaseTest): first_part_msg = "%s%s --es StartTime %d --es ScanTime %d" % ( self.PMC_BASE_CMD, scan_mode, self.SCAN_START_TIME, scan_time) - msg = "%s --es NoScanTime %d --es Repetitions %d" % (first_part_msg, - idle_time, - repetitions) + msg = "%s --es NoScanTime %d --es Repetitions %d" % ( + first_part_msg, idle_time, repetitions) self.ad.log.info("Send broadcast message: %s", msg) self.ad.adb.shell(msg) @@ -118,7 +116,6 @@ class BleScanPowerTest(PowerBaseTest): self.save_logs_for_power_test(result, start_times, end_times, False) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='37556d99-c535-4fd7-a7e7-5b737379d007') def test_power_for_scan_w_low_latency(self): """Test power usage when scan with low latency. @@ -141,11 +138,10 @@ class BleScanPowerTest(PowerBaseTest): Priority: 3 """ self._measure_power_for_scan_n_log_data( - ble_scan_settings_modes['low_latency'], self.SCAN_TIME_60, - self.IDLE_TIME_30, self.REPETITIONS_40) + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, + self.SCAN_TIME_60, self.IDLE_TIME_30, self.REPETITIONS_40) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9245360a-07b8-48a5-b26a-50d3b2b6e2c0') def test_power_for_scan_w_balanced(self): """Test power usage when scan with balanced mode. @@ -168,11 +164,10 @@ class BleScanPowerTest(PowerBaseTest): Priority: 3 """ self._measure_power_for_scan_n_log_data( - ble_scan_settings_modes['balanced'], self.SCAN_TIME_60, + ScanSettingsScanMode.SCAN_MODE_BALANCED.value, self.SCAN_TIME_60, self.IDLE_TIME_30, self.REPETITIONS_40) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9df99e3a-8cce-497a-b3d6-4ff6262e020e') def test_power_for_scan_w_low_power(self): """Test power usage when scan with low power. @@ -195,11 +190,10 @@ class BleScanPowerTest(PowerBaseTest): Priority: 3 """ self._measure_power_for_scan_n_log_data( - ble_scan_settings_modes['low_power'], self.SCAN_TIME_60, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, self.SCAN_TIME_60, self.IDLE_TIME_30, self.REPETITIONS_40) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cceeaf88-0ead-43e7-a25a-97eed93d1049') def test_power_for_intervaled_scans_w_balanced(self): """Test power usage when intervaled scans with balanced mode @@ -222,11 +216,10 @@ class BleScanPowerTest(PowerBaseTest): Priority: 3 """ self._measure_power_for_scan_n_log_data( - ble_scan_settings_modes['balanced'], self.SCAN_TIME_5, + ScanSettingsScanMode.SCAN_MODE_BALANCED.value, self.SCAN_TIME_5, self.IDLE_TIME_5, self.REPETITIONS_360) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5d20cdc2-876a-45b7-b3cf-064a37f0bb8a') def test_power_for_intervaled_scans_w_low_latency(self): """Test power usage when intervaled scans with low latency mode @@ -249,11 +242,10 @@ class BleScanPowerTest(PowerBaseTest): Priority: 3 """ self._measure_power_for_scan_n_log_data( - ble_scan_settings_modes['low_latency'], self.SCAN_TIME_5, + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value, self.SCAN_TIME_5, self.IDLE_TIME_5, self.REPETITIONS_360) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5e526f85-77e7-4741-b8cd-7cdffb7daa16') def test_power_for_intervaled_scans_w_low_power(self): """Test power usage when intervaled scans with low power mode @@ -276,5 +268,5 @@ class BleScanPowerTest(PowerBaseTest): Priority: 3 """ self._measure_power_for_scan_n_log_data( - ble_scan_settings_modes['low_power'], self.SCAN_TIME_5, + ScanSettingsScanMode.SCAN_MODE_LOW_POWER.value, self.SCAN_TIME_5, self.IDLE_TIME_5, self.REPETITIONS_360) diff --git a/acts/tests/google/ble/power/GattPowerTest.py b/acts/tests/google/ble/power/GattPowerTest.py index 6f8ca7ed9c..31b07a9121 100644 --- a/acts/tests/google/ble/power/GattPowerTest.py +++ b/acts/tests/google/ble/power/GattPowerTest.py @@ -22,7 +22,6 @@ Shield box one: Two Android Devices and Monsoon tool box import json import os -from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.PowerBaseTest import PowerBaseTest @@ -115,7 +114,6 @@ class GattPowerTest(PowerBaseTest): self.per_ad.take_bug_report(self.current_test_name, current_time) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8c5213fc-ffe8-4c32-bb63-1d2b7394dc0c') def test_power_for_60_sec_n_30_sec_idle_gatt_write(self): """Test power usage when do 60 sec GATT write & 30 sec idle @@ -148,7 +146,6 @@ class GattPowerTest(PowerBaseTest): self.WRITE_TIME_60, self.IDLE_TIME_30, self.REPETITIONS_40) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='fd682d46-89db-432d-aaa6-35ed63d6d764') def test_power_for_60_min_non_stop_gatt_write(self): """Test power usage when do a single GATT write. diff --git a/acts/tests/google/ble/scan/BleBackgroundScanTest.py b/acts/tests/google/ble/scan/BleBackgroundScanTest.py index 115b960dd2..3636048952 100644 --- a/acts/tests/google/ble/scan/BleBackgroundScanTest.py +++ b/acts/tests/google/ble/scan/BleBackgroundScanTest.py @@ -21,17 +21,13 @@ from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.BleEnum import BluetoothAdapterState from acts.test_utils.bt.bt_test_utils import bluetooth_off from acts.test_utils.bt.bt_test_utils import bluetooth_on from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_constants import bluetooth_le_off -from acts.test_utils.bt.bt_constants import bluetooth_le_on -from acts.test_utils.bt.bt_constants import bt_adapter_states -from acts.test_utils.bt.bt_constants import scan_result - -import time +from acts.test_utils.bt.bt_test_utils import scan_result class BleBackgroundScanTest(BluetoothBaseTest): @@ -43,6 +39,9 @@ class BleBackgroundScanTest(BluetoothBaseTest): active_scan_callback_list = [] active_adv_callback_list = [] + bluetooth_le_on = "BleStateChangedOn" + bluetooth_le_off = "BleStateChangedOff" + def __init__(self, controllers): BluetoothBaseTest.__init__(self, controllers) self.scn_ad = self.android_devices[0] @@ -50,9 +49,9 @@ class BleBackgroundScanTest(BluetoothBaseTest): def setup_test(self): if (self.scn_ad.droid.bluetoothGetLeState() == - bt_adapter_states['off']): + BluetoothAdapterState.STATE_OFF.value): self.scn_ad.droid.bluetoothEnableBLE() - self.scn_ad.ed.pop_event(bluetooth_le_on) + self.scn_ad.ed.pop_event(self.bluetooth_le_on) for a in self.android_devices: a.ed.clear_all_events() return True @@ -240,41 +239,46 @@ class BleBackgroundScanTest(BluetoothBaseTest): # Sleep because LE turns off after the bluetooth off event fires time.sleep(self.default_timeout) state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['off']: + if state != BluetoothAdapterState.STATE_OFF.value: self.log.error( - ble_state_error_msg.format("after BT Disable", - bt_adapter_states['off'], state)) + ble_state_error_msg.format( + "after BT Disable", BluetoothAdapterState.STATE_OFF.value, + state)) return False # TODO: BleStateChangedOn got generated as we shut off bluetooth above? self.scn_ad.ed.clear_all_events() result = self.scn_ad.droid.bluetoothEnableBLE() try: - self.scn_ad.ed.pop_event(bluetooth_le_on, self.default_timeout) + self.scn_ad.ed.pop_event(self.bluetooth_le_on, + self.default_timeout) except Empty: self.log.error("Bluetooth LE On event not found. Expected {}". - format(bluetooth_le_on)) + format(self.bluetooth_le_on)) return False state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['ble_on']: + if state != BluetoothAdapterState.STATE_BLE_ON.value: self.log.error( - ble_state_error_msg.format("before Airplane Mode OFF", - bt_adapter_states['ble_on'], state)) + ble_state_error_msg.format( + "before Airplane Mode OFF", + BluetoothAdapterState.STATE_BLE_ON.value, state)) return False self.scn_ad.droid.bluetoothListenForBleStateChange() self.scn_ad.droid.connectivityToggleAirplaneMode(True) try: - self.scn_ad.ed.pop_event(bluetooth_le_off, self.default_timeout) + self.scn_ad.ed.pop_event(self.bluetooth_le_off, + self.default_timeout) except Empty: self.log.error("Bluetooth LE Off event not found. Expected {}". - format(bluetooth_le_off)) + format(self.bluetooth_le_off)) return False state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['off']: + if state != BluetoothAdapterState.STATE_OFF.value: self.log.error( - ble_state_error_msg.format("after Airplane Mode ON", - bt_adapter_states['off'], state)) + ble_state_error_msg.format( + "after Airplane Mode ON", + BluetoothAdapterState.STATE_OFF.value, state)) return False result = self.scn_ad.droid.bluetoothEnableBLE() if result: @@ -283,18 +287,19 @@ class BleBackgroundScanTest(BluetoothBaseTest): ) return False state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['off']: + if state != BluetoothAdapterState.STATE_OFF.value: self.log.error( "Bluetooth LE State not OK after attempted enable. Expected {} got {}". - format(bt_adapter_states['off'], state)) + format(BluetoothAdapterState.STATE_OFF.value, state)) return False self.scn_ad.droid.connectivityToggleAirplaneMode(False) # Sleep to let Airplane Mode disable propogate through the system time.sleep(self.default_timeout) state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['off']: + if state != BluetoothAdapterState.STATE_OFF.value: self.log.error( - ble_state_error_msg.format("after Airplane Mode OFF", - bt_adapter_states['off'], state)) + ble_state_error_msg.format( + "after Airplane Mode OFF", + BluetoothAdapterState.STATE_OFF.value, state)) return False return True diff --git a/acts/tests/google/ble/scan/BleOnLostOnFoundTest.py b/acts/tests/google/ble/scan/BleOnLostOnFoundTest.py index 37f7e07b1e..bf59635c43 100644 --- a/acts/tests/google/ble/scan/BleOnLostOnFoundTest.py +++ b/acts/tests/google/ble/scan/BleOnLostOnFoundTest.py @@ -20,17 +20,15 @@ This test script exercises different onLost/onFound scenarios. from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import ScanSettingsCallbackType from acts.test_utils.bt.BleEnum import ScanSettingsMatchMode from acts.test_utils.bt.BleEnum import ScanSettingsMatchNum -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_match_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_match_nums -from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.bt_test_utils import adv_succ from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result class BleOnLostOnFoundTest(BluetoothBaseTest): @@ -57,7 +55,7 @@ class BleOnLostOnFoundTest(BluetoothBaseTest): def _start_generic_advertisement_include_device_name(self): self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) advertise_data = self.adv_ad.droid.bleBuildAdvertiseData() advertise_settings = self.adv_ad.droid.bleBuildAdvertiseSettings() advertise_callback = self.adv_ad.droid.bleGenBleAdvertiseCallback() @@ -109,14 +107,14 @@ class BleOnLostOnFoundTest(BluetoothBaseTest): filter_list = self.scn_ad.droid.bleGenFilterList() self.scn_ad.droid.bleSetScanFilterDeviceName( self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['found_and_lost']) + ScanSettingsCallbackType.CALLBACK_TYPE_FOUND_AND_LOST.value) self.scn_ad.droid.bleSetScanSettingsMatchMode( - ble_scan_settings_match_modes['aggresive']) + ScanSettingsMatchMode.AGGRESIVE.value) self.scn_ad.droid.bleSetScanSettingsNumOfMatches( - ble_scan_settings_match_nums['one']) + ScanSettingsMatchNum.MATCH_NUM_ONE_ADVERTISEMENT.value) scan_settings = self.scn_ad.droid.bleBuildScanSetting() scan_callback = self.scn_ad.droid.bleGenScanCallback() self.scn_ad.droid.bleBuildScanFilter(filter_list) @@ -127,23 +125,21 @@ class BleOnLostOnFoundTest(BluetoothBaseTest): event = self.scn_ad.ed.pop_event( scan_result.format(scan_callback), self.default_timeout * 3) found_callback_type = event['data']['CallbackType'] - if event['data']['CallbackType'] != ble_scan_settings_callback_types[ - 'first_match']: + if event['data'][ + 'CallbackType'] != ScanSettingsCallbackType.CALLBACK_TYPE_FIRST_MATCH.value: self.log.info( "Found Callbacreset_bluetoothkType:{}, Expected CallbackType:{}". - format(found_callback_type, ble_scan_settings_callback_types[ - 'first_match'])) + format(found_callback_type, ScanSettingsCallbackType. + CALLBACK_TYPE_FIRST_MATCH.value)) return False self.adv_ad.droid.bleStopBleAdvertising(adv_callback) event = self.scn_ad.ed.pop_event( scan_result.format(scan_callback), self.default_timeout * 4) found_callback_type = event['data']['CallbackType'] - if found_callback_type != ble_scan_settings_callback_types[ - 'match_lost']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'match_lost'])) + if found_callback_type != ScanSettingsCallbackType.CALLBACK_TYPE_MATCH_LOST.value: + self.log.info("Found CallbackType:{}, Expected CallbackType:{}". + format(found_callback_type, ScanSettingsCallbackType. + CALLBACK_TYPE_MATCH_LOST.value)) return False return True @@ -179,14 +175,14 @@ class BleOnLostOnFoundTest(BluetoothBaseTest): filter_list = self.scn_ad.droid.bleGenFilterList() self.scn_ad.droid.bleSetScanFilterDeviceName( self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['found_and_lost']) + ScanSettingsCallbackType.CALLBACK_TYPE_FOUND_AND_LOST.value) self.scn_ad.droid.bleSetScanSettingsMatchMode( - ble_scan_settings_match_modes['sticky']) + ScanSettingsMatchMode.STICKY.value) self.scn_ad.droid.bleSetScanSettingsNumOfMatches( - ble_scan_settings_match_nums['one']) + ScanSettingsMatchNum.MATCH_NUM_ONE_ADVERTISEMENT.value) scan_settings = self.scn_ad.droid.bleBuildScanSetting() scan_callback = self.scn_ad.droid.bleGenScanCallback() self.scn_ad.droid.bleBuildScanFilter(filter_list) @@ -197,23 +193,20 @@ class BleOnLostOnFoundTest(BluetoothBaseTest): event = self.scn_ad.ed.pop_event( scan_result.format(scan_callback), self.default_timeout * 3) found_callback_type = event['data']['CallbackType'] - if event['data']['CallbackType'] != ble_scan_settings_callback_types[ - 'first_match']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'first_match'])) + if event['data'][ + 'CallbackType'] != ScanSettingsCallbackType.CALLBACK_TYPE_FIRST_MATCH.value: + self.log.info("Found CallbackType:{}, Expected CallbackType:{}". + format(found_callback_type, ScanSettingsCallbackType. + CALLBACK_TYPE_FIRST_MATCH.value)) return False self.adv_ad.droid.bleStopBleAdvertising(adv_callback) event = self.scn_ad.ed.pop_event( scan_result.format(scan_callback), self.default_timeout * 4) found_callback_type = event['data']['CallbackType'] - if found_callback_type != ble_scan_settings_callback_types[ - 'match_lost']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'match_lost'])) + if found_callback_type != ScanSettingsCallbackType.CALLBACK_TYPE_MATCH_LOST.value: + self.log.info("Found CallbackType:{}, Expected CallbackType:{}". + format(found_callback_type, ScanSettingsCallbackType. + CALLBACK_TYPE_MATCH_LOST.value)) return False return True @@ -249,14 +242,14 @@ class BleOnLostOnFoundTest(BluetoothBaseTest): filter_list = self.scn_ad.droid.bleGenFilterList() self.scn_ad.droid.bleSetScanFilterDeviceName( self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['found_and_lost']) + ScanSettingsCallbackType.CALLBACK_TYPE_FOUND_AND_LOST.value) self.scn_ad.droid.bleSetScanSettingsMatchMode( - ble_scan_settings_match_modes['aggresive']) + ScanSettingsMatchMode.AGGRESIVE.value) self.scn_ad.droid.bleSetScanSettingsNumOfMatches( - ble_scan_settings_match_nums['few']) + ScanSettingsMatchNum.MATCH_NUM_FEW_ADVERTISEMENT.value) scan_settings = self.scn_ad.droid.bleBuildScanSetting() scan_callback = self.scn_ad.droid.bleGenScanCallback() self.scn_ad.droid.bleBuildScanFilter(filter_list) @@ -267,22 +260,19 @@ class BleOnLostOnFoundTest(BluetoothBaseTest): event = self.scn_ad.ed.pop_event( scan_result.format(scan_callback), self.default_timeout * 3) found_callback_type = event['data']['CallbackType'] - if event['data']['CallbackType'] != ble_scan_settings_callback_types[ - 'first_match']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'first_match'])) + if event['data'][ + 'CallbackType'] != ScanSettingsCallbackType.CALLBACK_TYPE_FIRST_MATCH.value: + self.log.info("Found CallbackType:{}, Expected CallbackType:{}". + format(found_callback_type, ScanSettingsCallbackType. + CALLBACK_TYPE_FIRST_MATCH.value)) return False self.adv_ad.droid.bleStopBleAdvertising(adv_callback) event = self.scn_ad.ed.pop_event( scan_result.format(scan_callback), self.default_timeout * 4) found_callback_type = event['data']['CallbackType'] - if found_callback_type != ble_scan_settings_callback_types[ - 'match_lost']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'match_lost'])) + if found_callback_type != ScanSettingsCallbackType.CALLBACK_TYPE_MATCH_LOST.value: + self.log.info("Found CallbackType:{}, Expected CallbackType:{}". + format(found_callback_type, ScanSettingsCallbackType. + CALLBACK_TYPE_MATCH_LOST.value)) return False return True diff --git a/acts/tests/google/ble/scan/BleOpportunisticScanTest.py b/acts/tests/google/ble/scan/BleOpportunisticScanTest.py index 514116ac1d..a26311e18c 100644 --- a/acts/tests/google/ble/scan/BleOpportunisticScanTest.py +++ b/acts/tests/google/ble/scan/BleOpportunisticScanTest.py @@ -25,14 +25,14 @@ from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.bt_test_utils import batch_scan_result from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result class BleOpportunisticScanTest(BluetoothBaseTest): @@ -99,8 +99,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): TAGS: LE, Advertising, Scanning, Opportunistic Scan Priority: 1 """ - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, @@ -136,8 +136,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning Priority: 1 """ - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( self.report_delay) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( @@ -179,8 +179,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): Priority: 1 """ self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -189,8 +189,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): self.active_scan_callback_list.append(scan_callback) if not self._verify_no_events_found(scan_result.format(scan_callback)): return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, @@ -242,8 +242,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): Priority: 1 """ self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( self.report_delay) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( @@ -256,8 +256,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): return False self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( self.report_delay) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list2, scan_settings2, scan_callback2 = generate_ble_scan_objects( self.scn_ad.droid) self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, @@ -310,8 +310,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): Priority: 1 """ self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( self.report_delay) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( @@ -323,8 +323,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): batch_scan_result.format(scan_callback)): return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, @@ -369,8 +369,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): Priority: 1 """ self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, @@ -380,8 +380,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): return False self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( self.report_delay) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, @@ -426,15 +426,15 @@ class BleOpportunisticScanTest(BluetoothBaseTest): self._setup_generic_advertisement() for _ in range(self.max_scan_instances - 1): self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['opportunistic']) + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, scan_callback) self.active_scan_callback_list.append(scan_callback) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, @@ -483,7 +483,7 @@ class BleOpportunisticScanTest(BluetoothBaseTest): self._setup_generic_advertisement() for _ in range(self.max_scan_instances - 1): self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['opportunistic']) + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( self.report_delay) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( @@ -492,8 +492,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): scan_callback) self.active_scan_callback_list.append(scan_callback) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( self.report_delay) filter_list2, scan_settings2, scan_callback2 = ( @@ -544,8 +544,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): Priority: 1 """ self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -554,8 +554,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): self.active_scan_callback_list.append(scan_callback) if not self._verify_no_events_found(scan_result.format(scan_callback)): return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) self.scn_ad.droid.bleSetScanFilterDeviceName("opp_test") filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) @@ -607,8 +607,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): Priority: 1 """ self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) self.scn_ad.droid.bleSetScanFilterDeviceName("opp_test") filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -618,8 +618,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): self.active_scan_callback_list.append(scan_callback) if not self._verify_no_events_found(scan_result.format(scan_callback)): return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, @@ -666,8 +666,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) self._setup_generic_advertisement() adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_OPPORTUNISTIC.value) self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) filter_list, scan_settings, scan_callback = generate_ble_scan_objects( self.scn_ad.droid) @@ -676,8 +676,8 @@ class BleOpportunisticScanTest(BluetoothBaseTest): self.active_scan_callback_list.append(scan_callback) if not self._verify_no_events_found(scan_result.format(scan_callback)): return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) filter_list2, scan_settings2, scan_callback2 = ( generate_ble_scan_objects(self.scn_ad.droid)) self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) diff --git a/acts/tests/google/ble/scan/DeathToBluetoothTest.py b/acts/tests/google/ble/scan/DeathToBluetoothTest.py new file mode 100644 index 0000000000..a1e16410e3 --- /dev/null +++ b/acts/tests/google/ble/scan/DeathToBluetoothTest.py @@ -0,0 +1,88 @@ +#/usr/bin/env python3.4 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +""" + +from queue import Empty + +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.BleEnum import * +from acts.test_utils.bt.bt_test_utils import * + + +class DeathToBluetoothTest(BluetoothBaseTest): + tests = None + default_timeout = 10 + max_scan_instances = 28 + report_delay = 2000 + scan_callbacks = [] + adv_callbacks = [] + active_scan_callback_list = [] + active_adv_callback_list = [] + + def __init__(self, controllers): + BluetoothBaseTest.__init__(self, controllers) + self.scn_ad = self.android_devices[0] + self.tests = ("test_death", ) + + def teardown_test(self): + self.active_adv_callback_list = [] + self.active_scan_callback_list = [] + + def on_exception(self, test_name, begin_time): + reset_bluetooth(self.android_devices) + + def on_fail(self, test_name, begin_time): + reset_bluetooth(self.android_devices) + + def _setup_generic_advertisement(self): + adv_callback, adv_data, adv_settings = generate_ble_advertise_objects( + self.adv_droid) + self.adv_droid.bleStartBleAdvertising(adv_callback, adv_data, + adv_settings) + self.active_adv_callback_list.append(adv_callback) + + def _verify_no_events_found(self, event_name): + try: + self.scn_ad.ed.pop_event(event_name, self.default_timeout) + self.log.error("Found an event when none was expected.") + return False + except Empty: + self.log.info("No scan result found as expected.") + return True + + @BluetoothBaseTest.bt_test_wrap + def test_death(self): + """ + Tests ... + Steps + 1: ... + :return: boolean + """ + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) + self.scn_ad.droid.bleSetScanSettingsCallbackType(6) + # self.scn_ad.droid.bleSetScanSettingsMatchMode(2) #sticky + self.scn_ad.droid.bleSetScanSettingsMatchMode(1) # aggresive + self.scn_ad.droid.bleSetScanSettingsNumOfMatches(1) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + for _ in range(10000): + self.scn_ad.ed.pop_event(scan_result.format(scan_callback)) + return True diff --git a/acts/tests/google/ble/system_tests/BleStressTest.py b/acts/tests/google/ble/system_tests/BleStressTest.py index a1387ab988..c1c29ba0c9 100644 --- a/acts/tests/google/ble/system_tests/BleStressTest.py +++ b/acts/tests/google/ble/system_tests/BleStressTest.py @@ -31,7 +31,7 @@ from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects from acts.test_utils.bt.bt_test_utils import get_advanced_droid_list from acts.test_utils.bt.bt_test_utils import get_mac_address_of_generic_advertisement from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import scan_result class BleStressTest(BluetoothBaseTest): diff --git a/acts/tests/google/ble/system_tests/GattLongevityTest.py b/acts/tests/google/ble/system_tests/GattLongevityTest.py index 19c76d5157..fe853b3e2f 100644 --- a/acts/tests/google/ble/system_tests/GattLongevityTest.py +++ b/acts/tests/google/ble/system_tests/GattLongevityTest.py @@ -20,12 +20,12 @@ This test script for GATT longevity tests. from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_connection_priority -from acts.test_utils.bt.bt_constants import gatt_characteristic_attr_length +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattEvent +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattConnectionPriority +from acts.test_utils.bt.GattEnum import GattCharacteristicAttrLength from acts.test_utils.bt.GattEnum import MtuSize from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu @@ -60,12 +60,13 @@ class GattLongevityTest(GattConnectedBaseTest): Priority: 0 """ self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) + self.bluetooth_gatt, + GattConnectionPriority.CONNECTION_PRIORITY_HIGH.value) self.cen_ad.droid.gattClientCharacteristicSetWriteType( self.bluetooth_gatt, self.discovered_services_index, self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) + GattCharacteristic.WRITE_TYPE_NO_RESPONSE.value) for i in range(self.longevity_iterations): self.log.debug("Iteration {} started.".format(i + 1)) @@ -82,16 +83,16 @@ class GattLongevityTest(GattConnectedBaseTest): self.test_service_index, self.WRITABLE_CHAR_UUID) # client shall not wait for server, get complete event right away - event = self._client_wait(gatt_event['char_write']) + event = self._client_wait(GattEvent.CHAR_WRITE) if event["data"]["Status"] != 0: self.log.error("Write status should be 0") return False - event = self._server_wait(gatt_event['char_write_req']) + event = self._server_wait(GattEvent.CHAR_WRITE_REQ) - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) + self.log.info("{} event found: {}".format( + GattCbStrings.CHAR_WRITE_REQ.value.format( + self.gatt_server_callback), event['data']['value'])) request_id = event['data']['requestId'] found_value = event['data']['value'] if found_value != char_value: diff --git a/acts/tests/google/bt/BtBasicFunctionalityTest.py b/acts/tests/google/bt/BtBasicFunctionalityTest.py index 43182036d0..7d89867e29 100644 --- a/acts/tests/google/bt/BtBasicFunctionalityTest.py +++ b/acts/tests/google/bt/BtBasicFunctionalityTest.py @@ -23,7 +23,7 @@ import time from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import bt_scan_mode_types +from acts.test_utils.bt.BtEnum import BluetoothScanModeType from acts.test_utils.bt.bt_test_utils import check_device_supported_profiles from acts.test_utils.bt.bt_test_utils import reset_bluetooth from acts.test_utils.bt.bt_test_utils import set_device_name @@ -53,7 +53,7 @@ class BtBasicFunctionalityTest(BluetoothBaseTest): return True def on_fail(self, test_name, begin_time): - take_btsnoop_logs(self.android_devices, self, test_name) + take_btsnoop_logs(self.android_devices, self, test_name, begin_time) reset_bluetooth(self.android_devices) @BluetoothBaseTest.bt_test_wrap @@ -106,7 +106,8 @@ class BtBasicFunctionalityTest(BluetoothBaseTest): """ self.droid_ad.droid.bluetoothMakeDiscoverable() scan_mode = self.droid_ad.droid.bluetoothGetScanMode() - if (scan_mode == bt_scan_mode_types['connectable_discoverable']): + if (scan_mode == + BluetoothScanModeType.SCAN_MODE_CONNECTABLE_DISCOVERABLE): self.log.debug("Android device1 scan mode is " "SCAN_MODE_CONNECTABLE_DISCOVERABLE") else: @@ -169,9 +170,9 @@ class BtBasicFunctionalityTest(BluetoothBaseTest): Priority: 1 """ self.droid_ad.droid.bluetoothMakeUndiscoverable() - set_bt_scan_mode(self.droid1_ad, bt_scan_mode_types['none']) + set_bt_scan_mode(self.droid1_ad, BluetoothScanModeType.SCAN_MODE_NONE) scan_mode = self.droid1_ad.droid.bluetoothGetScanMode() - if scan_mode == bt_scan_mode_types['none']: + if scan_mode == BluetoothScanModeType.SCAN_MODE_NONE: self.log.debug("Android device1 scan mode is SCAN_MODE_NONE") else: self.log.debug("Android device1 scan mode is not SCAN_MODE_NONE") @@ -253,7 +254,7 @@ class BtBasicFunctionalityTest(BluetoothBaseTest): Priority: 1 """ self.log.debug("Test scan mode STATE_OFF.") - return set_bt_scan_mode(self.droid_ad, bt_scan_mode_types['state_off']) + return set_bt_scan_mode(self.droid_ad, BluetoothScanModeType.STATE_OFF) #@BluetoothTest(UUID=27576aa8-d52f-45ad-986a-f44fb565167d) @BluetoothBaseTest.bt_test_wrap @@ -279,7 +280,8 @@ class BtBasicFunctionalityTest(BluetoothBaseTest): Priority: 1 """ self.log.debug("Test scan mode SCAN_MODE_NONE.") - return set_bt_scan_mode(self.droid_ad, bt_scan_mode_types['none']) + return set_bt_scan_mode(self.droid_ad, + BluetoothScanModeType.SCAN_MODE_NONE) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='cb998a99-31a6-46b6-9de6-a9a17081a604') @@ -305,7 +307,7 @@ class BtBasicFunctionalityTest(BluetoothBaseTest): """ self.log.debug("Test scan mode SCAN_MODE_CONNECTABLE.") return set_bt_scan_mode(self.droid_ad, - bt_scan_mode_types['connectable']) + BluetoothScanModeType.SCAN_MODE_CONNECTABLE) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='59bec55c-c64e-43e4-9a9a-e44408a801d7') @@ -330,8 +332,9 @@ class BtBasicFunctionalityTest(BluetoothBaseTest): Priority: 2 """ self.log.debug("Test scan mode SCAN_MODE_CONNECTABLE_DISCOVERABLE.") - return set_bt_scan_mode(self.droid_ad, - bt_scan_mode_types['connectable_discoverable']) + return set_bt_scan_mode( + self.droid_ad, + BluetoothScanModeType.SCAN_MODE_CONNECTABLE_DISCOVERABLE) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='cd20a09d-a68d-4f55-b016-ba283b0460df') diff --git a/acts/tests/google/bt/BtFactoryResetTest.py b/acts/tests/google/bt/BtFactoryResetTest.py index ed25566cb5..c2968e3bf6 100644 --- a/acts/tests/google/bt/BtFactoryResetTest.py +++ b/acts/tests/google/bt/BtFactoryResetTest.py @@ -54,7 +54,7 @@ class BtFactoryResetTest(BluetoothBaseTest): TAGS: Bluetooth, Factory Reset Priority: 2 """ - if not pair_pri_to_sec(self.pri_dut, self.sec_dut, attempts=1): + if not pair_pri_to_sec(self.pri_dut, self.sec_dut, attemps=1): self.log.error("Failed to bond devices.") return False if not self.pri_dut.droid.bluetoothFactoryReset(): diff --git a/acts/tests/google/bt/BtKillProcessTest.py b/acts/tests/google/bt/BtKillProcessTest.py index 7a9eed7c07..eedca38e23 100644 --- a/acts/tests/google/bt/BtKillProcessTest.py +++ b/acts/tests/google/bt/BtKillProcessTest.py @@ -18,7 +18,6 @@ Test script to test if Bluetooth will reboot successfully if it is killed. """ -import re import time from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest @@ -32,10 +31,8 @@ class BtKillProcessTest(BluetoothBaseTest): def _get_bt_pid(self): process_grep_string = "com.android.bluetooth" awk = "awk '{print $2}'" - pid = self.dut.adb.shell("ps | grep com.android.bluetooth") - if not pid: - return None - return (re.findall("\d+\W", pid)[0]) + return (self.dut.adb.shell("ps | grep {} | {}".format( + process_grep_string, awk)).decode('ascii')) def _is_bt_process_running(self): if self._get_bt_pid(): diff --git a/acts/tests/google/bt/RfcommTest.py b/acts/tests/google/bt/RfcommTest.py index cdd53ee710..c1d78d8d1f 100644 --- a/acts/tests/google/bt/RfcommTest.py +++ b/acts/tests/google/bt/RfcommTest.py @@ -24,7 +24,6 @@ import time from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import bt_rfcomm_uuids from acts.test_utils.bt.bt_test_utils import clear_bonded_devices from acts.test_utils.bt.bt_test_utils import kill_bluetooth_process from acts.test_utils.bt.bt_test_utils import orchestrate_rfcomm_connection @@ -223,7 +222,7 @@ class RfcommTest(BluetoothBaseTest): self.server_ad.droid.bluetoothStartPairingHelper() self.client_ad.droid.bluetoothStartPairingHelper() self.server_ad.droid.bluetoothRfcommBeginAcceptThread( - bt_rfcomm_uuids['default_uuid'], short_socket_timeout) + RfcommUuid.DEFAULT_UUID.value, short_socket_timeout) time.sleep(wait_time_before_connect_attempt) # Try to connect @@ -263,8 +262,8 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'base_uuid']) + return self._test_rfcomm_connection_with_uuid( + RfcommUuid.BASE_UUID.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='42c8d861-48b3-423b-ae8c-df140ebaad9d') @@ -289,7 +288,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['sdp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.SDP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='97cc310d-4096-481e-940f-abe6811784f3') @@ -314,7 +313,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['udp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.UDP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='5998a0cf-fc05-433a-abd8-c52717ea755c') @@ -339,8 +338,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'rfcomm']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.RFCOMM.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='e3c05357-99ec-4819-86e4-1363e3359317') @@ -365,7 +363,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['tcp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.TCP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='7304f8dc-f568-4489-9926-0b940ba7a45b') @@ -390,8 +388,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'tcs_bin']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.TCS_BIN.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='ea1cfc32-d3f0-4420-a8e5-793c6ddf5820') @@ -416,8 +413,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'tcs_at']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.TCS_AT.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='5b0d5608-38a5-48f7-b3e5-dc52a4a681dd') @@ -442,7 +438,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['att']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.ATT.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='e81f37ba-e914-4eb1-b144-b079f91c6734') @@ -467,7 +463,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['obex']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.OBEX.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='5edd766f-17fb-459c-985e-9c21afe1b104') @@ -492,7 +488,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['ip']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.IP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='7a429cca-bc65-4344-8fa5-13ca0d49a351') @@ -517,7 +513,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['ftp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.FTP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='a8ecdd7b-8529-4e0b-ad18-0d0cf61f4b02') @@ -542,7 +538,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['http']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.HTTP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='816569e6-6189-45b5-95c3-ea27b69698ff') @@ -567,7 +563,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['wsp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.WSP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='cd5e8c87-4df9-4f1d-ae0b-b47f84c75e44') @@ -592,7 +588,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['bnep']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.BNEP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='fda073d3-d856-438b-b208-61cce67689dd') @@ -617,7 +613,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['upnp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.UPNP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='0ab329bb-ef61-4574-a5c1-440fb45938ff') @@ -642,7 +638,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['hidp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.HIDP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='5b1d8c64-4f92-4a22-b61b-28b1a1086b39') @@ -667,8 +663,8 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'hardcopy_control_channel']) + return self._test_rfcomm_connection_with_uuid( + RfcommUuid.HARDCOPY_CONTROL_CHANNEL.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='1ae6ca34-87ab-48ad-8da8-98c997538af4') @@ -693,8 +689,8 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'hardcopy_data_channel']) + return self._test_rfcomm_connection_with_uuid( + RfcommUuid.HARDCOPY_DATA_CHANNEL.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='d18ed311-a533-4306-944a-6f0f95eac141') @@ -719,8 +715,8 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'hardcopy_notification']) + return self._test_rfcomm_connection_with_uuid( + RfcommUuid.HARDCOPY_NOTIFICATION.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='ab0af819-7d26-451d-8275-1119ee3c8df8') @@ -745,7 +741,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['avctp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.AVCTP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='124b545e-e842-433d-b541-9710a139c8fb') @@ -770,7 +766,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['avdtp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.AVDTP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='aea354b9-2ba5-4d7e-90a9-b637cb2fd48c') @@ -795,7 +791,7 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['cmtp']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.CMTP.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='b547b8d9-6453-41af-959f-8bc0d9a6c89a') @@ -820,8 +816,8 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'mcap_control_channel']) + return self._test_rfcomm_connection_with_uuid( + RfcommUuid.MCAP_CONTROL_CHANNEL.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='ba3ab84c-bc61-442c-944c-af4fbca157f1') @@ -846,8 +842,8 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids[ - 'mcap_data_channel']) + return self._test_rfcomm_connection_with_uuid( + RfcommUuid.MCAP_DATA_CHANNEL.value) @BluetoothBaseTest.bt_test_wrap @test_tracker_info(uuid='d6c7523d-9247-480e-8154-edd51ae1be50') @@ -872,4 +868,4 @@ class RfcommTest(BluetoothBaseTest): TAGS: Classic, RFCOMM Priority: 3 """ - return self._test_rfcomm_connection_with_uuid(bt_rfcomm_uuids['l2cap']) + return self._test_rfcomm_connection_with_uuid(RfcommUuid.L2CAP.value) diff --git a/acts/tests/google/bt/SonyXB2PairingTest.py b/acts/tests/google/bt/SonyXB2PairingTest.py deleted file mode 100644 index 3bb2ae7168..0000000000 --- a/acts/tests/google/bt/SonyXB2PairingTest.py +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" -Test pairing of an Android Device to a Sony XB2 Bluetooth speaker -""" -import logging -import time - -from acts.controllers.relay_lib.relay import SynchronizeRelays -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest - -log = logging - - -class SonyXB2PairingTest(BluetoothBaseTest): - DISCOVERY_TIME = 5 - - def __init__(self, controllers): - BluetoothBaseTest.__init__(self, controllers) - self.dut = self.android_devices[0] - # Do factory reset and then do delay for 3-seconds - self.dut.droid.bluetoothFactoryReset() - time.sleep(3) - self.sony_xb2_speaker = self.relay_devices[0] - - def setup_test(self): - super(BluetoothBaseTest, self).setup_test() - self.sony_xb2_speaker.setup() - self.sony_xb2_speaker.power_on() - # Wait for a moment between pushing buttons - time.sleep(0.25) - self.sony_xb2_speaker.enter_pairing_mode() - - def teardown_test(self): - super(BluetoothBaseTest, self).teardown_test() - self.sony_xb2_speaker.power_off() - self.sony_xb2_speaker.clean_up() - - def _perform_classic_discovery(self, scan_time=DISCOVERY_TIME): - self.dut.droid.bluetoothStartDiscovery() - time.sleep(scan_time) - self.dut.droid.bluetoothCancelDiscovery() - return self.dut.droid.bluetoothGetDiscoveredDevices() - - @BluetoothBaseTest.bt_test_wrap - def test_speaker_on(self): - """Test if the Sony XB2 speaker is powered on. - - Use scanning to determine if the speaker is powered on. - - Steps: - 1. Put the speaker into pairing mode. (Hold the button) - 2. Perform a scan on the DUT - 3. Check the scan list for the device. - - Expected Result: - Speaker is found. - - Returns: - Pass if True - Fail if False - - TAGS: ACTS_Relay - Priority: 1 - """ - - for device in self._perform_classic_discovery(): - if device['address'] == self.sony_xb2_speaker.mac_address: - self.dut.log.info("Desired device with MAC address %s found!", - self.sony_xb2_speaker.mac_address) - return True - return False - - @BluetoothBaseTest.bt_test_wrap - def test_speaker_off(self): - """Test if the Sony XB2 speaker is powered off. - - Use scanning to determine if the speaker is powered off. - - Steps: - 1. Power down the speaker - 2. Put the speaker into pairing mode. (Hold the button) - 3. Perform a scan on the DUT - 4. Check the scan list for the device. - - Expected Result: - Speaker is not found. - - Returns: - Pass if True - Fail if False - - TAGS: ACTS_Relay - Priority: 1 - """ - # Specific part of the test, turn off the speaker - self.sony_xb2_speaker.power_off() - - device_not_found = True - for device in self._perform_classic_discovery(): - if device['address'] == self.sony_xb2_speaker.mac_address: - self.dut.log.info("Undesired device with MAC address %s found!", - self.sony_xb2_speaker.mac_address) - device_not_found = False - - # Set the speaker back to the normal for tear_down() - self.sony_xb2_speaker.power_on() - # Give the relay and speaker some time, before it is turned off. - time.sleep(5) - return device_not_found - - @BluetoothBaseTest.bt_test_wrap - def test_pairing(self): - """Test pairing between a phone and Sony XB2 speaker. - - Test the Sony XB2 speaker can be paired to phone. - - Steps: - 1. Find the MAC address of remote controller from relay config file. - 2. Start the device paring process. - 3. Enable remote controller in pairing mode. - 4. Verify the remote is paired. - - Expected Result: - Speaker is paired. - - Returns: - Pass if True - Fail if False - - TAGS: ACTS_Relay - Priority: 1 - """ - - # BT scan activity - self._perform_classic_discovery() - self.dut.droid.bluetoothDiscoverAndBond( - self.sony_xb2_speaker.mac_address) - - end_time = time.time() + 20 - self.dut.log.info("Verifying devices are bonded") - while (time.time() < end_time): - bonded_devices = self.dut.droid.bluetoothGetBondedDevices() - for d in bonded_devices: - if d['address'] == self.sony_xb2_speaker.mac_address: - self.dut.log.info("Successfully bonded to device.") - self.log.info( - "XB2 Bonded devices:\n{}".format(bonded_devices)) - return True - # Timed out trying to bond. - self.dut.log.info("Failed to bond devices.") - - return False diff --git a/acts/tests/google/bt/audio_lab/BtFunhausMetricsTest.py b/acts/tests/google/bt/audio_lab/BtFunhausMetricsTest.py index af1f1f86f0..4de60eaf4a 100644 --- a/acts/tests/google/bt/audio_lab/BtFunhausMetricsTest.py +++ b/acts/tests/google/bt/audio_lab/BtFunhausMetricsTest.py @@ -13,7 +13,6 @@ # the License. import time -from acts.test_decorators import test_tracker_info from acts import asserts from acts.test_utils.bt.BtFunhausBaseTest import BtFunhausBaseTest @@ -31,7 +30,6 @@ class BtFunhausMetricsTest(BtFunhausBaseTest): def setup_test(self): return super(BtFunhausMetricsTest, self).setup_test() - @test_tracker_info(uuid='b712ed0e-c1fb-4bc8-9dee-83891aa22205') def test_run_bt_audio(self): """Test run Bluetooth A2DP audio for one iteration @@ -81,7 +79,6 @@ class BtFunhausMetricsTest(BtFunhausBaseTest): delta=10000) return True - @test_tracker_info(uuid='ab6b8c61-057b-4bf6-b0cf-8bec3ae3a7eb') def test_run_multiple_bt_audio(self): """Test metrics for multiple Bluetooth audio sessions diff --git a/acts/tests/google/bt/audio_lab/BtFunhausTest.py b/acts/tests/google/bt/audio_lab/BtFunhausTest.py index 941d2b099c..dc25915abb 100644 --- a/acts/tests/google/bt/audio_lab/BtFunhausTest.py +++ b/acts/tests/google/bt/audio_lab/BtFunhausTest.py @@ -58,9 +58,8 @@ class BtFunhausTest(BtFunhausBaseTest): self.start_playing_music_on_all_devices() sleep_interval = 120 - #twelve_hours_in_seconds = 43200 - one_hour_in_seconds = 3600 - end_time = time.time() + one_hour_in_seconds + twelve_hours_in_seconds = 43200 + end_time = time.time() + twelve_hours_in_seconds status, bluetooth_off_list, device_not_connected_list = \ self.monitor_music_play_util_deadline(end_time, sleep_interval) if not status: diff --git a/acts/tests/google/bt/gatt/GattOverBrEdrTest.py b/acts/tests/google/bt/gatt/GattOverBrEdrTest.py index d0e0ad24cc..71b79d887c 100644 --- a/acts/tests/google/bt/gatt/GattOverBrEdrTest.py +++ b/acts/tests/google/bt/gatt/GattOverBrEdrTest.py @@ -18,15 +18,15 @@ Test suite for GATT over BR/EDR. """ import time -from queue import Empty from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import gatt_transport -from acts.test_utils.bt.bt_constants import gatt_cb_strings +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattService +from acts.test_utils.bt.GattEnum import GattTransport +from acts.test_utils.bt.GattEnum import MtuSize +from acts.test_utils.bt.GattEnum import GattCbStrings from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids @@ -91,7 +91,7 @@ class GattOverBrEdrTest(BluetoothBaseTest): def _find_service_added_event(self, gatt_server_callback, uuid): event = self.per_ad.ed.pop_event( - gatt_cb_strings['serv_added'].format(gatt_server_callback), + GattCbStrings.SERV_ADDED.value.format(gatt_server_callback), self.default_timeout) if event['data']['serviceUuid'].lower() != uuid.lower(): self.log.info("Uuid mismatch. Found: {}, Expected {}.".format( @@ -132,9 +132,10 @@ class GattOverBrEdrTest(BluetoothBaseTest): self.gatt_server_list.append(gatt_server) try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, - gatt_transport['bredr'], - self.per_droid_mac_address)) + orchestrate_gatt_connection( + self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR.value, + self.per_droid_mac_address)) self.bluetooth_gatt_list.append(bluetooth_gatt) except GattTestUtilsError as err: self.log.error(err) @@ -176,16 +177,17 @@ class GattOverBrEdrTest(BluetoothBaseTest): self.gatt_server_list.append(gatt_server) try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, - gatt_transport['bredr'], - self.per_droid_mac_address)) + orchestrate_gatt_connection( + self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR.value, + self.per_droid_mac_address)) self.bluetooth_gatt_list.append(bluetooth_gatt) except GattTestUtilsError as err: self.log.error(err) return False if self.cen_ad.droid.gattClientReadRSSI(bluetooth_gatt): self.cen_ad.ed.pop_event( - gatt_cb_strings['rd_remote_rssi'].format(gatt_callback), + GattCbStrings.RD_REMOTE_RSSI.value.format(gatt_callback), self.default_timeout) return self._orchestrate_gatt_disconnection(bluetooth_gatt, gatt_callback) @@ -224,9 +226,10 @@ class GattOverBrEdrTest(BluetoothBaseTest): self.gatt_server_list.append(gatt_server) try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, - gatt_transport['bredr'], - self.per_droid_mac_address)) + orchestrate_gatt_connection( + self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR.value, + self.per_droid_mac_address)) self.bluetooth_gatt_list.append(bluetooth_gatt) except GattTestUtilsError as err: self.log.error(err) @@ -234,7 +237,7 @@ class GattOverBrEdrTest(BluetoothBaseTest): discovered_services_index = -1 if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): event = self.cen_ad.ed.pop_event( - gatt_cb_strings['gatt_serv_disc'].format(gatt_callback), + GattCbStrings.GATT_SERV_DISC.value.format(gatt_callback), self.default_timeout) discovered_services_index = event['data']['ServicesIndex'] return self._orchestrate_gatt_disconnection(bluetooth_gatt, @@ -280,9 +283,10 @@ class GattOverBrEdrTest(BluetoothBaseTest): self.gatt_server_list.append(gatt_server) try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, - gatt_transport['bredr'], - self.per_droid_mac_address)) + orchestrate_gatt_connection( + self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR.value, + self.per_droid_mac_address)) self.bluetooth_gatt_list.append(bluetooth_gatt) except GattTestUtilsError as err: self.log.error(err) @@ -290,7 +294,7 @@ class GattOverBrEdrTest(BluetoothBaseTest): discovered_services_index = -1 if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): event = self.cen_ad.ed.pop_event( - gatt_cb_strings['gatt_serv_disc'].format(gatt_callback), + GattCbStrings.GATT_SERV_DISC.value.format(gatt_callback), self.default_timeout) discovered_services_index = event['data']['ServicesIndex'] log_gatt_server_uuids(self.cen_ad, discovered_services_index) @@ -339,9 +343,10 @@ class GattOverBrEdrTest(BluetoothBaseTest): return False try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, - gatt_transport['bredr'], - self.per_droid_mac_address)) + orchestrate_gatt_connection( + self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR.value, + self.per_droid_mac_address)) self.bluetooth_gatt_list.append(bluetooth_gatt) except GattTestUtilsError as err: self.log.error(err) @@ -349,7 +354,7 @@ class GattOverBrEdrTest(BluetoothBaseTest): discovered_services_index = -1 if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): event = self.cen_ad.ed.pop_event( - gatt_cb_strings['gatt_serv_disc'].format(gatt_callback), + GattCbStrings.GATT_SERV_DISC.value.format(gatt_callback), self.default_timeout) discovered_services_index = event['data']['ServicesIndex'] log_gatt_server_uuids(self.cen_ad, discovered_services_index) @@ -393,9 +398,10 @@ class GattOverBrEdrTest(BluetoothBaseTest): for i in range(20): try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, - gatt_transport['bredr'], - self.per_droid_mac_address)) + orchestrate_gatt_connection( + self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR.value, + self.per_droid_mac_address)) self.bluetooth_gatt_list.append(bluetooth_gatt) except GattTestUtilsError as err: self.log.error(err) @@ -446,9 +452,10 @@ class GattOverBrEdrTest(BluetoothBaseTest): return False try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, - gatt_transport['bredr'], - self.per_droid_mac_address)) + orchestrate_gatt_connection( + self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR.value, + self.per_droid_mac_address)) self.bluetooth_gatt_list.append(bluetooth_gatt) except GattTestUtilsError as err: self.log.error(err) @@ -456,7 +463,7 @@ class GattOverBrEdrTest(BluetoothBaseTest): if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): try: event = self.cen_ad.ed.pop_event( - gatt_cb_strings['gatt_serv_disc'].format(gatt_callback), + GattCbStrings.GATT_SERV_DISC.value.format(gatt_callback), self.default_timeout) except Empty as err: self.log.error("Event not found: {}".format(err)) @@ -494,9 +501,9 @@ class GattOverBrEdrTest(BluetoothBaseTest): self.cen_ad.droid.gattClientWriteDescriptor( bluetooth_gatt, discovered_services_index, i, characteristic, descriptor) - event = self.per_ad.ed.pop_event(gatt_cb_strings[ - 'desc_write_req'].format(gatt_server_callback), - self.default_timeout) + event = self.per_ad.ed.pop_event( + GattCbStrings.DESC_WRITE_REQ.value.format( + gatt_server_callback), self.default_timeout) self.log.info( "onDescriptorWriteRequest event found: {}".format( event)) @@ -512,7 +519,7 @@ class GattOverBrEdrTest(BluetoothBaseTest): offset, test_value_return) self.log.info( "onDescriptorWrite event found: {}".format( - self.cen_ad.ed.pop_event(gatt_cb_strings[ - 'desc_write'].format( + self.cen_ad.ed.pop_event( + GattCbStrings.DESC_WRITE.value.format( gatt_callback), self.default_timeout))) return True diff --git a/acts/tests/google/bt/pan/BtPanTest.py b/acts/tests/google/bt/pan/BtPanTest.py index e0180199d4..26e9bcca83 100644 --- a/acts/tests/google/bt/pan/BtPanTest.py +++ b/acts/tests/google/bt/pan/BtPanTest.py @@ -22,7 +22,6 @@ tethering allowed. This device was not intended to run in a sheild box. """ -from acts.test_decorators import test_tracker_info from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.bt_test_utils import bluetooth_enabled_check from acts.test_utils.bt.bt_test_utils import orchestrate_and_verify_pan_connection @@ -38,7 +37,6 @@ class BtPanTest(BluetoothBaseTest): self.panu_dut = self.android_devices[1] @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='54f86e21-6d31-439c-bf57-426e9005cbc3') def test_pan_connection(self): """Test bluetooth PAN connection @@ -66,7 +64,6 @@ class BtPanTest(BluetoothBaseTest): self.panu_dut) @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='fa40a0b9-f326-4382-967a-fe4c73483a68') def test_pan_connection_then_disconnect(self): """Test bluetooth PAN connection then disconnect service diff --git a/acts/tests/google/bt/power/A2dpPowerTest.py b/acts/tests/google/bt/power/A2dpPowerTest.py index 05ba0a8f0a..1a00af4416 100644 --- a/acts/tests/google/bt/power/A2dpPowerTest.py +++ b/acts/tests/google/bt/power/A2dpPowerTest.py @@ -30,12 +30,11 @@ from acts import logger from acts.controllers import monsoon from acts.keys import Config from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest from acts.test_utils.bt.PowerBaseTest import PowerBaseTest from acts.test_utils.bt.bt_test_utils import bluetooth_enabled_check from acts.test_utils.bt.bt_test_utils import disable_bluetooth -from acts.controllers.relay_lib.sony_xb2_speaker import SonyXB2Speaker def push_file_to_device(ad, file_path, device_path, config_path): @@ -99,8 +98,12 @@ class A2dpPowerTest(PowerBaseTest): # LDAC playback quality constant for the codecs other than LDAC LDACBT_NONE = 0 - def _pair_by_config(self): + def setup_class(self): + + self.ad = self.android_devices[0] + bt_device_address = self.user_params["bt_device_address"] + # Push the bt_config.conf file to Android device # if it is specified in config file # so it can pair and connect automatically. @@ -120,19 +123,40 @@ class A2dpPowerTest(PowerBaseTest): if not push_file_to_device( self.ad, bt_config_path, bt_conf_path_dut, self.user_params[Config.key_config_path]): - self.log.error( - "Unable to push file {} to DUT.".format(bt_config_path)) + self.log.error("Unable to push file {} to DUT.".format( + bt_config_path)) self.log.info("Reboot") self.ad.reboot() + # Add music files to the Android device + music_path_dut = "/sdcard/Music/" + self.cd_quality_music_file = self.user_params["cd_quality_music_file"] + self.log.info("Push CD quality music file {}".format( + self.cd_quality_music_file)) + if not push_file_to_device(self.ad, self.cd_quality_music_file, + music_path_dut, + self.user_params[Config.key_config_path]): + self.log.error("Unable to push file {} to DUT.".format( + self.cd_quality_music_file)) + + self.hi_res_music_file = self.user_params["hi_res_music_file"] + self.log.info("Push Hi Res quality music file {}".format( + self.hi_res_music_file)) + if not push_file_to_device(self.ad, self.hi_res_music_file, + music_path_dut, + self.user_params[Config.key_config_path]): + self.log.error("Unable to find file {}.".format( + self.hi_res_music_file)) + if not bluetooth_enabled_check(self.ad): self.log.error("Failed to enable Bluetooth on DUT") return False # Verify Bluetooth device is connected - self.log.info("Waiting up to {} seconds for device to reconnect.". - format(self.WAIT_TIME)) + self.log.info( + "Waiting up to {} seconds for device to reconnect.".format( + self.WAIT_TIME)) start_time = time.time() result = False while time.time() < start_time + self.WAIT_TIME: @@ -142,102 +166,21 @@ class A2dpPowerTest(PowerBaseTest): break try: - self.ad.droid.bluetoothConnectBonded( - self.user_params["bt_device_address"]) + self.ad.droid.bluetoothConnectBonded(self.user_params[ + "bt_device_address"]) except Exception as err: self.log.error( "Failed to connect bonded device. Err: {}".format(err)) - if result is False: + if not result: self.log.error("No headset is connected") return False - return True - - def _discover_and_pair(self): - self.ad.droid.bluetoothStartDiscovery() - time.sleep(5) - self.ad.droid.bluetoothCancelDiscovery() - for device in self.ad.droid.bluetoothGetDiscoveredDevices(): - if device['address'] == self.a2dp_speaker.mac_address: - self.ad.droid.bluetoothDiscoverAndBond( - self.a2dp_speaker.mac_address) - end_time = time.time() + 20 - self.log.info("Verifying devices are bonded") - while (time.time() < end_time): - bonded_devices = self.ad.droid.bluetoothGetBondedDevices() - for d in bonded_devices: - if d['address'] == self.a2dp_speaker.mac_address: - self.log.info("Successfully bonded to device.") - self.log.info("XB2 Bonded devices:\n{}".format( - bonded_devices)) - return True - return False - - def setup_class(self): - self.ad = self.android_devices[0] - self.ad.droid.bluetoothFactoryReset() - # Factory reset requires a short delay to take effect - time.sleep(3) - - self.ad.log.info("Making sure BT phone is enabled here during setup") - if not bluetooth_enabled_check(self.ad): - self.log.error("Failed to turn Bluetooth on DUT") - # Give a breathing time of short delay to take effect - time.sleep(3) - - # Determine if we have a relay-based device - self.a2dp_speaker = None - if self.relay_devices[0]: - self.a2dp_speaker = self.relay_devices[0] - self.a2dp_speaker.setup() - # The device may be on, enter pairing mode. - self.a2dp_speaker.enter_pairing_mode() - if self._discover_and_pair() is False: - # The device is probably off, turn it on - self.a2dp_speaker.power_on() - time.sleep(0.25) - self.a2dp_speaker.enter_pairing_mode() - if self._discover_and_pair() is False: - self.log.info("Unable to pair to relay based device.") - return False - if len(self.ad.droid.bluetoothGetConnectedDevices()) == 0: - self.log.info("Not connected to relay based device.") - return False - else: - # No relay-based device used config - if self._pair_by_config() is False: - return False - - # Add music files to the Android device - music_path_dut = "/sdcard/Music/" - self.cd_quality_music_file = self.user_params["cd_quality_music_file"] - self.log.info( - "Push CD quality music file {}".format(self.cd_quality_music_file)) - if not push_file_to_device(self.ad, self.cd_quality_music_file, - music_path_dut, - self.user_params[Config.key_config_path]): - self.log.error("Unable to push file {} to DUT.".format( - self.cd_quality_music_file)) - - self.hi_res_music_file = self.user_params["hi_res_music_file"] - self.log.info( - "Push Hi Res quality music file {}".format(self.hi_res_music_file)) - if not push_file_to_device(self.ad, self.hi_res_music_file, - music_path_dut, - self.user_params[Config.key_config_path]): - self.log.error( - "Unable to find file {}.".format(self.hi_res_music_file)) # Then do other power testing setup in the base class # including start PMC etc super(A2dpPowerTest, self).setup_class() return True - def teardown_class(self): - if self.a2dp_speaker is not None: - self.a2dp_speaker.power_off() - self.a2dp_speaker.clean_up() - def _main_power_test_function_for_codec(self, codec_type, sample_rate, @@ -278,13 +221,13 @@ class A2dpPowerTest(PowerBaseTest): # Get the base name of music file music_name = os.path.basename(music_file) self.music_url = "file:///sdcard/Music/{}".format(music_name) - play_time = (self.MEASURE_TIME + self.DELAY_MEASURE_TIME + - self.DELAY_STOP_TIME) + play_time = self.MEASURE_TIME + self.DELAY_MEASURE_TIME + +self.DELAY_STOP_TIME play_msg = "%s --es MusicURL %s --es PlayTime %d" % ( self.PMC_BASE_CMD, self.music_url, play_time) if bt_off_mute == True: - msg = "%s --es BT_OFF_Mute %d" % (play_msg, 1) + msg = "%s --es BT_OFF_Mute %d" % (playing_msg, 1) else: codec1_msg = "%s --es CodecType %d --es SampleRate %d" % ( play_msg, codec_type, sample_rate) @@ -292,17 +235,14 @@ class A2dpPowerTest(PowerBaseTest): bits_per_sample) if codec_type == self.CODEC_LDAC: msg = "%s --es LdacPlaybackQuality %d" % ( - codec_msg, ldac_playback_quality) + play_msg, ldac_playback_quality) else: msg = codec_msg self.ad.log.info("Send broadcast message: %s", msg) self.ad.adb.shell(msg) # Check if PMC is ready - status_msg = "READY" - if bt_on_not_play == True: - status_msg = "SUCCEED" - if not self.check_pmc_status(self.LOG_FILE, status_msg, + if not self.check_pmc_status(self.LOG_FILE, "READY", "PMC is not ready"): return diff --git a/acts/tests/google/bt/pts/ble_lib.py b/acts/tests/google/bt/pts/ble_lib.py index f8ff402b62..508b351eaf 100644 --- a/acts/tests/google/bt/pts/ble_lib.py +++ b/acts/tests/google/bt/pts/ble_lib.py @@ -17,12 +17,12 @@ Ble libraries """ -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import small_timeout +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseTxPower +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.bt_test_utils import TIMEOUT_SMALL from acts.test_utils.bt.bt_test_utils import adv_fail -from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_test_utils import adv_succ from acts.test_utils.bt.bt_test_utils import advertising_set_on_own_address_read from acts.test_utils.bt.bt_test_utils import advertising_set_started from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects @@ -47,7 +47,7 @@ class BleLib(): adv_succ.format(advertise_callback), adv_fail.format(advertise_callback)) try: - event = self.dut.ed.pop_events(regex, 5, small_timeout) + event = self.dut.ed.pop_events(regex, 5, TIMEOUT_SMALL) except Empty: self.dut.log.error("Failed to get success or failed event.") return @@ -64,7 +64,7 @@ class BleLib(): if line: scan_response = bool(line) self.dut.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) self.dut.droid.bleSetAdvertiseSettingsIsConnectable(True) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.dut.droid)) @@ -76,21 +76,28 @@ class BleLib(): self.dut.droid.bleStartBleAdvertising( advertise_callback, advertise_data, advertise_settings) if self._verify_ble_adv_started(advertise_callback): - self.log.info("Tracking Callback ID: {}".format( - advertise_callback)) + self.log.info( + "Tracking Callback ID: {}".format(advertise_callback)) self.advertisement_list.append(advertise_callback) self.log.info(self.advertisement_list) def start_connectable_advertisement_set(self, line): """Start Connectable Advertisement Set""" adv_callback = self.dut.droid.bleAdvSetGenCallback() - adv_data = {"includeDeviceName": True, } + adv_data = { + "includeDeviceName": True, + } self.dut.droid.bleAdvSetStartAdvertisingSet({ - "connectable": True, - "legacyMode": False, - "primaryPhy": "PHY_LE_1M", - "secondaryPhy": "PHY_LE_1M", - "interval": 320 + "connectable": + True, + "legacyMode": + False, + "primaryPhy": + "PHY_LE_1M", + "secondaryPhy": + "PHY_LE_1M", + "interval": + 320 }, adv_data, None, None, None, 0, 0, adv_callback) evt = self.dut.ed.pop_event( advertising_set_started.format(adv_callback), self.default_timeout) @@ -144,15 +151,15 @@ class BleLib(): def start_generic_nonconnectable_advertisement(self, line): """Start a nonconnectable LE advertisement""" self.dut.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY.value) self.dut.droid.bleSetAdvertiseSettingsIsConnectable(False) advertise_callback, advertise_data, advertise_settings = ( generate_ble_advertise_objects(self.dut.droid)) self.dut.droid.bleStartBleAdvertising( advertise_callback, advertise_data, advertise_settings) if self._verify_ble_adv_started(advertise_callback): - self.log.info("Tracking Callback ID: {}".format( - advertise_callback)) + self.log.info( + "Tracking Callback ID: {}".format(advertise_callback)) self.advertisement_list.append(advertise_callback) self.log.info(self.advertisement_list) @@ -164,7 +171,7 @@ class BleLib(): time.sleep(1) self.advertisement_list = [] - def ble_stop_advertisement(self, callback_id): + def do_ble_stop_advertisement(self, callback_id): """Stop an LE advertisement""" if not callback_id: self.log.info("Need a callback ID") diff --git a/acts/tests/google/bt/pts/bta_lib.py b/acts/tests/google/bt/pts/bta_lib.py index f75ff6bd03..e1147ec169 100644 --- a/acts/tests/google/bt/pts/bta_lib.py +++ b/acts/tests/google/bt/pts/bta_lib.py @@ -17,7 +17,7 @@ Bluetooth adapter libraries """ -from acts.test_utils.bt.bt_constants import bt_scan_mode_types +from acts.test_utils.bt.BtEnum import BluetoothScanModeType from acts.test_utils.bt.bt_test_utils import set_bt_scan_mode import pprint @@ -32,7 +32,7 @@ class BtaLib(): def set_scan_mode(self, scan_mode): """Set the Scan mode of the Bluetooth Adapter""" - for mode in bt_scan_mode_types: + for mode in BluetoothScanModeType: if scan_mode == mode.name: set_bt_scan_mode(self.dut, mode.value) return @@ -100,11 +100,3 @@ class BtaLib(): def fetch_uuids_with_sdp(self): """BTA fetch UUIDS with SDP""" self.log.info(self.dut.droid.bluetoothFetchUuidsWithSdp(self.mac_addr)) - - def connect_profiles(self): - """Connect available profiles""" - self.dut.droid.bluetoothConnectBonded(self.mac_addr) - - def tts_speak(self): - """Open audio channel by speaking characters""" - self.dut.droid.ttsSpeak(self.mac_addr) diff --git a/acts/tests/google/bt/pts/cmd_input.py b/acts/tests/google/bt/pts/cmd_input.py index e1579b2a12..736b1c97e8 100644 --- a/acts/tests/google/bt/pts/cmd_input.py +++ b/acts/tests/google/bt/pts/cmd_input.py @@ -324,14 +324,6 @@ class CmdInput(cmd.Cmd): except Exception as err: self.log.info(FAILURE.format(cmd, err)) - def do_gattc_read_all_desc(self, line): - """Read all Descriptor values""" - cmd = "Read all Descriptor values" - try: - self.gattc_lib.read_all_desc() - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - """End GATT Client wrappers""" """Begin GATT Server wrappers""" @@ -345,8 +337,8 @@ class CmdInput(cmd.Cmd): def complete_gatts_setup_database(self, text, line, begidx, endidx): if not text: - completions = list(gatt_test_database.GATT_SERVER_DB_MAPPING.keys( - ))[:] + completions = list( + gatt_test_database.GATT_SERVER_DB_MAPPING.keys())[:] else: completions = [ s for s in gatt_test_database.GATT_SERVER_DB_MAPPING.keys() @@ -593,7 +585,7 @@ class CmdInput(cmd.Cmd): """Stop an LE advertisement""" cmd = "Stop a connectable LE advertisement" try: - self.ble_lib.ble_stop_advertisement(line) + self.do_ble_stop_advertisement(line) except Exception as err: self.log.info(FAILURE.format(cmd, err)) @@ -736,21 +728,6 @@ class CmdInput(cmd.Cmd): except Exception as err: self.log.info(FAILURE.format(cmd, err)) - def do_bta_connect_profiles(self, line): - """Connect available profiles""" - cmd = "Connect all profiles possible" - try: - self.bta_lib.connect_profiles() - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_bta_tts_speak(self, line): - cmd = "Open audio channel by speaking characters" - try: - self.bta_lib.tts_speak() - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - """End Bta wrappers""" """Begin Rfcomm wrappers""" @@ -848,111 +825,3 @@ class CmdInput(cmd.Cmd): self.log.info(FAILURE.format(cmd, err)) """End Config wrappers""" - """Begin HFP/HSP wrapper""" - - def do_bta_hsp_force_sco_audio_on(self, line): - """HFP/HSP Force SCO Audio ON""" - cmd = "HFP/HSP Force SCO Audio ON" - try: - if not self.pri_dut.droid.bluetoothHspForceScoAudio(True): - self.log.info( - FAILURE.format(cmd, - "bluetoothHspForceScoAudio returned false")) - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_bta_hsp_force_sco_audio_off(self, line): - """HFP/HSP Force SCO Audio OFF""" - cmd = "HFP/HSP Force SCO Audio OFF" - try: - if not self.pri_dut.droid.bluetoothHspForceScoAudio(False): - self.log.info( - FAILURE.format(cmd, - "bluetoothHspForceScoAudio returned false")) - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_bta_hsp_connect_audio(self, line): - """HFP/HSP connect audio""" - cmd = "HFP/HSP connect audio" - try: - if not self.pri_dut.droid.bluetoothHspConnectAudio(self.mac_addr): - self.log.info( - FAILURE.format( - cmd, "bluetoothHspConnectAudio returned false for " + - self.mac_addr)) - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_bta_hsp_disconnect_audio(self, line): - """HFP/HSP disconnect audio""" - cmd = "HFP/HSP disconnect audio" - try: - if not self.pri_dut.droid.bluetoothHspDisconnectAudio( - self.mac_addr): - self.log.info( - FAILURE.format( - cmd, "bluetoothHspDisconnectAudio returned false for " - + self.mac_addr)) - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_bta_hsp_connect_slc(self, line): - """HFP/HSP connect SLC with additional tries and help""" - cmd = "Connect to hsp with some help" - try: - if not self.connect_hsp_helper(self.pri_dut): - self.log.error("Failed to connect to HSP") - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_bta_hsp_disconnect_slc(self, line): - """HFP/HSP disconnect SLC""" - cmd = "HFP/HSP disconnect SLC" - try: - if not self.pri_dut.droid.bluetoothHspDisconnect(self.mac_addr): - self.log.info( - FAILURE.format( - cmd, "bluetoothHspDisconnect returned false for " + - self.mac_addr)) - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - """End HFP/HSP wrapper""" - """Begin HID wrappers""" - - def do_hid_get_report(self, line): - """Get HID Report""" - cmd = "Get HID Report" - try: - self.pri_dut.droid.bluetoothHidGetReport(self.mac_addr, "1", "1", - 1024) - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_hid_set_report(self, line): - """Get HID Report""" - cmd = "Get HID Report" - try: - self.pri_dut.droid.bluetoothHidSetReport(self.mac_addr, "1", - "Test") - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_hid_virtual_unplug(self, line): - """Get HID Report""" - cmd = "Get HID Report" - try: - self.pri_dut.droid.bluetoothHidVirtualUnplug(self.mac_addr) - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - def do_hid_send_report(self, line): - """Get HID Report""" - cmd = "Get HID Report" - try: - self.pri_dut.droid.bluetoothHidSendData(device_id, "42") - except Exception as err: - self.log.info(FAILURE.format(cmd, err)) - - """End HID wrappers""" diff --git a/acts/tests/google/bt/pts/config_lib.py b/acts/tests/google/bt/pts/config_lib.py index cffc466fd1..01796926e3 100644 --- a/acts/tests/google/bt/pts/config_lib.py +++ b/acts/tests/google/bt/pts/config_lib.py @@ -20,6 +20,9 @@ Bluetooth Config Pusher from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattTransport from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids import time diff --git a/acts/tests/google/bt/pts/gatt_test_database.py b/acts/tests/google/bt/pts/gatt_test_database.py index 360fbd7ff2..eeb1481f0d 100644 --- a/acts/tests/google/bt/pts/gatt_test_database.py +++ b/acts/tests/google/bt/pts/gatt_test_database.py @@ -15,12 +15,11 @@ # the License. from acts.test_utils.bt.GattEnum import CharacteristicValueFormat -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import gatt_char_types -from acts.test_utils.bt.bt_constants import gatt_characteristic_value_format -from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattService +from acts.test_utils.bt.GattEnum import GattCharTypes +from acts.test_utils.bt.GattEnum import GattCharDesc STRING_512BYTES = ''' 11111222223333344444555556666677777888889999900000 @@ -44,51 +43,84 @@ STRING_25BYTES = ''' INVALID_SMALL_DATABASE = { 'services': [{ - 'uuid': '00001800-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '00001800-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': gatt_char_types['device_name'], - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'instance_id': 0x0003, - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'Test Database' + 'uuid': + GattCharTypes.GATT_CHARAC_DEVICE_NAME.value, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'instance_id': + 0x0003, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'Test Database' }, { - 'uuid': gatt_char_types['appearance'], - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'instance_id': 0x0005, - 'value_type': gatt_characteristic_value_format['sint32'], - 'offset': 0, - 'value': 17 + 'uuid': + GattCharTypes.GATT_CHARAC_APPEARANCE.value, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'instance_id': + 0x0005, + 'value_type': + CharacteristicValueFormat.FORMAT_SINT32.value, + 'offset': + 0, + 'value': + 17 }, { - 'uuid': gatt_char_types['peripheral_pref_conn'], - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'instance_id': 0x0007 + 'uuid': + GattCharTypes.GATT_CHARAC_PERIPHERAL_PREF_CONN.value, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'instance_id': + 0x0007 }] }, { - 'uuid': '00001801-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '00001801-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': GattCharTypes.GATT_CHARAC_SERVICE_CHANGED.value, - 'properties': gatt_characteristic['property_indicate'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'instance_id': 0x0012, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + GattCharTypes.GATT_CHARAC_SERVICE_CHANGED.value, + 'properties': + GattCharacteristic.PROPERTY_INDICATE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'instance_id': + 0x0012, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x0000], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CLIENT_CHARAC_CFG_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + GattCharDesc.GATT_CLIENT_CHARAC_CFG_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, }] }, { - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'instance_id': 0x0015, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'instance_id': + 0x0015, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04] }] }] @@ -98,159 +130,242 @@ INVALID_SMALL_DATABASE = { LARGE_DB_1 = { 'services': [ { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 7, + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 7, 'characteristics': [{ - 'uuid': '0000b008-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'] | - gatt_characteristic['property_extended_props'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b008-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_EXTENDED_PROPS.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x08], 'descriptors': [{ - 'uuid': '0000b015-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b015-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, }, { - 'uuid': '0000b016-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b016-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, }, { - 'uuid': '0000b017-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'] | - gatt_characteristic['permission_read_encrypted_mitm'], + 'uuid': + '0000b017-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM.value, }] }] }, { - 'uuid': '0000a00d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['secondary'], - 'handles': 6, + 'uuid': + '0000a00d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_SECONDARY.value, + 'handles': + 6, 'characteristics': [{ - 'uuid': '0000b00c-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_extended_props'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00c-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_EXTENDED_PROPS.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x0C], }, { - 'uuid': '0000b00b-0000-0000-0123-456789abcdef', - 'properties': gatt_characteristic['property_extended_props'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00b-0000-0000-0123-456789abcdef', + 'properties': + GattCharacteristic.PROPERTY_EXTENDED_PROPS.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x0B], }] }, { - 'uuid': '0000a00a-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 10, + 'uuid': + '0000a00a-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 10, 'characteristics': [{ - 'uuid': '0000b001-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b001-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x01], }, { - 'uuid': '0000b002-0000-0000-0123-456789abcdef', - 'properties': gatt_characteristic['property_extended_props'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': STRING_512BYTES, + 'uuid': + '0000b002-0000-0000-0123-456789abcdef', + 'properties': + GattCharacteristic.PROPERTY_EXTENDED_PROPS.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + STRING_512BYTES, }, { - 'uuid': '0000b004-0000-0000-0123-456789abcdef', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': STRING_512BYTES, + 'uuid': + '0000b004-0000-0000-0123-456789abcdef', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + STRING_512BYTES, }, { - 'uuid': '0000b002-0000-0000-0123-456789abcdef', - 'properties': gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '11111222223333344444555556666677777888889999900000', + 'uuid': + '0000b002-0000-0000-0123-456789abcdef', + 'properties': + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '11111222223333344444555556666677777888889999900000', }, { - 'uuid': '0000b003-0000-0000-0123-456789abcdef', - 'properties': gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b003-0000-0000-0123-456789abcdef', + 'properties': + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x03], }] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 3, + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 3, 'characteristics': [{ - 'uuid': '0000b007-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b007-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x07], }] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 3, + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 3, 'characteristics': [{ - 'uuid': '0000b006-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'] | - gatt_characteristic['property_write_no_response'] | - gatt_characteristic['property_notify'] | - gatt_characteristic['property_indicate'], - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b006-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_WRITE_NO_RESPONSE.value | + GattCharacteristic.PROPERTY_NOTIFY.value | + GattCharacteristic.PROPERTY_INDICATE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x06], }] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 12, + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 12, 'characteristics': [ { - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], }, { - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_SERVER_CHARAC_CFG_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + GattCharDesc.GATT_SERVER_CHARAC_CFG_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': GattDescriptor.DISABLE_NOTIFICATION_VALUE.value }] }, { - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'properties': 0x0, - 'permissions': 0x0, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'properties': + 0x0, + 'permissions': + 0x0, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], 'descriptors': [{ - 'uuid': '0000b012-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b012-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, @@ -262,14 +377,20 @@ LARGE_DB_1 = { }] }, { - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], 'descriptors': [{ - 'uuid': '0000b012-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + '0000b012-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, @@ -283,222 +404,320 @@ LARGE_DB_1 = { ] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 7, + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 7, 'characteristics': [{ - 'uuid': '0000b005-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_write'] | - gatt_characteristic['property_extended_props'], - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b005-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_EXTENDED_PROPS.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x05], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x03, 0x00] }, { - 'uuid': GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x90 ] }, { - 'uuid': GattCharDesc.GATT_CHARAC_FMT_UUID.value, + 'uuid': + GattCharDesc.GATT_CHARAC_FMT_UUID.value, 'permissions': GattDescriptor.PERMISSION_READ_ENCRYPTED_MITM.value, 'value': [0x00, 0x01, 0x30, 0x01, 0x11, 0x31] }, { - 'uuid': '0000d5d4-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + '0000d5d4-0000-0000-0123-456789abcdef', + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x44] }] }] }, { - 'uuid': '0000a00c-0000-0000-0123-456789abcdef', - 'type': gatt_service_types['primary'], - 'handles': 7, + 'uuid': + '0000a00c-0000-0000-0123-456789abcdef', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 7, 'characteristics': [{ - 'uuid': '0000b009-0000-0000-0123-456789abcdef', - 'properties': gatt_characteristic['property_write'] | - gatt_characteristic['property_extended_props'] | - gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b009-0000-0000-0123-456789abcdef', + 'properties': + GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_EXTENDED_PROPS.value | + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x09], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, - 'permissions': gatt_descriptor['permission_read'], - 'value': gatt_descriptor['enable_notification_value'] + 'uuid': + GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, + 'value': + GattDescriptor.ENABLE_NOTIFICATION_VALUE.value }, { - 'uuid': '0000d9d2-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000d9d2-0000-0000-0123-456789abcdef', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { - 'uuid': '0000d9d3-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_write'], + 'uuid': + '0000d9d3-0000-0000-0123-456789abcdef', + 'permissions': + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x33] }] }] }, { - 'uuid': '0000a00f-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 18, + 'uuid': + '0000a00f-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 18, 'characteristics': [ { - 'uuid': '0000b00e-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "Length is ", + 'uuid': + '0000b00e-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "Length is ", 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_FMT_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x19, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00] }] }, { - 'uuid': '0000b00f-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00f-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x65], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_FMT_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x04, 0x00, 0x01, 0x27, 0x01, 0x01, 0x00] }] }, { - 'uuid': '0000b006-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b006-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x34, 0x12], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_FMT_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x06, 0x00, 0x10, 0x27, 0x01, 0x02, 0x00] }] }, { - 'uuid': '0000b007-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b007-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04, 0x03, 0x02, 0x01], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_FMT_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x08, 0x00, 0x17, 0x27, 0x01, 0x03, 0x00] }] }, { - 'uuid': '0000b010-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b010-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x65, 0x34, 0x12, 0x04, 0x03, 0x02, 0x01], 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_AGREG_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_AGREG_FMT_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0xa6, 0x00, 0xa9, 0x00, 0xac, 0x00] }] }, { - 'uuid': '0000b011-0000-1000-8000-00805f9b34fb', - 'properties': GattCharacteristic.WRITE_TYPE_SIGNED.value + 'uuid': + '0000b011-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.WRITE_TYPE_SIGNED.value | #for some reason 0x40 is not working... - gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x12] } ] }, { - 'uuid': '0000a00c-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 30, + 'uuid': + '0000a00c-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 30, 'characteristics': [{ - 'uuid': '0000b00a-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00a-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x0a], }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "111112222233333444445", + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "111112222233333444445", 'descriptors': [{ - 'uuid': '0000b012-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b012-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11 ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "2222233333444445555566", + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "2222233333444445555566", 'descriptors': [{ - 'uuid': '0000b013-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b013-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11, 0x22 ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "33333444445555566666777", + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "33333444445555566666777", 'descriptors': [{ - 'uuid': '0000b014-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b014-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11, 0x22, 0x33 ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, @@ -507,9 +726,11 @@ LARGE_DB_1 = { 0x11, 0x22, 0x33 ], 'descriptors': [{ - 'uuid': '0000b012-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b012-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, @@ -519,12 +740,16 @@ LARGE_DB_1 = { ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, @@ -533,9 +758,11 @@ LARGE_DB_1 = { 0x11, 0x22, 0x33, 0x44 ], 'descriptors': [{ - 'uuid': '0000b013-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b013-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, @@ -545,12 +772,16 @@ LARGE_DB_1 = { ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, @@ -559,9 +790,11 @@ LARGE_DB_1 = { 0x11, 0x22, 0x33, 0x44, 0x55 ], 'descriptors': [{ - 'uuid': '0000b014-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b014-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, @@ -571,17 +804,24 @@ LARGE_DB_1 = { ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "1111122222333334444455555666667777788888999", + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "1111122222333334444455555666667777788888999", 'descriptors': [{ - 'uuid': '0000b012-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b012-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, @@ -591,17 +831,24 @@ LARGE_DB_1 = { ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "22222333334444455555666667777788888999990000", + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "22222333334444455555666667777788888999990000", 'descriptors': [{ - 'uuid': '0000b013-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b013-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, @@ -611,17 +858,24 @@ LARGE_DB_1 = { ] }] }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "333334444455555666667777788888999990000011111", + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "333334444455555666667777788888999990000011111", 'descriptors': [{ - 'uuid': '0000b014-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b014-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, @@ -639,103 +893,168 @@ LARGE_DB_1 = { LARGE_DB_2 = { 'services': [ { - 'uuid': '0000a00c-0000-0000-0123-456789abdcef', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00c-0000-0000-0123-456789abdcef', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b00a-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0003, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00a-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0003, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], }, { - 'uuid': '0000b0002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0005, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '111112222233333444445', + 'uuid': + '0000b0002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0005, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '111112222233333444445', }, { - 'uuid': '0000b0002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0007, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '2222233333444445555566', + 'uuid': + '0000b0002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0007, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '2222233333444445555566', }, { - 'uuid': '0000b0002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0009, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '33333444445555566666777', + 'uuid': + '0000b0002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0009, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '33333444445555566666777', }, { - 'uuid': '0000b0002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x000b, - 'properties': 0x0a0, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '1111122222333334444455555666667777788888999', + 'uuid': + '0000b0002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x000b, + 'properties': + 0x0a0, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '1111122222333334444455555666667777788888999', }, { - 'uuid': '0000b0002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x000d, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '22222333334444455555666667777788888999990000', + 'uuid': + '0000b0002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x000d, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '22222333334444455555666667777788888999990000', }, { - 'uuid': '0000b0002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x000f, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'uuid': + '0000b0002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x000f, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }] }, { - 'uuid': '0000a00c-0000-0000-0123-456789abcdef', - 'handles': 5, - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00c-0000-0000-0123-456789abcdef', + 'handles': + 5, + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b009-0000-0000-0123-456789abcdef', - 'instance_id': 0x0023, - 'properties': 0x8a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b009-0000-0000-0123-456789abcdef', + 'instance_id': + 0x0023, + 'properties': + 0x8a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x09], 'descriptors': [{ - 'uuid': '0000d9d2-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000d9d2-0000-0000-0123-456789abcdef', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { - 'uuid': '0000d9d3-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_write'], + 'uuid': + '0000d9d3-0000-0000-0123-456789abcdef', + 'permissions': + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x33] }, { - 'uuid': GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, - 'permissions': gatt_descriptor['permission_write'], - 'value': gatt_descriptor['enable_notification_value'] + 'uuid': + GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_WRITE.value, + 'value': + GattDescriptor.ENABLE_NOTIFICATION_VALUE.value }] }] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b007-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0012, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b007-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0012, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], }] }, @@ -744,269 +1063,309 @@ LARGE_DB_2 = { DB_TEST = { 'services': [{ - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'characteristics': [{ - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], - 'value': [0x01], - 'descriptors': [{ - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], - 'value': [0x01] * 30 - }] - }, ] + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'characteristics': [ + { + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, + 'value': [0x01], + 'descriptors': [{ + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, + 'value': [0x01] * 30 + }] + }, + ] }] } PTS_TEST2 = { 'services': [{ - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [ { 'uuid': '000018ba-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000060aa-0000-0000-0123-456789abcdef', 'properties': 0x02, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '00000af2-0000-1000-8000-00805f9b34fb', 'properties': 0x20, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', 'properties': 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000004d5e-0000-1000-8000-00805f9b34fb', 'properties': 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000001b44-0000-1000-8000-00805f9b34fb', 'properties': 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000006b98-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08 | 0x10 | 0x04, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '00000247f-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '00000247f-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '00000247f-0000-1000-8000-00805f9b34fb', 'properties': 0x00, 'permissions': 0x00, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '00000247f-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000000d62-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08 | 0x80, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000002e85-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000004a64-0000-0000-0123-456789abcdef', 'properties': 0x02 | 0x08 | 0x80, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000005b4a-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000001c81-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000006b98-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000001b44-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000000c55-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '0000014dd-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000000c55-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000000c55-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000000c55-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000000c55-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '00000008f-0000-1000-8000-00805f9b34fb', 'properties': 0x02, 'permissions': 0x10, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { - 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '000000af2-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32 ], }, { - 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '000000af2-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32 ], }, { - 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '000000af2-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32 ], }, { - 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '000000af2-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32 ], }, { - 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '000000af2-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32 ], }, { - 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '000000af2-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32 ], }, { - 'uuid': '000000af2-0000-1000-8000-00805f9b34fb', - 'properties': 0x02 | 0x08, - 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '000000af2-0000-1000-8000-00805f9b34fb', + 'properties': + 0x02 | 0x08, + 'permissions': + 0x10 | 0x01, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32 @@ -1016,21 +1375,21 @@ PTS_TEST2 = { 'uuid': '000002aad-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000002ab0-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, { 'uuid': '000002ab3-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_512BYTES, }, ] @@ -1039,21 +1398,23 @@ PTS_TEST2 = { PTS_TEST = { 'services': [{ - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [ { 'uuid': '000018ba-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_25BYTES, }, { 'uuid': '000060aa-0000-1000-8000-00805f9b34fb', 'properties': 0x02 | 0x08, 'permissions': 0x10 | 0x01, - 'value_type': gatt_characteristic_value_format['string'], + 'value_type': CharacteristicValueFormat.STRING.value, 'value': STRING_25BYTES, }, ] @@ -1064,432 +1425,627 @@ PTS_TEST = { LARGE_DB_3 = { 'services': [ { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [ { - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0003, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0003, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], }, { - 'uuid': '0000b004-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0013, - 'properties': 0x10, - 'permissions': 0x17, - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b004-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0013, + 'properties': + 0x10, + 'permissions': + 0x17, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x04], 'descriptors': [ { 'uuid': GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x09] }, { 'uuid': GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { 'uuid': GattCharDesc.GATT_CLIENT_CHARAC_CFG_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x01, 0x00] }, { 'uuid': GattCharDesc.GATT_SERVER_CHARAC_CFG_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { - 'uuid': GattCharDesc.GATT_CHARAC_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + GattCharDesc.GATT_CHARAC_FMT_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { 'uuid': GattCharDesc.GATT_CHARAC_AGREG_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { 'uuid': GattCharDesc.GATT_CHARAC_VALID_RANGE_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { 'uuid': GattCharDesc.GATT_EXTERNAL_REPORT_REFERENCE.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { - 'uuid': GattCharDesc.GATT_REPORT_REFERENCE.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + GattCharDesc.GATT_REPORT_REFERENCE.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, ] }, { - 'uuid': GattCharTypes.GATT_CHARAC_SERVICE_CHANGED.value, - 'instance_id': 0x0023, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'uuid': + GattCharTypes.GATT_CHARAC_SERVICE_CHANGED.value, + 'instance_id': + 0x0023, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { - 'uuid': gatt_char_types['appearance'], - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'uuid': + GattCharTypes.GATT_CHARAC_APPEARANCE.value, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_PERIPHERAL_PRIV_FLAG.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_RECONNECTION_ADDRESS.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { - 'uuid': GattCharTypes.GATT_CHARAC_SYSTEM_ID.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'uuid': + GattCharTypes.GATT_CHARAC_SYSTEM_ID.value, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_MODEL_NUMBER_STRING.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_SERIAL_NUMBER_STRING.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_FIRMWARE_REVISION_STRING.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_HARDWARE_REVISION_STRING.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_SOFTWARE_REVISION_STRING.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { 'uuid': GattCharTypes.GATT_CHARAC_MANUFACTURER_NAME_STRING.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, { - 'uuid': GattCharTypes.GATT_CHARAC_PNP_ID.value, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'uuid': + GattCharTypes.GATT_CHARAC_PNP_ID.value, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, ] }, { - 'uuid': '0000a00d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['secondary'], - 'handles': 5, + 'uuid': + '0000a00d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_SECONDARY.value, + 'handles': + 5, 'characteristics': [{ - 'uuid': '0000b00c-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0023, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00c-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0023, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x0c], }, { - 'uuid': '0000b00b-0000-0000-0123-456789abcdef', - 'instance_id': 0x0025, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00b-0000-0000-0123-456789abcdef', + 'instance_id': + 0x0025, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x0b], }] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b008-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0032, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b008-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0032, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x08], }] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b007-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0042, - 'properties': gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b007-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0042, + 'properties': + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x07], }] }, { - 'uuid': '0000a00b-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b006-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0052, - 'properties': 0x3e, - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b006-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0052, + 'properties': + 0x3e, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x06], }] }, { - 'uuid': '0000a00a-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 10, + 'uuid': + '0000a00a-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 10, 'characteristics': [{ - 'uuid': '0000b001-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0074, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b001-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0074, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x01], }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0076, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '11111222223333344444555556666677777888889999900000', + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0076, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '11111222223333344444555556666677777888889999900000', }, { - 'uuid': '0000b003-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x0078, - 'properties': gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b003-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x0078, + 'properties': + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x03], }] }, { - 'uuid': '0000a00c-0000-0000-0123-456789abcdef', - 'type': gatt_service_types['primary'], - 'handles': 10, + 'uuid': + '0000a00c-0000-0000-0123-456789abcdef', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 10, 'characteristics': [{ - 'uuid': '0000b009-0000-0000-0123-456789abcdef', - 'instance_id': 0x0082, - 'properties': 0x8a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b009-0000-0000-0123-456789abcdef', + 'instance_id': + 0x0082, + 'properties': + 0x8a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x09], 'descriptors': [ { - 'uuid': '0000b009-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000b009-0000-0000-0123-456789abcdef', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x09] }, { - 'uuid': '0000d9d2-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '0000d9d2-0000-0000-0123-456789abcdef', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, { 'uuid': GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'permissions': GattDescriptor.PERMISSION_READ.value, 'value': [0x01, 0x00] }, { 'uuid': '0000d9d3-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_write'], + 'permissions': GattDescriptor.PERMISSION_WRITE.value, 'value': [0x22] }, ] }] }, { - 'uuid': '0000a00b-0000-0000-0123-456789abcdef', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00b-0000-0000-0123-456789abcdef', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b009-0000-0000-0123-456789abcdef', - 'instance_id': 0x0092, - 'properties': 0x8a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b009-0000-0000-0123-456789abcdef', + 'instance_id': + 0x0092, + 'properties': + 0x8a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x05], 'descriptors': [ { - 'uuid': GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, 'value': [0] * 26 }, { 'uuid': GattCharDesc.GATT_CHARAC_EXT_PROPER_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'permissions': GattDescriptor.PERMISSION_READ.value, 'value': [0x03, 0x00] }, { 'uuid': '0000d5d4-0000-0000-0123-456789abcdef', - 'permissions': gatt_descriptor['permission_read'], + 'permissions': GattDescriptor.PERMISSION_READ.value, 'value': [0x44] }, { 'uuid': GattCharDesc.GATT_CHARAC_FMT_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'permissions': GattDescriptor.PERMISSION_READ.value, 'value': [0x04, 0x00, 0x01, 0x30, 0x01, 0x11, 0x31] }, ] }] }, { - 'uuid': '0000a00c-0000-0000-0123-456789abcdef', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00c-0000-0000-0123-456789abcdef', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [ { 'uuid': '0000b00a-0000-1000-8000-00805f9b34fb', 'instance_id': 0x00a2, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'properties': GattCharacteristic.PROPERTY_READ.value, + 'permissions': GattCharacteristic.PERMISSION_READ.value, + 'value_type': CharacteristicValueFormat.BYTE.value, 'value': [0x0a], }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x00a4, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '111112222233333444445', + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x00a4, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '111112222233333444445', }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x00a6, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '2222233333444445555566', + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x00a6, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '2222233333444445555566', }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x00a8, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '33333444445555566666777', + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x00a8, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '33333444445555566666777', }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x00aa, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '1111122222333334444455555666667777788888999', + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x00aa, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '1111122222333334444455555666667777788888999', }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x00ac, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '22222333334444455555666667777788888999990000', + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x00ac, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '22222333334444455555666667777788888999990000', }, { - 'uuid': '0000b002-0000-1000-8000-00805f9b34fb', - 'instance_id': 0x00ae, - 'properties': 0x0a, - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': '333334444455555666667777788888999990000011111', + 'uuid': + '0000b002-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0x00ae, + 'properties': + 0x0a, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + '333334444455555666667777788888999990000011111', }, ] }, { - 'uuid': '0000a00e-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00e-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': '0000b00d-0000-1000-8000-00805f9b34fb', - 'instance_id': 0xffff, - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + '0000b00d-0000-1000-8000-00805f9b34fb', + 'instance_id': + 0xffff, + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x0d], }] }, @@ -1498,21 +2054,32 @@ LARGE_DB_3 = { TEST_DB_1 = { 'services': [{ - 'uuid': '0000180d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 4, + 'uuid': + '0000180d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 4, 'characteristics': [{ - 'uuid': '00002a29-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'test', - 'instance_id': 0x002a, + 'uuid': + '00002a29-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'test', + 'instance_id': + 0x002a, 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x01] }] }] @@ -1521,81 +2088,124 @@ TEST_DB_1 = { TEST_DB_2 = { 'services': [{ - 'uuid': '0000180d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 4, + 'uuid': + '0000180d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 4, 'characteristics': [{ - 'uuid': '00002a29-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], + 'uuid': + '00002a29-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, 'permissions': - gatt_characteristic['permission_read_encrypted_mitm'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'test', - 'instance_id': 0x002a, + GattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'test', + 'instance_id': + 0x002a, }, { - 'uuid': '00002a30-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], + 'uuid': + '00002a30-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, 'permissions': - gatt_characteristic['permission_read_encrypted_mitm'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'test', - 'instance_id': 0x002b, + GattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'test', + 'instance_id': + 0x002b, }] }] } TEST_DB_3 = { 'services': [{ - 'uuid': '0000180d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 4, + 'uuid': + '0000180d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 4, 'characteristics': [{ - 'uuid': '00002a29-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'test', - 'instance_id': 0x002a, + 'uuid': + '00002a29-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'test', + 'instance_id': + 0x002a, 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x01] }, { - 'uuid': '00002a20-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], - 'instance_id': 0x002c, + 'uuid': + '00002a20-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, + 'instance_id': + 0x002c, 'value': [0x01] }] }, { - 'uuid': '00002a30-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'] | - gatt_characteristic['property_write'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'test', - 'instance_id': 0x002b, + 'uuid': + '00002a30-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_WRITE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'test', + 'instance_id': + 0x002b, }] }] } TEST_DB_4 = { 'services': [{ - 'uuid': '0000180d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 4, + 'uuid': + '0000180d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 4, 'characteristics': [{ - 'uuid': '00002a29-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_write_no_response'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': "test", - 'instance_id': 0x002a, + 'uuid': + '00002a29-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_WRITE_NO_RESPONSE.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + "test", + 'instance_id': + 0x002a, 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, + 'uuid': + GattCharDesc.GATT_CHARAC_USER_DESC_UUID.value, 'permissions': GattDescriptor.PERMISSION_READ_ENCRYPTED_MITM.value, 'value': [0] * 512 @@ -1606,22 +2216,31 @@ TEST_DB_4 = { TEST_DB_5 = { 'services': [{ - 'uuid': '0000180d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000180d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': 'b2c83efa-34ca-11e6-ac61-9e71128cae77', - 'properties': gatt_characteristic['property_write'] | - gatt_characteristic['property_read'] | - gatt_characteristic['property_notify'], - 'permissions': gatt_characteristic['permission_read'] | - gatt_characteristic['permission_write'], - 'value_type': gatt_characteristic_value_format['byte'], + 'uuid': + 'b2c83efa-34ca-11e6-ac61-9e71128cae77', + 'properties': + GattCharacteristic.PROPERTY_WRITE.value | + GattCharacteristic.PROPERTY_READ.value | + GattCharacteristic.PROPERTY_NOTIFY.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value | + GattCharacteristic.PERMISSION_WRITE.value, + 'value_type': + CharacteristicValueFormat.BYTE.value, 'value': [0x1], - 'instance_id': 0x002c, + 'instance_id': + 0x002c, 'descriptors': [{ - 'uuid': '00002902-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'] | - gatt_descriptor['permission_write'], + 'uuid': + '00002902-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value | + GattDescriptor.PERMISSION_WRITE.value, }] }] }] @@ -1629,19 +2248,30 @@ TEST_DB_5 = { TEST_DB_6 = { 'services': [{ - 'uuid': '0000180d-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], - 'handles': 4, + 'uuid': + '0000180d-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, + 'handles': + 4, 'characteristics': [{ - 'uuid': '00002a29-0000-1000-8000-00805f9b34fb', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'test', - 'instance_id': 0x002a, + 'uuid': + '00002a29-0000-1000-8000-00805f9b34fb', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'test', + 'instance_id': + 0x002a, 'descriptors': [{ - 'uuid': '00002a19-0000-1000-8000-00805f9b34fb', - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + '00002a19-0000-1000-8000-00805f9b34fb', + 'permissions': + GattDescriptor.PERMISSION_READ.value, 'value': [0x01] * 30 }] }] @@ -1650,18 +2280,28 @@ TEST_DB_6 = { SIMPLE_READ_DESCRIPTOR = { 'services': [{ - 'uuid': '0000a00a-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00a-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': 'aa7edd5a-4d1d-4f0e-883a-d145616a1630', - 'properties': gatt_characteristic['property_read'], - 'permissions': gatt_characteristic['permission_read'], - 'instance_id': 0x002a, - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'Test Database', + 'uuid': + 'aa7edd5a-4d1d-4f0e-883a-d145616a1630', + 'properties': + GattCharacteristic.PROPERTY_READ.value, + 'permissions': + GattCharacteristic.PERMISSION_READ.value, + 'instance_id': + 0x002a, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'Test Database', 'descriptors': [{ - 'uuid': GattCharDesc.GATT_CLIENT_CHARAC_CFG_UUID.value, - 'permissions': gatt_descriptor['permission_read'], + 'uuid': + GattCharDesc.GATT_CLIENT_CHARAC_CFG_UUID.value, + 'permissions': + GattDescriptor.PERMISSION_READ.value, }] }] }] @@ -1669,43 +2309,71 @@ SIMPLE_READ_DESCRIPTOR = { CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE = { 'services': [{ - 'uuid': '0000a00a-0000-1000-8000-00805f9b34fb', - 'type': gatt_service_types['primary'], + 'uuid': + '0000a00a-0000-1000-8000-00805f9b34fb', + 'type': + GattService.SERVICE_TYPE_PRIMARY.value, 'characteristics': [{ - 'uuid': 'aa7edd5a-4d1d-4f0e-883a-d145616a1630', - 'properties': gatt_characteristic['property_write_no_response'], - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'instance_id': 0x0042, - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'Test Database' + 'uuid': + 'aa7edd5a-4d1d-4f0e-883a-d145616a1630', + 'properties': + GattCharacteristic.PROPERTY_WRITE_NO_RESPONSE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'instance_id': + 0x0042, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'Test Database' }, { - 'uuid': 'aa7edd6a-4d1d-4f0e-883a-d145616a1630', - 'properties': gatt_characteristic['property_write_no_response'], - 'permissions': gatt_characteristic['permission_write'] | - gatt_characteristic['permission_read'], - 'instance_id': 0x004d, - 'value_type': gatt_characteristic_value_format['string'], - 'value': 'Test Database' + 'uuid': + 'aa7edd6a-4d1d-4f0e-883a-d145616a1630', + 'properties': + GattCharacteristic.PROPERTY_WRITE_NO_RESPONSE.value, + 'permissions': + GattCharacteristic.PERMISSION_WRITE.value | + GattCharacteristic.PERMISSION_READ.value, + 'instance_id': + 0x004d, + 'value_type': + CharacteristicValueFormat.STRING.value, + 'value': + 'Test Database' }] }] } GATT_SERVER_DB_MAPPING = { - 'LARGE_DB_1': LARGE_DB_1, - 'LARGE_DB_3': LARGE_DB_3, - 'INVALID_SMALL_DATABASE': INVALID_SMALL_DATABASE, - 'SIMPLE_READ_DESCRIPTOR': SIMPLE_READ_DESCRIPTOR, + 'LARGE_DB_1': + LARGE_DB_1, + 'LARGE_DB_3': + LARGE_DB_3, + 'INVALID_SMALL_DATABASE': + INVALID_SMALL_DATABASE, + 'SIMPLE_READ_DESCRIPTOR': + SIMPLE_READ_DESCRIPTOR, 'CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE': CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE, - 'TEST_DB_1': TEST_DB_1, - 'TEST_DB_2': TEST_DB_2, - 'TEST_DB_3': TEST_DB_3, - 'TEST_DB_4': TEST_DB_4, - 'TEST_DB_5': TEST_DB_5, - 'LARGE_DB_3_PLUS': LARGE_DB_3, - 'DB_TEST': DB_TEST, - 'PTS_TEST': PTS_TEST, - 'PTS_TEST2': PTS_TEST2, - 'TEST_DB_6': TEST_DB_6, + 'TEST_DB_1': + TEST_DB_1, + 'TEST_DB_2': + TEST_DB_2, + 'TEST_DB_3': + TEST_DB_3, + 'TEST_DB_4': + TEST_DB_4, + 'TEST_DB_5': + TEST_DB_5, + 'LARGE_DB_3_PLUS': + LARGE_DB_3, + 'DB_TEST': + DB_TEST, + 'PTS_TEST': + PTS_TEST, + 'PTS_TEST2': + PTS_TEST2, + 'TEST_DB_6': + TEST_DB_6, } diff --git a/acts/tests/google/bt/pts/gattc_lib.py b/acts/tests/google/bt/pts/gattc_lib.py index 4bcb0f4b20..89718d6964 100644 --- a/acts/tests/google/bt/pts/gattc_lib.py +++ b/acts/tests/google/bt/pts/gattc_lib.py @@ -20,10 +20,9 @@ GATT Client Libraries from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_transport +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattTransport from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids import time @@ -46,13 +45,16 @@ class GattClientLib(): self.dut, self.mac_addr, autoconnect, - transport=gatt_transport['le']) + transport=GattTransport.TRANSPORT_LE.value) self.discovered_services_index = None def connect_over_bredr(self): """Perform GATT connection over BREDR""" self.bluetooth_gatt, self.gatt_callback = setup_gatt_connection( - self.dut, self.mac_addr, False, transport=gatt_transport['bredr']) + self.dut, + self.mac_addr, + False, + transport=GattTransport.TRANSPORT_BREDR.value) def disconnect(self): """Perform GATT disconnect""" @@ -69,7 +71,7 @@ class GattClientLib(): def _setup_discovered_services_index(self): if not self.discovered_services_index: self.dut.droid.gattClientDiscoverServices(self.bluetooth_gatt) - expected_event = gatt_cb_strings['gatt_serv_disc'].format( + expected_event = GattCbStrings.GATT_SERV_DISC.value.format( self.gatt_callback) event = self.dut.ed.pop_event(expected_event, 10) self.discovered_services_index = event['data']['ServicesIndex'] @@ -290,7 +292,7 @@ class GattClientLib(): self.dut.droid.gattClientWriteDescriptorByInstanceId( self.bluetooth_gatt, self.discovered_services_index, int(instance_id, 16), - gatt_descriptor['enable_notification_value']))) + GattDescriptor.ENABLE_NOTIFICATION_VALUE.value))) """ for i in range(services_count): characteristic_uuids = ( @@ -309,7 +311,7 @@ class GattClientLib(): self.dut.droid.gattClientDescriptorSetValueByIndex( self.bluetooth_gatt, self.discovered_services_index, i, j, k, - gatt_descriptor['enable_notification_value']) + GattDescriptor.ENABLE_NOTIFICATION_VALUE.value) time.sleep(2) #Necessary for PTS self.dut.droid.gattClientWriteDescriptorByIndex( self.bluetooth_gatt, @@ -370,32 +372,6 @@ class GattClientLib(): self.bluetooth_gatt, self.discovered_services_index, i, j) time.sleep(1) # Necessary for PTS - def read_all_desc(self): - """GATT Client read all Descriptor values""" - self._setup_discovered_services_index() - services_count = self.dut.droid.gattClientGetDiscoveredServicesCount( - self.discovered_services_index) - for i in range(services_count): - characteristic_uuids = ( - self.dut.droid.gattClientGetDiscoveredCharacteristicUuids( - self.discovered_services_index, i)) - for j in range(len(characteristic_uuids)): - descriptor_uuids = ( - self.dut.droid. - gattClientGetDiscoveredDescriptorUuidsByIndex( - self.discovered_services_index, i, j)) - for k in range(len(descriptor_uuids)): - time.sleep(1) - try: - self.log.info("Reading descriptor {}".format( - descriptor_uuids[k])) - self.dut.droid.gattClientReadDescriptorByIndex( - self.bluetooth_gatt, - self.discovered_services_index, i, j, k) - except Exception as err: - self.log.info("Failed to read to descriptor: {}". - format(descriptor_uuids[k])) - def write_all_char(self, line): """Write to every Characteristic on the GATT server""" args = line.split() @@ -410,6 +386,7 @@ class GattClientLib(): self.dut.droid.gattClientGetDiscoveredCharacteristicUuids( self.discovered_services_index, i)) for j in range(len(characteristic_uuids)): + time.sleep(1) char_inst_id = self.dut.droid.gattClientGetCharacteristicInstanceId( self.bluetooth_gatt, self.discovered_services_index, i, j) self.log.info("Writing to {} {}".format( @@ -421,7 +398,6 @@ class GattClientLib(): self.dut.droid.gattClientWriteCharacteristicByIndex( self.bluetooth_gatt, self.discovered_services_index, i, j) - time.sleep(1) except Exception as err: self.log.info("Failed to write to characteristic: {}". format(characteristic_uuids[j])) @@ -469,4 +445,4 @@ class GattClientLib(): if len(line) == 4: uuid = self.generic_uuid.format(line) self.dut.droid.gattClientDiscoverServiceByUuid(self.bluetooth_gatt, - uuid) + uuid)
\ No newline at end of file diff --git a/acts/tests/google/bt/pts/gatts_lib.py b/acts/tests/google/bt/pts/gatts_lib.py index 2e3a8f99b8..d87cb59d6e 100644 --- a/acts/tests/google/bt/pts/gatts_lib.py +++ b/acts/tests/google/bt/pts/gatts_lib.py @@ -19,13 +19,15 @@ import os from acts.keys import Config from acts.utils import rand_ascii_str -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_cb_err -from acts.test_utils.bt.bt_constants import gatt_transport -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_server_responses -from acts.test_utils.bt.bt_constants import gatt_service_types +from acts.test_utils.bt.GattEnum import CharacteristicValueFormat +from acts.test_utils.bt.GattEnum import GattCbStrings +from acts.test_utils.bt.GattEnum import GattCharacteristic +from acts.test_utils.bt.GattEnum import GattDescriptor +from acts.test_utils.bt.GattEnum import GattCbErr +from acts.test_utils.bt.GattEnum import GattTransport +from acts.test_utils.bt.GattEnum import GattEvent +from acts.test_utils.bt.GattEnum import GattServerResponses +from acts.test_utils.bt.GattEnum import GattService from acts.test_utils.bt.bt_test_utils import TIMEOUT_SMALL from gatt_test_database import STRING_512BYTES @@ -83,8 +85,8 @@ class GattServerLib(): for btgs in self.gatt_server_list: self.dut.droid.gattServerClose(btgs) except Exception as err: - self.log.error("Failed to close Bluetooth GATT Servers: {}".format( - err)) + self.log.error( + "Failed to close Bluetooth GATT Servers: {}".format(err)) self.characteristic_list = [] self.descriptor_list = [] self.gatt_server_list = [] @@ -107,22 +109,22 @@ class GattServerLib(): if len(args) == 2: user_input = args[0] mtu = int(args[1]) - desc_read = gatt_event['desc_read_req']['evt'].format( + desc_read = GattEvent.DESC_READ_REQ.value['evt'].format( self.gatt_server_callback) - desc_write = gatt_event['desc_write_req']['evt'].format( + desc_write = GattEvent.DESC_WRITE_REQ.value['evt'].format( self.gatt_server_callback) - char_read = gatt_event['char_read_req']['evt'].format( + char_read = GattEvent.CHAR_READ_REQ.value['evt'].format( self.gatt_server_callback) - char_write = gatt_event['char_write']['evt'].format( + char_write = GattEvent.CHAR_WRITE_REQ.value['evt'].format( self.gatt_server_callback) - execute_write = gatt_event['exec_write']['evt'].format( + execute_write = GattEvent.EXEC_WRITE.value['evt'].format( self.gatt_server_callback) regex = "({}|{}|{}|{}|{})".format(desc_read, desc_write, char_read, char_write, execute_write) events = self.dut.ed.pop_events(regex, 5, TIMEOUT_SMALL) status = 0 if user_input: - status = gatt_server_responses.get(user_input) + status = GattServerResponses.get(user_input) for event in events: self.log.debug("Found event: {}.".format(event)) request_id = event['data']['requestId'] @@ -131,8 +133,8 @@ class GattServerLib(): event['data']['execute'] == True): for key in self.write_mapping: value = self.write_mapping[key] - self.log.info("Writing key, value: {}, {}".format( - key, value)) + self.log.info( + "Writing key, value: {}, {}".format(key, value)) self.dut.droid.gattServerSetByteArrayValueByInstanceId( key, value) else: @@ -148,8 +150,8 @@ class GattServerLib(): event['data']['preparedWrite'] == True): value = event['data']['value'] if instance_id in self.write_mapping.keys(): - self.write_mapping[instance_id] = self.write_mapping[ - instance_id] + value + self.write_mapping[ + instance_id] = self.write_mapping[instance_id] + value self.log.info( "New Prepared Write Value for {}: {}".format( instance_id, self.write_mapping[instance_id])) @@ -157,8 +159,8 @@ class GattServerLib(): self.log.info("write mapping key, value {}, {}".format( instance_id, value)) self.write_mapping[instance_id] = value - self.log.info("current value {}, {}".format( - instance_id, value)) + self.log.info( + "current value {}, {}".format(instance_id, value)) self.dut.droid.gattServerSendResponse( self.gatt_server, 0, request_id, status, 0, value) continue @@ -182,8 +184,8 @@ class GattServerLib(): self.gatt_server, 0, request_id, status, offset, data) def _setup_service(self, serv): - service = self.dut.droid.gattServerCreateService(serv['uuid'], - serv['type']) + service = self.dut.droid.gattServerCreateService( + serv['uuid'], serv['type']) if 'handles' in serv: self.dut.droid.gattServerServiceSetHandlesToReserve( service, serv['handles']) @@ -205,11 +207,11 @@ class GattServerLib(): if 'value_type' in char: value_type = char['value_type'] value = char['value'] - if value_type == gatt_characteristic_value_format['string']: + if value_type == CharacteristicValueFormat.STRING.value: self.log.info("Set String value result: {}".format( self.dut.droid.gattServerCharacteristicSetStringValue( characteristic, value))) - elif value_type == gatt_characteristic_value_format['byte']: + elif value_type == CharacteristicValueFormat.BYTE.value: self.log.info("Set Byte Array value result: {}".format( self.dut.droid.gattServerCharacteristicSetByteValue( characteristic, value))) @@ -223,8 +225,8 @@ class GattServerLib(): descriptor = self.dut.droid.gattServerCreateBluetoothGattDescriptor( desc['uuid'], desc['permissions']) if 'value' in desc: - self.dut.droid.gattServerDescriptorSetByteValue(descriptor, - desc['value']) + self.dut.droid.gattServerDescriptorSetByteValue( + descriptor, desc['value']) if 'instance_id' in desc: self.dut.droid.gattServerDescriptorSetInstanceId( descriptor, desc['instance_id']) @@ -253,21 +255,21 @@ class GattServerLib(): self.dut.droid.gattServerAddCharacteristicToService( service, characteristic) self.dut.droid.gattServerAddService(self.gatt_server, service) - expected_event = gatt_cb_strings['serv_added'].format( + expected_event = GattCbStrings.SERV_ADDED.value.format( self.gatt_server_callback) self.dut.ed.pop_event(expected_event, 10) def send_continuous_response(self, user_input): """Send the same response""" - desc_read = gatt_event['desc_read_req']['evt'].format( + desc_read = GattEvent.DESC_READ_REQ.value['evt'].format( self.gatt_server_callback) - desc_write = gatt_event['desc_write_req']['evt'].format( + desc_write = GattEvent.DESC_WRITE_REQ.value['evt'].format( self.gatt_server_callback) - char_read = gatt_event['char_read_req']['evt'].format( + char_read = GattEvent.CHAR_READ_REQ.value['evt'].format( self.gatt_server_callback) - char_write = gatt_event['char_write']['evt'].format( + char_write = GattEvent.CHAR_WRITE_REQ.value['evt'].format( self.gatt_server_callback) - execute_write = gatt_event['char_exec_write']['evt'].format( + execute_write = GattEvent.CHAR_EXEC_WRITE.value['evt'].format( self.gatt_server_callback) regex = "({}|{}|{}|{}|{})".format(desc_read, desc_write, char_read, char_write, execute_write) @@ -300,15 +302,15 @@ class GattServerLib(): def send_continuous_response_data(self, user_input): """Send the same response with data""" - desc_read = gatt_event['desc_read_req']['evt'].format( + desc_read = GattEvent.DESC_READ_REQ.value['evt'].format( self.gatt_server_callback) - desc_write = gatt_event['desc_write_req']['evt'].format( + desc_write = GattEvent.DESC_WRITE_REQ.value['evt'].format( self.gatt_server_callback) - char_read = gatt_event['char_read_req']['evt'].format( + char_read = GattEvent.CHAR_READ_REQ.value['evt'].format( self.gatt_server_callback) - char_write = gatt_event['char_write']['evt'].format( + char_write = GattEvent.CHAR_WRITE_REQ.value['evt'].format( self.gatt_server_callback) - execute_write = gatt_event['exec_write']['evt'].format( + execute_write = GattEvent.EXEC_WRITE.value['evt'].format( self.gatt_server_callback) regex = "({}|{}|{}|{}|{})".format(desc_read, desc_write, char_read, char_write, execute_write) @@ -347,8 +349,7 @@ class GattServerLib(): value = event['data']['value'] if instance_id in self.write_mapping: self.write_mapping[ - instance_id] = self.write_mapping[ - instance_id] + value + instance_id] = self.write_mapping[instance_id] + value else: self.write_mapping[instance_id] = value else: diff --git a/acts/tests/google/bt/pts/instructions/DID_PTS_INSTRUCTIONS b/acts/tests/google/bt/pts/instructions/DID_PTS_INSTRUCTIONS deleted file mode 100644 index 0038cbbb5c..0000000000 --- a/acts/tests/google/bt/pts/instructions/DID_PTS_INSTRUCTIONS +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -DID -================================================================= - -TC_SR_SDI_BV_01_I - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE - -TC_SR_SDI_BV_02_I - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE - -TC_SR_SDI_BV_03_I - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE - -TC_SR_SDI_BV_04_I - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE diff --git a/acts/tests/google/bt/pts/instructions/GAP_PTS_INSTRUCTIONS b/acts/tests/google/bt/pts/instructions/GAP_PTS_INSTRUCTIONS index 47da157e27..16c5b23cbb 100644 --- a/acts/tests/google/bt/pts/instructions/GAP_PTS_INSTRUCTIONS +++ b/acts/tests/google/bt/pts/instructions/GAP_PTS_INSTRUCTIONS @@ -268,7 +268,7 @@ Note: Run the test a first time and it will fail. Change the address to be the peer address in the PTS logs that start with: SEC_LE?SEC_LE_REMOTE_CSRK_REQUEST_IND=PDU peerAddr: 'xxxxxxxxxxxx'O -TC_BOND_BON_BV_03 +BOND_BON_BV_03 config_reset Note: Send conenction request before pairing happens gattc_connect_over_le @@ -284,15 +284,6 @@ TC_BOND_BON_BV_04_C gattc_connect_over_le bta_unbond -TC_SEC_AUT_BV_11_C - ble_start_pairing_helper - gatts_setup_database LARGE_DB_3 - ble_start_generic_connectable_advertisement - gatts_send_response GATT_INSUFFICIENT_AUTHENTICATION - [PTS interaction] Enter pin from PTS to phone - gatts_send_response GATT_SUCCESS - [Wait 30 seconds for PTS to complete] - Note: Run the test a first time and it will fail. Change the address to be the peer address in the PTS logs that start with: SEC_LE?SEC_LE_REMOTE_CSRK_REQUEST_IND=PDU @@ -318,7 +309,7 @@ Note: Run the test a first time and it will fail. Change the address to be the peer address in the PTS logs that start with: SEC_LE?SEC_LE_REMOTE_CSRK_REQUEST_IND=PDU peerAddr: 'xxxxxxxxxxxx'O -TC_SEC_AUT_BV_17_C +SEC_AUT_BV_17_C Use PEER Address config_set_disable_mitm gatts_setup_database LARGE_DB_1 @@ -329,7 +320,7 @@ TC_SEC_AUT_BV_17_C bta_bond gattc_read_char_by_instance_id 7 -TC_SEC_AUT_BV_18_C +SEC_AUT_BV_18_C Use LE address config_set_disable_mitm gatts_setup_database LARGE_DB_1 @@ -343,25 +334,7 @@ TC_ADV_BV_01_C ble_adv_add_service_uuid_list 1802 1801 ble_start_generic_connectable_advertisement true -Note: Very flacky -Note: Run the test a first time and it will fail. Change the address to -be the peer address in the PTS logs that start with: - SEC_LE?SEC_LE_REMOTE_CSRK_REQUEST_IND=PDU - peerAddr: 'xxxxxxxxxxxx'O -TC_SEC_AUT_BV_19_C - config_set_disable_mtim - gattc_connect_over_le - bta_bond - [PTS Interaction] Press OK to disconnect - Note: Before PTS asks you to reconnect via gatt, perform next two commands quickly - bta_unbond - gattc_disconnect - gattc_connect_over_le - gattc_list_all_uuids - gattc_read_all_char - gattc_disconnect - -TC_SEC_AUT_BV_20_C +SEC_AUT_BV_20_C Note: Set IXIT value requires MITM to false config_set_disable_mitm bta_start_pairing_helper false diff --git a/acts/tests/google/bt/pts/instructions/GATT_PTS_INSTRUCTIONS b/acts/tests/google/bt/pts/instructions/GATT_PTS_INSTRUCTIONS index fe20ea8ce1..b2a9af4be8 100644 --- a/acts/tests/google/bt/pts/instructions/GATT_PTS_INSTRUCTIONS +++ b/acts/tests/google/bt/pts/instructions/GATT_PTS_INSTRUCTIONS @@ -254,6 +254,9 @@ TC_CL_GAR_BI_17_C [PTS Interaction] gattc_disconnect +TC_CL_GAR_BV_05_C + n_a - Need to be able to read multiple char instance ids in the same request + TC_CL_GAR_BV_06_C gattc_connect_over_le gattc_mod_read_desc_by_instance_id [handle] diff --git a/acts/tests/google/bt/pts/instructions/GAVDP_PTS_INSTRUCTIONS b/acts/tests/google/bt/pts/instructions/GAVDP_PTS_INSTRUCTIONS deleted file mode 100644 index 02da89add3..0000000000 --- a/acts/tests/google/bt/pts/instructions/GAVDP_PTS_INSTRUCTIONS +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -GAVDP -================================================================= - -TC_ACP_APP_CON_BV_01_C - bta_start_pairing_helper - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE - bta_tts_speak - -TC_ACP_APP_TRC_BV_02_C - bta_start_pairing_helper - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE - bta_connect_profiles - bta_tts_speak - -TC_INT_APP_CONN_BV_01_C - bta_start_pairing_helper - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE - bta_connect_profiles - bta_tts_speak - -TC_INT_APP_TRC_BV_02_C - bta_start_pairing_helper - bta_set_scan_mode SCAN_MODE_CONNECTABLE_DISCOVERABLE - bta_connect_profiles - bta_tts_speak - bta_tts_speak
\ No newline at end of file diff --git a/acts/tests/google/bt/pts/instructions/HOGP_PTS_INSTRUCTIONS b/acts/tests/google/bt/pts/instructions/HOGP_PTS_INSTRUCTIONS index 810bedfd68..7fca99ef29 100644 --- a/acts/tests/google/bt/pts/instructions/HOGP_PTS_INSTRUCTIONS +++ b/acts/tests/google/bt/pts/instructions/HOGP_PTS_INSTRUCTIONS @@ -15,127 +15,6 @@ HOGP ================================================================= -TC_RH_HGDS_BV_01_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - -TC_RH_HGDS_BV_02_C - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - -TC_RH_HGDS_BV_03_C - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_01_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_02_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_03_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_04_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_05_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_06_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_07_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_14_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_15_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - [PTS Interaction] Verify values - -TC_RH_HGCD_BV_16_I - bta_start_pairing_helper - bta_bond - bta_get_pairing_pin - [PTS Interaction] Enter PIN from phone to PTS - bta_disconnect - [PTS Interaction] Verify values - TC_RH_HGRF_BV_01_I bta_start_pairing_helper bta_bond diff --git a/acts/tests/google/bt/pts/instructions/SCPP_PTS_INSTRUCTIONS b/acts/tests/google/bt/pts/instructions/SCPP_PTS_INSTRUCTIONS deleted file mode 100644 index dae40f439d..0000000000 --- a/acts/tests/google/bt/pts/instructions/SCPP_PTS_INSTRUCTIONS +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -ScPP -================================================================= - -TC_SCPP_CL_SPDS_BV_01_I - gattc_connect_over_le - gattc_disconnect - [PTS Interaction] Verify values - -TC_SCPP_CL_SPDC_BV_01_I - gattc_connect_over_le - gattc_disconnect - [PTS Interaction] Verify values - -TC_SCPP_CL_SPDC_BV_02_I - gattc_connect_over_le - gattc_disconnect - [PTS Interaction] Verify values - -TC_SCPP_CL_SPDC_BV_03_I - gattc_connect_over_le - gattc_disconnect - [PTS Interaction] Verify values - -TC_SCPP_CL_SPWF_BV_01_I - Have NRF (nordic app installed and running) - gattc_connect_over_le - gattc_enable_notification_desc_by_instance_id 0075 - From nordic send a write command to the Scan Refresh Characteristic of any text value. - gattc_disconnect - -TC_SCPP_CL_SPCF_BV_01_I - gattc_connect_over_le - gattc_enable_notification_desc_by_instance_id 0075 - gattc_disconnect - -TC_SCPP_CL_SPNF_BV_01_I - Have NRF (nordic app installed and running) - gattc_connect_over_le - gattc_enable_notification_desc_by_instance_id 0075 - From nordic send a write command to the Scan Refresh Characteristic of any text value. - gattc_disconnect - diff --git a/acts/tests/google/bt/pts/rfcomm_lib.py b/acts/tests/google/bt/pts/rfcomm_lib.py index 257c929cf4..b585c2fe83 100644 --- a/acts/tests/google/bt/pts/rfcomm_lib.py +++ b/acts/tests/google/bt/pts/rfcomm_lib.py @@ -17,7 +17,7 @@ Bluetooth adapter libraries """ -from acts.test_utils.bt.bt_constants import bt_rfcomm_uuids +from acts.test_utils.bt.BtEnum import BluetoothScanModeType from acts.test_utils.bt.bt_test_utils import set_bt_scan_mode import pprint @@ -37,7 +37,7 @@ class RfcommLib(): uuid = line if uuid: self.dut.droid.bluetoothRfcommBeginConnectThread(self.mac_addr, - uuid) + uuid) else: self.dut.droid.bluetoothRfcommBeginConnectThread(self.mac_addr) @@ -69,8 +69,8 @@ class RfcommLib(): if uuid: self.dut.droid.bluetoothRfcommBeginAcceptThread(uuid) else: - self.dut.droid.bluetoothRfcommBeginAcceptThread(bt_rfcomm_uuids[ - 'base_uuid']) + self.dut.droid.bluetoothRfcommBeginAcceptThread( + RfcommUuid.BASE_UUID.value) def stop(self): """Stop RFCOMM Connection""" diff --git a/acts/tests/google/net/CoreNetworkingTest.py b/acts/tests/google/net/CoreNetworkingTest.py deleted file mode 100644 index b56b3c5ef9..0000000000 --- a/acts/tests/google/net/CoreNetworkingTest.py +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from acts import asserts -from acts import base_test -from acts.controllers import adb -from acts.test_decorators import test_tracker_info -from acts.test_utils.tel.tel_data_utils import wait_for_cell_data_connection -from acts.test_utils.tel.tel_test_utils import verify_http_connection -from acts.test_utils.wifi import wifi_test_utils as wutils - -dum_class = "com.android.tests.connectivity.uid.ConnectivityTestActivity" - - -class CoreNetworkingTest(base_test.BaseTestClass): - """ Tests for UID networking """ - - def setup_class(self): - """ Setup devices for tests and unpack params """ - self.dut = self.android_devices[0] - wutils.wifi_toggle_state(self.dut, False) - self.dut.droid.telephonyToggleDataConnection(True) - wait_for_cell_data_connection(self.log, self.dut, True) - asserts.assert_true( - verify_http_connection(self.log, self.dut), - "HTTP verification failed on cell data connection") - - def teardown_class(self): - """ Reset devices """ - wutils.wifi_toggle_state(self.dut, True) - - """ Test Cases """ - - @test_tracker_info(uuid="0c89d632-aafe-4bbd-a812-7b0eca6aafc7") - def test_uid_derace_data_saver_mode(self): - """ Verify UID de-race data saver mode - - Steps: - 1. Connect DUT to data network and verify internet - 2. Enable data saver mode - 3. Launch app and verify internet connectivity - 4. Disable data saver mode - """ - # Enable data saver mode - self.log.info("Enable data saver mode") - self.dut.adb.shell("cmd netpolicy set restrict-background true") - - # Launch app, check internet connectivity and close app - res = self.dut.droid.launchForResult(dum_class) - self.log.info("Internet connectivity status after app launch: %s " - % res['extras']['result']) - - # Disable data saver mode - self.log.info("Disable data saver mode") - self.dut.adb.shell("cmd netpolicy set restrict-background false") - - return res['extras']['result'] diff --git a/acts/tests/google/net/LegacyVpnTest.py b/acts/tests/google/net/LegacyVpnTest.py index 7f769919b5..0199f15bd7 100644 --- a/acts/tests/google/net/LegacyVpnTest.py +++ b/acts/tests/google/net/LegacyVpnTest.py @@ -57,9 +57,6 @@ class LegacyVpnTest(base_test.BaseTestClass): """ wifi_test_utils.reset_wifi(self.dut) - def on_fail(self, test_name, begin_time): - self.dut.take_bug_report(test_name, begin_time) - def download_load_certs(self, vpn_type, vpn_server_addr, ipsec_server_type): """ Download the certificates from VPN server and push to sdcard of DUT @@ -122,10 +119,18 @@ class LegacyVpnTest(base_test.BaseTestClass): Args: connected_vpn_info which specifies the VPN connection status """ - pkt_loss = "100% packet loss" - ping_result = self.dut.adb.shell("ping -c 3 -W 2 %s" - % self.vpn_verify_address) - return pkt_loss not in ping_result + try: + ping_result = self.dut.adb.shell("ping -c 3 -W 2 %s" + % self.vpn_verify_address) + if not connected_vpn_info and "100% packet loss" \ + not in "%s" % ping_result: + asserts.fail("VPN is disconnected.\ + Ping to the internal IP expected to fail") + except adb.AdbError as ping_error: + ping_error = "%s" % ping_error + if connected_vpn_info and "100% packet loss" in ping_error: + asserts.fail("Ping to the internal IP failed.\ + Expected to pass as VPN is connected") def legacy_vpn_connection_test_logic(self, vpn_profile): """ Test logic for each legacy VPN connection @@ -142,9 +147,6 @@ class LegacyVpnTest(base_test.BaseTestClass): Args: VpnProfileType (1 of the 6 types supported by Android) """ - # Wait for sometime so that VPN server flushes all interfaces and - # connections after graceful termination - time.sleep(10) self.dut.adb.shell("ip xfrm state flush") logging.info("Connecting to: %s", vpn_profile) self.dut.droid.vpnStartLegacyVpn(vpn_profile) @@ -154,170 +156,53 @@ class LegacyVpnTest(base_test.BaseTestClass): connectivity_const.VPN_STATE_CONNECTED, "Unable to establish VPN connection for %s" % vpn_profile) - ping_result = self.verify_ping_to_vpn_ip(connected_vpn_info) + self.verify_ping_to_vpn_ip(connected_vpn_info) ip_xfrm_state = self.dut.adb.shell("ip xfrm state") match_obj = re.search(r'hmac(.*)', "%s" % ip_xfrm_state) if match_obj: ip_xfrm_state = format(match_obj.group(0)).split() self.log.info("HMAC for ESP is %s " % ip_xfrm_state[0]) self.dut.droid.vpnStopLegacyVpn() - asserts.assert_true(ping_result, - "Ping to the internal IP failed. " - "Expected to pass as VPN is connected") connected_vpn_info = self.dut.droid.vpnGetLegacyVpnInfo() asserts.assert_true(not connected_vpn_info, "Unable to terminate VPN connection for %s" % vpn_profile) + self.verify_ping_to_vpn_ip(connected_vpn_info) """ Test Cases """ - @test_tracker_info(uuid="d2ac5a65-41fb-48de-a0a9-37e589b5456b") - def test_legacy_vpn_pptp(self): - """ Verify PPTP VPN connection """ - vpn = VPN_TYPE.PPTP - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][0], - self.ipsec_server_type[2]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="99af78dd-40b8-483a-8344-cd8f67594971") - def test_legacy_vpn_l2tp_ipsec_psk_libreswan(self): - """ Verify L2TP IPSec PSK VPN connection to - libreSwan server - """ - vpn = VPN_TYPE.L2TP_IPSEC_PSK - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][2], - self.ipsec_server_type[2]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="e67d8c38-92c3-4167-8b6c-a49ef939adce") - def test_legacy_vpn_l2tp_ipsec_rsa_libreswan(self): - """ Verify L2TP IPSec RSA VPN connection to - libreSwan server - """ - vpn = VPN_TYPE.L2TP_IPSEC_RSA - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][2], - self.ipsec_server_type[2]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="8b3517dc-6a3b-44c2-a85d-bd7b969df3cf") - def test_legacy_vpn_ipsec_xauth_psk_libreswan(self): - """ Verify IPSec XAUTH PSK VPN connection to - libreSwan server - """ - vpn = VPN_TYPE.IPSEC_XAUTH_PSK - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][2], - self.ipsec_server_type[2]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="abac663d-1d91-4b87-8e94-11c6e44fb07b") - def test_legacy_vpn_ipsec_xauth_rsa_libreswan(self): - """ Verify IPSec XAUTH RSA VPN connection to - libreSwan server - """ - vpn = VPN_TYPE.IPSEC_XAUTH_RSA - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][2], - self.ipsec_server_type[2]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="84140d24-53c0-4f6c-866f-9d66e04442cc") - def test_legacy_vpn_l2tp_ipsec_psk_openswan(self): - """ Verify L2TP IPSec PSK VPN connection to - openSwan server - """ - vpn = VPN_TYPE.L2TP_IPSEC_PSK - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][1], - self.ipsec_server_type[1]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="f7087592-7eed-465d-bfe3-ed7b6d9d5f9a") - def test_legacy_vpn_l2tp_ipsec_rsa_openswan(self): - """ Verify L2TP IPSec RSA VPN connection to - openSwan server - """ - vpn = VPN_TYPE.L2TP_IPSEC_RSA - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][1], - self.ipsec_server_type[1]) - self.legacy_vpn_connection_test_logic(vpn_profile) - @test_tracker_info(uuid="ed78973b-13ee-4dd4-b998-693ab741c6f8") - def test_legacy_vpn_ipsec_xauth_psk_openswan(self): - """ Verify IPSec XAUTH PSK VPN connection to - openSwan server - """ - vpn = VPN_TYPE.IPSEC_XAUTH_PSK - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][1], - self.ipsec_server_type[1]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="cfd125c4-b64c-4c49-b8e4-fbf05a9be8ec") - def test_legacy_vpn_ipsec_xauth_rsa_openswan(self): - """ Verify IPSec XAUTH RSA VPN connection to - openSwan server - """ - vpn = VPN_TYPE.IPSEC_XAUTH_RSA - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][1], - self.ipsec_server_type[1]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="419370de-0aa1-4a56-8c22-21567fa1cbb7") - def test_legacy_vpn_l2tp_ipsec_psk_strongswan(self): - """ Verify L2TP IPSec PSk VPN connection to - strongSwan server - """ - vpn = VPN_TYPE.L2TP_IPSEC_PSK - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][0], - self.ipsec_server_type[0]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="f7694081-8bd6-4e31-86ec-d538c4ff1f2e") - def test_legacy_vpn_l2tp_ipsec_rsa_strongswan(self): - """ Verify L2TP IPSec RSA VPN connection to - strongSwan server - """ - vpn = VPN_TYPE.L2TP_IPSEC_RSA - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][0], - self.ipsec_server_type[0]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="2f86eb98-1e05-42cb-b6a6-fd90789b6cde") - def test_legacy_vpn_ipsec_xauth_psk_strongswan(self): - """ Verify IPSec XAUTH PSK connection to - strongSwan server - """ - vpn = VPN_TYPE.IPSEC_XAUTH_PSK - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][0], - self.ipsec_server_type[0]) - self.legacy_vpn_connection_test_logic(vpn_profile) - - @test_tracker_info(uuid="af0cd7b1-e86c-4327-91b4-e9062758f2cf") - def test_legacy_vpn_ipsec_xauth_rsa_strongswan(self): - """ Verify IPSec XAUTH RSA connection to - strongswan server - """ - vpn = VPN_TYPE.IPSEC_XAUTH_RSA - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][0], - self.ipsec_server_type[0]) - self.legacy_vpn_connection_test_logic(vpn_profile) + @test_tracker_info(uuid="d2ac5a65-41fb-48de-a0a9-37e589b5456b") + def test_connection_to_legacy_vpn(self): + """ Verify VPN connection for all configurations. + Supported VPN configurations are + 1.) PPTP 2.) L2TP IPSEC PSK + 3.) IPSEC XAUTH PSK 4.) L2TP IPSEC RSA + 5.) IPSEC XAUTH RSA 6.) IPSec Hybrid RSA - @test_tracker_info(uuid="7b970d0a-1c7d-4a5a-b406-4815e190ef26") - def test_legacy_vpn_ipsec_hybrid_rsa_strongswan(self): - """ Verify IPSec Hybrid RSA connection to - strongswan server - """ - vpn = VPN_TYPE.IPSEC_HYBRID_RSA - vpn_profile = self.generate_legacy_vpn_profile( - vpn, self.vpn_server_addresses[vpn.name][0], - self.ipsec_server_type[0]) - self.legacy_vpn_connection_test_logic(vpn_profile) + Steps: + 1. Call legacy_vpn_connection_test_logic() for each VPN which + tests the connection to the corresponding server + + Return: + Pass: if all VPNs pass + Fail: if any one VPN fails + """ + def gen_name(vpn_profile): + return "test_legacy_vpn_" + vpn_profile[VPN_CONST.NAME][5:] + + vpn_profiles = [] + for vpn in VPN_TYPE: + for i in range(len(self.ipsec_server_type)): + vpn_profiles.append( + self.generate_legacy_vpn_profile(vpn, + self.vpn_server_addresses[vpn.name][i], + self.ipsec_server_type[i])) + # PPTP does not depend on ipsec and only strongswan supports Hybrid RSA + if vpn.name =="PPTP" or vpn.name =="IPSEC_HYBRID_RSA": + break + result = self.run_generated_testcases(self.legacy_vpn_connection_test_logic, + vpn_profiles, + name_func=gen_name,) + msg = ("The following configs failed vpn connection %s" + % pprint.pformat(result)) + asserts.assert_equal(len(result), 0, msg) diff --git a/acts/tests/google/power/PowerbaselineTest.py b/acts/tests/google/power/PowerbaselineTest.py deleted file mode 100644 index 6e7bffa26f..0000000000 --- a/acts/tests/google/power/PowerbaselineTest.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -from acts import asserts -from acts import base_test -from acts.test_utils.wifi import wifi_test_utils as wutils -from acts.test_utils.wifi import wifi_power_test_utils as wputils -from acts.test_decorators import test_tracker_info - - -class PowerbaselineTest(base_test.BaseTestClass): - """Power baseline tests for rockbottom state. - Rockbottom for wifi on/off, screen on/off, everything else turned off - - """ - - def __init__(self, controllers): - - base_test.BaseTestClass.__init__(self, controllers) - self.tests = ("test_rockbottom_screenoff_wifidisabled", - "test_rockbottom_screenoff_wifidisconnected", - "test_rockbottom_screenon_wifidisabled", - "test_rockbottom_screenon_wifidisconnected") - - def setup_class(self): - - self.dut = self.android_devices[0] - req_params = ["baselinetest_params"] - self.unpack_userparams(req_params) - self.unpack_testparams(self.baselinetest_params) - 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(8.0) - self.mon.attach_device(self.dut) - self.mon_info = { - "dut": self.mon, - "freq": self.mon_freq, - "duration": self.mon_duration, - "offset": self.mon_offset, - "data_path": self.mon_data_path - } - - def teardown_class(self): - - self.mon.usb("on") - - def unpack_testparams(self, bulk_params): - """Unpack all the test specific parameters. - - Args: - bulk_params: dict with all test specific params in the config file - """ - for key in bulk_params.keys(): - setattr(self, key, bulk_params[key]) - - def pass_fail_check(self, avg_current): - """Check the test result and decide if it passed or failed. - The threshold is provided in the config file - - Args: - avg_current: the average current as the test result - """ - test_name = self.current_test_name - current_threshold = self.threshold[test_name] - asserts.assert_true(avg_current < current_threshold, - ("Measured average current in [%s]: %s, which is " - "higher than acceptable threshold %.2fmA.") % - (test_name, avg_current, current_threshold)) - asserts.explicit_pass("Measurement finished for %s." % test_name) - - def rockbottom_test_func(self, screen_status, wifi_status): - """Test function for baseline rockbottom tests. - - Args: - screen_status: screen on or off - wifi_status: wifi enable or disable, on/off, not connected even on - """ - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - if wifi_status == "ON": - wutils.wifi_toggle_state(self.dut, True) - if screen_status == "OFF": - self.dut.droid.goToSleepNow() - self.dut.log.info("Screen is OFF") - # Collecting current measurement data and plot - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - self.pass_fail_check(avg_current) - - # Test cases - @test_tracker_info(uuid="e7ab71f4-1e14-40d2-baec-cde19a3ac859") - def test_rockbottom_screenoff_wifidisabled(self): - - self.rockbottom_test_func("OFF", "OFF") - - @test_tracker_info(uuid="167c847d-448f-4c7c-900f-82c552d7d9bb") - def test_rockbottom_screenoff_wifidisconnected(self): - - self.rockbottom_test_func("OFF", "ON") - - @test_tracker_info(uuid="2cd25820-8548-4e60-b0e3-63727b3c952c") - def test_rockbottom_screenon_wifidisabled(self): - - self.rockbottom_test_func("ON", "OFF") - - @test_tracker_info(uuid="d7d90a1b-231a-47c7-8181-23814c8ff9b6") - def test_rockbottom_screenon_wifidisconnected(self): - - self.rockbottom_test_func("ON", "ON") diff --git a/acts/tests/google/power/PowerdtimTest.py b/acts/tests/google/power/PowerdtimTest.py deleted file mode 100644 index b5ffc5e6b9..0000000000 --- a/acts/tests/google/power/PowerdtimTest.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging -import os -import time -from acts import base_test -from acts.controllers.ap_lib import hostapd_constants as hc -from acts.test_decorators import test_tracker_info -from acts.test_utils.wifi import wifi_test_utils as wutils -from acts.test_utils.wifi import wifi_power_test_utils as wputils - - -class PowerdtimTest(base_test.BaseTestClass): - def __init__(self, controllers): - - base_test.BaseTestClass.__init__(self, controllers) - self.tests = ("test_2g_screenoff_dtimx1", "test_2g_screenoff_dtimx2", - "test_2g_screenoff_dtimx4", "test_2g_screenoff_dtimx9", - "test_2g_screenon_dtimx1", "test_2g_screenon_dtimx2", - "test_2g_screenon_dtimx4", "test_2g_screenon_dtimx9", - "test_5g_screenoff_dtimx1", "test_5g_screenoff_dtimx2", - "test_5g_screenoff_dtimx4", "test_5g_screenoff_dtimx9", - "test_5g_screenon_dtimx1", "test_5g_screenon_dtimx2", - "test_5g_screenon_dtimx4", "test_5g_screenon_dtimx9") - - def setup_class(self): - - self.log = logging.getLogger() - self.dut = self.android_devices[0] - self.access_point = self.access_points[0] - req_params = ["main_network", "aux_network", "dtimtest_params"] - self.unpack_userparams(req_params) - self.unpack_testparams(self.dtimtest_params) - 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(8.0) - self.mon.attach_device(self.dut) - self.mon_info = { - "dut": self.mon, - "freq": self.mon_freq, - "duration": self.mon_duration, - "offset": self.mon_offset, - "data_path": self.mon_data_path - } - self.num_atten = self.attenuators[0].instrument.num_atten - - def teardown_class(self): - - self.mon.usb("on") - - def unpack_testparams(self, bulk_params): - """Unpack all the test specific parameters. - - Args: - bulk_params: dict with all test specific params in the config file - """ - for key in bulk_params.keys(): - setattr(self, key, bulk_params[key]) - - def dtim_test_func(self, dtim, screen_status, network, dtim_max=6): - """A reusable function for DTIM test. - Covering different DTIM value, with screen ON or OFF and 2g/5g network - - Args: - dtim: the value for DTIM set on the phone - screen_status: screen on or off - network: a dict of information for the network to connect - """ - # Initialize the dut to rock-bottom state - wputils.change_dtim( - self.dut, gEnableModulatedDTIM=dtim, gMaxLIModulatedDTIM=dtim_max) - self.dut.log.info('DTIM value of the phone is now {}'.format(dtim)) - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - [ - self.attenuators[i].set_atten(self.atten_level['main_AP'][i]) - for i in range(self.num_atten) - ] - self.log.info("Set attenuation level to connect the main AP") - wputils.ap_setup(self.access_point, network) - wutils.wifi_connect(self.dut, network) - if screen_status == "OFF": - self.dut.droid.goToSleepNow() - self.dut.log.info("Screen is OFF") - time.sleep(5) - # Collect power data and plot - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - # Test cases - @test_tracker_info(uuid="2a70a78b-93a8-46a6-a829-e1624b8239d2") - def test_2g_screenoff_dtimx1(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(1, "OFF", network) - - @test_tracker_info(uuid="b6c4114d-984a-4269-9e77-2bec0e4b6e6f") - def test_2g_screenoff_dtimx2(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(2, "OFF", network) - - @test_tracker_info(uuid="2ae5bc29-3d5f-4fbb-9ff6-f5bd499a9d6e") - def test_2g_screenoff_dtimx4(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(4, "OFF", network) - - @test_tracker_info(uuid="b37fa75f-6166-4247-b15c-adcda8c7038e") - def test_2g_screenoff_dtimx9(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(9, "OFF", network, dtim_max=10) - - @test_tracker_info(uuid="384d3b0f-4335-4b00-8363-308ec27a150c") - def test_2g_screenon_dtimx1(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(1, "ON", network) - - @test_tracker_info(uuid="dee62525-7c7a-4a3c-97c2-db6b272fb8b2") - def test_2g_screenon_dtimx2(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(2, "ON", network) - - @test_tracker_info(uuid="79d0f065-2c46-4400-b02c-5ad60e79afea") - def test_2g_screenon_dtimx4(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(4, "ON", network) - - @test_tracker_info(uuid="50bda9c9-b443-4f0e-b4a6-cdc4483084b7") - def test_2g_screenon_dtimx9(self): - network = self.main_network[hc.BAND_2G] - self.dtim_test_func(9, "ON", network, dtim_max=10) - - @test_tracker_info(uuid="5e2f73cb-7e4e-4a25-8fd5-c85adfdf466e") - def test_5g_screenoff_dtimx1(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(1, "OFF", network) - - @test_tracker_info(uuid="017f57c3-e133-461d-80be-d025d1491d8a") - def test_5g_screenoff_dtimx2(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(2, "OFF", network) - - @test_tracker_info(uuid="b84a1cb3-9573-4bfd-9875-0f33cb171cc5") - def test_5g_screenoff_dtimx4(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(4, "OFF", network) - - @test_tracker_info(uuid="75644df4-2cc8-4bbd-8985-0656a4f9d056") - def test_5g_screenoff_dtimx9(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(9, "OFF", network, dtim_max=10) - - @test_tracker_info(uuid="327af44d-d9e7-49e0-9bda-accad6241dc7") - def test_5g_screenon_dtimx1(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(1, "ON", network) - - @test_tracker_info(uuid="96c7a28d-9d7d-404f-bd9f-3661b5a4b4c9") - def test_5g_screenon_dtimx2(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(2, "ON", network) - - @test_tracker_info(uuid="8b32585f-2517-426b-a2c9-8087093cf991") - def test_5g_screenon_dtimx4(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(4, "ON", network) - - @test_tracker_info(uuid="17a35bfe-f0a4-41cf-822a-f727a8b8090f") - def test_5g_screenon_dtimx9(self): - network = self.main_network[hc.BAND_5G] - self.dtim_test_func(9, "ON", network, dtim_max=10) diff --git a/acts/tests/google/power/PowerroamingTest.py b/acts/tests/google/power/PowerroamingTest.py deleted file mode 100644 index 6e95b3f56e..0000000000 --- a/acts/tests/google/power/PowerroamingTest.py +++ /dev/null @@ -1,249 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging -import os -import time -from acts import base_test -from acts.controllers.ap_lib import hostapd_constants as hc -from acts.test_decorators import test_tracker_info -from acts.test_utils.wifi import wifi_constants as wc -from acts.test_utils.wifi import wifi_test_utils as wutils -from acts.test_utils.wifi import wifi_power_test_utils as wputils - - -class PowerroamingTest(base_test.BaseTestClass): - def __init__(self, controllers): - - base_test.BaseTestClass.__init__(self, controllers) - self.tests = ("test_screenoff_roaming", "test_screenoff_fastroaming", - "test_screenon_toggle_between_AP", - "test_screenoff_toggle_between_AP", - "test_screenoff_wifi_wedge") - - def setup_class(self): - - self.log = logging.getLogger() - self.dut = self.android_devices[0] - self.access_point_main = self.access_points[0] - self.access_point_aux = self.access_points[1] - req_params = ("main_network", "aux_network", "roamingtest_params") - self.unpack_userparams(req_params) - self.unpack_testparams(self.roamingtest_params) - 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(8.0) - self.mon_duration_all = self.mon_duration - self.mon.attach_device(self.dut) - self.mon_info = { - "dut": self.mon, - "freq": self.mon_freq, - "duration": self.mon_duration, - "offset": self.mon_offset, - "data_path": self.mon_data_path - } - self.num_atten = self.attenuators[0].instrument.num_atten - - def teardown_class(self): - - self.mon.usb("on") - - def unpack_testparams(self, bulk_params): - """Unpack all the test specific parameters. - - Args: - bulk_params: dict with all test specific params in the config file - """ - for key in bulk_params.keys(): - setattr(self, key, bulk_params[key]) - - # Test cases - @test_tracker_info(uuid="392622d3-0c5c-4767-afa2-abfb2058b0b8") - def test_screenoff_roaming(self): - """Test roaming power consumption with screen off. - Change the attenuation level to trigger roaming between two APs - - """ - # Setup both APs - network_main = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point_main, network_main) - network_aux = self.aux_network[hc.BAND_2G] - wputils.ap_setup(self.access_point_aux, network_aux) - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - # Set attenuator and add two networks to the phone - self.log.info("Set attenuation to connect device to both APs") - [ - self.attenuators[i].set_atten(self.atten_level["initial_state"][i]) - for i in range(self.num_atten) - ] - wutils.wifi_connect(self.dut, network_aux) - time.sleep(5) - wutils.wifi_connect(self.dut, network_main) - self.dut.droid.goToSleepNow() - time.sleep(5) - # Set attenuator to trigger roaming - self.dut.log.info("Trigger roaming now") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - @test_tracker_info(uuid="2fec5208-043a-410a-8fd2-6784d70a3587") - def test_screenoff_fastroaming(self): - - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - # Setup the aux AP - network_main = self.main_network[hc.BAND_2G] - network_aux = self.aux_network[hc.BAND_2G] - # Set the same SSID for the AUX AP for fastroaming purpose - network_aux[wc.SSID] = network_main[wc.SSID] - wputils.ap_setup(self.access_point_aux, network_aux) - # Set attenuator and add two networks to the phone - self.log.info("Set attenuation to connect device to the aux AP") - [ - self.attenuators[i].set_atten(self.atten_level[wc.AP_MAIN][i]) - for i in range(self.num_atten) - ] - wutils.wifi_connect(self.dut, network_aux) - time.sleep(5) - # Setup the main AP - wputils.ap_setup(self.access_point_main, network_main) - # Set attenuator to connect the phone to main AP - self.log.info("Set attenuation to connect device to the main AP") - [ - self.attenuators[i].set_atten(self.atten_level[wc.AP_MAIN][i]) - for i in range(self.num_atten) - ] - wutils.wifi_connect(self.dut, network_main) - time.sleep(5) - self.dut.droid.goToSleepNow() - # Trigger fastroaming - self.dut.log.info("Trigger fastroaming now") - [ - self.attenuators[i].set_atten(self.atten_level[wc.AP_MAIN][i]) - for i in range(self.num_atten) - ] - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - @test_tracker_info(uuid="a0459b7c-74ce-4adb-8e55-c5365bc625eb") - def test_screenoff_toggle_between_AP(self): - - # Setup both APs - network_main = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point_main, network_main) - network_aux = self.aux_network[hc.BAND_2G] - wputils.ap_setup(self.access_point_aux, network_aux) - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - self.mon_info["duration"] = self.toggle_interval - self.dut.droid.goToSleepNow() - time.sleep(5) - self.log.info("Set attenuation to connect device to both APs") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - # Toggle between two networks - for i in range(self.toggle_times): - self.dut.log.info('Connecting to %s' % network_main[wc.SSID]) - self.dut.droid.wifiConnect(network_main) - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, 0) - self.dut.log.info('Connecting to %s' % network_aux[wc.SSID]) - self.dut.droid.wifiConnect(network_aux) - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, 0) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - @test_tracker_info(uuid="e5ff95c0-b17e-425c-a903-821ba555a9b9") - def test_screenon_toggle_between_AP(self): - - # Setup both APs - network_main = self.main_network[hc.BAND_5G] - wputils.ap_setup(self.access_point_main, network_main) - network_aux = self.aux_network[hc.BAND_5G] - wputils.ap_setup(self.access_point_aux, network_aux) - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - self.mon_info["duration"] = self.toggle_interval - self.log.info("Set attenuation to connect device to both APs") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - # Toggle between two networks - for i in range(self.toggle_times): - self.dut.log.info('Connecting to %s' % network_main[wc.SSID]) - self.dut.droid.wifiConnect(network_main) - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, 0) - self.dut.log.info('Connecting to %s' % network_aux[wc.SSID]) - self.dut.droid.wifiConnect(network_aux) - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, 0) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - @test_tracker_info(uuid="a16ae337-326f-4d09-990f-42232c3c0dc4") - def test_screenoff_wifi_wedge(self): - - # Setup both APs - network_main = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point_main, network_main) - network_aux = self.aux_network[hc.BAND_2G] - wputils.ap_setup(self.access_point_aux, network_aux) - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - # Set attenuator to connect phone to both networks - self.log.info("Set attenuation to connect device to both APs") - [ - self.attenuators[i].set_atten(self.atten_level["initial_state"][i]) - for i in range(self.num_atten) - ] - wutils.wifi_connect(self.dut, network_main) - wutils.wifi_connect(self.dut, network_aux) - self.log.info("Forget network {}".format(network_aux[wc.SSID])) - wutils.wifi_forget_network(self.dut, network_aux[wc.SSID]) - self.log.info("Set attenuation to trigger wedge condition") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.dut.droid.goToSleepNow() - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) diff --git a/acts/tests/google/power/PowerscanTest.py b/acts/tests/google/power/PowerscanTest.py deleted file mode 100644 index 0522feda1b..0000000000 --- a/acts/tests/google/power/PowerscanTest.py +++ /dev/null @@ -1,336 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import logging -import os -import time -from acts import base_test -from acts.controllers.ap_lib import hostapd_constants as hc -from acts.test_decorators import test_tracker_info -from acts.test_utils.wifi import wifi_test_utils as wutils -from acts.test_utils.wifi import wifi_power_test_utils as wputils - -UNLOCK_SCREEN = "input keyevent 82" - - -class PowerscanTest(base_test.BaseTestClass): - def __init__(self, controllers): - - base_test.BaseTestClass.__init__(self, controllers) - self.tests = ("test_single_shot_scan_2g_highRSSI", - "test_single_shot_scan_2g_lowRSSI", - "test_single_shot_scan_5g_highRSSI", - "test_single_shot_scan_5g_lowRSSI", - "test_background_scan" - "test_wifi_scan_2g", "test_wifi_scan_5g", - "test_scan_wifidisconnected_turnonscreen", - "test_scan_wificonnected_turnonscreen", - "test_scan_screenoff_below_rssi_threshold", - "test_scan_screenoff_lost_wificonnection") - - def setup_class(self): - - self.log = logging.getLogger() - self.dut = self.android_devices[0] - self.access_point = self.access_points[0] - req_params = ("main_network", "scantest_params") - self.unpack_userparams(req_params) - self.unpack_testparams(self.scantest_params) - 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(8.0) - self.mon.attach_device(self.dut) - self.mon_info = { - "dut": self.mon, - "freq": self.mon_freq, - "duration": self.mon_duration, - "offset": self.mon_offset, - "data_path": self.mon_data_path - } - self.num_atten = self.attenuators[0].instrument.num_atten - - def unpack_testparams(self, bulk_params): - """Unpack all the test specific parameters. - - Args: - bulk_params: dict with all test specific params in the config file - """ - for key in bulk_params.keys(): - setattr(self, key, bulk_params[key]) - - def setup_test(self): - - self.SINGLE_SHOT_SCAN = ( - "am instrument -w -r -e min_scan_count \"700\"" - " -e WifiScanTest-testWifiSingleShotScan %d" - " -e class com.google.android.platform.powertests." - "WifiScanTest#testWifiSingleShotScan" - " com.google.android.platform.powertests/" - "android.test.InstrumentationTestRunner > /dev/null &" % - (self.mon_duration + self.mon_offset + 10)) - self.BACKGROUND_SCAN = ( - "am instrument -w -r -e min_scan_count \"1\" -e " - "WifiScanTest-testWifiBackgroundScan %d -e class " - "com.google.android.platform.powertests.WifiScan" - "Test#testWifiBackgroundScan com.google.android." - "platform.powertests/android.test.Instrumentation" - "TestRunner > /dev/null &" % - (self.mon_duration + self.mon_offset + 10)) - self.WIFI_SCAN = ( - "am instrument -w -r -e min_scan_count \"1\" -e " - "WifiScanTest-testWifiScan %d -e class " - "com.google.android.platform.powertests.WifiScanTest#" - "testWifiScan com.google.android.platform.powertests/" - "android.test.InstrumentationTestRunner > /dev/null &" % - (self.mon_duration + self.mon_offset + 10)) - - def teardown_class(self): - - self.mon.usb("on") - - def powrapk_scan_test_func(self, scan_command): - """Test function for power.apk triggered scans. - Args: - scan_command: the adb shell command to trigger scans - - """ - self.mon_info["offset"] == 0 - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - self.log.info("Wait for {} seconds".format(self.settle_wait_time)) - time.sleep(self.settle_wait_time) - self.log.info("Running power apk command to trigger scans") - self.dut.adb.shell_nb(scan_command) - self.dut.droid.goToSleepNow() - # Collect power data and plot - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - # Test cases - @test_tracker_info(uuid="e5539b01-e208-43c6-bebf-6f1e73d8d8cb") - def test_single_shot_scan_2g_highRSSI(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - self.log.info("Set attenuation to get high RSSI at 2g") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.SINGLE_SHOT_SCAN) - - @test_tracker_info(uuid="14c5a762-95bc-40ea-9fd4-27126df7d86c") - def test_single_shot_scan_2g_lowRSSI(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - self.log.info("Set attenuation to get low RSSI at 2g") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.SINGLE_SHOT_SCAN) - - @test_tracker_info(uuid="a6506600-c567-43b5-9c25-86b505099b97") - def test_single_shot_scan_2g_noAP(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - self.log.info("Set attenuation so all AP is out of reach ") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.SINGLE_SHOT_SCAN) - - @test_tracker_info(uuid="1a458248-1159-4c8e-a39f-92fc9e69c4dd") - def test_single_shot_scan_5g_highRSSI(self): - - network = self.main_network[hc.BAND_5G] - wputils.ap_setup(self.access_point, network) - self.log.info("Set attenuation to get high RSSI at 5g") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.SINGLE_SHOT_SCAN) - - @test_tracker_info(uuid="bd4da426-a621-4131-9f89-6e5a77f321d2") - def test_single_shot_scan_5g_lowRSSI(self): - - network = self.main_network[hc.BAND_5G] - wputils.ap_setup(self.access_point, network) - self.log.info("Set attenuation to get low RSSI at 5g") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.SINGLE_SHOT_SCAN) - - @test_tracker_info(uuid="288b3add-8925-4803-81c0-53debf157ffc") - def test_single_shot_scan_5g_noAP(self): - - network = self.main_network[hc.BAND_5G] - wputils.ap_setup(self.access_point, network) - self.log.info("Set attenuation so all AP is out of reach ") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.SINGLE_SHOT_SCAN) - - @test_tracker_info(uuid="f401c66c-e515-4f51-8ef2-2a03470d8ff2") - def test_background_scan(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - self.powrapk_scan_test_func(self.BACKGROUND_SCAN) - - @test_tracker_info(uuid="fe38c1c7-937c-42c0-9381-98356639df8f") - def test_wifi_scan_2g(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.WIFI_SCAN) - - @test_tracker_info(uuid="8eedefd1-3a08-4ac2-ba55-5eb438def3d4") - def test_wifi_scan_5g(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - self.powrapk_scan_test_func(self.WIFI_SCAN) - - @test_tracker_info(uuid="ff5ea952-ee31-4968-a190-82935ce7a8cb") - def test_scan_wifidisconnected_turnonscreen(self): - - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - self.dut.droid.goToSleepNow() - self.log.info("Screen is OFF") - time.sleep(5) - self.dut.droid.wakeUpNow() - self.log.info("Now turn on screen to trigger scans") - self.dut.adb.shell(UNLOCK_SCREEN) - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - @test_tracker_info(uuid="9a836e5b-8128-4dd2-8e96-e79177810bdd") - def test_scan_wificonnected_turnonscreen(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - # Set attenuators to connect main AP - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - wutils.wifi_connect(self.dut, network) - time.sleep(10) - self.dut.droid.goToSleepNow() - self.log.info("Screen is OFF") - time.sleep(5) - self.dut.droid.wakeUpNow() - self.log.info("Now turn on screen to trigger scans") - self.dut.adb.shell(UNLOCK_SCREEN) - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - @test_tracker_info(uuid="51e3c4f1-742b-45af-afd5-ae3552a03272") - def test_scan_screenoff_below_rssi_threshold(self): - - network = self.main_network[hc.BAND_2G] - wputils.ap_setup(self.access_point, network) - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - # Set attenuator and add main network to the phone - self.log.info("Set attenuation so device connection has medium RSSI") - [ - self.attenuators[i].set_atten(self.atten_level["initial_state"][i]) - for i in range(self.num_atten) - ] - wutils.wifi_connect(self.dut, network) - self.dut.droid.goToSleepNow() - time.sleep(20) - # Set attenuator to make RSSI below threshold - self.log.info("Set attenuation to drop RSSI below threhold") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) - - @test_tracker_info(uuid="a16ae337-326f-4d09-990f-42232c3c0dc4") - def test_scan_screenoff_lost_wificonnection(self): - - network = self.main_network[hc.BAND_5G] - wputils.ap_setup(self.access_point, network) - # Initialize the dut to rock-bottom state - wputils.dut_rockbottom(self.dut) - wutils.wifi_toggle_state(self.dut, True) - # Set attenuator and add main network to the phone - self.log.info("Set attenuation so device connection has medium RSSI") - [ - self.attenuators[i].set_atten(self.atten_level["initial_state"][i]) - for i in range(self.num_atten) - ] - wutils.wifi_connect(self.dut, network) - self.dut.droid.goToSleepNow() - time.sleep(5) - # Set attenuator to make RSSI below threshold - self.log.info("Set attenuation so device loses connection") - [ - self.attenuators[i].set_atten( - self.atten_level[self.current_test_name][i]) - for i in range(self.num_atten) - ] - file_path, avg_current = wputils.monsoon_data_collect_save( - self.dut, self.mon_info, self.current_test_name, self.bug_report) - wputils.monsoon_data_plot(self.mon_info, file_path) - wputils.pass_fail_check(self, avg_current) diff --git a/acts/tests/google/tel/live/TelLiveDataTest.py b/acts/tests/google/tel/live/TelLiveDataTest.py index b199dd9e8c..87512e23e7 100644 --- a/acts/tests/google/tel/live/TelLiveDataTest.py +++ b/acts/tests/google/tel/live/TelLiveDataTest.py @@ -17,10 +17,7 @@ Test Script for Telephony Pre Check In Sanity """ -import collections -import random import time -import os from acts.test_decorators import test_tracker_info from acts.base_test import BaseTestClass from queue import Empty @@ -59,7 +56,6 @@ from acts.test_utils.tel.tel_data_utils import tethering_check_internet_connecti from acts.test_utils.tel.tel_data_utils import wifi_cell_switching from acts.test_utils.tel.tel_data_utils import wifi_tethering_cleanup from acts.test_utils.tel.tel_data_utils import wifi_tethering_setup_teardown -from acts.test_utils.tel.tel_test_utils import active_file_download_test from acts.test_utils.tel.tel_test_utils import call_setup_teardown from acts.test_utils.tel.tel_test_utils import check_is_wifi_connected from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state @@ -112,8 +108,6 @@ class TelLiveDataTest(TelephonyBaseTest): "wifi_network_ssid") or self.user_params.get("wifi_network_ssid_2g") self.wifi_network_pass = self.user_params.get( "wifi_network_pass") or self.user_params.get("wifi_network_pass_2g") - self.provider = self.android_devices[-1] - self.clients = self.android_devices[:-1] @test_tracker_info(uuid="1b0354f3-8668-4a28-90a5-3b3d2b2756d3") @TelephonyBaseTest.tel_test_wrap @@ -690,34 +684,34 @@ class TelLiveDataTest(TelephonyBaseTest): False if failed. """ ensure_phones_idle(self.log, self.android_devices) + provider = self.android_devices[0] if network_generation: if not ensure_network_generation( - self.log, self.provider, network_generation, + self.log, provider, network_generation, MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA): - self.provider.log.error("Device failed to connect to %s.", - network_generation) + provider.log.error("Device failed to connect to %s.", + network_generation) return False self.log.info("Airplane Off, Wifi Off, Data On.") - toggle_airplane_mode(self.log, self.provider, False) - wifi_toggle_state(self.log, self.provider, False) - self.provider.droid.telephonyToggleDataConnection(True) - for ad in self.clients: + toggle_airplane_mode(self.log, provider, False) + wifi_toggle_state(self.log, provider, False) + provider.droid.telephonyToggleDataConnection(True) + for ad in self.android_devices[1:]: ad.droid.telephonyToggleDataConnection(False) - if not wait_for_cell_data_connection(self.log, self.provider, True): - self.provider.log.error( - "Provider failed to enable data connection.") + if not wait_for_cell_data_connection(self.log, provider, True): + provider.log.error("Provider failed to enable data connection.") return False self.log.info("Verify internet") - if not verify_internet_connection(self.log, self.provider): - self.provider.log.error("Data not available on cell.") + if not verify_internet_connection(self.log, provider): + provider.log.error("Data not available on cell.") return False # Turn off active SoftAP if any. - if self.provider.droid.wifiIsApEnabled(): - stop_wifi_tethering(self.log, self.provider) + if provider.droid.wifiIsApEnabled(): + stop_wifi_tethering(self.log, provider) return True @@ -742,7 +736,7 @@ class TelLiveDataTest(TelephonyBaseTest): return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10) @@ -768,7 +762,7 @@ class TelLiveDataTest(TelephonyBaseTest): return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_5G, check_interval=10, check_iteration=10) @@ -794,7 +788,7 @@ class TelLiveDataTest(TelephonyBaseTest): return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10) @@ -820,7 +814,7 @@ class TelLiveDataTest(TelephonyBaseTest): return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_5G, check_interval=10, check_iteration=10) @@ -846,8 +840,7 @@ class TelLiveDataTest(TelephonyBaseTest): return wifi_tethering_setup_teardown( self.log, - self.provider, - self.clients, + ads[0], [ads[1], ads[2]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10) @@ -866,13 +859,14 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(RAT_2G): self.log.error("Verify 2G Internet access failed.") return False return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10) @@ -891,13 +885,14 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(RAT_2G): self.log.error("Verify 2G Internet access failed.") return False return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_5G, check_interval=10, check_iteration=10) @@ -919,26 +914,24 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Verify provider Internet access failed.") return False self.log.info("Connect WiFi.") - if not ensure_wifi_connected(self.log, self.provider, - self.wifi_network_ssid, + if not ensure_wifi_connected(self.log, ads[0], self.wifi_network_ssid, self.wifi_network_pass): self.log.error("WiFi connect fail.") return False self.log.info("Start WiFi Tethering.") if not wifi_tethering_setup_teardown( - self.log, - self.provider, [self.clients[0]], - check_interval=10, + self.log, ads[0], [ads[1]], check_interval=10, check_iteration=2): self.log.error("WiFi Tethering failed.") return False - if (not wait_for_wifi_data_connection(self.log, self.provider, True) or - not verify_internet_connection(self.log, self.provider)): + if (not wait_for_wifi_data_connection(self.log, ads[0], True) or + not verify_internet_connection(self.log, ads[0])): self.log.error("Provider data did not return to Wifi") return False return True @@ -959,6 +952,7 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Provider Internet access check failed.") return False @@ -966,7 +960,7 @@ class TelLiveDataTest(TelephonyBaseTest): ssid = rand_ascii_str(10) if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -975,48 +969,43 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("WiFi Tethering failed.") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + ads[0].log.error("Provider WiFi tethering stopped.") return False - self.provider.log.info( + ads[0].log.info( "Disable Data on Provider, verify no data on Client.") - self.provider.droid.telephonyToggleDataConnection(False) + ads[0].droid.telephonyToggleDataConnection(False) time.sleep(WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING) - if verify_internet_connection(self.log, self.provider): - self.provider.log.error("Disable data on provider failed.") + if verify_internet_connection(self.log, ads[0]): + ads[0].log.error("Disable data on provider failed.") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + ads[0].log.error("Provider WiFi tethering stopped.") return False - if not check_is_wifi_connected(self.log, self.clients[0], ssid): - self.clients[0].log.error("Client WiFi is not connected") + if not check_is_wifi_connected(self.log, ads[1], ssid): + ads[1].log.error("Client WiFi is not connected") return False self.log.info( "Enable Data on Provider, verify data available on Client.") - self.provider.droid.telephonyToggleDataConnection(True) - if not wait_for_cell_data_connection(self.log, self.provider, - True): - self.provider.log.error( - "Provider failed to enable data connection.") + ads[0].droid.telephonyToggleDataConnection(True) + if not wait_for_cell_data_connection(self.log, ads[0], True): + ads[0].log.error("Provider failed to enable data connection.") return False - if not verify_internet_connection(self.log, self.provider): - self.provider.log.error( - "Provider internet connection check failed.") + if not verify_internet_connection(self.log, ads[0]): + ads[0].log.error("Provider internet connection check failed.") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering stopped.") return False - if not check_is_wifi_connected(self.log, self.clients[0], ssid) or ( - not verify_internet_connection(self.log, self.clients[0])): - self.clients[0].log.error( - "Client wifi connection check failed!") + if not check_is_wifi_connected(self.log, ads[1], ssid) or ( + not verify_internet_connection(self.log, ads[1])): + ads[1].log.error("Client wifi connection check failed!") return False finally: - if not wifi_tethering_cleanup(self.log, self.provider, - self.clients): + if not wifi_tethering_cleanup(self.log, ads[0], [ads[1]]): return False return True @@ -1039,13 +1028,14 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(RAT_4G): self.log.error("Verify 4G Internet access failed.") return False try: if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -1053,32 +1043,31 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("WiFi Tethering failed.") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering stopped.") return False self.log.info("Provider change RAT from LTE to 3G.") if not ensure_network_generation( self.log, - self.provider, + ads[0], RAT_3G, voice_or_data=NETWORK_SERVICE_DATA, toggle_apm_after_setting=False): - self.provider.log.error("Provider failed to reselect to 3G.") + self.log.error("Provider failed to reselect to 3G.") return False time.sleep(WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING) - if not verify_internet_connection(self.log, self.provider): - self.provider.log.error("Data not available on Provider.") + if not verify_internet_connection(self.log, ads[0]): + self.log.error("Data not available on Provider.") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering stopped.") return False - if not tethering_check_internet_connection( - self.log, self.provider, [self.clients[0]], 10, 5): + if not tethering_check_internet_connection(self.log, ads[0], + [ads[1]], 10, 5): return False finally: - if not wifi_tethering_cleanup(self.log, self.provider, - self.clients): + if not wifi_tethering_cleanup(self.log, ads[0], [ads[1]]): return False return True @@ -1101,13 +1090,14 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(RAT_3G): self.log.error("Verify 3G Internet access failed.") return False try: if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -1115,28 +1105,28 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("WiFi Tethering failed.") return False - if not self.provider.droid.wifiIsApEnabled(): + if not ads[0].droid.wifiIsApEnabled(): self.log.error("Provider WiFi tethering stopped.") return False self.log.info("Provider change RAT from 3G to 4G.") if not ensure_network_generation( self.log, - self.provider, + ads[0], RAT_4G, voice_or_data=NETWORK_SERVICE_DATA, toggle_apm_after_setting=False): self.log.error("Provider failed to reselect to 4G.") return False time.sleep(WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING) - if not verify_internet_connection(self.log, self.provider): - self.provider.log.error("Data not available on Provider.") + if not verify_internet_connection(self.log, ads[0]): + self.log.error("Data not available on Provider.") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering stopped.") return False - if not tethering_check_internet_connection( - self.log, self.provider, [self.clients[0]], 10, 5): + if not tethering_check_internet_connection(self.log, ads[0], + [ads[1]], 10, 5): return False finally: if not wifi_tethering_cleanup(self.log, ads[0], [ads[1]]): @@ -1159,6 +1149,7 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(RAT_4G): self.log.error("Verify 4G Internet access failed.") return False @@ -1166,7 +1157,7 @@ class TelLiveDataTest(TelephonyBaseTest): ssid = rand_ascii_str(10) if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -1175,47 +1166,44 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("WiFi Tethering failed.") return False - if not self.provider.droid.wifiIsApEnabled(): + if not ads[0].droid.wifiIsApEnabled(): self.log.error("Provider WiFi tethering stopped.") return False self.log.info( "Provider turn on APM, verify no wifi/data on Client.") - if not toggle_airplane_mode(self.log, self.provider, True): + if not toggle_airplane_mode(self.log, ads[0], True): self.log.error("Provider turn on APM failed.") return False time.sleep(WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING) - if self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering not stopped.") + if ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering not stopped.") return False - if verify_internet_connection(self.log, self.clients[0]): - self.clients[0].log.error( - "Client should not have Internet connection.") + if verify_internet_connection(self.log, ads[1]): + self.log.error("Client should not have Internet connection.") return False - wifi_info = self.clients[0].droid.wifiGetConnectionInfo() - self.clients[0].log.info("WiFi Info: {}".format(wifi_info)) + wifi_info = ads[1].droid.wifiGetConnectionInfo() + self.log.info("WiFi Info: {}".format(wifi_info)) + if wifi_info[WIFI_SSID_KEY] == ssid: - self.clients[0].log.error( - "WiFi error. WiFi should not be connected.".format( - wifi_info)) + self.log.error("WiFi error. WiFi should not be connected.". + format(wifi_info)) return False self.log.info("Provider turn off APM.") - if not toggle_airplane_mode(self.log, self.provider, False): - self.provider.log.error("Provider turn on APM failed.") + if not toggle_airplane_mode(self.log, ads[0], False): + self.log.error("Provider turn on APM failed.") return False time.sleep(WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING) - if self.provider.droid.wifiIsApEnabled(): - self.provider.log.error( - "Provider WiFi tethering should not on.") + if ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering should not on.") return False - if not verify_internet_connection(self.log, self.provider): - self.provider.log.error( - "Provider should have Internet connection.") + if not verify_internet_connection(self.log, ads[0]): + self.log.error("Provider should have Internet connection.") return False finally: - self.clients[0].droid.telephonyToggleDataConnection(True) - wifi_reset(self.log, self.clients[0]) + ads[1].droid.telephonyToggleDataConnection(True) + wifi_reset(self.log, ads[1]) return True @test_tracker_info(uuid="037e80fc-6eab-4cd1-846a-b9780a1d502d") @@ -1228,15 +1216,19 @@ class TelLiveDataTest(TelephonyBaseTest): Returns: True if entitlement check returns True. """ - if (not wait_for_cell_data_connection(self.log, self.provider, True) or - not verify_internet_connection(self.log, self.provider)): + ad = self.android_devices[0] + + if (not wait_for_cell_data_connection(self.log, + self.android_devices[0], True) or + not verify_internet_connection(self.log, + self.android_devices[0])): self.log.error("Failed cell data call for entitlement check.") return False - result = self.provider.droid.carrierConfigIsTetheringModeAllowed( + result = ad.droid.carrierConfigIsTetheringModeAllowed( TETHERING_MODE_WIFI, MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK) - self.provider.log.info("Tethering entitlement check result: %s", - result) + self.log.info("{} tethering entitlement check result: {}.".format( + ad.serial, result)) return result @test_tracker_info(uuid="4972826e-39ea-42f7-aae0-06fe3aa9ecc6") @@ -1257,8 +1249,8 @@ class TelLiveDataTest(TelephonyBaseTest): for i in range(1, self.stress_test_number + 1): - ensure_phones_default_state(self.log, - [self.provider, self.clients[0]]) + ensure_phones_default_state( + self.log, [self.android_devices[0], self.android_devices[1]]) if self.test_tethering_4g_to_2gwifi(): success_count += 1 @@ -1290,6 +1282,7 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False @@ -1299,7 +1292,7 @@ class TelLiveDataTest(TelephonyBaseTest): return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10, @@ -1318,6 +1311,7 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False @@ -1328,7 +1322,7 @@ class TelLiveDataTest(TelephonyBaseTest): return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10, @@ -1386,6 +1380,7 @@ class TelLiveDataTest(TelephonyBaseTest): True if WiFi tethering succeed on all SSIDs. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(RAT_4G): self.log.error("Setup Failed.") return False @@ -1405,7 +1400,7 @@ class TelLiveDataTest(TelephonyBaseTest): password = rand_ascii_str(8) self.log.info("SSID: <{}>, Password: <{}>".format(ssid, password)) if not self._test_start_wifi_tethering_connect_teardown( - self.provider, self.clients[0], ssid, password): + ads[0], ads[1], ssid, password): fail_list[ssid] = password if (len(fail_list) > 0): @@ -1426,6 +1421,7 @@ class TelLiveDataTest(TelephonyBaseTest): True if WiFi tethering succeed on all passwords. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(RAT_4G): self.log.error("Setup Failed.") return False @@ -1446,7 +1442,7 @@ class TelLiveDataTest(TelephonyBaseTest): ssid = rand_ascii_str(8) self.log.info("SSID: <{}>, Password: <{}>".format(ssid, password)) if not self._test_start_wifi_tethering_connect_teardown( - self.provider, self.clients[0], ssid, password): + ads[0], ads[1], ssid, password): fail_list[ssid] = password if (len(fail_list) > 0): @@ -1458,12 +1454,14 @@ class TelLiveDataTest(TelephonyBaseTest): def _test_tethering_wifi_and_voice_call(self, provider_data_rat, provider_setup_func, provider_in_call_check_func): + provider = self.android_devices[0] + client = self.android_devices[1] if not self._test_setup_tethering(provider_data_rat): self.log.error("Verify 4G Internet access failed.") return False - tasks = [(provider_setup_func, (self.log, self.provider)), - (phone_setup_voice_general, (self.log, self.clients[0]))] + tasks = [(provider_setup_func, (self.log, provider)), + (phone_setup_voice_general, (self.log, client))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up VoLTE.") return False @@ -1472,7 +1470,7 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.info("1. Setup WiFi Tethering.") if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + provider, [client], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -1482,40 +1480,39 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.info("2. Make outgoing call.") if not call_setup_teardown( self.log, - self.provider, - self.clients[0], + provider, + client, ad_hangup=None, verify_caller_func=provider_in_call_check_func): self.log.error("Setup Call Failed.") return False self.log.info("3. Verify data.") - if not verify_internet_connection(self.log, self.provider): - self.provider.log.error("Provider have no Internet access.") - if not verify_internet_connection(self.log, self.clients[0]): - self.clients[0].log.error("Client have no Internet access.") - hangup_call(self.log, self.provider) + if not verify_internet_connection(self.log, provider): + self.log.error("Provider have no Internet access.") + if not verify_internet_connection(self.log, client): + self.log.error("Client have no Internet access.") + hangup_call(self.log, provider) time.sleep(WAIT_TIME_BETWEEN_REG_AND_CALL) self.log.info("4. Make incoming call.") if not call_setup_teardown( self.log, - self.clients[0], + client, provider, ad_hangup=None, verify_callee_func=provider_in_call_check_func): self.log.error("Setup Call Failed.") return False self.log.info("5. Verify data.") - if not verify_internet_connection(self.log, self.provider): - self.provider.log.error("Provider have no Internet access.") - if not verify_internet_connection(self.log, self.clients[0]): - self.clients[0].log.error("Client have no Internet access.") - hangup_call(self.log, self.provider) + if not verify_internet_connection(self.log, provider): + self.log.error("Provider have no Internet access.") + if not verify_internet_connection(self.log, client): + self.log.error("Client have no Internet access.") + hangup_call(self.log, provider) finally: - if not wifi_tethering_cleanup(self.log, self.provider, - self.clients): + if not wifi_tethering_cleanup(self.log, provider, [client]): return False return True @@ -1587,13 +1584,14 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10, @@ -1615,13 +1613,14 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False try: if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -1629,24 +1628,24 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("WiFi Tethering failed.") return False - if not self.provider.droid.wifiIsApEnabled(): + if not ads[0].droid.wifiIsApEnabled(): self.log.error("Provider WiFi tethering stopped.") return False - self.provider.log.info("Reboot provider") - self.provider.reboot() + self.log.info("Reboot DUT:{}".format(ads[0].serial)) + ads[0].reboot() time.sleep(WAIT_TIME_AFTER_REBOOT + WAIT_TIME_TETHERING_AFTER_REBOOT) self.log.info("After reboot check if tethering stopped.") - if self.provider.droid.wifiIsApEnabled(): + if ads[0].droid.wifiIsApEnabled(): self.log.error("Provider WiFi tethering did NOT stopped.") return False finally: - self.clients[0].droid.telephonyToggleDataConnection(True) - wifi_reset(self.log, self.clients[0]) - if self.provider.droid.wifiIsApEnabled(): - stop_wifi_tethering(self.log, self.provider) + ads[1].droid.telephonyToggleDataConnection(True) + wifi_reset(self.log, ads[1]) + if ads[0].droid.wifiIsApEnabled(): + stop_wifi_tethering(self.log, ads[0]) return True @test_tracker_info(uuid="5cf04ca2-dfde-43d6-be74-78b9abdf6c26") @@ -1667,22 +1666,23 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False self.log.info("Make sure DUT can connect to live network by WIFI") - if ((not ensure_wifi_connected(self.log, self.provider, + if ((not ensure_wifi_connected(self.log, ads[0], self.wifi_network_ssid, self.wifi_network_pass)) or - (not verify_internet_connection(self.log, self.provider))): + (not verify_internet_connection(self.log, ads[0]))): self.log.error("WiFi connect fail.") return False try: if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -1694,29 +1694,27 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("Provider WiFi tethering stopped.") return False - self.provider.log.info("Reboot Provider") - self.provider.reboot() + self.log.info("Reboot DUT:{}".format(ads[0].serial)) + ads[0].reboot() time.sleep(WAIT_TIME_AFTER_REBOOT) time.sleep(WAIT_TIME_TETHERING_AFTER_REBOOT) self.log.info("After reboot check if tethering stopped.") - if self.provider.droid.wifiIsApEnabled(): - self.provider.log.error( - "Provider WiFi tethering did NOT stopped.") + if ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering did NOT stopped.") return False self.log.info("Make sure WiFi can connect automatically.") - if (not wait_for_wifi_data_connection(self.log, self.provider, - True) or - not verify_internet_connection(self.log, self.provider)): + if (not wait_for_wifi_data_connection(self.log, ads[0], True) or + not verify_internet_connection(self.log, ads[0])): self.log.error("Data did not return to WiFi") return False finally: - self.clients[0].droid.telephonyToggleDataConnection(True) - wifi_reset(self.log, self.clients[0]) - if self.provider.droid.wifiIsApEnabled(): - stop_wifi_tethering(self.log, self.provider) + ads[1].droid.telephonyToggleDataConnection(True) + wifi_reset(self.log, ads[1]) + if ads[0].droid.wifiIsApEnabled(): + stop_wifi_tethering(self.log, ads[0]) return True @test_tracker_info(uuid="e0621997-c5bd-4137-afa6-b43406e9c713") @@ -1736,26 +1734,28 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices + if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False self.log.info("Make sure DUT can connect to live network by WIFI") - if ((not ensure_wifi_connected(self.log, self.provider, + if ((not ensure_wifi_connected(self.log, ads[0], self.wifi_network_ssid, self.wifi_network_pass)) or - (not verify_internet_connection(self.log, self.provider))): + (not verify_internet_connection(self.log, ads[0]))): self.log.error("WiFi connect fail.") return False - self.provider.log.info("Reboot provider") - self.provider.reboot() + self.log.info("Reboot DUT:{}".format(ads[0].serial)) + ads[0].reboot() time.sleep(WAIT_TIME_AFTER_REBOOT) time.sleep(WAIT_TIME_TETHERING_AFTER_REBOOT) return wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=10) @@ -1778,13 +1778,14 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False try: if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -1792,32 +1793,33 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("WiFi Tethering failed.") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering stopped.") return False - self.provider.log.info("Turn off screen on provider") - self.provider.droid.goToSleepNow() + self.log.info( + "Turn off screen on provider: <{}>.".format(ads[0].serial)) + ads[0].droid.goToSleepNow() time.sleep(60) - if not verify_internet_connection(self.log, self.clients[0]): - self.client.log.error("Client have no Internet access.") + if not verify_internet_connection(self.log, ads[1]): + self.log.error("Client have no Internet access.") return False - self.provider.log.info("Enable doze mode on provider") - if not enable_doze(self.provider): - self.provider.log.error("Failed to enable doze mode.") + self.log.info( + "Enable doze mode on provider: <{}>.".format(ads[0].serial)) + if not enable_doze(ads[0]): + self.log.error("Failed to enable doze mode.") return False time.sleep(60) - if not verify_internet_connection(self.log, self.clients[0]): - self.clients[0].log.error("Client have no Internet access.") + if not verify_internet_connection(self.log, ads[1]): + self.log.error("Client have no Internet access.") return False finally: self.log.info("Disable doze mode.") - if not disable_doze(self.provider): + if not disable_doze(ads[0]): self.log.error("Failed to disable doze mode.") return False - if not wifi_tethering_cleanup(self.log, self.provider, - [self.clients[0]]): + if not wifi_tethering_cleanup(self.log, ads[0], [ads[1]]): return False return True @@ -2050,6 +2052,7 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ + ads = self.android_devices if not self._test_setup_tethering(network_generation): self.log.error("Verify Internet access failed.") return False @@ -2057,7 +2060,7 @@ class TelLiveDataTest(TelephonyBaseTest): # Start WiFi Tethering if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -2065,17 +2068,17 @@ class TelLiveDataTest(TelephonyBaseTest): self.log.error("WiFi Tethering failed.") return False - if not self.provider.droid.wifiIsApEnabled(): + if not ads[0].droid.wifiIsApEnabled(): self.log.error("Provider WiFi tethering stopped.") return False # Make a voice call if voice_call_direction == DIRECTION_MOBILE_ORIGINATED: - ad_caller = self.provider - ad_callee = self.clients[0] + ad_caller = ads[0] + ad_callee = ads[1] else: - ad_caller = self.clients[0] - ad_callee = self.provider + ad_caller = ads[1] + ad_callee = ads[0] if not call_setup_teardown(self.log, ad_caller, ad_callee, None, None, None): self.log.error("Failed to Establish {} Voice Call".format( @@ -2083,37 +2086,33 @@ class TelLiveDataTest(TelephonyBaseTest): return False # Tethering should still be on. - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering stopped.") return False if not is_data_available_during_call: - if verify_internet_connection( - self.log, self.clients[0], retry=0): - self.clients[0].log.error( - "Client should not have Internet Access.") + if verify_internet_connection(self.log, ads[1], retry=0): + self.log.error("Client should not have Internet Access.") return False else: - if not verify_internet_connection(self.log, self.clients[0]): - self.clients[0].error( - "Client should have Internet Access.") + if not verify_internet_connection(self.log, ads[1]): + self.log.error("Client should have Internet Access.") return False # Hangup call. Client should have data. - if not hangup_call(self.log, self.provider): - self.provider.log.error("Failed to hang up call") + if not hangup_call(self.log, ads[0]): + self.log.error("Failed to hang up call") return False - if not self.provider.droid.wifiIsApEnabled(): - self.provider.log.error("Provider WiFi tethering stopped.") + if not ads[0].droid.wifiIsApEnabled(): + self.log.error("Provider WiFi tethering stopped.") return False - if not verify_internet_connection(self.log, self.clients[0]): - self.clients[0].log.error( - "Client should have Internet Access.") + if not verify_internet_connection(self.log, ads[1]): + self.log.error("Client should have Internet Access.") return False finally: - self.clients[0].droid.telephonyToggleDataConnection(True) - wifi_reset(self.log, self.clients[0]) - if self.provider.droid.wifiIsApEnabled(): - stop_wifi_tethering(self.log, self.provider) + ads[1].droid.telephonyToggleDataConnection(True) + wifi_reset(self.log, ads[1]) + if ads[0].droid.wifiIsApEnabled(): + stop_wifi_tethering(self.log, ads[0]) return True @test_tracker_info(uuid="4d7a68c6-5eae-4242-a6e6-668f830caec3") @@ -2188,12 +2187,12 @@ class TelLiveDataTest(TelephonyBaseTest): True if success. False if failed. """ - current_data_sub_id = self.provider.droid.subscriptionGetDefaultDataSubId( - ) + ads = self.android_devices + current_data_sub_id = ads[0].droid.subscriptionGetDefaultDataSubId() current_sim_slot_index = get_slot_index_from_subid( - self.log, self.provider, current_data_sub_id) - self.provider.log.info("Current Data is on subId: %s, SIM slot: %s", - current_data_sub_id, current_sim_slot_index) + self.log, ads[0], current_data_sub_id) + self.log.info("Current Data is on subId: {}, SIM slot: {}".format( + current_data_sub_id, current_sim_slot_index)) if not self._test_setup_tethering(): self.log.error("Verify Internet access failed.") return False @@ -2201,7 +2200,7 @@ class TelLiveDataTest(TelephonyBaseTest): # Start WiFi Tethering if not wifi_tethering_setup_teardown( self.log, - self.provider, [self.clients[0]], + ads[0], [ads[1]], ap_band=WIFI_CONFIG_APBAND_2G, check_interval=10, check_iteration=2, @@ -2214,20 +2213,19 @@ class TelLiveDataTest(TelephonyBaseTest): SIM2_SLOT_INDEX : SIM1_SLOT_INDEX}[current_sim_slot_index] self.log.info( "Change Data to SIM slot: {}".format(next_sim_slot_index)) - if not change_data_sim_and_verify_data(self.log, self.provider, + if not change_data_sim_and_verify_data(self.log, ads[0], next_sim_slot_index): - self.provider.log.error("Failed to change data SIM.") + self.log.error("Failed to change data SIM.") return False current_sim_slot_index = next_sim_slot_index - if not verify_internet_connection(self.log, self.clients[0]): - self.clients[0].log.error( - "Client should have Internet Access.") + if not verify_internet_connection(self.log, ads[1]): + self.log.error("Client should have Internet Access.") return False finally: - self.cliets[0].droid.telephonyToggleDataConnection(True) - wifi_reset(self.log, self.clients[0]) - if self.provider.droid.wifiIsApEnabled(): - stop_wifi_tethering(self.log, self.provider) + ads[1].droid.telephonyToggleDataConnection(True) + wifi_reset(self.log, ads[1]) + if ads[0].droid.wifiIsApEnabled(): + stop_wifi_tethering(self.log, ads[0]) return True @test_tracker_info(uuid="8bb9383f-ddf9-400c-a831-c9462bae6b47") @@ -2304,85 +2302,6 @@ class TelLiveDataTest(TelephonyBaseTest): return True - @test_tracker_info(uuid="ef03eff7-ddd3-48e9-8f67-5e271e14048b") - @TelephonyBaseTest.tel_test_wrap - def test_vzw_embms_services(self): - ad = self.android_devices[0] - # Install App and Push config - self.log.info("Pushing embms config and apk to the Android device.") - embms_path_str = "embms_path" - android_embms_path = "/sdcard/mobitv" - if embms_path_str not in self.user_params: - self.log.error("Need vzwdca for embms test in config file") - return False - embms_path = self.user_params[embms_path_str] - ad.adb.shell("mkdir /sdcard/mobitv") - dcafile = os.path.join(embms_path, "dca.config") - apkfile = os.path.join(embms_path, "VzwDCA-v3035.apk") - ad.adb.push("%s %s" % (dcafile, android_embms_path)) - ad.adb.install("%s" % apkfile) - - # Co-ordinates Mapping - lcd_density = ad.adb.shell("getprop ro.sf.lcd_density") - ad.log.debug("lcd_density %s" % lcd_density) - if "420" in lcd_density: - agree_y_axis = 1000 - else: - agree_y_axis = 1300 - - # Screen ON needed to open the VZW App - if "ON" in \ - ad.adb.shell( - "dumpsys power | grep 'Display Power: state' | cut -d '=' -f2"): - ad.log.info("Screen already ON") - ad.adb.shell("input keyevent 82") - else: - ad.log.info("Screen OFF, turning ON") - ad.adb.shell("input keyevent 26") - ad.adb.shell("input keyevent 82") - - try: - # Check if app is installed - if ad.is_apk_installed("com.mobitv.vzwdca"): - ad.log.info("VZWDCA App is successfully installed") - else: - ad.log.error("VZWDCA App is not installed") - return False - - # Grant Permissions, Start, Agree, Register - for cmd in ("pm grant com.mobitv.vzwdca " - "android.permission.READ_EXTERNAL_STORAGE", - "pm grant com.mobitv.vzwdca " - "android.permission.WRITE_EXTERNAL_STORAGE", - "am start -a android.intent.action.VIEW -n " - "com.mobitv.vzwdca/.DcaActivity", - "input tap 500 %d" % agree_y_axis, "input keyevent 66", - "input keyevent 66", "input keyevent 66"): - time.sleep(1) - ad.log.info(cmd) - ad.adb.shell(cmd) - - # Check Reg-DeReg - time.sleep(5) - if ad.is_apk_running("com.qualcomm.ltebc_vzw"): - ad.log.info("EMBMS Registered successfully") - ad.adb.shell("input keyevent 61") - time.sleep(1) - ad.adb.shell("input keyevent 66") - time.sleep(1) - if not ad.is_apk_running("com.qualcomm.ltebc_vzw"): - ad.log.info("EMBMS De-Registered successfully") - return True - else: - ad.log.error("EMBMS De-Registeration Failed") - return False - else: - ad.log.error("EMBMS Registeration Failed") - return False - finally: - ad.log.info("Force Close the VZW App") - ad.adb.shell("am force-stop com.mobitv.vzwdca") - @test_tracker_info(uuid="8a8cd773-77f5-4802-85ac-1a654bb4743c") @TelephonyBaseTest.tel_test_wrap def test_disable_data_on_non_active_data_sim(self): @@ -2444,57 +2363,4 @@ class TelLiveDataTest(TelephonyBaseTest): ad.droid.telephonyToggleDataConnectionForSubscription( non_active_sub_id, True) return True - - def file_download_stress(self): - failure = 0 - total_count = 0 - self.result_info = collections.defaultdict(int) - dut = self.android_devices[0] - self.max_sleep_time = int(self.user_params.get("max_sleep_time", 1200)) - #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"] - file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB"] - while total_count < self.stress_test_number: - total_count += 1 - try: - dut.log.info(dict(self.result_info)) - selection = random.randrange(0, len(file_names)) - file_name = file_names[selection] - self.result_info["Total %s file download" % file_name] += 1 - if not active_file_download_test(self.log, dut, file_name): - self.result_info["%s file download failure" % - file_name] += 1 - failure += 1 - dut.take_bug_report("%s_failure_%s" % (self.test_name, - failure), - time.strftime("%m-%d-%Y-%H-%M-%S")) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except Exception as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - dut.log.info("File download test failure: %s/%s", failure, - total_count) - if failure / total_count > 0.1: - dut.log.error("File download test failure: %s/%s", failure, - total_count) - return False - return True - - @test_tracker_info(uuid="5381a6fa-6771-4b00-a0d6-4a3891a6dba8") - @TelephonyBaseTest.tel_test_wrap - def test_file_download_stress_default(self): - """File download stress test - - Steps: - 1. Download a file random picked. - 2. Device sleep for sometime and Repeat 1 . - - Expected Results: - Total download failure rate is less than 10%. - - Returns: - True if success. - False if failed. - """ - return self.file_download_stress() """ Tests End """ diff --git a/acts/tests/google/tel/live/TelLiveMobilityStressTest.py b/acts/tests/google/tel/live/TelLiveMobilityStressTest.py index 7da1491d7e..134fbb6171 100644 --- a/acts/tests/google/tel/live/TelLiveMobilityStressTest.py +++ b/acts/tests/google/tel/live/TelLiveMobilityStressTest.py @@ -56,23 +56,13 @@ from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_2g from acts.test_utils.tel.tel_voice_utils import phone_setup_volte from acts.test_utils.tel.tel_voice_utils import get_current_voice_rat - -from acts.logger import epoch_to_log_line_timestamp -from acts.utils import get_current_epoch_time from acts.utils import rand_ascii_str - from TelWifiVoiceTest import TelWifiVoiceTest from TelWifiVoiceTest import ATTEN_NAME_FOR_WIFI_2G from TelWifiVoiceTest import ATTEN_NAME_FOR_WIFI_5G from TelWifiVoiceTest import ATTEN_NAME_FOR_CELL_3G from TelWifiVoiceTest import ATTEN_NAME_FOR_CELL_4G -import socket -from acts.controllers.sl4a_client import Sl4aProtocolError - -IGNORE_EXCEPTIONS = (BrokenPipeError, Sl4aProtocolError) -EXCEPTION_TOLERANCE = 20 - class TelLiveMobilityStressTest(TelWifiVoiceTest): def setup_class(self): @@ -91,10 +81,6 @@ class TelLiveMobilityStressTest(TelWifiVoiceTest): self.user_params.get("signal_change_interval", 10)) self.signal_change_step = int( self.user_params.get("signal_change_step", 5)) - self.min_sms_length = int(self.user_params.get("min_sms_length", 1)) - self.min_mms_length = int(self.user_params.get("min_mms_length", 1)) - self.min_phone_call_duration = int( - self.user_params.get("min_phone_call_duration", 10)) self.dut = self.android_devices[0] self.helper = self.android_devices[1] @@ -127,16 +113,13 @@ class TelLiveMobilityStressTest(TelWifiVoiceTest): selection = random.randrange(0, 2) message_type_map = {0: "SMS", 1: "MMS"} max_length_map = {0: self.max_sms_length, 1: self.max_mms_length} - min_length_map = {0: self.min_sms_length, 1: self.min_mms_length} - length = random.randrange(min_length_map[selection], - max_length_map[selection] + 1) + length = random.randrange(0, max_length_map[selection] + 1) text = rand_ascii_str(length) message_content_map = {0: [text], 1: [("Mms Message", text, None)]} message_func_map = { 0: sms_send_receive_verify, 1: mms_send_receive_verify } - self.result_info["Total %s" % message_type_map[selection]] += 1 if not message_func_map[selection](self.log, ads[0], ads[1], message_content_map[selection]): self.log.error("%s of length %s from %s to %s fails", @@ -151,50 +134,37 @@ class TelLiveMobilityStressTest(TelWifiVoiceTest): return True def _make_phone_call(self, ads): - self.result_info["Total Calls"] += 1 if not call_setup_teardown( self.log, ads[0], ads[1], ad_hangup=ads[random.randrange(0, 2)], + verify_caller_func=is_voice_attached, + verify_callee_func=is_voice_attached, wait_time_in_call=random.randrange( - self.min_phone_call_duration, - self.max_phone_call_duration)): - self.log.error("Call setup and teardown failed.") - self.result_info["Call Failure"] += 1 + 30, self.max_phone_call_duration)): + ads[0].log.error("Setup phone Call failed.") return False - self.log.info("Call setup and teardown succeed.") + ads[0].log.info("Setup call successfully.") return True def crash_check_test(self): failure = 0 while time.time() < self.finishing_time: - self.dut.log.info(dict(self.result_info)) - try: - begin_time = epoch_to_log_line_timestamp( - get_current_epoch_time()) - time.sleep(self.crash_check_interval) - crash_report = self.dut.check_crash_report( - "checking_crash", begin_time, True) - if crash_report: - self.dut.log.error("Find new crash reports %s", - crash_report) - failure += 1 - self.result_info["Crashes"] += 1 - except IGNORE_EXCEPTION as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Crashes found: %s", failure) - if failure: - return "%s crashes" % failure - else: - return "" + new_crash = self.dut.check_crash_report() + crash_diff = set(new_crash).difference(set(self.dut.crash_report)) + self.dut.crash_report = new_crash + if crash_diff: + self.dut.log.error("Find new crash reports %s", + list(crash_diff)) + self.dut.pull_files(list(crash_diff)) + failure += 1 + self.result_info["Crashes"] += 1 + self._take_bug_report("%s_crash_found" % self.test_name, + time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(self.crash_check_interval) + return failure def environment_change_4g_wifi(self): #block cell 3G, WIFI 2G @@ -225,7 +195,7 @@ class TelLiveMobilityStressTest(TelWifiVoiceTest): set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], MIN_RSSI_RESERVED_VALUE, MAX_RSSI_RESERVED_VALUE, self.signal_change_step, self.signal_change_interval) - return "" + return 0 def environment_change_4g_3g(self): #block wifi 2G and 5G @@ -256,110 +226,66 @@ class TelLiveMobilityStressTest(TelWifiVoiceTest): MIN_RSSI_RESERVED_VALUE, MAX_RSSI_RESERVED_VALUE, self.signal_change_step, self.signal_change_interval) - return "" + return 0 def call_test(self): failure = 0 total_count = 0 while time.time() < self.finishing_time: - try: - ads = [self.dut, self.helper] - random.shuffle(ads) - total_count += 1 - # Current Voice RAT - self.dut.log.info("Current Voice RAT is %s", - get_current_voice_rat(self.log, self.dut)) - self.helper.log.info("Current Voice RAT is %s", - get_current_voice_rat( - self.log, self.helper)) - if not self._make_phone_call(ads): - failure += 1 - self._take_bug_report("%s_call_failure" % self.test_name, - time.strftime("%m-%d-%Y-%H-%M-%S")) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTION as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Call test failure: %s/%s", failure, total_count) - if failure: - return "Call test failure: %s/%s" % (failure, total_count) - else: - return "" + ads = [self.dut, self.helper] + random.shuffle(ads) + total_count += 1 + # Current Voice RAT + self.dut.log.info("Current Voice RAT is %s", + get_current_voice_rat(self.log, self.dut)) + self.helper.log.info("Current Voice RAT is %s", + get_current_voice_rat(self.log, self.helper)) + if not self._make_phone_call(ads): + failure += 1 + self.log.error("New call test failure: %s/%s", failure, + total_count) + self.result_info["Call failure"] += 1 + self._take_bug_report("%s_call_failure" % self.test_name, + time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def message_test(self): failure = 0 total_count = 0 while time.time() < self.finishing_time: - try: - ads = [self.dut, self.helper] - random.shuffle(ads) - total_count += 1 - if not self._send_message(ads): - failure += 1 - #self._take_bug_report("%s_messaging_failure" % self.test_name, - # time.strftime("%m-%d-%Y-%H-%M-%S")) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTION as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Messaging test failure: %s/%s", failure, - total_count) - if failure / total_count > 0.1: - return "Messaging test failure: %s/%s" % (failure, total_count) - else: - return "" + ads = [self.dut, self.helper] + random.shuffle(ads) + total_count += 1 + if not self._send_message(ads): + failure += 1 + self.log.error("New messaging test failure: %s/%s", failure, + total_count) + #self._take_bug_report("%s_messaging_failure" % self.test_name, + # time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def data_test(self): failure = 0 - total_count = 0 #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"] #wifi download is very slow in lab, limit the file size upto 200MB file_names = ["5MB", "10MB", "20MB", "50MB", "200MB"] while time.time() < self.finishing_time: - total_count += 1 - try: - self.dut.log.info(dict(self.result_info)) - self.result_info["Total file download"] += 1 - selection = random.randrange(0, len(file_names)) - file_name = file_names[selection] - if not active_file_download_test(self.log, self.dut, - file_name): - self.result_info["%s file download failure" % - file_name] += 1 - #self._take_bug_report("%s_download_failure" % self.test_name, - # time.strftime("%m-%d-%Y-%H-%M-%S")) - failure += 1 - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTION as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("File download test failure: %s/%s", failure, - total_count) - if failure / total_count > 0.1: - return "File download test failure: %s/%s" % (failure, total_count) - else: - return "" + self.dut.log.info(dict(self.result_info)) + self.result_info["Total file download"] += 1 + selection = random.randrange(0, 5) + file_name = file_names[selection] + if not active_file_download_test(self.log, self.dut, file_name): + self.result_info["%s file download failure" % file_name] += 1 + #self._take_bug_report("%s_download_failure" % self.test_name, + # time.strftime("%m-%d-%Y-%H-%M-%S")) + failure += 1 + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def parallel_tests(self, change_env_func, setup_func=None): if setup_func and not setup_func(): @@ -369,13 +295,12 @@ class TelLiveMobilityStressTest(TelWifiVoiceTest): self.finishing_time = time.time() + self.max_run_time results = run_multithread_func(self.log, [(self.call_test, []), ( self.message_test, []), (self.data_test, []), ( - self.crash_check_test, []), (change_env_func, [])]) + change_env_func, []), (self.crash_check_test, [])]) self.log.info(dict(self.result_info)) - error_message = " ".join(results).strip() - if error_message: - self.log.error(error_message) - fail(error_message) - return True + if results[0]: + fail(str(dict(self.result_info))) + else: + return True """ Tests Begin """ diff --git a/acts/tests/google/tel/live/TelLiveNoSimTest.py b/acts/tests/google/tel/live/TelLiveNoSimTest.py deleted file mode 100644 index f886e61c54..0000000000 --- a/acts/tests/google/tel/live/TelLiveNoSimTest.py +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - Google -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" - Test Script for Telephony Pre Check In Sanity -""" - -import time -import os -from acts.test_decorators import test_tracker_info -from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest -from acts.test_utils.tel.tel_test_utils import dumpsys_telecom_call_info -from acts.test_utils.tel.tel_test_utils import hung_up_call_by_adb -from acts.test_utils.tel.tel_test_utils import initiate_call -from acts.test_utils.tel.tel_test_utils import initiate_emergency_dialer_call_by_adb -from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode_by_adb -from acts.test_utils.tel.tel_test_utils import STORY_LINE - - -class TelLiveNoSimTest(TelephonyBaseTest): - def setup_class(self): - self.wifi_network_ssid = self.user_params.get( - "wifi_network_ssid") or self.user_params.get("wifi_network_ssid_2g") - self.wifi_network_pass = self.user_params.get( - "wifi_network_pass") or self.user_params.get("wifi_network_pass_2g") - self.dut = self.android_devices[0] - self.fake_emergency_number = self.user_params.get( - "fake_emergency_number", STORY_LINE.strip("+")) - - def teardown_class(self): - super(TelephonyBaseTest, self).teardown_class() - #reboot to load default emergency number list ril.ecclist - self.dut.reboot() - - def setup_test(self): - if not self.dut.skip_sl4a and not getattr(self.dut, "droid"): - self.dut.start_services() - - def change_emergency_number_list(self): - existing = self.dut.adb.shell("getprop ril.ecclist") - if self.fake_emergency_number in existing: return - emergency_numbers = "%s,%s" % (existing, self.fake_emergency_number) - self.dut.log.info("Change emergency numbes to %s", emergency_numbers) - self.dut.adb.shell("setprop ril.ecclist %s" % emergency_numbers) - - def fake_emergency_call_test(self, by_emergency_dialer=True): - self.change_emergency_number_list() - time.sleep(1) - call_numbers = len(dumpsys_telecom_call_info(self.dut)) - if by_emergency_dialer: - dialing_func = initiate_emergency_dialer_call_by_adb - else: - dialing_func = initiate_call - if dialing_func( - self.log, self.dut, self.fake_emergency_number, timeout=10): - hung_up_call_by_adb(self.dut) - self.dut.log.error( - "calling to the fake emergency number should fail") - calls_info = dumpsys_telecom_call_info(self.dut) - if len(calls_info) <= call_numbers: - self.dut.log.error("New call is not in sysdump telecom") - return False - else: - self.dut.log.info("New call info = %s", calls_info[call_numbers]) - return True - - """ Tests Begin """ - - @test_tracker_info(uuid="91bc0c02-c1f2-4112-a7f8-c91617bff53e") - @TelephonyBaseTest.tel_test_wrap - def test_fake_emergency_call_by_emergency_dialer(self): - """Test emergency call with emergency dialer in user account. - - Change system emergency number list to "611". - Use the emergency dialer to call "611". - Verify DUT has in call activity. - - Returns: - True if success. - False if failed. - """ - return self.fake_emergency_call_test() - - @test_tracker_info(uuid="cdf7ddad-480f-4757-83bd-a74321b799f7") - @TelephonyBaseTest.tel_test_wrap - def test_fake_emergency_call_by_dialer(self): - """Test emergency call with dialer. - - Change system emergency number list to "611". - Call "611" by dialer. - Verify DUT has in call activity. - - Returns: - True if success. - False if failed. - """ - return self.fake_emergency_call_test(by_emergency_dialer=False) - - @test_tracker_info(uuid="e147960a-4227-41e2-bd06-65001ad5e0cd") - @TelephonyBaseTest.tel_test_wrap - def test_fake_emergency_call_in_apm(self): - """Test emergency call with emergency dialer in airplane mode. - - Enable airplane mode. - Change system emergency number list to "611". - Use the emergency dialer to call "611". - Verify DUT has in call activity. - - Returns: - True if success. - False if failed. - """ - try: - toggle_airplane_mode_by_adb(self.log, self.dut, True) - if self.fake_emergency_call_test(): - return True - else: - return False - finally: - toggle_airplane_mode_by_adb(self.log, self.dut, False) - - @test_tracker_info(uuid="34068bc8-bfa0-4c7b-9450-e189a0b93c8a") - @TelephonyBaseTest.tel_test_wrap - def test_fake_emergency_call_in_screen_lock(self): - """Test emergency call with emergency dialer in screen lock phase. - - Enable device password and then reboot upto password query window. - Change system emergency number list to "611". - Use the emergency dialer to call "611". - Verify DUT has in call activity. - - Returns: - True if success. - False if failed. - """ - try: - if not self.dut.device_password and getattr(self.dut, "droid"): - self.dut.droid.setDevicePassword("1111") - self.dut.reboot(stop_at_lock_screen=True) - if self.fake_emergency_call_test(): - return True - else: - return False - finally: - if not self.dut.ensure_screen_on(): - self.dut.log.error("User screen cannot come up") - return False - self.dut.start_services(self.dut.skip_sl4a) - if not self.dut.device_password: - self.dut.droid.disableDevicePassword() - - @test_tracker_info(uuid="1ef97f8a-eb3d-45b7-b947-ac409bb70587") - @TelephonyBaseTest.tel_test_wrap - def test_fake_emergency_call_in_screen_lock_apm(self): - """Test emergency call with emergency dialer in screen lock phase. - - Enable device password and then reboot upto password query window. - Change system emergency number list to "611". - Use the emergency dialer to call "611". - Verify DUT has in call activity. - - Returns: - True if success. - False if failed. - """ - try: - toggle_airplane_mode_by_adb(self.log, self.dut, True) - if not self.dut.device_password and getattr(self.dut, "droid"): - self.dut.droid.setDevicePassword("1111") - self.dut.reboot(stop_at_lock_screen=True) - if self.fake_emergency_call_test(): - return True - else: - return False - finally: - toggle_airplane_mode_by_adb(self.log, self.dut, False) - if not self.dut.ensure_screen_on(): - self.dut.log.error("User screen cannot come up") - return False - self.dut.start_services(self.dut.skip_sl4a) - if not self.dut.device_password: - self.dut.droid.disableDevicePassword() - - @test_tracker_info(uuid="50f8b3d9-b126-4419-b5e5-b37b850deb8e") - @TelephonyBaseTest.tel_test_wrap - def test_fake_emergency_call_in_setupwizard(self): - """Test emergency call with emergency dialer in setupwizard. - - Wipe the device and then reboot upto setupwizard. - Change system emergency number list to "611". - Use the emergency dialer to call "611". - Verify DUT has in call activity. - - Returns: - True if success. - False if failed. - """ - try: - self.dut.fastboot_wipe() - if self.fake_emergency_call_test(): - return True - else: - return False - finally: - self.dut.ensure_screen_on() - self.dut.exit_setup_wizard() - if self.dut.device_password: - self.dut.droid.setDevicePassword(self.dut.device_password) - - -""" Tests End """ diff --git a/acts/tests/google/tel/live/TelLivePostflightTest.py b/acts/tests/google/tel/live/TelLivePostflightTest.py index 85f4bcd652..1899c38eab 100644 --- a/acts/tests/google/tel/live/TelLivePostflightTest.py +++ b/acts/tests/google/tel/live/TelLivePostflightTest.py @@ -16,49 +16,23 @@ """ Test Script for Telephony Post Flight check. """ -import os -from acts import utils -from acts.test_decorators import test_tracker_info + from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest from acts.asserts import fail class TelLivePostflightTest(TelephonyBaseTest): - @test_tracker_info(uuid="ba6e260e-d2e1-4c01-9d51-ef2df1591039") @TelephonyBaseTest.tel_test_wrap def test_check_crash(self): msg = "" for ad in self.android_devices: - post_crash = ad.check_crash_report(self.test_id, None, False) + post_crash = ad.check_crash_report() pre_crash = getattr(ad, "crash_report_preflight", []) crash_diff = list(set(post_crash).difference(set(pre_crash))) if crash_diff: msg += "%s find new crash reports %s" % (ad.serial, crash_diff) + ad.pull_files(crash_diff) ad.log.error("Find new crash reports %s", crash_diff) - crash_path = os.path.join(ad.log_path, self.test_id, "Crashes") - utils.create_dir(crash_path) - ad.pull_files(crash_diff, crash_path) - if msg: - fail(msg) - return True - - @test_tracker_info(uuid="a94a0145-27be-4610-90f7-3af561d1b1ec") - @TelephonyBaseTest.tel_test_wrap - def test_check_dialer_crash(self): - msg = "" - for ad in self.android_devices: - tombstones = ad.get_file_names("/data/tombstones/") - if not tombstones: continue - for tombstone in tombstones: - ts_path = os.path.join("/data/tombstones/", tombstone) - if ad.adb.shell("cat %s | grep pid | grep dialer" % ts_path): - message = "%s dialer crash: %s " % (ad.serial, ts_path) - ad.log.error(message) - msg += message - crash_path = os.path.join(ad.log_path, self.test_id, - "Crashes") - utils.create_dir(crash_path) - ad.pull_files([], crash_path) if msg: fail(msg) return True diff --git a/acts/tests/google/tel/live/TelLivePreflightTest.py b/acts/tests/google/tel/live/TelLivePreflightTest.py index 2e0a78c05e..b0d809ac2f 100644 --- a/acts/tests/google/tel/live/TelLivePreflightTest.py +++ b/acts/tests/google/tel/live/TelLivePreflightTest.py @@ -64,12 +64,6 @@ class TelLivePreflightTest(TelephonyBaseTest): "wifi_network_pass") or self.user_params.get( "wifi_network_pass_2g") - def setup_class(self): - pass - - def setup_test(self): - pass - """ Tests Begin """ @TelephonyBaseTest.tel_test_wrap @@ -102,8 +96,7 @@ class TelLivePreflightTest(TelephonyBaseTest): @TelephonyBaseTest.tel_test_wrap def test_check_crash(self): for ad in self.android_devices: - ad.crash_report_preflight = ad.check_crash_report( - self.test_id, None, True) + ad.crash_report_preflight = ad.check_crash_report() if ad.crash_report_preflight: msg = "Find crash reports %s before test starts" % ( ad.crash_report_preflight) diff --git a/acts/tests/google/tel/live/TelLiveRebootStressTest.py b/acts/tests/google/tel/live/TelLiveRebootStressTest.py index bb3692384b..446e2e99d7 100644 --- a/acts/tests/google/tel/live/TelLiveRebootStressTest.py +++ b/acts/tests/google/tel/live/TelLiveRebootStressTest.py @@ -25,7 +25,6 @@ from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest from acts.test_utils.tel.tel_data_utils import wifi_tethering_setup_teardown from acts.test_utils.tel.tel_defines import AOSP_PREFIX from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE -from acts.test_utils.tel.tel_defines import CAPABILITY_VT from acts.test_utils.tel.tel_defines import CAPABILITY_WFC from acts.test_utils.tel.tel_defines import CAPABILITY_OMADM from acts.test_utils.tel.tel_defines import DATA_STATE_CONNECTED @@ -33,7 +32,6 @@ from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_PROVISIONING from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK from acts.test_utils.tel.tel_defines import TETHERING_MODE_WIFI from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT -from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_CRASH from acts.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_FOR_IMS @@ -41,11 +39,6 @@ from acts.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED from acts.test_utils.tel.tel_defines import WFC_MODE_DISABLED from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_ONLY from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED -from acts.test_utils.tel.tel_defines import VT_STATE_BIDIRECTIONAL -from acts.test_utils.tel.tel_subscription_utils import \ - get_incoming_voice_sub_id -from acts.test_utils.tel.tel_subscription_utils import \ - get_outgoing_voice_sub_id from acts.test_utils.tel.tel_lookup_tables import device_capabilities from acts.test_utils.tel.tel_lookup_tables import operator_capabilities from acts.test_utils.tel.tel_test_utils import call_setup_teardown @@ -57,9 +50,6 @@ from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode from acts.test_utils.tel.tel_test_utils import wait_for_cell_data_connection from acts.test_utils.tel.tel_test_utils import verify_http_connection -from acts.test_utils.tel.tel_test_utils import trigger_modem_crash -from acts.test_utils.tel.tel_test_utils import initiate_call -from acts.test_utils.tel.tel_test_utils import wait_and_answer_call from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan @@ -75,10 +65,6 @@ from acts.test_utils.tel.tel_voice_utils import phone_idle_3g from acts.test_utils.tel.tel_voice_utils import phone_idle_csfb from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan from acts.test_utils.tel.tel_voice_utils import phone_idle_volte -from acts.test_utils.tel.tel_video_utils import video_call_setup_teardown -from acts.test_utils.tel.tel_video_utils import phone_setup_video -from acts.test_utils.tel.tel_video_utils import \ - is_phone_in_call_video_bidirectional from acts.utils import rand_ascii_str @@ -96,8 +82,8 @@ class TelLiveRebootStressTest(TelephonyBaseTest): self.wifi_network_pass = None self.dut = self.android_devices[0] - self.ad_reference = self.android_devices[1] if len( - self.android_devices) > 1 else None + self.ad_reference = self.android_devices[ + 1] if len(self.android_devices) > 1 else None self.dut_model = get_model_name(self.dut) self.dut_operator = get_operator_name(self.log, self.dut) @@ -114,7 +100,7 @@ class TelLiveRebootStressTest(TelephonyBaseTest): def _check_provision(self): elapsed_time = 0 while (elapsed_time < MAX_WAIT_TIME_PROVISIONING): - if self._check_provisioning(): + if self._check_provisioning(self.dut): return True else: time.sleep(CHECK_INTERVAL) @@ -140,7 +126,7 @@ class TelLiveRebootStressTest(TelephonyBaseTest): total_count = float(len(input_list)) if input_list == []: return False - return float(total_sum / total_count) + return float(total_sum/total_count) def _check_lte_data(self): self.log.info("Check LTE data.") @@ -153,12 +139,12 @@ class TelLiveRebootStressTest(TelephonyBaseTest): return True def _check_volte(self): - if (CAPABILITY_VOLTE in operator_capabilities[self.dut_operator]): + if (CAPABILITY_VOLTE in device_capabilities[self.dut_model] and + CAPABILITY_VOLTE in operator_capabilities[self.dut_operator]): self.log.info("Check VoLTE") if not phone_setup_volte(self.log, self.dut): self.log.error("Failed to setup VoLTE.") return False - time.sleep(5) if not call_setup_teardown(self.log, self.dut, self.ad_reference, self.dut, is_phone_in_call_volte): self.log.error("VoLTE Call Failed.") @@ -170,27 +156,9 @@ class TelLiveRebootStressTest(TelephonyBaseTest): return False return True - def _check_vt(self): - if (CAPABILITY_VT in operator_capabilities[self.dut_operator]): - self.log.info("Check VT") - if not phone_setup_video(self.log, self.dut): - self.log.error("Failed to setup VT.") - return False - time.sleep(5) - if not video_call_setup_teardown( - self.log, - self.dut, - self.ad_reference, - self.dut, - video_state=VT_STATE_BIDIRECTIONAL, - verify_caller_func=is_phone_in_call_video_bidirectional, - verify_callee_func=is_phone_in_call_video_bidirectional): - self.log.error("VT Call Failed.") - return False - return True - def _check_wfc(self): - if (CAPABILITY_WFC in operator_capabilities[self.dut_operator]): + if (CAPABILITY_WFC in device_capabilities[self.dut_model] and + CAPABILITY_WFC in operator_capabilities[self.dut_operator]): self.log.info("Check WFC") if not phone_setup_iwlan( self.log, self.dut, True, WFC_MODE_WIFI_PREFERRED, @@ -266,76 +234,6 @@ class TelLiveRebootStressTest(TelephonyBaseTest): return False return True - def _telephony_monitor_test(self): - """ - Steps - - 1. Reboot the phone - 2. Start Telephony Monitor using adb/developer options - 3. Verify if it is running - 4. Phone Call from A to B - 5. Answer on B - 6. Trigger ModemSSR on B - 7. There will be a call drop with Media Timeout/Server Unreachable - 8. Parse logcat to confirm that - - Expected Results: - UI Notification is received by User - - Returns: - True is pass, False if fail. - """ - # Reboot - ads = self.android_devices - ads[0].adb.shell( - "am start -n com.android.settings/.DevelopmentSettings", - ignore_status=True) - ads[0].log.info("reboot!") - ads[0].reboot() - ads[0].log.info("wait %d secs for radio up." % WAIT_TIME_AFTER_REBOOT) - time.sleep(WAIT_TIME_AFTER_REBOOT) - - # Ensure apk is running - if not ads[0].is_apk_running("com.google.telephonymonitor"): - ads[0].log.info("TelephonyMonitor is not running, start it now") - ads[0].adb.shell( - 'am broadcast -a ' - 'com.google.gservices.intent.action.GSERVICES_OVERRIDE -e ' - '"ce.telephony_monitor_enable" "true"') - - # Setup Phone Call - caller_number = ads[0].cfg['subscription'][get_outgoing_voice_sub_id( - ads[0])]['phone_num'] - callee_number = ads[1].cfg['subscription'][get_incoming_voice_sub_id( - ads[1])]['phone_num'] - tasks = [(phone_setup_voice_general, (self.log, ads[0])), - (phone_setup_voice_general, (self.log, ads[1]))] - if not multithread_func(self.log, tasks): - self.log.error("Phone Failed to Set Up Properly.") - return False - - if not initiate_call(ads[0].log, ads[0], callee_number): - ads[0].log.error("Phone was unable to initate a call") - return False - if not wait_and_answer_call(self.log, ads[1], caller_number): - ads[0].log.error("wait_and_answer_call failed") - return False - - # Modem SSR - time.sleep(5) - ads[1].log.info("Triggering ModemSSR") - ads[1].adb.shell( - "echo restart > /sys/kernel/debug/msm_subsys/modem", - ignore_status=True) - time.sleep(60) - - # Parse logcat for UI notification - if ads[0].search_logcat("Bugreport notification title Call Drop:"): - ads[0].log.info("User got the Call Drop Notification") - else: - ads[0].log.error("User didn't get Call Drop Notification in 1 min") - return False - return True - def _reboot_stress_test(self, **kwargs): """Reboot Reliability Test @@ -378,7 +276,10 @@ class TelLiveRebootStressTest(TelephonyBaseTest): self.log.error("method %s is not supported" % method) required_methods = [] - for method in test_method_mapping.keys(): + for method in ("check_provistion", "check_call_setup_teardown", + "check_lte_data", "check_volte", "check_wfc", + "check_3g", "check_tethering", "check_data_roaming", + "clear_provion"): if method in kwargs: required_methods.append(method) for i in range(1, self.stress_test_number + 1): @@ -408,89 +309,6 @@ class TelLiveRebootStressTest(TelephonyBaseTest): test_result = False return test_result - def _crash_recovery_test(self, **kwargs): - """Crash Recovery Test - - Arguments: - check_lte_data: whether to check the LTE data. - check_volte: whether to check Voice over LTE. - check_vt: whether to check VT - check_wfc: whether to check Wifi Calling. - - Expected Results: - All Features should work as intended post crash recovery - - Returns: - True is pass, False if fail. - """ - CHECK_INTERVAL = 10 - - toggle_airplane_mode(self.log, self.dut, False) - phone_setup_voice_general(self.log, self.ad_reference) - fail_count = collections.defaultdict(int) - test_result = True - test_method_mapping = { - "check_provision": self._check_provision, - "check_call_setup_teardown": self._check_call_setup_teardown, - "check_lte_data": self._check_lte_data, - "check_volte": self._check_volte, - "check_vt": self._check_vt, - "check_wfc": self._check_wfc, - "check_3g": self._check_3g, - "check_tethering": self._check_tethering, - "check_data_roaming": self._check_data_roaming_status, - "clear_provision": self._clear_provisioning - } - for kwarg in kwargs: - if kwarg not in test_method_mapping: - self.log.error("method %s is not supported" % method) - - required_methods = [] - for method in test_method_mapping.keys(): - if method in kwargs: required_methods.append(method) - - process_list = ("rild", "netmgrd", "com.android.phone", "imsqmidaemon", - "imsdatadaemon", "ims_rtp_daemon", "netd", - "com.android.ims.rcsservice", "system_server", "cnd", - "modem") - for service in process_list: - iteration_result = "pass" - self.log.info("Crash Recover Test for Process <%s>" % service) - self.log.info("%s kill Process %s" % (self.dut.serial, service)) - if service == "modem": - trigger_modem_crash(self.log, self.dut) - time.sleep(WAIT_TIME_AFTER_CRASH * 2) - else: - process_pid = self.dut.adb.shell("pidof %s" % service) - self.log.info("%s is the pidof %s" % (process_pid, service)) - if not process_pid: - self.dut.log.error("Process %s not running" % service) - iteration_result = "fail" - if service == "netd" or service == "system_server": - self.dut.stop_services() - self.dut.adb.shell( - "kill -9 %s" % process_pid, ignore_status=True) - self.log.info("%s wait %d sec for radio up." % - (self.dut.serial, WAIT_TIME_AFTER_CRASH)) - time.sleep(WAIT_TIME_AFTER_CRASH) - if service == "netd" or service == "system_server": - self.dut.start_services() - process_pid_new = self.dut.adb.shell("pidof %s" % service) - if process_pid == process_pid_new: - self.log.error("kill failed old:%s new:%s" % - (process_pid, process_pid_new)) - for check in required_methods: - if not test_method_mapping[check](): - fail_count[check] += 1 - iteration_result = "fail" - self.log.info("Crash Recover Test for Process <%s> %s" % - (service, iteration_result)) - for failure, count in fail_count.items(): - if count: - self.log.error("%d %s failures" % (count, failure)) - test_result = False - return test_result - def _telephony_bootup_time_test(self, **kwargs): """Telephony Bootup Perf Test @@ -516,28 +334,25 @@ class TelLiveRebootStressTest(TelephonyBaseTest): for i in range(1, self.stress_test_number + 1): ad.log.info("Telephony Bootup Time Test %s Iteration: %d / %d", - self.test_name, i, self.stress_test_number) + self.test_name, i, self.stress_test_number) ad.log.info("reboot!") ad.reboot() iteration_result = "pass" time.sleep(30) text_search_mapping = { - 'boot_complete': "processing action (sys.boot_completed=1)", - 'Voice_Reg': - "< VOICE_REGISTRATION_STATE {.regState = REG_HOME", - 'Data_Reg': "< DATA_REGISTRATION_STATE {.regState = REG_HOME", - 'Data_Call_Up': "onSetupConnectionCompleted result=SUCCESS", - 'VoLTE_Enabled': "isVolteEnabled=true", + 'boot_complete' : "processing action (sys.boot_completed=1)", + 'Voice_Reg' : "< VOICE_REGISTRATION_STATE {.regState = REG_HOME", + 'Data_Reg' : "< DATA_REGISTRATION_STATE {.regState = REG_HOME", + 'Data_Call_Up' : "onSetupConnectionCompleted result=SUCCESS", + 'VoLTE_Enabled' : "isVolteEnabled=true", } - text_obj_mapping = { - "boot_complete": None, - "Voice_Reg": None, - "Data_Reg": None, - "Data_Call_Up": None, - "VoLTE_Enabled": None, - } + text_obj_mapping = {"boot_complete" : None, + "Voice_Reg" : None, + "Data_Reg" : None, + "Data_Call_Up" : None, + "VoLTE_Enabled" : None,} blocked_for_calculate = ["boot_complete"] for tel_state in text_search_mapping: @@ -546,8 +361,9 @@ class TelLiveRebootStressTest(TelephonyBaseTest): text_obj_mapping[tel_state] = dict_match[0]['datetime_obj'] else: ad.log.error("Cannot Find Text %s in logcat", - text_search_mapping[tel_state]) + text_search_mapping[tel_state]) blocked_for_calculate.append(tel_state) + fail_count[tel_state] += 1 for tel_state in text_search_mapping: if tel_state not in blocked_for_calculate: @@ -558,13 +374,10 @@ class TelLiveRebootStressTest(TelephonyBaseTest): if tel_state in keyword_time_dict: keyword_time_dict[tel_state].append(time_diff.seconds) else: - keyword_time_dict[tel_state] = [ - time_diff.seconds, - ] + keyword_time_dict[tel_state] = [time_diff.seconds,] ad.log.info("Telephony Bootup Time Test %s Iteration: %d / %d %s", - self.test_name, i, self.stress_test_number, - iteration_result) + self.test_name, i, self.stress_test_number, iteration_result) for tel_state in text_search_mapping: if tel_state not in blocked_for_calculate: @@ -574,17 +387,18 @@ class TelLiveRebootStressTest(TelephonyBaseTest): tel_state, self.stress_test_number, avg_time) else: ad.log.error("Average %s for %d iterations = %.2f seconds", - tel_state, self.stress_test_number, avg_time) + tel_state, self.stress_test_number, avg_time) fail_count[tel_state] += 1 ad.log.info("Bootup Time Dict {}".format(keyword_time_dict)) for failure, count in fail_count.items(): if count: - ad.log.error("%d %d failures in %d iterations", count, failure, - self.stress_test_number) + ad.log.error("%d %d failures in %d iterations", + count, failure, self.stress_test_number) test_result = False return test_result + """ Tests Begin """ @test_tracker_info(uuid="4d9b425b-f804-45f4-8f47-0ba3f01a426b") @@ -735,41 +549,5 @@ class TelLiveRebootStressTest(TelephonyBaseTest): """ return self._telephony_bootup_time_test() - @TelephonyBaseTest.tel_test_wrap - @test_tracker_info(uuid="08752fac-dbdb-4d5b-91f6-4ffc3a3ac6d6") - def test_crash_recovery_functional(self): - """Crash Recovery Test - - Steps: - 1. Crash multiple daemons/processes - 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT - - Expected Results: - No crash happens in functional test, features work fine. - - Returns: - True is pass, False if fail. - """ - return self._crash_recovery_test( - check_lte_data=True, check_volte=True, check_vt=True) - - @TelephonyBaseTest.tel_test_wrap - @test_tracker_info(uuid="b6d2fccd-5dfd-4637-aa3b-257837bfba54") - def test_telephonymonitor_functional(self): - """Telephony Monitor Functional Test - - Steps: - 1. Verify Telephony Monitor functionality is working or not - 2. Force Trigger a call drop : media timeout and ensure it is - notified by Telephony Monitor - - Expected Results: - feature work fine, and does report to User about Call Drop - - Returns: - True is pass, False if fail. - """ - return self._telephony_monitor_test() - """ Tests End """ diff --git a/acts/tests/google/tel/live/TelLiveSettingsTest.py b/acts/tests/google/tel/live/TelLiveSettingsTest.py index 59d84c6c3e..dc070d0612 100644 --- a/acts/tests/google/tel/live/TelLiveSettingsTest.py +++ b/acts/tests/google/tel/live/TelLiveSettingsTest.py @@ -28,14 +28,12 @@ from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_WFC_ENABLED from acts.test_utils.tel.tel_defines import RAT_FAMILY_WLAN from acts.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED from acts.test_utils.tel.tel_defines import WFC_MODE_DISABLED -from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_ONLY from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED -from acts.test_utils.tel.tel_test_utils import call_setup_teardown from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected from acts.test_utils.tel.tel_test_utils import is_droid_in_rat_family from acts.test_utils.tel.tel_test_utils import is_wfc_enabled from acts.test_utils.tel.tel_test_utils import set_wfc_mode -from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode_by_adb +from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode from acts.test_utils.tel.tel_test_utils import toggle_volte from acts.test_utils.tel.tel_test_utils import verify_http_connection from acts.test_utils.tel.tel_test_utils import wait_for_ims_registered @@ -47,13 +45,11 @@ from acts.test_utils.tel.tel_test_utils import wait_for_wfc_enabled from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection from acts.test_utils.tel.tel_test_utils import wifi_reset from acts.test_utils.tel.tel_test_utils import wifi_toggle_state -from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan from acts.test_utils.tel.tel_voice_utils import phone_setup_volte from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan -from acts.test_utils.tel.tel_voice_utils import phone_idle_volte class TelLiveSettingsTest(TelephonyBaseTest): @@ -200,7 +196,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): if not phone_idle_iwlan(self.log, self.ad): self.log.error("WFC is not available.") return False - if not toggle_airplane_mode_by_adb(self.log, self.ad, False): + if not toggle_airplane_mode(self.log, self.ad, False): self.log.error("Failed to turn off airplane mode") return False is_wfc_not_available = wait_for_wfc_disabled(self.log, self.ad) @@ -314,7 +310,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. """ - if not toggle_airplane_mode_by_adb(self.log, self.ad, True): + if not toggle_airplane_mode(self.log, self.ad, True): self.log.error("Failed to turn on airplane mode") return False return self._wifi_connected_enable_wfc_teardown_wfc( @@ -415,7 +411,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. """ - if not toggle_airplane_mode_by_adb(self.log, self.ad, True): + if not toggle_airplane_mode(self.log, self.ad, True): self.log.error("Failed to turn on airplane mode") return False return self._wifi_connected_enable_wfc_teardown_wfc( @@ -562,7 +558,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 4. DUT WiFI Calling feature bit return True, network rat is iwlan. """ - if not toggle_airplane_mode_by_adb(self.log, self.ad, True): + if not toggle_airplane_mode(self.log, self.ad, True): self.log.error("Failed to turn on airplane mode") return False return self._wifi_connected_set_wfc_mode_change_wfc_mode( @@ -663,7 +659,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 4. DUT WiFI Calling feature bit return True, network rat is iwlan. """ - if not toggle_airplane_mode_by_adb(self.log, self.ad, True): + if not toggle_airplane_mode(self.log, self.ad, True): self.log.error("Failed to turn on airplane mode") return False return self._wifi_connected_set_wfc_mode_change_wfc_mode( @@ -686,7 +682,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 5. DUT WiFI Calling feature bit return True, network rat is iwlan. """ - if not toggle_airplane_mode_by_adb(self.log, self.ad, True): + if not toggle_airplane_mode(self.log, self.ad, True): self.log.error("Failed to turn on airplane mode") return False return self._wifi_connected_set_wfc_mode_turn_off_apm( @@ -709,7 +705,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 5. DUT WiFI Calling feature bit return False, network rat is not iwlan. """ - if not toggle_airplane_mode_by_adb(self.log, self.ad, True): + if not toggle_airplane_mode(self.log, self.ad, True): self.log.error("Failed to turn on airplane mode") return False return self._wifi_connected_set_wfc_mode_turn_off_apm( @@ -750,7 +746,7 @@ class TelLiveSettingsTest(TelephonyBaseTest): } wifi_reset(self.log, ad) - toggle_airplane_mode_by_adb(self.log, ad, True) + toggle_airplane_mode(self.log, ad, True) set_wfc_mode(self.log, ad, WFC_MODE_WIFI_PREFERRED) @@ -951,230 +947,3 @@ class TelLiveSettingsTest(TelephonyBaseTest): self.log.error("Test Failed in iteration: {}.".format(i)) return False return True - - def verify_volte_on_wfc_off(self): - result = True - if self.ad.droid.imsGetWfcMode() != WFC_MODE_DISABLED: - self.ad.log.error( - "WFC mode is not disabled after IMS factory reset") - result = False - else: - self.ad.log.info("WFC mode is disabled as expected") - if not self.ad.droid.imsIsEnhanced4gLteModeSettingEnabledByUser(): - self.ad.log.error("VoLTE mode is not on") - result = False - else: - self.ad.log.info("VoLTE mode is turned on as expected") - if not phone_idle_volte(self.log, self.ad): - self.ad.log.error("Voice RAT is not in LTE") - result = False - if not call_setup_teardown(self.log, self.ad, self.android_devices[1], - self.ad, is_phone_in_call_volte): - self.ad.log.error("Voice call in VoLTE failed") - result = False - return result - - def verify_volte_off_wfc_off(self): - result = True - if self.ad.droid.imsGetWfcMode() != WFC_MODE_DISABLED: - self.ad.log.error( - "WFC mode is not disabled after IMS factory reset") - result = False - else: - self.ad.log.info("WFC mode is disabled as expected") - if self.ad.droid.imsIsEnhanced4gLteModeSettingEnabledByUser(): - self.ad.log.error("VoLTE mode is on") - result = False - else: - self.ad.log.info("VoLTE mode is turned off as expected") - if not call_setup_teardown(self.log, self.ad, self.android_devices[1], - self.ad, None): - self.ad.log.error("Voice call failed") - result = False - return result - - def revert_default_telephony_setting(self): - toggle_airplane_mode_by_adb(self.log, self.ad, True) - default_data_roaming = int( - self.ad.adb.getprop("ro.com.android.dataroaming") == 'true') - default_network_preference = int( - self.ad.adb.getprop("ro.telephony.default_network")) - self.ad.log.info("Default data roaming %s, network preference %s", - default_data_roaming, default_network_preference) - new_data_roaming = abs(default_data_roaming - 1) - new_network_preference = abs(default_network_preference - 1) - self.ad.log.info( - "Set data roaming = %s, mobile data = 0, network preference = %s", - new_data_roaming, new_network_preference) - self.ad.adb.shell("settings put global mobile_data 0") - self.ad.adb.shell( - "settings put global data_roaming %s" % new_data_roaming) - self.ad.adb.shell("settings put global preferred_network_mode %s" % - new_network_preference) - - def verify_default_telephony_setting(self): - default_data_roaming = int( - self.ad.adb.getprop("ro.com.android.dataroaming") == 'true') - default_network_preference = int( - self.ad.adb.getprop("ro.telephony.default_network")) - self.ad.log.info("Default data roaming %s, network preference %s", - default_data_roaming, default_network_preference) - data_roaming = int( - self.ad.adb.shell("settings get global data_roaming")) - mobile_data = int(self.ad.adb.shell("settings get global mobile_data")) - network_preference = int( - self.ad.adb.shell("settings get global preferred_network_mode")) - airplane_mode = int( - self.ad.adb.shell("settings get global airplane_mode_on")) - result = True - self.ad.log.info("data_roaming = %s, mobile_data = %s, " - "network_perference = %s, airplane_mode = %s", - data_roaming, mobile_data, network_preference, - airplane_mode) - if airplane_mode: - self.ad.log.error("Airplane mode is on") - result = False - if data_roaming != default_data_roaming: - self.ad.log.error("Data roaming is %s, expecting %s", data_roaming, - default_data_roaming) - result = False - if not mobile_data: - self.ad.log.error("Mobile data is off") - result = False - if network_preference != default_network_preference: - self.ad.log.error("preferred_network_mode is %s, expecting %s", - network_preference, default_network_preference) - result = False - return result - - @TelephonyBaseTest.tel_test_wrap - @test_tracker_info(uuid="135301ea-6d00-4233-98fd-cda706d61eb2") - def test_ims_factory_reset_to_volte_on_wfc_off(self): - """Test VOLTE is enabled WFC is disabled after ims factory reset. - - Steps: - 1. Setup VoLTE, WFC, APM is various mode. - 2. Call IMS factory reset. - 3. Verify VoLTE is on, WFC is off after IMS factory reset. - 4. Verify VoLTE Voice call can be made successful. - - Expected Results: VoLTE is on, WFC is off after IMS factory reset. - """ - result = True - for airplane_mode in (True, False): - for volte_mode in (True, False): - for wfc_mode in (WFC_MODE_DISABLED, - WFC_MODE_CELLULAR_PREFERRED, - WFC_MODE_WIFI_PREFERRED): - self.ad.log.info("Set VoLTE %s, WFC %s, APM %s", - volte_mode, wfc_mode, airplane_mode) - toggle_airplane_mode_by_adb(self.log, self.ad, - airplane_mode) - toggle_volte(self.log, self.ad, volte_mode) - set_wfc_mode(self.log, self.ad, wfc_mode) - self.ad.log.info("Call IMS factory reset") - self.ad.droid.imsFactoryReset() - self.ad.log.info("Ensure airplane mode is off") - toggle_airplane_mode_by_adb(self.log, self.ad, False) - if not self.verify_volte_on_wfc_off(): result = False - return result - - @TelephonyBaseTest.tel_test_wrap - @test_tracker_info(uuid="5318bf7a-4210-4b49-b361-9539d28f3e38") - def test_ims_factory_reset_to_volte_off_wfc_off(self): - """Test VOLTE is enabled WFC is disabled after ims factory reset. - - Steps: - 1. Setup VoLTE, WFC, APM is various mode. - 2. Call IMS factory reset. - 3. Verify VoLTE is on, WFC is off after IMS factory reset. - 4. Verify VoLTE Voice call can be made successful. - - Expected Results: VoLTE is on, WFC is off after IMS factory reset. - """ - result = True - for airplane_mode in (True, False): - for volte_mode in (True, False): - for wfc_mode in (WFC_MODE_DISABLED, - WFC_MODE_CELLULAR_PREFERRED, - WFC_MODE_WIFI_PREFERRED): - self.ad.log.info("Set VoLTE %s, WFC %s, APM %s", - volte_mode, wfc_mode, airplane_mode) - toggle_airplane_mode_by_adb(self.log, self.ad, - airplane_mode) - toggle_volte(self.log, self.ad, volte_mode) - set_wfc_mode(self.log, self.ad, wfc_mode) - self.ad.log.info("Call IMS factory reset") - self.ad.droid.imsFactoryReset() - self.ad.log.info("Ensure airplane mode is off") - toggle_airplane_mode_by_adb(self.log, self.ad, False) - if not self.verify_volte_off_wfc_off(): result = False - return result - - @TelephonyBaseTest.tel_test_wrap - @test_tracker_info(uuid="c6149bd6-7080-453d-af37-1f9bd350a764") - def test_telephony_factory_reset(self): - """Test VOLTE is enabled WFC is disabled after telephony factory reset. - - Steps: - 1. Setup DUT with various dataroaming, mobiledata, and default_network. - 2. Call telephony factory reset. - 3. Verify DUT back to factory default. - - Expected Results: dataroaming is off, mobiledata is on, network - preference is back to default. - """ - self.ad.log.info("Call telephony factory reset") - self.revert_default_telephony_setting() - self.ad.droid.telephonyFactoryReset() - return self.verify_default_telephony_setting() - - @TelephonyBaseTest.tel_test_wrap - @test_tracker_info(uuid="ce60740f-4d8e-4013-a7cf-65589e8a0893") - def test_factory_reset_by_wipe_to_volte_on_wfc_off(self): - """Verify the network setting after factory reset by wipe. - - Steps: - 1. Config VoLTE off, WFC on, APM on, data_roaming on, mobile_data on - preferred_network_mode. - 2. Factory reset by . - 3. Verify VoLTE is on, WFC is off after IMS factory reset. - 4. Verify VoLTE Voice call can be made successful. - - Expected Results: VoLTE is on, WFC is off after IMS factory reset. - """ - self.ad.log.info("Set VoLTE off, WFC wifi preferred, APM on") - toggle_airplane_mode_by_adb(self.log, self.ad, True) - toggle_volte(self.log, self.ad, False) - set_wfc_mode(self.log, self.ad, WFC_MODE_WIFI_PREFERRED) - self.revert_default_telephony_setting() - self.ad.log.info("Wipe in fastboot") - self.ad.fastboot_wipe() - result = self.verify_volte_on_wfc_off() - if not self.verify_default_telephony_setting(): result = False - return result - - @TelephonyBaseTest.tel_test_wrap - @test_tracker_info(uuid="44e9291e-949b-4db1-a209-c6d41552ec27") - def test_factory_reset_by_wipe_to_volte_off_wfc_off(self): - """Verify the network setting after factory reset by wipe. - - Steps: - 1. Config VoLTE on, WFC on, APM on, data_roaming on, mobile_data on - preferred_network_mode. - 2. Factory reset by . - 3. Verify VoLTE is on, WFC is off after IMS factory reset. - 4. Verify VoLTE Voice call can be made successful. - - Expected Results: VoLTE is on, WFC is off after IMS factory reset. - """ - self.ad.log.info("Set VoLTE on, WFC wifi preferred, APM on") - toggle_airplane_mode_by_adb(self.log, self.ad, True) - toggle_volte(self.log, self.ad, True) - set_wfc_mode(self.log, self.ad, WFC_MODE_WIFI_PREFERRED) - self.revert_default_telephony_setting() - self.ad.log.info("Wipe in fastboot") - self.ad.fastboot_wipe() - result = self.verify_volte_off_wfc_off() - if not self.verify_default_telephony_setting(): result = False - return result diff --git a/acts/tests/google/tel/live/TelLiveSinglePhoneStressTest.py b/acts/tests/google/tel/live/TelLiveSinglePhoneStressTest.py index 2541ca6f0e..db6e824cae 100644 --- a/acts/tests/google/tel/live/TelLiveSinglePhoneStressTest.py +++ b/acts/tests/google/tel/live/TelLiveSinglePhoneStressTest.py @@ -25,14 +25,6 @@ from acts.asserts import fail from acts.test_decorators import test_tracker_info from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED -from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_ONLY -from acts.test_utils.tel.tel_defines import NETWORK_MODE_WCDMA_ONLY -from acts.test_utils.tel.tel_defines import NETWORK_MODE_GLOBAL -from acts.test_utils.tel.tel_defines import NETWORK_MODE_CDMA -from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY -from acts.test_utils.tel.tel_defines import NETWORK_MODE_TDSCDMA_GSM_WCDMA -from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA -from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_MODE_CHANGE from acts.test_utils.tel.tel_test_utils import active_file_download_test from acts.test_utils.tel.tel_test_utils import call_setup_teardown from acts.test_utils.tel.tel_test_utils import ensure_phone_default_state @@ -47,9 +39,6 @@ from acts.test_utils.tel.tel_test_utils import set_wfc_mode from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify from acts.test_utils.tel.tel_test_utils import mms_send_receive_verify from acts.test_utils.tel.tel_test_utils import verify_incall_state -from acts.test_utils.tel.tel_test_utils import set_preferred_network_mode_pref -from acts.test_utils.tel.tel_test_utils import start_adb_tcpdump -from acts.test_utils.tel.tel_test_utils import stop_adb_tcpdump from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_2g from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb @@ -61,40 +50,26 @@ from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_2g from acts.test_utils.tel.tel_voice_utils import phone_setup_volte from acts.test_utils.tel.tel_voice_utils import get_current_voice_rat -from acts.logger import epoch_to_log_line_timestamp -from acts.utils import get_current_epoch_time from acts.utils import rand_ascii_str -import socket -from acts.controllers.sl4a_client import Sl4aProtocolError - -IGNORE_EXCEPTIONS = (BrokenPipeError, Sl4aProtocolError) -EXCEPTION_TOLERANCE = 20 - class TelLiveSinglePhoneStressTest(TelephonyBaseTest): def setup_class(self): super(TelLiveSinglePhoneStressTest, self).setup_class() self.dut = self.android_devices[0] self.call_server_number = self.user_params.get("call_server_number", - "7124325335") + "9523521350") self.user_params["telephony_auto_rerun"] = False self.wifi_network_ssid = self.user_params.get( - "wifi_network_ssid") or self.user_params.get( - "wifi_network_ssid_2g") + "wifi_network_ssid") or self.user_params.get("wifi_network_ssid_2g") self.wifi_network_pass = self.user_params.get( - "wifi_network_pass") or self.user_params.get( - "wifi_network_pass_2g") + "wifi_network_pass") or self.user_params.get("wifi_network_pass_2g") self.max_phone_call_duration = int( self.user_params.get("max_phone_call_duration", 3600)) self.max_sleep_time = int(self.user_params.get("max_sleep_time", 1200)) self.max_run_time = int(self.user_params.get("max_run_time", 18000)) self.max_sms_length = int(self.user_params.get("max_sms_length", 1000)) self.max_mms_length = int(self.user_params.get("max_mms_length", 160)) - self.min_sms_length = int(self.user_params.get("min_sms_length", 1)) - self.min_mms_length = int(self.user_params.get("min_mms_length", 1)) - self.min_phone_call_duration = int( - self.user_params.get("min_phone_call_duration", 10)) self.crash_check_interval = int( self.user_params.get("crash_check_interval", 300)) @@ -151,278 +126,111 @@ class TelLiveSinglePhoneStressTest(TelephonyBaseTest): def crash_check_test(self): failure = 0 while time.time() < self.finishing_time: - self.dut.log.info(dict(self.result_info)) - try: - begin_time = epoch_to_log_line_timestamp( - get_current_epoch_time()) - time.sleep(self.crash_check_interval) - crash_report = self.dut.check_crash_report("checking_crash", - begin_time, True) - if crash_report: - self.dut.log.error("Find new crash reports %s", - crash_report) - failure += 1 - self.result_info["Crashes"] += 1 - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Crashes found: %s", failure) - if failure: - return "%s crashes" % failure - else: - return "" + new_crash = self.dut.check_crash_report() + crash_diff = set(new_crash).difference(set(self.dut.crash_report)) + self.dut.crash_report = new_crash + if crash_diff: + self.dut.log.error("Find new crash reports %s", + list(crash_diff)) + self.dut.pull_files(list(crash_diff)) + failure += 1 + self.result_info["Crashes"] += 1 + self._take_bug_report("%s_crash_found" % self.test_name, + time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(self.crash_check_interval) + return failure def call_test(self): failure = 0 - total_count = 0 - while time.time() < self.finishing_time: - total_count += 1 - try: - self.dut.log.info(dict(self.result_info)) - self.result_info["Total Calls"] += 1 - duration = random.randrange(self.min_phone_call_duration, - self.max_phone_call_duration) - # Current Voice RAT - self.dut.log.info("Current Voice RAT is %s", - get_current_voice_rat(self.log, self.dut)) - self.dut.log.info("Make call to %s with call duration %s", - self.call_server_number, duration) - if not initiate_call(self.log, self.dut, - self.call_server_number): - self.dut.log.error("Initiate phone call to %s failed.", - self.call_server_number) - self.result_info["Call initiation failure"] += 1 - failure += 1 - self._take_bug_report("%s_call_initiation_failure" % - self.test_name, - time.strftime("%m-%d-%Y-%H-%M-%S")) - continue - elapse_time = 0 - interval = min(60, duration) - while elapse_time < duration: - interval = min(duration - elapse_time, interval) - time.sleep(interval) - elapse_time += interval - if not is_phone_in_call(self.log, self.dut): - self.dut.log.error("Call droped.") - self.result_info["Call drop"] += 1 - failure += 1 - self._take_bug_report( - "%s_call_drop" % self.test_name, - time.strftime("%m-%d-%Y-%H-%M-%S")) - break - else: - self.dut.log.info("DUT is in call") - else: - hangup_call(self.log, self.dut) - self.dut.log.info("Call test succeed.") - ensure_phone_idle(self.log, self.dut) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Call test failure: %s/%s", failure, total_count) - if failure: - return "Call test failure: %s/%s" % (failure, total_count) - else: - return "" - - def volte_modechange_volte_test(self): - failure = 0 - total_count = 0 - sub_id = self.dut.droid.subscriptionGetDefaultSubId() while time.time() < self.finishing_time: - total_count += 1 - try: - self.dut.log.info(dict(self.result_info)) - self.result_info["Total Calls"] += 1 - duration = random.randrange(self.min_phone_call_duration, - self.max_phone_call_duration) - # Current Voice RAT - self.dut.log.info("Current Voice RAT is %s", - get_current_voice_rat(self.log, self.dut)) - self.dut.log.info("Make call to %s with call duration %s", - self.call_server_number, duration) - if not initiate_call(self.log, self.dut, - self.call_server_number): - self.dut.log.error("Initiate phone call to %s failed.", - self.call_server_number) - self.result_info["Call initiation failure"] += 1 - failure += 1 - self._take_bug_report("%s_call_initiation_failure" % - self.test_name, + self.dut.log.info(dict(self.result_info)) + self.result_info["Total Calls"] += 1 + duration = random.randrange(1, self.max_phone_call_duration) + # Current Voice RAT + self.dut.log.info("Current Voice RAT is %s", + get_current_voice_rat(self.log, self.dut)) + self.dut.log.info("Make call to %s with call duration %s", + self.call_server_number, duration) + if not initiate_call(self.log, self.dut, self.call_server_number): + self.dut.log.error("Initiate phone call to %s failed.", + self.call_server_number) + self.result_info["Call initiation failure"] += 1 + self._take_bug_report( + "%s_call_initiation_failure" % self.test_name, + time.strftime("%m-%d-%Y-%H-%M-%S")) + continue + elapse_time = 0 + interval = min(60, duration) + while elapse_time < duration: + interval = min(duration - elapse_time, interval) + time.sleep(interval) + elapse_time += interval + if not is_phone_in_call(self.log, self.dut): + self.dut.log.error("Call droped.") + self.result_info["Call drop"] += 1 + self._take_bug_report("%s_call_drop" % self.test_name, time.strftime("%m-%d-%Y-%H-%M-%S")) - continue - elapse_time = 0 - interval = min(5, duration) - while elapse_time < duration: - interval = min(duration - elapse_time, interval) - time.sleep(interval) - elapse_time += interval - if not is_phone_in_call_volte(self.log, self.dut): - self.dut.log.error("Call not VoLTE") - self.result_info["Call not VoLTE"] += 1 - failure += 1 - self._take_bug_report( - "%s_not_in_volte" % self.test_name, - time.strftime("%m-%d-%Y-%H-%M-%S")) - break - else: - self.dut.log.info("DUT is in VoLTE call") + break else: - hangup_call(self.log, self.dut) - self.dut.log.info("VoLTE test succeed.") - - # ModePref change to non-LTE - network_preference_list = [ - NETWORK_MODE_TDSCDMA_GSM_WCDMA, - NETWORK_MODE_WCDMA_ONLY, NETWORK_MODE_GLOBAL, - NETWORK_MODE_CDMA, NETWORK_MODE_GSM_ONLY - ] - network_preference = random.choice(network_preference_list) - set_preferred_network_mode_pref(self.dut.log, self.dut, - sub_id, network_preference) - time.sleep(WAIT_TIME_AFTER_MODE_CHANGE) - self.dut.log.info( - "Current Voice RAT is %s", - get_current_voice_rat(self.log, self.dut)) - - # ModePref change back to with LTE - set_preferred_network_mode_pref( - self.dut.log, self.dut, sub_id, - NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) - time.sleep(WAIT_TIME_AFTER_MODE_CHANGE) - - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("VoLTE test failure: %s/%s", failure, - total_count) - if failure: - return "VoLTE test failure: %s/%s" % (failure, total_count) - else: - return "" + self.dut.log.info("DUT is in call") + else: + hangup_call(self.log, self.dut) + self.dut.log.info("Call test succeed.") + ensure_phone_idle(self.log, self.dut) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def message_test(self): failure = 0 total_count = 0 message_type_map = {0: "SMS", 1: "MMS"} max_length_map = {0: self.max_sms_length, 1: self.max_mms_length} - min_length_map = {0: self.min_sms_length, 1: self.min_mms_length} message_func_map = { 0: sms_send_receive_verify, 1: mms_send_receive_verify } while time.time() < self.finishing_time: - try: - self.dut.log.info(dict(self.result_info)) - total_count += 1 - selection = random.randrange(0, 2) - message_type = message_type_map[selection] - self.result_info["Total %s" % message_type] += 1 - length = random.randrange(min_length_map[selection], - max_length_map[selection] + 1) - text = rand_ascii_str(length) - message_content_map = { - 0: [text], - 1: [("Mms Message", text, None)] - } - if not message_func_map[selection]( - self.log, self.dut, self.dut, - message_content_map[selection]): - self.log.error("%s of length %s from self to self fails", - message_type, length) - self.result_info["%s failure" % message_type] += 1 - #self._take_bug_report("%s_messaging_failure" % self.test_name, - # time.strftime("%m-%d-%Y-%H-%M-%S")) - failure += 1 - else: - self.dut.log.info( - "%s of length %s from self to self succeed", - message_type, length) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Messaging test failure: %s/%s", failure, - total_count) - if failure / total_count > 0.1: - return "Messaging test failure: %s/%s" % (failure, total_count) - else: - return "" + self.dut.log.info(dict(self.result_info)) + total_count += 1 + selection = random.randrange(0, 2) + message_type = message_type_map[selection] + self.result_info["Total %s" % message_type] += 1 + length = random.randrange(0, max_length_map[selection] + 1) + text = rand_ascii_str(length) + message_content_map = {0: [text], 1: [("Mms Message", text, None)]} + if not message_func_map[selection](self.log, self.dut, self.dut, + message_content_map[selection]): + self.log.error("%s of length %s from self to self fails", + message_type, length) + self.result_info["%s failure" % message_type] += 1 + #self._take_bug_report("%s_messaging_failure" % self.test_name, + # time.strftime("%m-%d-%Y-%H-%M-%S")) + failure += 1 + else: + self.dut.log.info("%s of length %s from self to self succeed", + message_type, length) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def data_test(self): failure = 0 total_count = 0 - tcpdump_pid = None - #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"] - file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB"] + file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"] while time.time() < self.finishing_time: - total_count += 1 - pull_tcpdump = False - try: - self.dut.log.info(dict(self.result_info)) - self.result_info["Total file download"] += 1 - selection = random.randrange(0, len(file_names)) - file_name = file_names[selection] - (tcpdump_pid, tcpdump_file) = \ - start_adb_tcpdump(self.dut, self.test_name, mask="all") - if not active_file_download_test(self.log, self.dut, - file_name): - self.result_info["%s file download failure" % - file_name] += 1 - failure += 1 - pull_tcpdump = True - self._take_bug_report("%s_download_failure" % - self.test_name, - time.strftime("%m-%d-%Y-%H-%M-%S")) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - finally: - if tcpdump_pid is not None: - stop_adb_tcpdump(self.dut, tcpdump_pid, tcpdump_file, - pull_tcpdump) - self.dut.log.info("File download test failure: %s/%s", failure, - total_count) - if failure / total_count > 0.1: - return "File download test failure: %s/%s" % (failure, total_count) - else: - return "" + self.dut.log.info(dict(self.result_info)) + self.result_info["Total file download"] += 1 + selection = random.randrange(0, 7) + file_name = file_names[selection] + if not active_file_download_test(self.log, self.dut, file_name): + self.result_info["%s file download failure" % file_name] += 1 + #self._take_bug_report("%s_download_failure" % self.test_name, + # time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def parallel_tests(self, setup_func=None): if setup_func and not setup_func(): @@ -434,27 +242,8 @@ class TelLiveSinglePhoneStressTest(TelephonyBaseTest): self.message_test, []), (self.data_test, []), (self.crash_check_test, [])]) self.log.info(dict(self.result_info)) - error_message = " ".join(results).strip() - if error_message: - self.log.error(error_message) - fail(error_message) - return True - - def parallel_volte_tests(self, setup_func=None): - if setup_func and not setup_func(): - self.log.error("Test setup %s failed", setup_func.__name__) - return False - self.result_info = collections.defaultdict(int) - self.finishing_time = time.time() + self.max_run_time - results = run_multithread_func( - self.log, [(self.volte_modechange_volte_test, []), - (self.message_test, []), (self.crash_check_test, [])]) - self.log.info(dict(self.result_info)) - error_message = " ".join(results).strip() - if error_message: - self.log.error(error_message) - fail(error_message) - return True + if sum(results): + fail(str(dict(self.result_info))) """ Tests Begin """ @@ -494,11 +283,4 @@ class TelLiveSinglePhoneStressTest(TelephonyBaseTest): """ 2G call stress test""" return self.parallel_tests(setup_func=self._setup_2g) - @test_tracker_info(uuid="af580fca-fea6-4ca5-b981-b8c710302d37") - @TelephonyBaseTest.tel_test_wrap - def test_volte_modeprefchange_parallel_stress(self): - """ VoLTE Mode Pref call stress test""" - return self.parallel_volte_tests( - setup_func=self._setup_lte_volte_enabled) - """ Tests End """ diff --git a/acts/tests/google/tel/live/TelLiveSmsTest.py b/acts/tests/google/tel/live/TelLiveSmsTest.py index 9b4e874182..f3d6ea2c91 100644 --- a/acts/tests/google/tel/live/TelLiveSmsTest.py +++ b/acts/tests/google/tel/live/TelLiveSmsTest.py @@ -495,7 +495,7 @@ class TelLiveSmsTest(TelephonyBaseTest): return self._sms_test_mt(ads) - @test_tracker_info(uuid="bb8e1a06-a4b5-4f9b-9ab2-408ace9a1deb") + @test_tracker_info(uuid="57db830c-71eb-46b3-adaa-915c641de18d") @TelephonyBaseTest.tel_test_wrap def test_mms_mo_general(self): """Test MMS basic function between two phone. Phones in any network. @@ -886,7 +886,7 @@ class TelLiveSmsTest(TelephonyBaseTest): return self._sms_test_mt(ads) - @test_tracker_info(uuid="90fc6775-de19-49d1-8b8e-e3bc9384c733") + @test_tracker_info(uuid="eae3c1cb-dc9d-4682-9ab5-ef39d207766d") @TelephonyBaseTest.tel_test_wrap def test_mms_mo_4g(self): """Test MMS text function between two phone. Phones in LTE network. @@ -910,7 +910,7 @@ class TelLiveSmsTest(TelephonyBaseTest): return self._mms_test_mo(ads) - @test_tracker_info(uuid="274572bb-ec9f-4c30-aab4-1f4c3f16b372") + @test_tracker_info(uuid="2f4b3f56-6995-4d11-9a03-67c18a126c4e") @TelephonyBaseTest.tel_test_wrap def test_mms_mt_4g(self): """Test MMS text function between two phone. Phones in LTE network. diff --git a/acts/tests/google/tel/live/TelLiveStressCallTest.py b/acts/tests/google/tel/live/TelLiveStressCallTest.py index 42f85a9df7..b3e120fe89 100644 --- a/acts/tests/google/tel/live/TelLiveStressCallTest.py +++ b/acts/tests/google/tel/live/TelLiveStressCallTest.py @@ -43,7 +43,6 @@ from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_2g from acts.test_utils.tel.tel_voice_utils import phone_setup_volte -from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan from acts.test_utils.tel.tel_video_utils import phone_setup_video from acts.test_utils.tel.tel_video_utils import video_call_setup from acts.test_utils.tel.tel_video_utils import \ @@ -58,11 +57,9 @@ class TelLiveStressCallTest(TelephonyBaseTest): self.callee = self.android_devices[1] self.user_params["telephony_auto_rerun"] = False self.wifi_network_ssid = self.user_params.get( - "wifi_network_ssid") or self.user_params.get( - "wifi_network_ssid_2g") + "wifi_network_ssid") or self.user_params.get("wifi_network_ssid_2g") self.wifi_network_pass = self.user_params.get( - "wifi_network_pass") or self.user_params.get( - "wifi_network_pass_2g") + "wifi_network_pass") or self.user_params.get("wifi_network_pass_2g") self.phone_call_iteration = int( self.user_params.get("phone_call_iteration", 500)) self.phone_call_duration = int( @@ -79,7 +76,7 @@ class TelLiveStressCallTest(TelephonyBaseTest): ad, self.wifi_network_ssid, self.wifi_network_pass, - retries=3): + retry=3): ad.log.error("Phone Wifi connection fails.") return False ad.log.info("Phone WIFI is connected successfully.") @@ -87,7 +84,7 @@ class TelLiveStressCallTest(TelephonyBaseTest): ad.log.error("Phone failed to enable Wifi-Calling.") return False ad.log.info("Phone is set in Wifi-Calling successfully.") - if not phone_idle_iwlan(self.log, ad): + if not phone_idle_iwlan(self.log, self.ad): ad.log.error("Phone is not in WFC enabled state.") return False ad.log.info("Phone is in WFC enabled state.") @@ -179,15 +176,15 @@ class TelLiveStressCallTest(TelephonyBaseTest): iteration_result = False self.log.error("%s call dialing failure.", msg) else: - if network_check_func and not network_check_func(self.log, - self.caller): + if network_check_func and not network_check_func( + self.log, self.caller): fail_count["caller_network_check"] += 1 iteration_result = False self.log.error("%s network check %s failure.", msg, network_check_func.__name__) - if network_check_func and not network_check_func(self.log, - self.callee): + if network_check_func and not network_check_func( + self.log, self.callee): fail_count["callee_network_check"] += 1 iteration_result = False self.log.error("%s network check failure.", msg) diff --git a/acts/tests/google/tel/live/TelLiveStressTest.py b/acts/tests/google/tel/live/TelLiveStressTest.py index 62dfcba435..f6f312fa1c 100644 --- a/acts/tests/google/tel/live/TelLiveStressTest.py +++ b/acts/tests/google/tel/live/TelLiveStressTest.py @@ -24,14 +24,6 @@ from acts.asserts import fail from acts.test_decorators import test_tracker_info from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED -from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_ONLY -from acts.test_utils.tel.tel_defines import NETWORK_MODE_WCDMA_ONLY -from acts.test_utils.tel.tel_defines import NETWORK_MODE_GLOBAL -from acts.test_utils.tel.tel_defines import NETWORK_MODE_CDMA -from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY -from acts.test_utils.tel.tel_defines import NETWORK_MODE_TDSCDMA_GSM_WCDMA -from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA -from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_MODE_CHANGE from acts.test_utils.tel.tel_test_utils import active_file_download_test from acts.test_utils.tel.tel_test_utils import call_setup_teardown from acts.test_utils.tel.tel_test_utils import ensure_phone_default_state @@ -44,7 +36,6 @@ from acts.test_utils.tel.tel_test_utils import set_wfc_mode from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify from acts.test_utils.tel.tel_test_utils import mms_send_receive_verify from acts.test_utils.tel.tel_test_utils import verify_incall_state -from acts.test_utils.tel.tel_test_utils import set_preferred_network_mode_pref from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_2g from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb @@ -55,18 +46,8 @@ from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_2g from acts.test_utils.tel.tel_voice_utils import phone_setup_volte -from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan -from acts.test_utils.tel.tel_voice_utils import get_current_voice_rat -from acts.logger import epoch_to_log_line_timestamp -from acts.utils import get_current_epoch_time from acts.utils import rand_ascii_str -import socket -from acts.controllers.sl4a_client import Sl4aProtocolError - -IGNORE_EXCEPTIONS = (BrokenPipeError, Sl4aProtocolError) -EXCEPTION_TOLERANCE = 20 - class TelLiveStressTest(TelephonyBaseTest): def setup_class(self): @@ -75,11 +56,9 @@ class TelLiveStressTest(TelephonyBaseTest): self.helper = self.android_devices[1] self.user_params["telephony_auto_rerun"] = False self.wifi_network_ssid = self.user_params.get( - "wifi_network_ssid") or self.user_params.get( - "wifi_network_ssid_2g") + "wifi_network_ssid") or self.user_params.get("wifi_network_ssid_2g") self.wifi_network_pass = self.user_params.get( - "wifi_network_pass") or self.user_params.get( - "wifi_network_pass_2g") + "wifi_network_pass") or self.user_params.get("wifi_network_pass_2g") self.phone_call_iteration = int( self.user_params.get("phone_call_iteration", 500)) self.max_phone_call_duration = int( @@ -88,10 +67,6 @@ class TelLiveStressTest(TelephonyBaseTest): self.max_run_time = int(self.user_params.get("max_run_time", 18000)) self.max_sms_length = int(self.user_params.get("max_sms_length", 1000)) self.max_mms_length = int(self.user_params.get("max_mms_length", 160)) - self.min_sms_length = int(self.user_params.get("min_sms_length", 1)) - self.min_mms_length = int(self.user_params.get("min_mms_length", 1)) - self.min_phone_call_duration = int( - self.user_params.get("min_phone_call_duration", 10)) self.crash_check_interval = int( self.user_params.get("crash_check_interval", 300)) @@ -104,7 +79,7 @@ class TelLiveStressTest(TelephonyBaseTest): ad, self.wifi_network_ssid, self.wifi_network_pass, - retries=3): + retry=3): ad.log.error("Phone Wifi connection fails.") return False ad.log.info("Phone WIFI is connected successfully.") @@ -154,16 +129,13 @@ class TelLiveStressTest(TelephonyBaseTest): selection = random.randrange(0, 2) message_type_map = {0: "SMS", 1: "MMS"} max_length_map = {0: self.max_sms_length, 1: self.max_mms_length} - min_length_map = {0: self.min_sms_length, 1: self.min_mms_length} - length = random.randrange(min_length_map[selection], - max_length_map[selection] + 1) + length = random.randrange(0, max_length_map[selection] + 1) text = rand_ascii_str(length) message_content_map = {0: [text], 1: [("Mms Message", text, None)]} message_func_map = { 0: sms_send_receive_verify, 1: mms_send_receive_verify } - self.result_info["Total %s" % message_type_map[selection]] += 1 if not message_func_map[selection](self.log, ads[0], ads[1], message_content_map[selection]): self.log.error("%s of length %s from %s to %s fails", @@ -178,215 +150,86 @@ class TelLiveStressTest(TelephonyBaseTest): return True def _make_phone_call(self, ads): - self.result_info["Total Calls"] += 1 if not call_setup_teardown( self.log, ads[0], ads[1], ad_hangup=ads[random.randrange(0, 2)], wait_time_in_call=random.randrange( - self.min_phone_call_duration, - self.max_phone_call_duration)): - self.log.error("Call setup and teardown failed.") - self.result_info["Call Failure"] += 1 + 1, self.max_phone_call_duration)): + ads[0].log.error("Setup phone Call failed.") return False - self.log.info("Call setup and teardown succeed.") - return True - - def _make_volte_call(self, ads): - self.result_info["Total Calls"] += 1 - if not call_setup_teardown( - self.log, - ads[0], - ads[1], - ad_hangup=ads[0], - verify_caller_func=is_phone_in_call_volte, - verify_callee_func=None, - wait_time_in_call=random.randrange( - self.min_phone_call_duration, - self.max_phone_call_duration)): - self.log.error("Call setup and teardown failed.") - self.result_info["Call Failure"] += 1 - return False - self.log.info("Call setup and teardown succeed.") + ads[0].log.info("Setup call successfully.") return True def crash_check_test(self): failure = 0 while time.time() < self.finishing_time: - self.dut.log.info(dict(self.result_info)) - try: - begin_time = epoch_to_log_line_timestamp( - get_current_epoch_time()) - time.sleep(self.crash_check_interval) - crash_report = self.dut.check_crash_report("checking_crash", - begin_time, True) - if crash_report: - self.dut.log.error("Find new crash reports %s", - crash_report) - failure += 1 - self.result_info["Crashes"] += 1 - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Crashes found: %s", failure) - if failure: - return "%s crashes" % failure - else: - return "" + new_crash = self.dut.check_crash_report() + crash_diff = set(new_crash).difference(set(self.dut.crash_report)) + self.dut.crash_report = new_crash + if crash_diff: + self.dut.log.error("Find new crash reports %s", + list(crash_diff)) + self.dut.pull_files(list(crash_diff)) + failure += 1 + self.result_info["Crashes"] += 1 + self._take_bug_report("%s_crash_found" % self.test_name, + time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(self.crash_check_interval) + return failure def call_test(self): failure = 0 total_count = 0 while time.time() < self.finishing_time: - try: - ads = [self.dut, self.helper] - random.shuffle(ads) - total_count += 1 - if not self._make_phone_call(ads): - failure += 1 - self._take_bug_report("%s_call_failure" % self.test_name, - time.strftime("%m-%d-%Y-%H-%M-%S")) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Call test failure: %s/%s", failure, total_count) - if failure: - return "Call test failure: %s/%s" % (failure, total_count) - else: - return "" - - def volte_modechange_volte_test(self): - failure = 0 - total_count = 0 - sub_id = self.dut.droid.subscriptionGetDefaultSubId() - while time.time() < self.finishing_time: - try: - ads = [self.dut, self.helper] - total_count += 1 - if not self._make_volte_call(ads): - failure += 1 - self._take_bug_report("%s_call_failure" % self.test_name, - time.strftime("%m-%d-%Y-%H-%M-%S")) - - # ModePref change to non-LTE - network_preference_list = [ - NETWORK_MODE_TDSCDMA_GSM_WCDMA, NETWORK_MODE_WCDMA_ONLY, - NETWORK_MODE_GLOBAL, NETWORK_MODE_CDMA, - NETWORK_MODE_GSM_ONLY - ] - network_preference = random.choice(network_preference_list) - set_preferred_network_mode_pref(ads[0].log, ads[0], sub_id, - network_preference) - time.sleep(WAIT_TIME_AFTER_MODE_CHANGE) - self.dut.log.info("Current Voice RAT is %s", - get_current_voice_rat(self.log, self.dut)) - - # ModePref change back to with LTE - set_preferred_network_mode_pref( - ads[0].log, ads[0], sub_id, - NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA) - time.sleep(WAIT_TIME_AFTER_MODE_CHANGE) - self.dut.log.info("Current Voice RAT is %s", - get_current_voice_rat(self.log, self.dut)) - - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("VoLTE test failure: %s/%s", failure, - total_count) - if failure: - return "VoLTE test failure: %s/%s" % (failure, total_count) - else: - return "" + ads = [self.dut, self.helper] + random.shuffle(ads) + total_count += 1 + if not self._make_phone_call(ads): + failure += 1 + self.log.error("New call test failure: %s/%s", failure, + total_count) + self._take_bug_report("%s_call_failure" % self.test_name, + time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def message_test(self): failure = 0 total_count = 0 while time.time() < self.finishing_time: - try: - ads = [self.dut, self.helper] - random.shuffle(ads) - total_count += 1 - if not self._send_message(ads): - failure += 1 - #self._take_bug_report("%s_messaging_failure" % self.test_name, - # time.strftime("%m-%d-%Y-%H-%M-%S")) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise - except Exception as e: - self.finishing_time = time.time() - raise - self.dut.log.info("Messaging test failure: %s/%s", failure, - total_count) - if failure / total_count > 0.1: - return "Messaging test failure: %s/%s" % (failure, total_count) - else: - return "" + ads = [self.dut, self.helper] + random.shuffle(ads) + total_count += 1 + if not self._send_message(ads): + failure += 1 + self.log.error("New messaging test failure: %s/%s", failure, + total_count) + #self._take_bug_report("%s_messaging_failure" % self.test_name, + # time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def data_test(self): failure = 0 total_count = 0 - #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"] - file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB"] + file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"] while time.time() < self.finishing_time: - try: - self.dut.log.info(dict(self.result_info)) - self.result_info["Total file download"] += 1 - selection = random.randrange(0, len(file_names)) - file_name = file_names[selection] - total_count += 1 - if not active_file_download_test(self.log, self.dut, - file_name): - self.result_info["%s file download failure" % - file_name] += 1 - failure += 1 - #self._take_bug_report("%s_download_failure" % self.test_name, - # time.strftime("%m-%d-%Y-%H-%M-%S")) - self.dut.droid.goToSleepNow() - time.sleep(random.randrange(0, self.max_sleep_time)) - except IGNORE_EXCEPTIONS as e: - self.log.error("Exception error %s", str(e)) - self.result_info["Exception Errors"] += 1 - if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE: - self.finishing_time = time.time() - raise "Too many %s errors" % IGNORE_EXCEPTIONS - except Exception as e: - self.log.error(e) - self.finishing_time = time.time() - raise - self.dut.log.info("File download test failure: %s/%s", failure, - total_count) - if failure / total_count > 0.1: - return "File download test failure: %s/%s" % (failure, total_count) - else: - return "" + self.dut.log.info(dict(self.result_info)) + self.result_info["Total file download"] += 1 + selection = random.randrange(0, 7) + file_name = file_names[selection] + if not active_file_download_test(self.log, self.dut, file_name): + self.result_info["%s file download failure" % file_name] += 1 + #self._take_bug_report("%s_download_failure" % self.test_name, + # time.strftime("%m-%d-%Y-%H-%M-%S")) + self.dut.droid.goToSleepNow() + time.sleep(random.randrange(0, self.max_sleep_time)) + return failure def parallel_tests(self, setup_func=None): if setup_func and not setup_func(): @@ -398,27 +241,8 @@ class TelLiveStressTest(TelephonyBaseTest): self.message_test, []), (self.data_test, []), (self.crash_check_test, [])]) self.log.info(dict(self.result_info)) - error_message = " ".join(results).strip() - if error_message: - self.log.error(error_message) - fail(error_message) - return True - - def parallel_volte_tests(self, setup_func=None): - if setup_func and not setup_func(): - self.log.error("Test setup %s failed", setup_func.__name__) - return False - self.result_info = collections.defaultdict(int) - self.finishing_time = time.time() + self.max_run_time - results = run_multithread_func( - self.log, [(self.volte_modechange_volte_test, []), - (self.message_test, []), (self.crash_check_test, [])]) - self.log.info(dict(self.result_info)) - error_message = " ".join(results).strip() - if error_message: - self.log.error(error_message) - fail(error_message) - return True + if sum(results): + fail(str(dict(self.result_info))) """ Tests Begin """ @@ -458,11 +282,4 @@ class TelLiveStressTest(TelephonyBaseTest): """ 2G call stress test""" return self.parallel_tests(setup_func=self._setup_2g) - @test_tracker_info(uuid="af580fca-fea6-4ca5-b981-b8c710302d37") - @TelephonyBaseTest.tel_test_wrap - def test_volte_modeprefchange_parallel_stress(self): - """ VoLTE Mode Pref call stress test""" - return self.parallel_volte_tests( - setup_func=self._setup_lte_volte_enabled) - """ Tests End """ diff --git a/acts/tests/google/tel/live/TelLiveVoiceTest.py b/acts/tests/google/tel/live/TelLiveVoiceTest.py index 4740a47267..7431934609 100644 --- a/acts/tests/google/tel/live/TelLiveVoiceTest.py +++ b/acts/tests/google/tel/live/TelLiveVoiceTest.py @@ -18,7 +18,6 @@ """ import time -import os from acts.test_decorators import test_tracker_info from acts.test_utils.tel.tel_subscription_utils import \ get_subid_from_slot_index @@ -82,9 +81,6 @@ from acts.test_utils.tel.tel_test_utils import wait_for_cell_data_connection from acts.test_utils.tel.tel_test_utils import wait_for_ringing_call from acts.test_utils.tel.tel_test_utils import wait_for_not_network_rat from acts.test_utils.tel.tel_test_utils import wifi_toggle_state -from acts.test_utils.tel.tel_test_utils import start_adb_tcpdump -from acts.test_utils.tel.tel_test_utils import stop_adb_tcpdump -from acts.test_utils.tel.tel_test_utils import set_wifi_to_default from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_1x from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_2g from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g @@ -93,6 +89,7 @@ from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_not_iwlan from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_wcdma from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte +from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan from acts.test_utils.tel.tel_voice_utils import \ @@ -121,6 +118,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.stress_test_number = self.get_stress_test_number() self.wifi_network_ssid = self.user_params["wifi_network_ssid"] self.wifi_network_pass = self.user_params.get("wifi_network_pass") + self.long_duration_call_total_duration = self.user_params.get( "long_duration_call_total_duration", DEFAULT_LONG_DURATION_CALL_TOTAL_DURATION) @@ -583,41 +581,32 @@ class TelLiveVoiceTest(TelephonyBaseTest): Returns: True if pass; False if fail. """ - try: - (tcpdump_pid, tcpdump_file) = \ - start_adb_tcpdump(ads[0], self.test_name) - tasks = [(phone_setup_iwlan, (self.log, ads[0], apm_mode, wfc_mode, - wifi_ssid, wifi_pwd)), - (phone_setup_iwlan, (self.log, ads[1], apm_mode, wfc_mode, - wifi_ssid, wifi_pwd))] - if not multithread_func(self.log, tasks): - self.log.error("Phone Failed to Set Up Properly.") - return False - - ad_ping = ads[0] + tasks = [(phone_setup_iwlan, (self.log, ads[0], apm_mode, wfc_mode, + wifi_ssid, wifi_pwd)), + (phone_setup_iwlan, (self.log, ads[1], apm_mode, wfc_mode, + wifi_ssid, wifi_pwd))] + if not multithread_func(self.log, tasks): + self.log.error("Phone Failed to Set Up Properly.") + return False - call_task = (two_phone_call_short_seq, ( - self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, - ads[1], phone_idle_iwlan, is_phone_in_call_iwlan, None, - WAIT_TIME_IN_CALL_FOR_IMS)) - ping_task = (adb_shell_ping, (ad_ping, DEFAULT_PING_DURATION)) + ad_ping = ads[0] - results = run_multithread_func(self.log, [ping_task, call_task]) + call_task = (two_phone_call_short_seq, + (self.log, ads[0], phone_idle_iwlan, + is_phone_in_call_iwlan, ads[1], phone_idle_iwlan, + is_phone_in_call_iwlan, None, WAIT_TIME_IN_CALL_FOR_IMS)) + ping_task = (adb_shell_ping, (ad_ping, DEFAULT_PING_DURATION)) - if not results[1]: - self.log.error("Call setup failed in active ICMP transfer.") - return False - if results[0]: - self.log.info( - "ICMP transfer succeeded with parallel phone call.") - return True - else: - self.log.error( - "ICMP transfer failed with parallel phone call.") - return False - finally: - if tcpdump_pid is not None: - stop_adb_tcpdump(ads[0], tcpdump_pid, tcpdump_file) + results = run_multithread_func(self.log, [ping_task, call_task]) + if not results[1]: + self.log.error("Call setup failed in active ICMP transfer.") + return False + if results[0]: + self.log.info("ICMP transfer succeeded with parallel phone call.") + return True + else: + self.log.error("ICMP transfer failed with parallel phone call.") + return False @test_tracker_info(uuid="a4a043c0-f4ba-4405-9262-42c752cc4487") @TelephonyBaseTest.tel_test_wrap @@ -857,8 +846,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], False, WFC_MODE_WIFI_ONLY, self.wifi_network_ssid, self.wifi_network_pass)), @@ -885,8 +873,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED, self.wifi_network_ssid, self.wifi_network_pass)), @@ -913,8 +900,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], True, WFC_MODE_WIFI_ONLY, self.wifi_network_ssid, self.wifi_network_pass)), @@ -941,8 +927,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED, self.wifi_network_ssid, self.wifi_network_pass)), @@ -969,8 +954,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], False, WFC_MODE_WIFI_ONLY, self.wifi_network_ssid, self.wifi_network_pass)), @@ -997,8 +981,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED, self.wifi_network_ssid, self.wifi_network_pass)), @@ -1025,8 +1008,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], True, WFC_MODE_WIFI_ONLY, self.wifi_network_ssid, self.wifi_network_pass)), @@ -1053,8 +1035,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_iwlan, (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED, self.wifi_network_ssid, self.wifi_network_pass)), @@ -1081,8 +1062,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_csfb, (self.log, ads[0])), (phone_setup_csfb, (self.log, ads[1]))] if not multithread_func(self.log, tasks): @@ -1107,8 +1087,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_voice_3g, (self.log, ads[0])), (phone_setup_voice_3g, (self.log, ads[1]))] if not multithread_func(self.log, tasks): @@ -1291,8 +1270,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_csfb, (self.log, ads[0])), (phone_setup_csfb, (self.log, ads[1]))] if not multithread_func(self.log, tasks): @@ -1319,8 +1297,7 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if pass; False if fail. """ ads = self.android_devices - # Turn OFF WiFi for Phone B - set_wifi_to_default(self.log, ads[1]) + tasks = [(phone_setup_voice_3g, (self.log, ads[0])), (phone_setup_voice_3g, (self.log, ads[1]))] if not multithread_func(self.log, tasks): @@ -1380,8 +1357,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( success_count, fail_count, str(100 * success_count / (success_count + fail_count)))) - if success_count / (success_count + fail_count - ) >= MINIMUM_SUCCESS_RATE: + if success_count / ( + success_count + fail_count) >= MINIMUM_SUCCESS_RATE: return True else: return False @@ -1439,8 +1416,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( success_count, fail_count, str(100 * success_count / (success_count + fail_count)))) - if success_count / (success_count + fail_count - ) >= MINIMUM_SUCCESS_RATE: + if success_count / ( + success_count + fail_count) >= MINIMUM_SUCCESS_RATE: return True else: return False @@ -1498,8 +1475,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( success_count, fail_count, str(100 * success_count / (success_count + fail_count)))) - if success_count / (success_count + fail_count - ) >= MINIMUM_SUCCESS_RATE: + if success_count / ( + success_count + fail_count) >= MINIMUM_SUCCESS_RATE: return True else: return False @@ -1557,8 +1534,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( success_count, fail_count, str(100 * success_count / (success_count + fail_count)))) - if success_count / (success_count + fail_count - ) >= MINIMUM_SUCCESS_RATE: + if success_count / ( + success_count + fail_count) >= MINIMUM_SUCCESS_RATE: return True else: return False @@ -1616,8 +1593,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.log.info("Final Count - Success: {}, Failure: {} - {}%".format( success_count, fail_count, str(100 * success_count / (success_count + fail_count)))) - if success_count / (success_count + fail_count - ) >= MINIMUM_SUCCESS_RATE: + if success_count / ( + success_count + fail_count) >= MINIMUM_SUCCESS_RATE: return True else: return False @@ -1669,8 +1646,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.log.info("Final Count - Success: {}, Failure: {}".format( success_count, fail_count)) - if success_count / (success_count + fail_count - ) >= MINIMUM_SUCCESS_RATE: + if success_count / ( + success_count + fail_count) >= MINIMUM_SUCCESS_RATE: return True else: return False @@ -1722,8 +1699,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): self.log.info("Final Count - Success: {}, Failure: {}".format( success_count, fail_count)) - if success_count / (success_count + fail_count - ) >= MINIMUM_SUCCESS_RATE: + if success_count / ( + success_count + fail_count) >= MINIMUM_SUCCESS_RATE: return True else: return False @@ -3172,8 +3149,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if success. False if failed. """ - if not phone_setup_voice_3g(self.log, self.android_devices[0]): - self.android_devices[0].log.error("Failed to setup 3G") + if not phone_setup_csfb(self.log, self.android_devices[0]): + self.android_devices[0].log.error("Failed to setup VoLTE") return False return self._test_call_setup_in_active_data_transfer( GEN_3G, @@ -3198,8 +3175,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if success. False if failed. """ - if not phone_setup_voice_3g(self.log, self.android_devices[0]): - self.android_devices[0].log.error("Failed to setup 3G") + if not phone_setup_csfb(self.log, self.android_devices[0]): + self.android_devices[0].log.error("Failed to setup VoLTE") return False return self._test_call_setup_in_active_data_transfer( GEN_3G, @@ -3224,8 +3201,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if success. False if failed. """ - if not phone_setup_voice_2g(self.log, self.android_devices[0]): - self.android_devices[0].log.error("Failed to setup voice in 2G") + if not phone_setup_csfb(self.log, self.android_devices[0]): + self.android_devices[0].log.error("Failed to setup VoLTE") return False return self._test_call_setup_in_active_data_transfer( GEN_2G, @@ -3250,8 +3227,8 @@ class TelLiveVoiceTest(TelephonyBaseTest): True if success. False if failed. """ - if not phone_setup_voice_2g(self.log, self.android_devices[0]): - self.android_devices[0].log.error("Failed to setup voice in 2G") + if not phone_setup_csfb(self.log, self.android_devices[0]): + self.android_devices[0].log.error("Failed to setup VoLTE") return False return self._test_call_setup_in_active_data_transfer( GEN_2G, diff --git a/acts/tests/google/tel/live/TelWifiVoiceTest.py b/acts/tests/google/tel/live/TelWifiVoiceTest.py index 4b8af0808e..cc44ec5f68 100755 --- a/acts/tests/google/tel/live/TelWifiVoiceTest.py +++ b/acts/tests/google/tel/live/TelWifiVoiceTest.py @@ -377,8 +377,8 @@ class TelWifiVoiceTest(TelephonyBaseTest): def _phone_wait_for_not_wfc(self): result = wait_for_wfc_disabled(self.log, self.android_devices[0], MAX_WAIT_TIME_NW_SELECTION) - self.log.info( - "_phone_wait_for_not_wfc: WFC_disabled is {}".format(result)) + self.log.info("_phone_wait_for_not_wfc: WFC_disabled is {}".format( + result)) if not result: return False # TODO: b/26338343 Need to check Data RAT. Data RAT should not be iwlan. @@ -554,8 +554,8 @@ class TelWifiVoiceTest(TelephonyBaseTest): is_airplane_mode) if ensure_wifi_connected(self.log, self.android_devices[0], - self.live_network_ssid, self.live_network_pwd, - 1): + self.live_network_ssid, + self.live_network_pwd, 1): self.log.error("{} connect WiFI succeed, expected not succeed". format(self.android_devices[0].serial)) return False @@ -593,8 +593,8 @@ class TelWifiVoiceTest(TelephonyBaseTest): return False if ensure_wifi_connected(self.log, self.android_devices[0], - self.live_network_ssid, self.live_network_pwd, - 1): + self.live_network_ssid, + self.live_network_pwd, 1): self.log.error("{} connect WiFI succeed, expected not succeed". format(self.android_devices[0].serial)) return False @@ -2421,13 +2421,15 @@ class TelWifiVoiceTest(TelephonyBaseTest): ads, DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_absent, self._wfc_phone_setup_cellular_absent_wfc_disabled, None, - self._is_phone_not_in_call, None, "initiate_call fail.") + self._is_phone_not_in_call, None, + "initiate_call fail.") mt_result = self._wfc_call_sequence( ads, DIRECTION_MOBILE_TERMINATED, self._wfc_set_wifi_strong_cell_absent, self._wfc_phone_setup_cellular_absent_wfc_disabled, None, - self._is_phone_not_in_call, None, "wait_and_answer_call fail.") + self._is_phone_not_in_call, None, + "wait_and_answer_call fail.") self.log.info("MO: {}, MT: {}".format(mo_result, mt_result)) return ((mo_result is True) and (mt_result is True)) @@ -2491,8 +2493,8 @@ class TelWifiVoiceTest(TelephonyBaseTest): return False if ensure_wifi_connected(self.log, self.android_devices[0], - self.live_network_ssid, self.live_network_pwd, - 1): + self.live_network_ssid, + self.live_network_pwd, 1): self.log.error("{} connect WiFI succeed, expected not succeed". format(self.android_devices[0].serial)) return False @@ -3121,9 +3123,11 @@ class TelWifiVoiceTest(TelephonyBaseTest): """ # Decrease WiFi RSSI to MIN_RSSI_RESERVED_VALUE set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], - self.wifi_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE, 2, 1) + self.wifi_rssi_with_no_atten, + MIN_RSSI_RESERVED_VALUE, 2, 1) set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], - self.wifi_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE, 2, 1) + self.wifi_rssi_with_no_atten, + MIN_RSSI_RESERVED_VALUE, 2, 1) # Make sure phone hand-out, not drop call if not self._phone_wait_for_not_wfc(): self.log.error("Phone should hand out.") @@ -3387,27 +3391,31 @@ class TelWifiVoiceTest(TelephonyBaseTest): self._wfc_phone_setup_wifi_preferred, self._phone_idle_volte, self._is_phone_in_call_volte, self._hand_in_hand_out_stress, True) - def _decrease_cellular_rssi_check_phone_hand_out(self): + def _increase_cellular_rssi_check_phone_hand_out(self): """Private Test utility for hand_out test. - Decrease Cellular RSSI to MIN_RSSI_RESERVED_VALUE 1db per sec - PhoneA should still be in call. PhoneA should hand-out to iWLAN. + Increase Cellular RSSI to CELL_STRONG_RSSI_VALUE, in 30s. + PhoneA should still be in call. PhoneA should hand-out to LTE. + PhoneA should have data on WiFi. """ - time.sleep(60) - # Decrease Cellular RSSI to MIN_RSSI_RESERVED_VALUE + # Increase Cellular RSSI to CELL_STRONG_RSSI_VALUE set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], - self.cell_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE) + self.cell_rssi_with_no_atten, MAX_RSSI_RESERVED_VALUE, 1, 1) set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], - self.cell_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE, 1, 1) - # Make sure phone hand-out to iWLAN, not drop call - if not self._phone_wait_for_wfc(): - self.log.error("Phone should hand out to iWLAN.") + self.cell_rssi_with_no_atten, MAX_RSSI_RESERVED_VALUE, 1, 1) + # Make sure phone hand-out, not drop call + if not self._phone_wait_for_not_wfc(): + self.log.error("Phone should hand out.") + return False + if not self._is_phone_in_call_volte(): + self.log.error("Phone should be in volte call.") return False - time.sleep(30) - if not self._is_phone_in_call_iwlan(): - self.log.error("Phone should be in iWLAN call.") + # Make sure WiFi still connected and have data. + if (not wait_for_wifi_data_connection(self.log, + self.android_devices[0], True) or + not verify_http_connection(self.log, self.android_devices[0])): + self.log.error("No Data on Wifi") return False - time.sleep(30) return True @test_tracker_info(uuid="2242aa49-474c-496b-be1b-ccd900523a54") @@ -3415,18 +3423,19 @@ class TelWifiVoiceTest(TelephonyBaseTest): def test_hand_out_cellular_preferred(self): """WiFi Hand-Out Threshold - Cellular Preferred - Cellular signal strong, WiFi signal strong. + Cellular signal absent, WiFi signal strong. PhoneA VoLTE enabled, WFC Cellular preferred, WiFi associated. - Call from PhoneA to PhoneB, PhoneA should be on LTE. - Decrease Cellular RSSI to MIN using 1db every sec - PhoneA should still be in call. PhoneA should hand-out to iWLAN. + Call from PhoneA to PhoneB, PhoneA should be on iwlan. + Increase Cellular RSSI to CELL_STRONG_RSSI_VALUE, in 30s. + PhoneA should still be in call. PhoneA should hand-out to LTE. + PhoneA should have data on WiFi. """ return self._wfc_call_sequence( [self.android_devices[0], self.android_devices[1]], - DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong, - self._wfc_phone_setup_cellular_preferred, self._phone_idle_volte, - self._is_phone_in_call_volte, - self._decrease_cellular_rssi_check_phone_hand_out, True) + DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_absent, + self._wfc_phone_setup_cellular_absent_cellular_preferred, + self._phone_idle_iwlan, self._is_phone_in_call_iwlan, + self._increase_cellular_rssi_check_phone_hand_out, True) def _decrease_wifi_rssi_check_phone_not_hand_out(self): """Private Test utility for hand_out test. @@ -3596,10 +3605,9 @@ class TelWifiVoiceTest(TelephonyBaseTest): rssi_monitoring_id_lower = ad.droid.connectivitySetRssiThresholdMonitor( LOWER_RSSI_THRESHOLD) - self.log.info( - "Initial RSSI: {}," - "rssi_monitoring_id_lower should be available.".format( - INITIAL_RSSI)) + self.log.info("Initial RSSI: {}," + "rssi_monitoring_id_lower should be available.". + format(INITIAL_RSSI)) try: event = ad.ed.wait_for_event( EventNetworkCallback, diff --git a/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py b/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py index 6f5cdb90b3..9b1af9b64c 100644 --- a/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py +++ b/acts/tests/google/wifi/WifiEnterpriseRoamingTest.py @@ -124,6 +124,18 @@ class WifiEnterpriseRoamingTest(base_test.BaseTestClass): attn_val_name) raise + def gen_eap_configs(self): + """Generates configurations for different EAP authentication types. + + Returns: + A list of dicts each representing an EAP configuration. + """ + configs = [self.config_tls] + # self.config_sim + configs += wutils.expand_enterprise_config_by_phase2(self.config_ttls) + configs += wutils.expand_enterprise_config_by_phase2(self.config_peap) + return configs + def trigger_roaming_and_validate(self, attn_val_name, expected_con): """Sets attenuators to trigger roaming and validate the DUT connected to the BSSID expected. @@ -175,50 +187,20 @@ class WifiEnterpriseRoamingTest(base_test.BaseTestClass): """ Tests Begin """ - @test_tracker_info(uuid="b15e4b3f-841d-428d-87ac-272f29f06e14") - def test_roaming_with_config_tls(self): - self.roaming_between_a_and_b_logic(self.config_tls) - - @test_tracker_info(uuid="d349cfec-b4af-48b2-88b7-744f5de25d43") - def test_roaming_with_config_ttls_none(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.NONE.value - self.roaming_between_a_and_b_logic(config) - - @test_tracker_info(uuid="89b8161c-754e-4138-831d-5fe40f521ce4") - def test_roaming_with_config_ttls_pap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value - self.roaming_between_a_and_b_logic(config) - - @test_tracker_info(uuid="d4925470-924b-4d03-8437-83e26b5f2df3") - def test_roaming_with_config_ttls_mschap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAP.value - self.roaming_between_a_and_b_logic(config) - - @test_tracker_info(uuid="206b1327-dd9c-4742-8717-e7bf2a04eed6") - def test_roaming_with_config_ttls_mschapv2(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - self.roaming_between_a_and_b_logic(config) - - @test_tracker_info(uuid="c2c0168b-2933-4954-af62-fb41f42dc45a") - def test_roaming_with_config_ttls_gtc(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - self.roaming_between_a_and_b_logic(config) - - @test_tracker_info(uuid="481c4102-8f5b-4fcd-95cc-5e3285f47985") - def test_roaming_with_config_peap_mschapv2(self): - config = dict(self.config_peap) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - self.roaming_between_a_and_b_logic(config) - - @test_tracker_info(uuid="404155d4-33a7-42b3-b369-5f2d63d19f16") - def test_roaming_with_config_peap_gtc(self): - config = dict(self.config_peap) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - self.roaming_between_a_and_b_logic(config) + # TODO: gmoturu Move run_generated_testcases to individual tests + @test_tracker_info(uuid="dd8899d7-e1c8-4066-b5c0-fd80b88e20ee") + @signals.generated_test + def test_roaming_with_different_auth_method(self): + eap_configs = self.gen_eap_configs() + self.log.info("Testing %d different configs.", len(eap_configs)) + random.shuffle(eap_configs) + failed = self.run_generated_testcases( + self.roaming_between_a_and_b_logic, + eap_configs, + name_func=wutils.generate_eap_test_name) + asserts.assert_equal( + len(failed), 0, + "The following configs failed enterprise roaming test: %s" % + pprint.pformat(failed)) """ Tests End """ diff --git a/acts/tests/google/wifi/WifiEnterpriseTest.py b/acts/tests/google/wifi/WifiEnterpriseTest.py index b1a5391ab9..b28ca669ee 100755 --- a/acts/tests/google/wifi/WifiEnterpriseTest.py +++ b/acts/tests/google/wifi/WifiEnterpriseTest.py @@ -36,6 +36,8 @@ Ent = WifiEnums.Enterprise class WifiEnterpriseTest(base_test.BaseTestClass): def __init__(self, controllers): base_test.BaseTestClass.__init__(self, controllers) + self.tests = ("test_eap_connect", "test_eap_connect_negative", + "test_eap_connect_config_store", ) def setup_class(self): self.dut = self.android_devices[0] @@ -164,7 +166,53 @@ class WifiEnterpriseTest(base_test.BaseTestClass): verdict = wutils.wifi_connect(ad, config) asserts.explicit_pass("Connection failed as expected.") - def gen_negative_configs(self, config, neg_params): + def expand_config_by_phase2(self, config): + """Take an enterprise config and generate a list of configs, each with + a different phase2 auth type. + + Args: + config: A dict representing enterprise config. + + Returns + A list of enterprise configs. + """ + results = [] + for phase2_type in EapPhase2: + # Skip a special case for passpoint TTLS. + if Ent.FQDN in config and phase2_type == EapPhase2.GTC: + continue + c = dict(config) + c[Ent.PHASE2] = phase2_type.value + results.append(c) + return results + + def gen_eap_configs(self): + """Generates configurations for different EAP authentication types. + + Returns: + A list of dicts each representing an EAP configuration. + """ + configs = [self.config_tls, self.config_pwd, self.config_sim, + self.config_aka, self.config_aka_prime] + configs += wutils.expand_enterprise_config_by_phase2(self.config_ttls) + configs += wutils.expand_enterprise_config_by_phase2(self.config_peap0) + configs += wutils.expand_enterprise_config_by_phase2(self.config_peap1) + return configs + + def gen_passpoint_configs(self): + """Generates passpoint configurations for different EAP authentication + types. + + Returns: + A list of dicts each representing an EAP configuration for + passpoint networks. + """ + configs = [self.config_passpoint_tls] + configs += wutils.expand_enterprise_config_by_phase2( + self.config_passpoint_ttls) + return configs + + def gen_negative_configs(self, configs, neg_params): """Generic function used to generate negative configs. For all the valid configurations, if a param in the neg_params also @@ -172,26 +220,29 @@ class WifiEnterpriseTest(base_test.BaseTestClass): of the param. Args: - config: A valid configuration. + configs: A list of valid configurations. neg_params: A dict that has all the invalid values. Returns: - An invalid configurations generated based on the valid - configuration. Each invalid configuration has a different invalid + A list of invalid configurations generated based on the valid + configurations. Each invalid configuration has a different invalid field. """ - nc = dict(config) - for k, v in neg_params.items(): - # Skip negative test for TLS's identity field since it's not - # used for auth. - if config[Ent.EAP] == EAP.TLS and k == Ent.IDENTITY: - continue - if k in config: - nc[k] = v - nc["invalid_field"] = k - return nc - - def gen_negative_eap_configs(self, config): + results = [] + for c in configs: + for k, v in neg_params.items(): + # Skip negative test for TLS's identity field since it's not + # used for auth. + if c[Ent.EAP] == EAP.TLS and k == Ent.IDENTITY: + continue + if k in c: + nc = dict(c) + nc[k] = v + nc["invalid_field"] = k + results.append(nc) + return results + + def gen_negative_eap_configs(self): """Generates invalid configurations for different EAP authentication types. @@ -199,11 +250,8 @@ class WifiEnterpriseTest(base_test.BaseTestClass): authentication info exists in a config, a copy of the config is made with an invalid value of the param. - Args: - A valid network configration - Returns: - An invalid EAP configuration. + A list of dicts each representing an invalid EAP configuration. """ neg_params = { Ent.CLIENT_CERT: self.invalid_client_cert, @@ -212,17 +260,16 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Ent.IDENTITY: "fake_identity", Ent.PASSWORD: "wrong_password" } - return self.gen_negative_configs(config, neg_params) + configs = self.gen_eap_configs() + return self.gen_negative_configs(configs, neg_params) - def gen_negative_passpoint_configs(self, config): + def gen_negative_passpoint_configs(self): """Generates invalid configurations for different EAP authentication types with passpoint support. - Args: - A valid network configration - Returns: - An invalid EAP configuration with passpoint fields. + A list of dicts each representing an invalid EAP configuration + with passpoint fields. """ neg_params = { Ent.CLIENT_CERT: self.invalid_client_cert, @@ -235,7 +282,56 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Ent.PLMN: "fake_plmn", Ent.ROAMING_IDS: [1234567890, 9876543210] } - return self.gen_negative_configs(config, neg_params) + configs = self.gen_passpoint_configs() + return self.gen_negative_configs(configs, neg_params) + + def gen_eap_test_name_for_config_store(self, config, ad): + """Generates a test case name based on an EAP configuration for config + store tests. + + Args: + config: A dict representing an EAP credential. + ad: Discarded. This is here because name function signature needs + to be consistent with logic function signature for generated + test cases. + + Returns: + A string representing the name of a generated EAP test case. + """ + return wutils.generate_eap_test_name(config) + "-config_store" + + def gen_passpoint_test_name(self, config, ad): + """Generates a test case name based on an EAP passpoint configuration. + + Args: + config: A dict representing an EAP passpoint credential. + ad: Discarded. This is here because name function signature needs + to be consistent with logic function signature for generated + test cases. + + Returns: + A string representing the name of a generated EAP passpoint connect + test case. + """ + name = wutils.generate_eap_test_name(config) + name = name.replace("connect", "passpoint_connect") + return name + + def gen_passpoint_test_name_for_config_store(self, config, ad): + """Generates a test case name based on an EAP passpoint configuration + for config store tests. + + Args: + config: A dict representing an EAP passpoint credential. + ad: Discarded. This is here because name function signature needs + to be consistent with logic function signature for generated + test cases. + + Returns: + A string representing the name of a generated EAP passpoint connect + test case. + """ + return self.gen_passpoint_test_name(config, ad) + "-config_store" def eap_connect_toggle_wifi(self, config, @@ -256,10 +352,12 @@ class WifiEnterpriseTest(base_test.BaseTestClass): wutils.wifi_connect(ad, config) wutils.toggle_wifi_and_wait_for_reconnection(ad, config, num_of_tries=5) - """ Tests """ + """Tests""" - # EAP connect tests - """ Test connecting to enterprise networks of different authentication + @test_tracker_info(uuid="d1e897d4-9813-4b49-93e5-eb3970113be8") + @signals.generated_test + def test_eap_connect(self): + """Test connecting to enterprise networks of different authentication types. The authentication types tested are: @@ -275,83 +373,23 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Expect: Successful connection and Internet access through the enterprise networks. - """ - @test_tracker_info(uuid="4e720cac-ea17-4de7-a540-8dc7c49f9713") - def test_eap_connect_with_config_tls(self): - wutils.wifi_connect(self.dut, self.config_tls) - - @test_tracker_info(uuid="10e3a5e9-0018-4162-a9fa-b41500f13340") - def test_eap_connect_with_config_pwd(self): - wutils.wifi_connect(self.dut, self.config_pwd) - - @test_tracker_info(uuid="b4513f78-a1c4-427f-bfc7-2a6b3da714b5") - def test_eap_connect_with_config_sim(self): - wutils.wifi_connect(self.dut, self.config_sim) - - @test_tracker_info(uuid="7d390e30-cb67-4b55-bf00-567adad2d9b0") - def test_eap_connect_with_config_aka(self): - wutils.wifi_connect(self.dut, self.config_aka) - - @test_tracker_info(uuid="742f921b-27c3-4b68-a3ca-88e64fe79c1d") - def test_eap_connect_with_config_aka_prime(self): - wutils.wifi_connect(self.dut, self.config_aka_prime) - - @test_tracker_info(uuid="d34e30f3-6ef6-459f-b47a-e78ed90ce4c6") - def test_eap_connect_with_config_ttls_none(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.NONE.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="0dca3a15-472e-427c-8e06-4e38088ee973") - def test_eap_connect_with_config_ttls_pap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="47c4b459-2cb1-4fc7-b4e7-82534e8e090e") - def test_eap_connect_with_config_ttls_mschap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAP.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="fdb286c7-8069-481d-baf0-c5dd7a31ff03") - def test_eap_connect_with_config_ttls_mschapv2(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="d9315962-7987-4ee7-905d-6972c78ce8a1") - def test_eap_connect_with_config_ttls_gtc(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="90a67bd3-30da-4daf-8ab0-d964d7ad19be") - def test_eap_connect_with_config_peap0_mschapv2(self): - config = dict(self.config_peap0) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="3c451ba4-0c83-4eef-bc95-db4c21893008") - def test_eap_connect_with_config_peap0_gtc(self): - config = dict(self.config_peap0) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="6b45157d-0325-417a-af18-11af5d240d79") - def test_eap_connect_with_config_peap1_mschapv2(self): - config = dict(self.config_peap1) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="1663decc-71ae-4f95-a027-8a6dbf9c337f") - def test_eap_connect_with_config_peap1_gtc(self): - config = dict(self.config_peap1) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - wutils.wifi_connect(self.dut, config) - - # EAP connect negative tests - """ Test connecting to enterprise networks. + """ + eap_configs = self.gen_eap_configs() + self.log.info("Testing %d different configs.", len(eap_configs)) + random.shuffle(eap_configs) + failed = self.run_generated_testcases(wutils.wifi_connect, + eap_configs, + args=(self.dut, ), + name_func=wutils.generate_eap_test_name, + format_args=True) + asserts.assert_equal( + len(failed), 0, "The following configs failed EAP connect test: %s" + % pprint.pformat(failed)) + + @test_tracker_info(uuid="10d78928-e6bf-4c75-a5d3-aae05f0d6a04") + @signals.generated_test + def test_eap_connect_negative(self): + """Test connecting to enterprise networks. Procedures: For each enterprise wifi network @@ -359,97 +397,28 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Expect: Fail to establish connection. - """ - @test_tracker_info(uuid="b2a91f1f-ccd7-4bd1-ab81-19aab3d8ee38") - def test_eap_connect_negative_with_config_tls(self): - config = self.gen_negative_eap_configs(self.config_tls) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="6466abde-1d16-4168-9dd8-1e7a0a19889b") - def test_eap_connect_negative_with_config_pwd(self): - config = self.gen_negative_eap_configs(self.config_pwd) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="d7742a2a-85b0-409a-99d8-47711ddc5612") - def test_eap_connect_negative_with_config_sim(self): - config = self.gen_negative_eap_configs(self.config_sim) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="0ec0de93-cab3-4f41-960b-c0af64ff48c4") - def test_eap_connect_negative_with_config_aka(self): - config = self.gen_negative_eap_configs(self.config_aka) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="bb640ea4-32a6-48ea-87c9-f7128fffbbf6") - def test_eap_connect_negative_with_config_aka_prime(self): - config = self.gen_negative_eap_configs(self.config_aka_prime) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="86336ada-0ced-45a4-8a22-c4aa23c81111") - def test_eap_connect_negative_with_config_ttls_none(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.NONE.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="71e0498d-9973-4958-94bd-79051c328920") - def test_eap_connect_negative_with_config_ttls_pap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="c04142a8-b204-4d2d-98dc-150b16c8397e") - def test_eap_connect_negative_with_config_ttls_mschap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAP.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="625e7aa5-e3e6-4bbe-98c0-5aad8ca1555b") - def test_eap_connect_negative_with_config_ttls_mschapv2(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="24ea0d80-0a3f-41c2-8e05-d6387e589058") - def test_eap_connect_negative_with_config_ttls_gtc(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="b7c1f0f8-6338-4501-8e1d-c9b136aaba88") - def test_eap_connect_negative_with_config_peap0_mschapv2(self): - config = dict(self.config_peap0) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="9cf83dcb-38ad-4f75-9ea9-98de1cfaf7f3") - def test_eap_connect_negative_with_config_peap0_gtc(self): - config = dict(self.config_peap0) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="89bb2b6b-d073-402a-bdc1-68ac5f8752a3") - def test_eap_connect_negative_with_config_peap1_mschapv2(self): - config = dict(self.config_peap1) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="2252a864-9ff7-43b5-82d9-afe57d1f5e5f") - def test_eap_connect_negative_with_config_peap1_gtc(self): - config = dict(self.config_peap1) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - config = self.gen_negative_eap_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - # EAP connect config store tests - """ Test connecting to enterprise networks of different authentication + """ + neg_eap_configs = self.gen_negative_eap_configs() + self.log.info("Testing %d different configs.", len(neg_eap_configs)) + random.shuffle(neg_eap_configs) + + def name_gen(config, ad): + name = wutils.generate_eap_test_name(config) + name += "-with_wrong-{}".format(config["invalid_field"]) + return name + + failed = self.run_generated_testcases(self.eap_negative_connect_logic, + neg_eap_configs, + args=(self.dut, ), + name_func=name_gen) + msg = ("The following configs failed negative EAP connect test: %s" % + pprint.pformat(failed)) + asserts.assert_equal(len(failed), 0, msg) + + @test_tracker_info(uuid="f79e6063-5615-4399-b618-86968d5445c8") + @signals.generated_test + def test_eap_connect_config_store(self): + """Test connecting to enterprise networks of different authentication types after wifi toggle. The authentication types tested are: @@ -467,86 +436,23 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Expect: Successful connection and Internet access through the enterprise networks. - """ - @test_tracker_info(uuid="2a933b7f-27d7-4201-a34f-25b9d8072a8c") - def test_eap_connect_config_store_with_config_tls(self): - self.eap_connect_toggle_wifi(self.config_tls, self.dut) - - @test_tracker_info(uuid="08dc071b-9fea-408a-a3f6-d3493869f6d4") - def test_eap_connect_config_store_with_config_pwd(self): - self.eap_connect_toggle_wifi(self.config_pwd, self.dut) - - @test_tracker_info(uuid="230cb03e-58bc-41cb-b9b3-7215c2ab2325") - def test_eap_connect_config_store_with_config_sim(self): - self.eap_connect_toggle_wifi(self.config_sim, self.dut) - - @test_tracker_info(uuid="dfc3e59c-2309-4598-8c23-bb3fe95ef89f") - def test_eap_connect_config_store_with_config_aka(self): - self.eap_connect_toggle_wifi(self.config_aka, self.dut) - - @test_tracker_info(uuid="6050a1d1-4f3a-476d-bf93-638abd066790") - def test_eap_connect_config_store_with_config_aka_prime(self): - self.eap_connect_toggle_wifi(self.config_aka_prime, self.dut) - - @test_tracker_info(uuid="03108057-cc44-4a80-8331-77c93694099c") - def test_eap_connect_config_store_with_config_ttls_none(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.NONE.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="53dd8195-e272-4589-a261-b8fa3607ad8d") - def test_eap_connect_config_store_with_config_ttls_pap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="640f697b-9c62-4b19-bd76-53b236a152e0") - def test_eap_connect_config_store_with_config_ttls_mschap(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAP.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="f0243684-fae0-46f3-afbd-bf525fc712e2") - def test_eap_connect_config_store_with_config_ttls_mschapv2(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="49ec7202-3b00-49c3-970a-201360888c74") - def test_eap_connect_config_store_with_config_ttls_gtc(self): - config = dict(self.config_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="1c6abfa3-f344-4e28-b891-5481ab79efcf") - def test_eap_connect_config_store_with_config_peap0_mschapv2(self): - config = dict(self.config_peap0) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="2815bc76-49fa-43a5-a4b6-84788f9809d5") - def test_eap_connect_config_store_with_config_peap0_gtc(self): - config = dict(self.config_peap0) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="e93f7472-6895-4e36-bff2-9b2dcfd07ad0") - def test_eap_connect_config_store_with_config_peap1_mschapv2(self): - config = dict(self.config_peap1) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="6da72fa0-b858-4475-9559-46fe052d0d64") - def test_eap_connect_config_store_with_config_peap1_gtc(self): - config = dict(self.config_peap1) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - self.eap_connect_toggle_wifi(config, self.dut) - - # Removing 'test_' for all passpoint based testcases as we want to disable - # them. Adding the valid test cases to self.tests make them run in serial - # (TODO): gmoturu - Update the passpoint tests to test the valid scenario - # Passpoint connect tests - """ Test connecting to enterprise networks of different authentication + """ + eap_configs = self.gen_eap_configs() + self.log.info("Testing %d different configs.", len(eap_configs)) + random.shuffle(eap_configs) + failed = self.run_generated_testcases( + self.eap_connect_toggle_wifi, + eap_configs, + args=(self.dut, ), + name_func=wutils.generate_eap_test_name) + asserts.assert_equal( + len(failed), 0, "The following configs failed EAP connect test: %s" + % pprint.pformat(failed)) + + @test_tracker_info(uuid="85b7950f-c36e-44b1-939b-509550db5918") + @signals.generated_test + def test_passpoint_connect(self): + """Test connecting to enterprise networks of different authentication types with passpoint support. The authentication types tested are: @@ -561,55 +467,28 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Expect: Successful connection and Internet access through the enterprise networks with passpoint support. - """ - @test_tracker_info(uuid="0b942524-bde9-4fc6-ac6a-fef1c247cb8e") - def passpoint_connect_with_config_passpoint_tls(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - wutils.wifi_connect(self.dut, self.config_passpoint_tls) - - @test_tracker_info(uuid="33a014aa-99e7-4612-b732-54fabf1bf922") - def passpoint_connect_with_config_passpoint_ttls_none(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.NONE.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="1aba8bf9-2b09-4956-b418-c3f4dadab330") - def passpoint_connect_with_config_passpoint_ttls_pap(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="cd978fc9-a393-4b1e-bba3-1efc52224500") - def passpoint_connect_with_config_passpoint_ttls_mschap(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAP.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="bc311ee7-ba64-4c76-a629-b916701bf6a5") - def passpoint_connect_with_config_passpoint_ttls_mschapv2(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - wutils.wifi_connect(self.dut, config) - - @test_tracker_info(uuid="357e5162-5081-4149-bedd-ef2c0f88b97e") - def passpoint_connect_with_config_passpoint_ttls_gtc(self): + """ asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - wutils.wifi_connect(self.dut, config) - - # Passpoint connect negative tests - """ Test connecting to enterprise networks. + "Passpoint is not supported on device %s" % + self.dut.model) + passpoint_configs = self.gen_passpoint_configs() + self.log.info("Testing %d different configs.", len(passpoint_configs)) + random.shuffle(passpoint_configs) + failed = self.run_generated_testcases( + wutils.wifi_connect, + passpoint_configs, + args=(self.dut, ), + name_func=self.gen_passpoint_test_name, + format_args=True) + asserts.assert_equal( + len(failed), 0, + "The following configs failed passpoint connect test: %s" % + pprint.pformat(failed)) + + @test_tracker_info(uuid="0e068a2f-cc7b-4c11-ada1-d0d1b0f4163b") + @signals.generated_test + def test_passpoint_connect_negative(self): + """Test connecting to enterprise networks. Procedures: For each enterprise wifi network @@ -617,61 +496,33 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Expect: Fail to establish connection. - """ - @test_tracker_info(uuid="7b6b44a0-ff70-49b4-94ca-a98bedc18f92") - def passpoint_connect_negative_with_config_passpoint_tls(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = self.gen_negative_passpoint_configs(self.config_passpoint_tls) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="3dbde40a-e88c-4166-b932-163663a10a41") - def passpoint_connect_negative_with_config_passpoint_ttls_none(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.NONE.value - config = self.gen_negative_passpoint_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="8ee22ad6-d561-4ca2-a808-9f372fce56b4") - def passpoint_connect_negative_with_config_passpoint_ttls_pap(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value - config = self.gen_negative_passpoint_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="db5cefe7-9cb8-47a6-8635-006c80b97012") - def passpoint_connect_negative_with_config_passpoint_ttls_mschap(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAP.value - config = self.gen_negative_passpoint_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="8f49496e-80df-48ce-9c51-42f0c6b81aff") - def passpoint_connect_negative_with_config_passpoint_ttls_mschapv2(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - config = self.gen_negative_passpoint_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - @test_tracker_info(uuid="6561508f-598e-408d-96b6-15b631664be6") - def passpoint_connect_negative_with_config_passpoint_ttls_gtc(self): + """ asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - config = self.gen_negative_passpoint_configs(config) - self.eap_negative_connect_logic(config, self.dut) - - # Passpoint connect config store tests - """ Test connecting to enterprise networks of different authentication + "Passpoint is not supported on device %s" % + self.dut.model) + neg_passpoint_configs = self.gen_negative_passpoint_configs() + self.log.info("Testing %d different configs.", + len(neg_passpoint_configs)) + random.shuffle(neg_passpoint_configs) + + def name_gen(config, ad): + name = self.gen_passpoint_test_name(config, ad) + name += "-with_wrong-{}".format(config["invalid_field"]) + return name + + failed = self.run_generated_testcases(self.eap_negative_connect_logic, + neg_passpoint_configs, + args=(self.dut, ), + name_func=name_gen) + asserts.assert_equal( + len(failed), 0, + "The following configs failed negative passpoint connect test: %s" + % pprint.pformat(failed)) + + @test_tracker_info(uuid="a17347e0-4b0e-49ae-8bd2-60ba185e1c35") + @signals.generated_test + def test_passpoint_connect_config_store(self): + """Test connecting to enterprise networks of different authentication types with passpoint support after wifi toggle. The authentication types tested are: @@ -688,49 +539,19 @@ class WifiEnterpriseTest(base_test.BaseTestClass): Expect: Successful connection and Internet access through the enterprise networks with passpoint support. - """ - @test_tracker_info(uuid="5d5e6bb0-faea-4a6e-a6bc-c87de997a4fd") - def passpoint_connect_config_store_with_config_passpoint_tls(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - self.eap_connect_toggle_wifi(self.config_passpoint_tls, self.dut) - - @test_tracker_info(uuid="0c80262d-23c1-439f-ad64-7b8ada5d1962") - def passpoint_connect_config_store_with_config_passpoint_ttls_none(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.NONE.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="786e424c-b5a6-4fe9-a951-b3de16ebb6db") - def passpoint_connect_config_store_with_config_passpoint_ttls_pap(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="22fd61bf-722a-4016-a778-fc33e94ed211") - def passpoint_connect_config_store_with_config_passpoint_ttls_mschap(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAP.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="2abd348c-9c66-456b-88ad-55f971717620") - def passpoint_connect_config_store_with_config_passpoint_ttls_mschapv2(self): - asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.MSCHAPV2.value - self.eap_connect_toggle_wifi(config, self.dut) - - @test_tracker_info(uuid="043e8cdd-db95-4f03-b308-3c8cecf874b1") - def passpoint_connect_config_store_with_config_passpoint_ttls_gtc(self): + """ asserts.skip_if(not self.dut.droid.wifiIsPasspointSupported(), - "Passpoint is not supported on %s" % self.dut.model) - config = dict(self.config_passpoint_ttls) - config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.GTC.value - self.eap_connect_toggle_wifi(config, self.dut) + "Passpoint is not supported on device %s" % + self.dut.model) + passpoint_configs = self.gen_passpoint_configs() + self.log.info("Testing %d different configs.", len(passpoint_configs)) + random.shuffle(passpoint_configs) + failed = self.run_generated_testcases( + self.eap_connect_toggle_wifi, + passpoint_configs, + args=(self.dut, ), + name_func=self.gen_passpoint_test_name_for_config_store) + asserts.assert_equal( + len(failed), 0, + "The following configs failed passpoint connect test: %s" % + pprint.pformat(failed)) diff --git a/acts/tests/google/wifi/WifiIOTTest.py b/acts/tests/google/wifi/WifiIOTTest.py index cb977bf799..3c125417aa 100755 --- a/acts/tests/google/wifi/WifiIOTTest.py +++ b/acts/tests/google/wifi/WifiIOTTest.py @@ -37,7 +37,6 @@ class WifiIOTTest(WifiBaseTest): """ def __init__(self, controllers): - self.attenuators = None WifiBaseTest.__init__(self, controllers) def setup_class(self): @@ -50,31 +49,27 @@ class WifiIOTTest(WifiBaseTest): asserts.assert_true( len(self.iot_networks) > 0, "Need at least one iot network with psk.") - self.iot_networks.append(self.open_network) + self.iot_networks.extend(self.open_network) wutils.wifi_toggle_state(self.dut, True) if "iperf_server_address" in self.user_params: self.iperf_server = self.iperf_servers[0] - - # create hashmap for testcase name and SSIDs - self.iot_test_prefix = "test_iot_connection_to_" - self.ssid_map = {} - for network in self.iot_networks: - SSID = network['SSID'].replace('-','_') - self.ssid_map[SSID] = network - self.iperf_server.start() + self.iot_test_prefix = "test_connection_to-" def setup_test(self): self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() + if self.iot_test_prefix in self.current_test_name: + if "iperf_server_address" in self.user_params: + self.iperf_server.start() def teardown_test(self): self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() wutils.reset_wifi(self.dut) - - def teardown_class(self): - self.iperf_server.stop() + if self.current_test_name and self.iot_test_prefix in self.current_test_name: + if "iperf_server_address" in self.user_params: + self.iperf_server.stop() def on_fail(self, test_name, begin_time): self.dut.take_bug_report(test_name, begin_time) @@ -82,37 +77,41 @@ class WifiIOTTest(WifiBaseTest): """Helper Functions""" - def connect_to_wifi_network(self, network): + def connect_to_wifi_network(self, params): """Connection logic for open and psk wifi networks. Args: - params: Dictionary with network info. + params: A tuple of network info and AndroidDevice object. """ + network, ad = params + droid = ad.droid + ed = ad.ed SSID = network[WifiEnums.SSID_KEY] - self.dut.ed.clear_all_events() - wutils.start_wifi_connection_scan(self.dut) - scan_results = self.dut.droid.wifiGetScanResults() + ed.clear_all_events() + wutils.start_wifi_connection_scan(ad) + scan_results = droid.wifiGetScanResults() wutils.assert_network_in_list({WifiEnums.SSID_KEY: SSID}, scan_results) - wutils.wifi_connect(self.dut, network, num_of_tries=3) + wutils.wifi_connect(ad, network, num_of_tries=3) - def run_iperf_client(self, network): + def run_iperf_client(self, params): """Run iperf traffic after connection. Args: - params: Dictionary with network info. + params: A tuple of network info and AndroidDevice object. """ if "iperf_server_address" in self.user_params: wait_time = 5 + network, ad = params SSID = network[WifiEnums.SSID_KEY] self.log.info("Starting iperf traffic through {}".format(SSID)) time.sleep(wait_time) port_arg = "-p {}".format(self.iperf_server.port) - success, data = self.dut.run_iperf_client(self.iperf_server_address, - port_arg) + success, data = ad.run_iperf_client(self.iperf_server_address, + port_arg) self.log.debug(pprint.pformat(data)) asserts.assert_true(success, "Error occurred in iPerf traffic.") - def connect_to_wifi_network_and_run_iperf(self, network): + def connect_to_wifi_network_and_run_iperf(self, params): """Connection logic for open and psk wifi networks. Logic steps are @@ -120,254 +119,21 @@ class WifiIOTTest(WifiBaseTest): 2. Run iperf traffic. Args: - params: A dictionary with network info. + params: A tuple of network info and AndroidDevice object. """ - self.connect_to_wifi_network(network) - self.run_iperf_client(network) + self.connect_to_wifi_network(params) + self.run_iperf_client(params) """Tests""" - @test_tracker_info(uuid="a57cc861-b6c2-47e4-9db6-7a3ab32c6e20") - def test_iot_connection_to_ubiquity_ap1_2g(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="2065c2f7-2b89-4da7-a15d-e5dc17b88d52") - def test_iot_connection_to_ubiquity_ap1_5g(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="6870e35b-f7a7-45bf-b021-fea049ae53de") - def test_iot_connection_to_AirportExpress_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="95f4b405-79d7-4873-a152-4384acc88f41") - def test_iot_connection_to_AirportExpress_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="02a8cc75-6781-4153-8d90-bed7568a1e78") - def test_iot_connection_to_AirportExtreme_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="83a42c97-1358-4ba7-bdb2-238fdb1c945e") - def test_iot_connection_to_AirportExtreme_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="d56cc46a-f772-4c96-b84e-4e05c82f5f9d") - def test_iot_connection_to_AirportExtremeOld_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="4b57277d-ea96-4379-bd71-8b4f03253ec8") - def test_iot_connection_to_AirportExtremeOld_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="2503d9ed-35df-4be0-b838-590324cecaee") - def test_iot_connection_to_Dlink_AC1200_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="0a44e148-a4bf-43f4-88eb-e4c1ffa850ce") - def test_iot_connection_to_Dlink_AC1200_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="6bd77417-089f-4fb1-b4c2-2cd673c64bcb") - def test_iot_connection_to_Dlink_AC3200_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="9fbff6e7-36c8-4342-9c29-bce6a8ef04ec") - def test_iot_connection_to_Dlink_AC3200_5G_1(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="bfccdaa9-8e01-488c-9768-8c71ab5ec157") - def test_iot_connection_to_Dlink_AC3200_5G_2(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="0e4978de-0435-4856-ae5a-c39cc64e375b") - def test_iot_connection_to_Dlink_N750_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="cdb82797-9981-4ba6-8958-025f59c60e83") - def test_iot_connection_to_Dlink_N750_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="0bf8f129-eb96-4b1e-94bd-8dd93e8731e3") - def test_iot_connection_to_Linksys_E800_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="f231216d-6ab6-46b7-a0a5-1ac15935e412") - def test_iot_connection_to_Linksys_AC1900_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="5acd4bec-b210-4b4c-8b2c-60f3f67798a9") - def test_iot_connection_to_Linksys_AC1900_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="f4fd9877-b13f-47b0-9523-1ce363200c2f") - def test_iot_connection_to_Linksys_AC2400_2g(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="438d679a-4f6c-476d-9eba-63b6f1f2bef4") - def test_iot_connection_to_Linksys_AC2400_5g(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="b9bc00d8-46c5-4c5e-bd58-93ab1ca8d53b") - def test_iot_connection_to_NETGEAR_AC1900_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="fb4c7d80-4c12-4b08-a40a-2745e2bd167b") - def test_iot_connection_to_NETGEAR_AC1900_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="054d2ffc-97fd-4613-bf47-acedd0fa4701") - def test_iot_connection_to_NETGEAR_AC3200_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="d15a789a-def5-4c6a-b59e-1a75f73cc6a9") - def test_iot_connection_to_NETGEAR_AC3200_5G_1(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="1de6369e-97da-479f-b17c-9144bb814f51") - def test_iot_connection_to_NETGEAR_AC3200_5G_2(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="008ec18e-fd48-4359-8a0d-223c921a1faa") - def test_iot_connection_to_NETGEAR_N300_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="c61eeaf0-af02-46bf-bcec-871e2f9dee71") - def test_iot_connection_to_WNDR4500v2_AES_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="dcad3474-4022-48bc-8529-07321611b616") - def test_iot_connection_to_WNDR4500v2_WEP_SHARED128_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="3573a880-4542-4dea-9909-aa2f9865a059") - def test_iot_connection_to_ARCHER_WEP_OPEN_64_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="9c15c52e-945a-4b9b-bf0e-5bd6293dad1c") - def test_iot_connection_to_ARCHER_WEP_OPEN_128_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="e5517b82-c225-449d-83ac-055a561a764f") - def test_iot_connection_to_TP_LINK_AC1700_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="9531d3cc-129d-4501-a5e3-d7502120cd8b") - def test_iot_connection_to_TP_LINK_AC1700_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="eab810d4-8e07-49c9-86c1-cb8d1a0285d0") - def test_iot_connection_to_TP_LINK_N300_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="05d4cb25-a58d-46b4-a5ff-6e3fe28f2b16") - def test_iot_connection_to_fritz_7490_5g(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="8333e5e6-72fd-4957-bab0-fa45ce1d765a") - def test_iot_connection_to_NETGEAR_R8500_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="c88053fb-730f-4447-a802-1fb9721f69df") - def test_iot_connection_to_NETGEAR_R8500_5G1(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="f5d1e44b-396b-4976-bb0c-160bdce89a59") - def test_iot_connection_to_NETGEAR_R8500_5G2(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="7c12f943-d9e2-45b1-aa84-fcb43efbbb04") - def test_iot_connection_to_TP_LINK_5504_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="52be6b76-5e43-4289-83e1-4cd0d995d39b") - def test_iot_connection_to_TP_LINK_5504_5G_1(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="0b43d1da-e207-443d-b16c-c4ee3e924036") - def test_iot_connection_to_TP_LINK_5504_5G_2(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="4adcef5c-589a-4398-a28c-28a56d762f72") - def test_iot_connection_to_TP_LINK_C2600_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="3955a443-505b-4015-9daa-f52abbad8377") - def test_iot_connection_to_TP_LINK_C2600_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="3e9115dd-adb6-40a4-9831-dca8f1f32abe") - def test_iot_connection_to_Linksys06832_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="5dca028a-7384-444f-b231-973054afe215") - def test_iot_connection_to_Linksys06832_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="e639f6db-ad8e-4b4f-91f3-10acdf93142a") - def test_iot_connection_to_AmpedAthena_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="3dd90d80-952f-4f17-a48a-fe42e7d6e1ff") - def test_iot_connection_to_AmpedAthena_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="b9babe3a-ecba-4c5c-bc6b-0ba48c744e66") - def test_iot_connection_to_ASUS_AC3100_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="f8f06f92-821d-4e80-8f1e-efb6c6adc12a") - def test_iot_connection_to_ASUS_AC3100_5G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) - - @test_tracker_info(uuid="f4d227df-1151-469a-b01c-f4b1c1f7a84b") - def test_iot_connection_to_NETGEAR_WGR614_2G(self): - ssid_key = self.current_test_name.replace(self.iot_test_prefix, "") - self.connect_to_wifi_network_and_run_iperf(self.ssid_map[ssid_key]) + @test_tracker_info(uuid="cfc0084d-8fe4-4d19-8af2-6c9a8d1e2b6b") + @acts.signals.generated_test + def test_iot_with_password(self): + params = list( + itertools.product(self.iot_networks, self.android_devices)) + name_gen = lambda p: "test_connection_to-%s" % p[0][WifiEnums.SSID_KEY] + failed = self.run_generated_testcases( + self.connect_to_wifi_network_and_run_iperf, + params, + name_func=name_gen) + asserts.assert_true(not failed, "Failed ones: {}".format(failed)) diff --git a/acts/tests/google/wifi/WifiManagerTest.py b/acts/tests/google/wifi/WifiManagerTest.py index 5f1fb86d50..6f366a4b8d 100755 --- a/acts/tests/google/wifi/WifiManagerTest.py +++ b/acts/tests/google/wifi/WifiManagerTest.py @@ -58,6 +58,7 @@ class WifiManagerTest(WifiBaseTest): a.set_atten(0) req_params = [] opt_param = [ + "additional_energy_info_models", "additional_tdls_models", "open_network", "reference_networks", "iperf_server_address" ] self.unpack_userparams( @@ -72,32 +73,29 @@ class WifiManagerTest(WifiBaseTest): wutils.wifi_toggle_state(self.dut, True) if "iperf_server_address" in self.user_params: self.iperf_server = self.iperf_servers[0] + self.iot_test_prefix = "test_connection_to-" self.wpapsk_2g = self.reference_networks[0]["2g"] self.wpapsk_5g = self.reference_networks[0]["5g"] - self.open_network = self.open_network[0]["2g"] - self.iperf_server.start() def setup_test(self): self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() + if self.iot_test_prefix in self.current_test_name: + if "iperf_server_address" in self.user_params: + self.iperf_server.start() def teardown_test(self): self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() wutils.reset_wifi(self.dut) - - def teardown_class(self): - self.iperf_server.stop() + if self.current_test_name and self.iot_test_prefix in self.current_test_name: + if "iperf_server_address" in self.user_params: + self.iperf_server.stop() def on_fail(self, test_name, begin_time): self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) - def teardown_class(self): - if "AccessPoint" in self.user_params: - del self.user_params["reference_networks"] - del self.user_params["open_network"] - """Helper Functions""" def connect_to_wifi_network(self, params): @@ -290,44 +288,6 @@ class WifiManagerTest(WifiBaseTest): self.log.info("Running iperf client {}".format(args)) self.run_iperf(args) - def get_energy_info(self): - """ Steps: - 1. Check that the WiFi energy info reporting support on this device - is as expected (support or not). - 2. If the device does not support energy info reporting as - expected, skip the test. - 3. Call API to get WiFi energy info. - 4. Verify the values of "ControllerEnergyUsed" and - "ControllerIdleTimeMillis" in energy info don't decrease. - 5. Repeat from Step 3 for 10 times. - """ - # Check if dut supports energy info reporting. - actual_support = self.dut.droid.wifiIsEnhancedPowerReportingSupported() - model = self.dut.model - if not actual_support: - asserts.skip( - ("Device %s does not support energy info reporting as " - "expected.") % model) - # Verify reported values don't decrease. - self.log.info(("Device %s supports energy info reporting, verify that " - "the reported values don't decrease.") % model) - energy = 0 - idle_time = 0 - for i in range(10): - info = self.dut.droid.wifiGetControllerActivityEnergyInfo() - self.log.debug("Iteration %d, got energy info: %s" % (i, info)) - new_energy = info["ControllerEnergyUsed"] - new_idle_time = info["ControllerIdleTimeMillis"] - asserts.assert_true(new_energy >= energy, - "Energy value decreased: previous %d, now %d" % - (energy, new_energy)) - energy = new_energy - asserts.assert_true(new_idle_time >= idle_time, - "Idle time decreased: previous %d, now %d" % ( - idle_time, new_idle_time)) - idle_time = new_idle_time - wutils.start_wifi_connection_scan(self.dut) - """Tests""" @test_tracker_info(uuid="525fc5e3-afba-4bfd-9a02-5834119e3c66") @@ -595,21 +555,28 @@ class WifiManagerTest(WifiBaseTest): " toggling Airplane mode and rebooting.") raise signals.TestFailure(msg) - @test_tracker_info(uuid="81eb7527-4c92-4422-897a-6b5f6445e84a") - def test_config_store_with_wpapsk_2g(self): - self.connect_to_wifi_network_toggle_wifi_and_run_iperf( - (self.wpapsk_2g, self.dut)) + @test_tracker_info(uuid="117b1d1c-963d-40f1-bf50-7cbc8b5e1c69") + @acts.signals.generated_test + def test_config_store(self): + params = list( + itertools.product([self.wpapsk_2g, self.wpapsk_5g], + self.android_devices)) - @test_tracker_info(uuid="8457903d-cb7e-4c89-bcea-7f59585ea6e0") - def test_config_store_with_wpapsk_5g(self): - self.connect_to_wifi_network_toggle_wifi_and_run_iperf( - (self.wpapsk_5g, self.dut)) + def name_gen(p): + return "test_connection_to-%s-for_config_store" % p[0][ + WifiEnums.SSID_KEY] + + failed = self.run_generated_testcases( + self.connect_to_wifi_network_toggle_wifi_and_run_iperf, + params, + name_func=name_gen) + asserts.assert_false(failed, "Failed ones: {}".format(failed)) @test_tracker_info(uuid="b9fbc13a-47b4-4f64-bd2c-e5a3cb24ab2f") def test_tdls_supported(self): - model = self.dut.model + model = acts.utils.trim_model_name(self.dut.model) self.log.debug("Model is %s" % model) - if not model.startswith("volantis"): + if model in self.tdls_models: asserts.assert_true(self.dut.droid.wifiIsTdlsSupported(), ( "TDLS should be supported on %s, but device is " "reporting not supported.") % model) @@ -620,8 +587,46 @@ class WifiManagerTest(WifiBaseTest): @test_tracker_info(uuid="50637d40-ea59-4f4b-9fc1-e6641d64074c") def test_energy_info(self): - """Verify the WiFi energy info reporting feature """ - self.get_energy_info() + """Verify the WiFi energy info reporting feature. + + Steps: + 1. Check that the WiFi energy info reporting support on this device + is as expected (support or not). + 2. If the device does not support energy info reporting as + expected, skip the test. + 3. Call API to get WiFi energy info. + 4. Verify the values of "ControllerEnergyUsed" and + "ControllerIdleTimeMillis" in energy info don't decrease. + 5. Repeat from Step 3 for 10 times. + """ + # Check if dut supports energy info reporting. + actual_support = self.dut.droid.wifiIsEnhancedPowerReportingSupported() + model = self.dut.model + expected_support = model in self.energy_info_models + asserts.assert_equal(expected_support, actual_support) + if not actual_support: + asserts.skip( + ("Device %s does not support energy info reporting as " + "expected.") % model) + # Verify reported values don't decrease. + self.log.info(("Device %s supports energy info reporting, verify that " + "the reported values don't decrease.") % model) + energy = 0 + idle_time = 0 + for i in range(10): + info = self.dut.droid.wifiGetControllerActivityEnergyInfo() + self.log.debug("Iteration %d, got energy info: %s" % (i, info)) + new_energy = info["ControllerEnergyUsed"] + new_idle_time = info["ControllerIdleTimeMillis"] + asserts.assert_true(new_energy >= energy, + "Energy value decreased: previous %d, now %d" % + (energy, new_energy)) + energy = new_energy + asserts.assert_true(new_idle_time >= idle_time, + "Idle time decreased: previous %d, now %d" % ( + idle_time, new_idle_time)) + idle_time = new_idle_time + wutils.start_wifi_connection_scan(self.dut) @test_tracker_info(uuid="1f1cf549-53eb-4f36-9f33-ce06c9158efc") def test_energy_info_connected(self): @@ -630,4 +635,4 @@ class WifiManagerTest(WifiBaseTest): Connect to a wifi network, then the same as test_energy_info. """ wutils.wifi_connect(self.dut, self.open_network) - self.get_energy_info() + self.test_energy_info() diff --git a/acts/tests/google/wifi/WifiNetworkSelectorTest.py b/acts/tests/google/wifi/WifiNetworkSelectorTest.py index b52946dec8..17b4b28456 100644 --- a/acts/tests/google/wifi/WifiNetworkSelectorTest.py +++ b/acts/tests/google/wifi/WifiNetworkSelectorTest.py @@ -55,7 +55,7 @@ class WifiNetworkSelectorTest(WifiBaseTest): 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) + self.legacy_configure_ap_and_start() def setup_test(self): #reset and clear all saved networks on the DUT @@ -77,11 +77,6 @@ class WifiNetworkSelectorTest(WifiBaseTest): self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) - def teardown_class(self): - if "AccessPoint" in self.user_params: - del self.user_params["reference_networks"] - del self.user_params["open_network"] - """ Helper Functions """ def add_networks(self, ad, networks): @@ -192,7 +187,7 @@ class WifiNetworkSelectorTest(WifiBaseTest): """ #add a open network and a secure saved network to DUT networks = [ - self.open_network[AP_1]['5g'], self.reference_networks[AP_1]['5g'] + self.open_network['5g'], self.reference_networks[AP_1]['5g'] ] self.add_networks(self.dut, networks) #move the DUT in range diff --git a/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py b/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py index 32d4c1fc4e..7c8891ebb2 100644 --- a/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py +++ b/acts/tests/google/wifi/WifiNewSetupAutoJoinTest.py @@ -31,17 +31,20 @@ NETWORK_ERROR = "Device is not connected to reference network" class WifiNewSetupAutoJoinTest(WifiBaseTest): def __init__(self, controllers): WifiBaseTest.__init__(self, controllers) - - def add_network_and_enable(self, network): - """Add a network and enable it. - - Args: - network : Network details for the network to be added. - - """ - ret = self.dut.droid.wifiAddNetwork(network) - asserts.assert_true(ret != -1, "Add network %r failed" % network) - self.dut.droid.wifiEnableNetwork(ret, 0) + self.tests = ("test_autojoin_out_of_range", + "test_autojoin_Ap1_2g", + "test_autojoin_Ap1_2gto5g", + "test_autojoin_in_AP1_5gto2g", + "test_autojoin_swtich_AP1toAp2", + "test_autojoin_Ap2_2gto5g", + "test_autojoin_Ap2_5gto2g", + "test_autojoin_out_of_range", + "test_autojoin_Ap2_2g", + "test_autojoin_Ap2_2gto5g", + "test_autojoin_in_Ap2_5gto2g", + "test_autojoin_swtich_AP2toAp1", + "test_autojoin_Ap1_2gto5g", + "test_autojoin_Ap1_5gto2g", ) def setup_class(self): """It will setup the required dependencies from config file and configure @@ -90,12 +93,29 @@ class WifiNewSetupAutoJoinTest(WifiBaseTest): wait_time = 15 self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() - # Add and enable all networks. - for network in self.reference_networks: - self.add_network_and_enable(network['2g']) - self.add_network_and_enable(network['5g']) - self.dut.droid.wifiLockRelease() - self.dut.droid.goToSleepNow() + try: + self.dut.droid.wifiConnectByConfig(self.reference_networks[0][ + '2g']) + connect_result = self.dut.ed.pop_event( + wifi_constants.CONNECT_BY_CONFIG_SUCCESS, 1) + self.log.info(connect_result) + time.sleep(wait_time) + if self.ref_ssid_count == 2: #add 5g network as well + self.dut.droid.wifiConnectByConfig(self.reference_networks[ + 0]['5g']) + connect_result = self.dut.ed.pop_event( + wifi_constants.CONNECT_BY_CONFIG_SUCCESS, 1) + self.log.info(connect_result) + time.sleep(wait_time) + current_network = self.dut.droid.wifiGetConnectionInfo() + self.log.info("Current network: {}".format(current_network)) + asserts.assert_true('network_id' in current_network, + NETWORK_ID_ERROR) + asserts.assert_true(current_network['network_id'] >= 0, + NETWORK_ERROR) + finally: + self.dut.droid.wifiLockRelease() + self.dut.droid.goToSleepNow() def check_connection(self, network_bssid): """Check current wifi connection networks. @@ -147,206 +167,154 @@ class WifiNewSetupAutoJoinTest(WifiBaseTest): self.max_bugreports -= 1 self.dut.cat_adb_log(test_name, begin_time) - def teardown_class(self): - if "AccessPoint" in self.user_params: - del self.user_params["reference_networks"] - del self.user_params["open_network"] - """ Tests Begin """ - """ Test wifi auto join functionality move in range of AP1. - - 1. Attenuate the signal to low range of AP1 and Ap2 not visible at all. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="9ea2c78d-d305-497f-87a5-f621f0a4b34e") - def test_autojoin_Ap1_2g_AP1_20_AP2_95_AP3_95(self): - att0, att1, att2, att3 = self.atten_val["Ap1_2g"] - variance = 5 - attn_value = [att0 + variance * 2, att1, att2, att3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - - @test_tracker_info(uuid="7c34a508-2ffa-4bca-82b3-9637b7c8250a") - def test_autojoin_Ap1_2g_AP1_15_AP2_95_AP3_95(self): - att0, att1, att2, att3 = self.atten_val["Ap1_2g"] - variance = 5 - attn_value = [att0 + variance, att1, att2, att3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) + def test_autojoin_Ap1_2g(self): + """Test wifi auto join functionality move in range of AP1. - @test_tracker_info(uuid="ea614fcc-7fca-4172-ba3a-5978427eb40f") - def test_autojoin_Ap1_2g_AP1_10_AP2_95_AP3_95(self): - att0, att1, att2, att3 = self.atten_val["Ap1_2g"] - variance = 5 - attn_value = [att0, att1, att2, att3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - - @test_tracker_info(uuid="a1ad25cf-11e7-4240-b3c0-9f14325d5b2d") - def test_autojoin_Ap1_2g_AP1_5_AP2_95_AP3_95(self): + 1. Attenuate the signal to low range of AP1 and Ap2 not visible at all. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, att3 = self.atten_val["Ap1_2g"] variance = 5 - attn_value = [att0 - variance, att1, att2, att3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - - """ Test wifi auto join functionality move to high range. + attenuations = ([att0 + variance * 2, att1, att2, att3], + [att0 + variance, att1, att2, att3], [att0, att1, att2, att3], + [att0 - variance, att1, att2, att3]) + name_func = lambda att_value, bssid: ("test_autojoin_Ap1_2g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[0]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, + "Number of test_autojoin_Ap1_2g failed {}".format(len(failed))) - 1. Attenuate the signal to high range of AP1. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="b5eba5ec-96e5-4bd8-b483-f5b2a9504558") - def test_autojoin_Ap1_2gto5g_AP1_55_AP2_10_AP3_95(self): - att0, att1, att2, attn3 = self.atten_val["Ap1_2gto5g"] - variance = 5 - attn_value = [att0 + variance * 2, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["5g"]['bssid']) + def test_autojoin_Ap1_2gto5g(self): + """Test wifi auto join functionality move to high range. - @test_tracker_info(uuid="e63543f7-5f43-4ba2-a5bd-2af3c159a622") - def test_autojoin_Ap1_2gto5g_AP1_50_AP2_10_AP3_95(self): - att0, att1, att2, attn3 = self.atten_val["Ap1_2gto5g"] - variance = 5 - attn_value = [att0 + variance, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["5g"]['bssid']) - - @test_tracker_info(uuid="0c2cef5d-695d-4d4e-832d-f5e8b393a09c") - def test_autojoin_Ap1_2gto5g_AP1_45_AP2_10_AP3_95(self): + 1. Attenuate the signal to high range of AP1. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["Ap1_2gto5g"] variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["5g"]['bssid']) + attenuations = ([att0 + variance * 2, att1, att2, attn3], + [att0 + variance, att1, att2, attn3], [att0, att1, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_Ap1_2gto5g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[0]["5g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, + "Number of test_autojoin_Ap1_2gto5g failed {}".format(len(failed))) - """ Test wifi auto join functionality move to low range toward AP2. - - 1. Attenuate the signal to medium range of AP1 and low range of AP2. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="37822578-d35c-462c-87c0-7a2d9252938c") - def test_autojoin_in_AP1_5gto2g_AP1_5_AP2_80_AP3_95(self): - att0, att1, att2, attn3 = self.atten_val["In_AP1_5gto2g"] - variance = 5 - attn_value = [att0 - variance, att1 + variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) + def test_autojoin_in_AP1_5gto2g(self): + """Test wifi auto join functionality move to low range toward AP2. - @test_tracker_info(uuid="194ffe44-9718-4beb-b69e-cccb569f9b81") - def test_autojoin_in_AP1_5gto2g_AP1_10_AP2_75_AP3_95(self): - att0, att1, att2, attn3 = self.atten_val["In_AP1_5gto2g"] - variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - - @test_tracker_info(uuid="09bdcb0f-7833-4604-a839-f7d981bf4aca") - def test_autojoin_in_AP1_5gto2g_AP1_15_AP2_70_AP3_95(self): + 1. Attenuate the signal to medium range of AP1 and low range of AP2. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["In_AP1_5gto2g"] variance = 5 - attn_value = [att0 + variance, att1 - variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) + attenuations = ([att0 - variance, att1 + variance, att2, attn3], + [att0, att1, att2, attn3], + [att0 + variance, att1 - variance, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_in_AP1_5gto2g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[0]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, "Number of test_autojoin_in_AP1_5gto2g failed {}".format( + len(failed))) - """ Test wifi auto join functionality move from low range of AP1 to better - range of AP2. - - 1. Attenuate the signal to low range of AP1 and medium range of AP2. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="8ffdcab1-2bfb-4acd-b1e8-089ba8a4ec41") - def test_autojoin_swtich_AP1toAp2_AP1_65_AP2_75_AP3_2(self): - att0, att1, att2, attn3 = self.atten_val["Swtich_AP1toAp2"] - variance = 5 - attn_value = [att0 - variance, att1 + variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) - - @test_tracker_info(uuid="23e05821-3c53-4033-830e-a446b6105831") - def test_autojoin_swtich_AP1toAp2_AP1_70_AP2_70_AP3_2(self): - att0, att1, att2, attn3 = self.atten_val["Swtich_AP1toAp2"] - variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) + def test_autojoin_swtich_AP1toAp2(self): + """Test wifi auto join functionality move from low range of AP1 to better + range of AP2. - @test_tracker_info(uuid="a56ad87d-d37f-4606-9ae8-af6f55cbb6cf") - def test_autojoin_swtich_AP1toAp2_AP1_75_AP2_65_AP3_2(self): + 1. Attenuate the signal to low range of AP1 and medium range of AP2. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["Swtich_AP1toAp2"] variance = 5 - attn_value = [att0 + variance, att1 - variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) - - """ Test wifi auto join functionality move to high range of AP2. + attenuations = ([att0 - variance, att1 + variance, att2, attn3], + [att0, att1, att2, attn3], + [att0 + variance, att1 - variance, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_swtich_AP1toAp2_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[1]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, "Number of test_autojoin_swtich_AP1toAp2 failed {}".format( + len(failed))) - 1. Attenuate the signal to out range of AP1 and high range of AP2. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="7a8b9242-f93c-449a-90a6-4562274a213a") - def test_autojoin_Ap2_2gto5g_AP1_70_AP2_85_AP3_75(self): - att0, att1, att2, attn3 = self.atten_val["Ap2_2gto5g"] - variance = 5 - attn_value = [att0 - variance, att1 + variance * 2, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["5g"]['bssid']) - - @test_tracker_info(uuid="5e0c5485-a3ae-438a-92e5-9a6b5a22cb82") - def test_autojoin_Ap2_2gto5g_AP1_75_AP2_80_AP3_75(self): - att0, att1, att2, attn3 = self.atten_val["Ap2_2gto5g"] - variance = 5 - attn_value = [att0, att1 + variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["5g"]['bssid']) + def test_autojoin_Ap2_2gto5g(self): + """Test wifi auto join functionality move to high range of AP2. - @test_tracker_info(uuid="3b289144-a12a-424f-822e-8d173d75c3c3") - def test_autojoin_Ap2_2gto5g_AP1_75_AP2_75_AP3_75(self): + 1. Attenuate the signal to out range of AP1 and high range of AP2. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["Ap2_2gto5g"] variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["5g"]['bssid']) + attenuations = ([att0 - variance, att1 + variance * 2, att2, attn3], + [att0, att1 + variance, att2, attn3], [att0, att1, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_Ap2_2gto5g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[1]["5g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, + "Number of test_autojoin_Ap2_2gto5g failed {}".format(len(failed))) - """ Test wifi auto join functionality move to low range of AP2. - - 1. Attenuate the signal to low range of AP2. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable. - """ @test_tracker_info(uuid="009457df-f430-402c-96ab-c456b043b6f5") - def test_autojoin_Ap2_5gto2g_AP1_75_AP2_70_AP3_10(self): - att0, att1, att2, attn3 = self.atten_val["Ap2_5gto2g"] - variance = 5 - attn_value = [att0, att1 - variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) - - @test_tracker_info(uuid="15ef731c-ddfb-4118-aedb-c177f50bdea0") - def test_autojoin_Ap2_5gto2g_AP1_75_AP2_75_AP3_10(self): - att0, att1, att2, attn3 = self.atten_val["Ap2_5gto2g"] - variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) + def test_autojoin_Ap2_5gto2g(self): + """Test wifi auto join functionality move to low range of AP2. - @test_tracker_info(uuid="f79b0570-56a0-43d2-962d-9e114d48bacf") - def test_autojoin_Ap2_5gto2g_AP1_75_AP2_80_AP3_10(self): + 1. Attenuate the signal to low range of AP2. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable. + """ att0, att1, att2, attn3 = self.atten_val["Ap2_5gto2g"] variance = 5 - attn_value = [att0, att1 + variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) + attenuations = ([att0, att1 - variance, att2, attn3], [att0, att1, att2, attn3], + [att0, att1 + variance, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_Ap2_5gto2g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[1]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, + "Number of test_autojoin_Ap2_5gto2g failed {}".format(len(failed))) @test_tracker_info(uuid="c6d070af-b601-42f1-adec-5ac564154b29") def test_autojoin_out_of_range(self): @@ -378,138 +346,103 @@ class WifiNewSetupAutoJoinTest(WifiBaseTest): self.dut.droid.wifiLockRelease() self.dut.droid.goToSleepNow() - """ Test wifi auto join functionality move in low range of AP2. - - 1. Attenuate the signal to move in range of AP2 and Ap1 not visible at all. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="15c27654-bae0-4d2d-bdc8-54fb04b901d1") - def test_autojoin_Ap2_2g_AP1_75_AP2_85_AP3_10(self): - att0, att1, att2, attn3 = self.atten_val["Ap2_2g"] - variance = 5 - attn_value = [att0, att1 + variance * 2, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) + def test_autojoin_Ap2_2g(self): + """Test wifi auto join functionality move in low range of AP2. - @test_tracker_info(uuid="af40824a-4d65-4789-980f-d534abeca36b") - def test_autojoin_Ap2_2g_AP1_75_AP2_80_AP3_10(self): - att0, att1, att2, attn3 = self.atten_val["Ap2_2g"] - variance = 5 - attn_value = [att0, att1 + variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) - - @test_tracker_info(uuid="2d482060-9865-472b-810b-c74c6a099e6c") - def test_autojoin_Ap2_2g_AP1_75_AP2_75_AP3_10(self): + 1. Attenuate the signal to move in range of AP2 and Ap1 not visible at all. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["Ap2_2g"] variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) + attenuations = ([att0, att1 + variance * 2, att2, attn3], + [att0, att1 + variance, att2, attn3], [att0, att1, att2, attn3], + [att0, att1 - variance, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_Ap2_2g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[1]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, + "Number of test_autojoin_Ap2_2g failed {}".format(len(failed))) - @test_tracker_info(uuid="b5cad09e-6e31-40f4-a568-2a1d5271e20c") - def test_autojoin_Ap2_2g_AP1_75_AP2_70_AP3_10(self): - att0, att1, att2, attn3 = self.atten_val["Ap2_2g"] - variance = 5 - attn_value = [att0, att1 - variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) - - """ Test wifi auto join functionality move to medium range of Ap2 and - low range of AP1. - - 1. Attenuate the signal to move in medium range of AP2 and low range of AP1. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="80e74c78-59e2-46db-809d-cb03bd1b6824") - def test_autojoin_in_Ap2_5gto2g_AP1_75_AP2_70_AP3_10(self): - att0, att1, att2, attn3 = self.atten_val["In_Ap2_5gto2g"] - variance = 5 - attn_value = [att0, att1 - variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) + def test_autojoin_in_Ap2_5gto2g(self): + """Test wifi auto join functionality move to medium range of Ap2 and + low range of AP1. - @test_tracker_info(uuid="d2a188bd-91cf-4412-a098-739c0c236fe1") - def test_autojoin_in_Ap2_5gto2g_AP1_75_AP2_75_AP3_10(self): + 1. Attenuate the signal to move in medium range of AP2 and low range of AP1. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["In_Ap2_5gto2g"] variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) + attenuations = ([att0, att1 - variance, att2, attn3], [att0, att1, att2, attn3], + [att0, att1 + variance, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_in_Ap2_5gto2g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[1]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, "Number of test_autojoin_in_Ap2_5gto2g failed {}".format( + len(failed))) - @test_tracker_info(uuid="032e81e9-bc8a-4fa2-a96b-d733c241869e") - def test_autojoin_in_Ap2_5gto2g_AP1_75_AP2_80_AP3_10(self): - att0, att1, att2, attn3 = self.atten_val["In_Ap2_5gto2g"] - variance = 5 - attn_value = [att0, att1 + variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[1]["2g"]['bssid']) - - """ Test wifi auto join functionality move from low range of AP2 to better - range of AP1. - - 1. Attenuate the signal to low range of AP2 and medium range of AP1. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="01faeba0-bd66-4d30-a3d9-b81e959025b2") - def test_autojoin_swtich_AP2toAp1_AP1_15_AP2_65_AP3_75(self): - att0, att1, att2, attn3 = self.atten_val["Swtich_AP2toAp1"] - variance = 5 - attn_value = [att0 + variance, att1 - variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - - @test_tracker_info(uuid="68b15c50-03ab-4385-9231-280002315fe5") - def test_autojoin_swtich_AP2toAp1_AP1_10_AP2_70_AP3_75(self): - att0, att1, att2, attn3 = self.atten_val["Swtich_AP2toAp1"] - variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) + def test_autojoin_swtich_AP2toAp1(self): + """Test wifi auto join functionality move from low range of AP2 to better + range of AP1. - @test_tracker_info(uuid="1986d79b-097e-44c9-9aff-7bcd56490c3b") - def test_autojoin_swtich_AP2toAp1_AP1_5_AP2_75_AP3_75(self): + 1. Attenuate the signal to low range of AP2 and medium range of AP1. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["Swtich_AP2toAp1"] variance = 5 - attn_value = [att0 - variance, att1 + variance, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - - """ Test wifi auto join functionality move to medium range of AP1. + attenuations = ([att0 + variance, att1 - variance, att2, attn3], + [att0, att1, att2, attn3], + [att0 - variance, att1 + variance, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_swtich_AP2toAp1_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[0]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, "Number of test_autojoin_swtich_AP2toAp1 failed {}".format( + len(failed))) - 1. Attenuate the signal to medium range of AP1. - 2. Wake up the device. - 3. Check that device is connected to right BSSID and maintain stable - connection to BSSID in range. - """ @test_tracker_info(uuid="ec509d40-e339-47c2-995e-cc77f5a28687") - def test_autojoin_Ap1_5gto2g_AP1_10_AP2_80_AP3_95(self): - att0, att1, att2, attn3 = self.atten_val["Ap1_5gto2g"] - variance = 5 - attn_value = [att0, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - - @test_tracker_info(uuid="ddc66d1e-3241-4040-996a-85bc2a2a4d67") - def test_autojoin_Ap1_5gto2g_AP1_15_AP2_80_AP3_95(self): - att0, att1, att2, attn3 = self.atten_val["Ap1_5gto2g"] - variance = 5 - attn_value = [att0 + variance, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) + def test_autojoin_Ap1_5gto2g(self): + """Test wifi auto join functionality move to medium range of AP1. - @test_tracker_info(uuid="dfc84504-230f-428e-b701-edc496d0e7b3") - def test_autojoin_Ap1_5gto2g_AP1_20_AP2_80_AP3_95(self): + 1. Attenuate the signal to medium range of AP1. + 2. Wake up the device. + 3. Check that device is connected to right BSSID and maintain stable + connection to BSSID in range. + """ att0, att1, att2, attn3 = self.atten_val["Ap1_5gto2g"] variance = 5 - attn_value = [att0 + variance * 2, att1, att2, attn3] - self.set_attn_and_validate_connection( - attn_value, self.reference_networks[0]["2g"]['bssid']) - + attenuations = ([att0, att1, att2, attn3], [att0 + variance, att1, att2, attn3], + [att0 + variance * 2, att1, att2, attn3]) + name_func = lambda att_value, bssid: ("test_autojoin_Ap1_5gto2g_AP1_{}_AP2" + "_{}_AP3_{}").format(att_value[0], att_value[1], att_value[2]) + failed = self.run_generated_testcases( + self.set_attn_and_validate_connection, + attenuations, + args=(self.reference_networks[0]["2g"]['bssid'], ), + name_func=name_func) + asserts.assert_false( + failed, + "Number of test_autojoin_Ap1_5gto2g failed {}".format(len(failed))) """ Tests End """ diff --git a/acts/tests/google/wifi/WifiPnoTest.py b/acts/tests/google/wifi/WifiPnoTest.py index c0588a8a5e..ffdbab82b3 100644 --- a/acts/tests/google/wifi/WifiPnoTest.py +++ b/acts/tests/google/wifi/WifiPnoTest.py @@ -22,7 +22,7 @@ import acts.test_utils.wifi.wifi_test_utils as wutils from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest WifiEnums = wutils.WifiEnums -MAX_ATTN = 95 + class WifiPnoTest(WifiBaseTest): @@ -42,11 +42,9 @@ class WifiPnoTest(WifiBaseTest): self.pno_network_a = self.reference_networks[0]['2g'] self.pno_network_b = self.reference_networks[0]['5g'] + self.attenuators = wutils.group_attenuators(self.attenuators) self.attn_a = self.attenuators[0] self.attn_b = self.attenuators[1] - # Disable second AP's networks, so that it does not interfere during PNO - self.attenuators[2].set_atten(MAX_ATTN) - self.attenuators[3].set_atten(MAX_ATTN) self.set_attns("default") def setup_test(self): @@ -66,11 +64,6 @@ class WifiPnoTest(WifiBaseTest): self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) - def teardown_class(self): - if "AccessPoint" in self.user_params: - del self.user_params["reference_networks"] - del self.user_params["open_network"] - """Helper Functions""" def set_attns(self, attn_val_name): @@ -106,8 +99,6 @@ class WifiPnoTest(WifiBaseTest): self.log.info("Wait %ss for PNO to trigger.", self.pno_interval) time.sleep(self.pno_interval) try: - self.log.info("Connected to %s network after PNO interval" - % self.dut.droid.wifiGetConnectionInfo()) expected_ssid = expected_con[WifiEnums.SSID_KEY] verify_con = {WifiEnums.SSID_KEY: expected_ssid} wutils.verify_wifi_connection_info(self.dut, verify_con) @@ -116,8 +107,8 @@ class WifiPnoTest(WifiBaseTest): finally: pass - def add_and_enable_dummy_networks(self, num_networks): - """Add some dummy networks to the device and enable them. + def add_dummy_networks(self, num_networks): + """Add some dummy networks to the device. Args: num_networks: Number of networks to add. @@ -127,58 +118,39 @@ class WifiPnoTest(WifiBaseTest): network = {} network[WifiEnums.SSID_KEY] = ssid_name_base + str(i) network[WifiEnums.PWD_KEY] = "pno_dummy" - self.add_network_and_enable(network) - - def add_network_and_enable(self, network): - """Add a network and enable it. - - Args: - network : Network details for the network to be added. - - """ - ret = self.dut.droid.wifiAddNetwork(network) - asserts.assert_true(ret != -1, "Add network %r failed" % network) - self.dut.droid.wifiEnableNetwork(ret, 0) - + asserts.assert_true( + self.dut.droid.wifiAddNetwork(network) != -1, + "Add network %r failed" % network) """ Tests Begin """ @test_tracker_info(uuid="33d3cae4-5fa7-4e90-b9e2-5d3747bba64c") - def test_simple_pno_connection_2g_to_5g(self): - """Test PNO triggered autoconnect to a network. - - Steps: - 1. Switch off the screen on the device. - 2. Save 2 valid network configurations (a & b) in the device. - 3. Attenuate 5Ghz network and wait for a few seconds to trigger PNO. - 4. Check the device connected to 2Ghz network automatically. - 5. Attenuate 2Ghz network and wait for a few seconds to trigger PNO. - 6. Check the device connected to 5Ghz network automatically. - """ - self.add_network_and_enable(self.pno_network_a) - self.add_network_and_enable(self.pno_network_b) - self.trigger_pno_and_assert_connect("a_on_b_off", self.pno_network_a) - self.trigger_pno_and_assert_connect("b_on_a_off", self.pno_network_b) - - @test_tracker_info(uuid="39b945a1-830f-4f11-9e6a-9e9641066a96") - def test_simple_pno_connection_5g_to_2g(self): + def test_simple_pno_connection(self): """Test PNO triggered autoconnect to a network. Steps: 1. Switch off the screen on the device. 2. Save 2 valid network configurations (a & b) in the device. - 3. Attenuate 2Ghz network and wait for a few seconds to trigger PNO. - 4. Check the device connected to 5Ghz network automatically. - 5. Attenuate 5Ghz network and wait for a few seconds to trigger PNO. - 6. Check the device connected to 2Ghz network automatically. - + 3. Attenuate network b. + 4. Connect the device to network a. + 5. Attenuate network a and remove attenuation on network b and wait for + a few seconds to trigger PNO. + 6. Check the device connected to network b automatically. + 8. Attenuate network b and remove attenuation on network a and wait for + a few seconds to trigger PNO. + 9. Check the device connected to network a automatically. """ - self.add_network_and_enable(self.pno_network_a) - self.add_network_and_enable(self.pno_network_b) + asserts.assert_true( + self.dut.droid.wifiAddNetwork(self.pno_network_a) != -1, + "Add network %r failed" % self.pno_network_a) + asserts.assert_true( + self.dut.droid.wifiAddNetwork(self.pno_network_b) != -1, + "Add network %r failed" % self.pno_network_b) + self.set_attns("a_on_b_off") + wutils.wifi_connect(self.dut, self.pno_network_a), self.trigger_pno_and_assert_connect("b_on_a_off", self.pno_network_b) self.trigger_pno_and_assert_connect("a_on_b_off", self.pno_network_a) - @test_tracker_info(uuid="844b15be-ff45-4b09-a11b-0b2b4bb13b22") def test_pno_connection_with_multiple_saved_networks(self): """Test PNO triggered autoconnect to a network when there are more @@ -192,7 +164,7 @@ class WifiPnoTest(WifiBaseTest): 1. Save 16 dummy network configurations in the device. 2. Run the simple pno test. """ - self.add_and_enable_dummy_networks(16) - self.test_simple_pno_connection_2g_to_5g() + self.add_dummy_networks(16) + self.test_simple_pno_connection() """ Tests End """ diff --git a/acts/tests/google/wifi/WifiPreFlightTest.py b/acts/tests/google/wifi/WifiPreFlightTest.py deleted file mode 100755 index aae022191a..0000000000 --- a/acts/tests/google/wifi/WifiPreFlightTest.py +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import copy -import pprint -import time - -import acts.base_test -import acts.test_utils.wifi.wifi_test_utils as wutils - -from acts import asserts -from acts.test_decorators import test_tracker_info -from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest - -SCAN_TIME = 30 -WAIT_TIME = 2 - - -class WifiPreFlightTest(WifiBaseTest): - """ Pre-flight checks for Wifi tests. - - Test Bed Requirement: - * One Android device - * 4 reference networks - two 2G and two 5G networks - * Attenuators to attenuate each reference network - - Tests: - * Check if reference networks show up in wifi scan - * Check if attenuators attenuate the correct network - """ - - def __init__(self, controllers): - WifiBaseTest.__init__(self, controllers) - self.WIFI_2G = "2g" - self.WIFI_5G = "5g" - self.PASSWORD = "password" - self.MIN_SIGNAL_LEVEL = -45 - - def setup_class(self): - self.dut = self.android_devices[0] - wutils.wifi_test_device_init(self.dut) - wutils.wifi_toggle_state(self.dut, True) - - # Get reference networks as a list - req_params = ["reference_networks"] - self.unpack_userparams(req_param_names=req_params) - networks = [] - for ref_net in self.reference_networks: - networks.append(ref_net[self.WIFI_2G]) - networks.append(ref_net[self.WIFI_5G]) - self.reference_networks = networks - asserts.assert_true( - len(self.reference_networks) == 4, - "Need at least 4 reference network with psk.") - - # Set attenuation to 0 and verify reference - # networks show up in the scanned results - if getattr(self, "attenuators", []): - for a in self.attenuators: - a.set_atten(0) - - self.target_networks = [] - for ref_net in self.reference_networks: - self.target_networks.append( {'BSSID': ref_net['bssid']} ) - result = self._find_reference_networks_no_attn() - - if result: - self.log.error("Did not find or signal strength too low " - "for the following reference networks\n%s\n" % result) - return False - - def teardown_class(self): - wutils.reset_wifi(self.dut) - for a in self.attenuators: - a.set_atten(0) - - """ Helper functions """ - def _find_reference_networks_no_attn(self): - """ Verify that when ATTN set to 0, all reference networks - show up in the scanned results - - Args: - 1. List of reference networks - - Returns: - 1. List of networks not found. Empty if all reference - networks are found - """ - found_networks = copy.deepcopy(self.target_networks) - start_time = time.time() - while(time.time() < start_time + SCAN_TIME): - if not found_networks: - break - time.sleep(WAIT_TIME) - scanned_networks = self.dut.droid.wifiGetScanResults() - for net in self.target_networks: - if net in found_networks: - result = wutils.match_networks(net, scanned_networks) - if result and result[0]['level'] > self.MIN_SIGNAL_LEVEL: - found_networks.remove(net) - elif result: - self.log.warn("Signal strength for %s is low: %sdBm" - % (net, result[0]['level'])) - return found_networks - - def _find_network_after_setting_attn(self, target_network): - """ Find network after setting attenuation - - Args: - 1. target_network to find in the scanned_results - - Returns: - 1. True if - a. if max_attn is set and target_network not found - 2. False if not - """ - start_time = time.time() - while(time.time() < start_time + SCAN_TIME): - time.sleep(WAIT_TIME) - scanned_networks = self.dut.droid.wifiGetScanResults() - result = wutils.match_networks(target_network, scanned_networks) - if not result: - return True - return False - - """ Tests """ - def test_attenuators(self): - """ Test if attenuating a channel, disables the correct - reference network - - Reference networks for each testbed should match - attenuators as follows - - wh_ap1_2g - channel 1 - wh_ap1_5g - channel 2 - wh_ap2_2g - channel 3 - wh_ap2_5g - channel 4 - - Steps: - 1. Set attenuation on each channel to 95 - 2. Verify that the corresponding network does not show - up in the scanned results - """ - found_networks = [] - - # attenuate 1 channel at a time and find the network - for i in range(len(self.attenuators)): - target_network = {} - target_network['BSSID'] = self.reference_networks[i]['bssid'] - - # set the attn to max and verify target network is not found - self.attenuators[i].set_atten(95) - result = self._find_network_after_setting_attn(target_network) - if result: - target_network['ATTN'] = i - found_networks.append(target_network) - - if found_networks: - self.log.error("Attenuators did not match the networks\n %s\n" - % pprint.pformat(found_networks)) - return False diff --git a/acts/tests/google/wifi/WifiScannerMultiScanTest.py b/acts/tests/google/wifi/WifiScannerMultiScanTest.py index 0ff357419f..14cd318e36 100755 --- a/acts/tests/google/wifi/WifiScannerMultiScanTest.py +++ b/acts/tests/google/wifi/WifiScannerMultiScanTest.py @@ -267,11 +267,6 @@ class WifiScannerMultiScanTest(WifiBaseTest): self.max_bugreports -= 1 self.dut.cat_adb_log(test_name, begin_time) - def teardown_class(self): - if "AccessPoint" in self.user_params: - del self.user_params["reference_networks"] - del self.user_params["open_network"] - """ Helper Functions Begin """ def start_scan(self, scan_setting): diff --git a/acts/tests/google/wifi/WifiScannerScanTest.py b/acts/tests/google/wifi/WifiScannerScanTest.py index 9eb6d382f3..d19a620112 100755 --- a/acts/tests/google/wifi/WifiScannerScanTest.py +++ b/acts/tests/google/wifi/WifiScannerScanTest.py @@ -51,12 +51,7 @@ class WifiScannerScanTest(WifiBaseTest): # There are order dependencies among these tests so we'll have to leave # it here for now. :( self.tests = ( - "test_available_channels_band_1", - "test_available_channels_band_2", - "test_available_channels_band_3", - "test_available_channels_band_4", - "test_available_channels_band_6", - "test_available_channels_band_7", + "test_available_channels_generated", "test_wifi_scanner_single_scan_channel_sanity", "test_wifi_scanner_with_wifi_off", "test_single_scan_report_each_scan_for_channels_with_enumerated_params", @@ -120,11 +115,6 @@ class WifiScannerScanTest(WifiBaseTest): self.max_bugreports -= 1 self.dut.cat_adb_log(test_name, begin_time) - def teardown_class(self): - if "AccessPoint" in self.user_params: - del self.user_params["reference_networks"] - del self.user_params["open_network"] - """ Helper Functions Begin """ def wifi_generate_scanner_scan_settings(self, extended, scan_type, @@ -560,35 +550,22 @@ class WifiScannerScanTest(WifiBaseTest): """ Helper Functions End """ """ Tests Begin """ - # Test channels - """ Test available channels for different bands. - - 1. Get available channels for different bands. - 2. Verify that channels match with supported channels for respective band. - """ @test_tracker_info(uuid="7cca8142-529f-4951-ab6f-cd03b359b3cc") - def test_available_channels_band_1(self): - self.check_get_available_channels_with_one_band(1) - - @test_tracker_info(uuid="612afda1-0d74-4d2f-bc37-72ef2b98310a") - def test_available_channels_band_2(self): - self.check_get_available_channels_with_one_band(2) + def test_available_channels_generated(self): + """Test available channels for different bands. - @test_tracker_info(uuid="a9275bb9-afa7-4dd4-b2e0-60296ffd33bb") - def test_available_channels_band_3(self): - self.check_get_available_channels_with_one_band(3) - - @test_tracker_info(uuid="5413632e-ce72-4ecc-bf9b-33ac9e4bf3fc") - def test_available_channels_band_4(self): - self.check_get_available_channels_with_one_band(4) - - @test_tracker_info(uuid="a8f40b4f-d79d-4d2f-bed8-3b139a082f6c") - def test_available_channels_band_6(self): - self.check_get_available_channels_with_one_band(6) - - @test_tracker_info(uuid="84cdfc25-8e64-42c7-b7f9-0a04e45d78b6") - def test_available_channels_band_7(self): - self.check_get_available_channels_with_one_band(7) + 1. Get available channels for different bands. + 2. Verify that channels match with supported channels for respective band. + """ + bands = (1, 2, 3, 4, 6, 7) + name_func = lambda band: "test_get_channel_band_{}".format(band) + failed = self.run_generated_testcases( + self.check_get_available_channels_with_one_band, + bands, + name_func=name_func) + asserts.assert_true( + not failed, + "Number of test_get_channel_band failed {}".format(len(failed))) @test_tracker_info(uuid="95069244-b76c-4834-b3a6-96b0d8da98d8") def test_single_scan_report_each_scan_for_channels_with_enumerated_params( @@ -604,7 +581,21 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_AFTER_EACH_SCAN) self.log.debug("Scan settings: %s\n%s", len(scan_settings), scan_settings) - self.wifi_scanner_single_scan(scan_settings[0]) + + def name_func(scan_setting): + return ( + "test_single_scan_report_each_scan_for_channels_%s" + "_numBssidsPerScan_%s_maxScansToCache_%s_period_%s") % ( + scan_setting["channels"], scan_setting["numBssidsPerScan"], + scan_setting["maxScansToCache"], + scan_setting["periodInMs"]) + + failed = self.run_generated_testcases(self.wifi_scanner_single_scan, + scan_settings, + name_func=name_func) + asserts.assert_false( + failed, ("Number of test_single_scan_report_each_scan_for_channels" + " failed {}").format(len(failed))) @test_tracker_info(uuid="5595ebe5-6d91-4379-a606-be59967e5ec9") def test_single_scan_report_each_scan_for_band_with_enumerated_params( @@ -620,7 +611,20 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_AFTER_EACH_SCAN) self.log.debug("Scan settings:%s\n%s", len(scan_settings), scan_settings) - self.wifi_scanner_single_scan(scan_settings[0]) + + def scan_setting_name_gen(scan_setting): + return "test_single_scan_report_each_scan_for_band_%s_numBssidsPerScan_%s_maxScansToCache_%s_period_%s" % ( + scan_setting["band"], scan_setting["numBssidsPerScan"], + scan_setting["maxScansToCache"], scan_setting["periodInMs"]) + + name_func = scan_setting_name_gen + failed = self.run_generated_testcases(self.wifi_scanner_single_scan, + scan_settings, + name_func=name_func) + asserts.assert_true( + not failed, + "Number of test_single_scan_report_each_scan_for_band failed %s" % + len(failed)) @test_tracker_info(uuid="44989f93-e63b-4c2e-a90a-a483477303bb") def test_batch_scan_report_buffer_full_for_channels_with_enumerated_params( @@ -637,7 +641,16 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_AFTER_BUFFER_FULL) self.log.debug("Scan settings:%s\n%s", len(scan_settings), scan_settings) - self.wifi_scanner_batch_scan(scan_settings[0]) + name_func = ( + lambda scan_setting: ("test_batch_scan_report_buffer_full_for_channels_{}" + "_numBssidsPerScan_{}_maxScansToCache_{}_periodInMs_{}").format(scan_setting["channels"], scan_setting["numBssidsPerScan"], scan_setting["maxScansToCache"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases(self.wifi_scanner_batch_scan, + scan_settings, + name_func=name_func) + asserts.assert_false(failed, ( + "Number of test_batch_scan_report_buffer_full_for_channels" + " failed {}").format(len(failed))) @test_tracker_info(uuid="63538df6-388a-4c16-964f-e9c19b750e07") def test_batch_scan_report_buffer_full_for_band_with_enumerated_params( @@ -654,7 +667,16 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_AFTER_BUFFER_FULL) self.log.debug("Scan settings:{}\n{}".format( len(scan_settings), scan_settings)) - self.wifi_scanner_batch_scan(scan_settings[0]) + name_func = ( + lambda scan_setting: ("test_batch_scan_report_buffer_full_for_band_{}" + "_numBssidsPerScan_{}_maxScansToCache_{}_periodInMs_{}").format(scan_setting["band"], scan_setting["numBssidsPerScan"], scan_setting["maxScansToCache"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases(self.wifi_scanner_batch_scan, + scan_settings, + name_func=name_func) + asserts.assert_false( + failed, ("Number of test_batch_scan_report_buffer_full_for_band" + " failed {}").format(len(failed))) @test_tracker_info(uuid="bd4e8c53-16c8-4ed6-b680-55c1ba688ad8") def test_batch_scan_report_each_scan_for_channels_with_enumerated_params( @@ -671,7 +693,16 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_AFTER_EACH_SCAN) self.log.debug("Scan settings:{}\n{}".format( len(scan_settings), scan_settings)) - self.wifi_scanner_batch_scan(scan_settings[0]) + name_func = ( + lambda scan_setting: ("test_batch_scan_report_each_scan_for_channels_{}" + "_numBssidsPerScan_{}_maxScansToCache_{}_periodInMs_{}").format(scan_setting["channels"], scan_setting["numBssidsPerScan"], scan_setting["maxScansToCache"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases(self.wifi_scanner_batch_scan, + scan_settings, + name_func=name_func) + asserts.assert_false( + failed, ("Number of test_batch_scan_report_each_scan_for_channels" + " failed {}").format(len(failed))) @test_tracker_info(uuid="d11e8c09-97d0-49c1-bf09-b9ec672c2fa6") def test_batch_scan_report_each_scan_for_band_with_enumerated_params(self): @@ -687,7 +718,16 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_AFTER_EACH_SCAN) self.log.debug("Scan settings:{}\n{}".format( len(scan_settings), scan_settings)) - self.wifi_scanner_batch_scan(scan_settings[0]) + name_func = ( + lambda scan_setting: ("test_batch_scan_report_each_scan_for_band_{}" + "_numBssidsPerScan_{}_maxScansToCache_{}_periodInMs_{}").format(scan_setting["band"], scan_setting["numBssidsPerScan"], scan_setting["maxScansToCache"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases(self.wifi_scanner_batch_scan, + scan_settings, + name_func=name_func) + asserts.assert_true( + not failed, ("Number of test_batch_scan_report_each_scan_for_band" + " failed {}").format(len(failed))) @test_tracker_info(uuid="7f967b0e-82fe-403e-9d74-0dee7f09a21d") def test_single_scan_report_full_scan_for_channels_with_enumerated_params( @@ -704,7 +744,16 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_FULL_SCAN_RESULT) self.log.debug("Full Scan settings:{}\n{}".format( len(scan_settings), scan_settings)) - self.wifi_scanner_single_scan_full(scan_settings[0]) + name_func = ( + lambda scan_setting: "test_single_scan_report_full_scan_for_channels_{}_periodInMs_{}".format(scan_setting["channels"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases( + self.wifi_scanner_single_scan_full, + scan_settings, + name_func=name_func) + asserts.assert_false( + failed, ("Number of test_single_scan_report_full_scan_for_channels" + " failed {}").format(len(failed))) @test_tracker_info(uuid="34d09f60-31bf-4952-8fb3-03fc93ec98fa") def test_single_scan_report_full_scan_for_band_with_enumerated_params( @@ -721,7 +770,16 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_FULL_SCAN_RESULT) self.log.debug("Full Scan settings:{}\n{}".format( len(scan_settings), scan_settings)) - self.wifi_scanner_single_scan_full(scan_settings[0]) + name_func = ( + lambda scan_setting: "test_single_scan_report_full_scan_for_band_{}_periodInMs_{}".format(scan_setting["band"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases( + self.wifi_scanner_single_scan_full, + scan_settings, + name_func=name_func) + asserts.assert_true( + not failed, ("Number of test_single_scan_report_full_scan_for_band" + " failed {}").format(len(failed))) @test_tracker_info(uuid="0ddccf2e-b518-45a7-ae75-96924070b841") def test_batch_scan_report_full_scan_for_channels_with_enumerated_params( @@ -738,7 +796,17 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_FULL_SCAN_RESULT) self.log.debug("Full Scan settings:{}\n{}".format( len(scan_settings), scan_settings)) - self.wifi_scanner_batch_scan_full(scan_settings[0]) + name_func = ( + lambda scan_setting: ("test_batch_scan_report_full_scan_for_channels" + "_{}_periodInMs_{}").format(scan_setting["channels"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases( + self.wifi_scanner_batch_scan_full, + scan_settings, + name_func=name_func) + asserts.assert_false( + failed, ("Number of test_batch_scan_report_full_scan_for_channels" + " failed {}").format(len(failed))) @test_tracker_info(uuid="0685b667-8470-43a0-923d-dee71428f8ce") def test_batch_scan_report_full_scan_for_band_with_enumerated_params(self): @@ -754,7 +822,17 @@ class WifiScannerScanTest(WifiBaseTest): wutils.WifiEnums.REPORT_EVENT_FULL_SCAN_RESULT) self.log.debug("Full Scan settings:{}\n{}".format( len(scan_settings), scan_settings)) - self.wifi_scanner_batch_scan_full(scan_settings[0]) + name_func = ( + lambda scan_setting: ("test_batch_scan_report_full_scan_for_band" + "_{}_periodInMs_{}").format(scan_setting["band"], scan_setting["periodInMs"]) + ) + failed = self.run_generated_testcases( + self.wifi_scanner_batch_scan_full, + scan_settings, + name_func=name_func) + asserts.assert_true( + not failed, ("Number of test_batch_scan_report_full_scan_for_band" + " failed {}").format(len(failed))) @test_tracker_info(uuid="740e1c18-911a-43d2-9317-3827ecf71d3b") def test_wifi_connection_while_single_scan(self): diff --git a/acts/tests/google/wifi/WifiTetheringPowerTest.py b/acts/tests/google/wifi/WifiTetheringPowerTest.py deleted file mode 100644 index dd3cf7435f..0000000000 --- a/acts/tests/google/wifi/WifiTetheringPowerTest.py +++ /dev/null @@ -1,266 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import threading -import time - -from acts import base_test -from acts import asserts -from acts.controllers import adb -from acts.controllers import monsoon -from acts.test_decorators import test_tracker_info -from acts.test_utils.wifi import wifi_test_utils as wutils -from acts.test_utils.tel import tel_data_utils as tel_utils -from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G -from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G -from acts.test_utils.tel.tel_test_utils import http_file_download_by_chrome -from acts.utils import force_airplane_mode -from acts.utils import set_adaptive_brightness -from acts.utils import set_ambient_display -from acts.utils import set_auto_rotate -from acts.utils import set_location_service - - -class WifiTetheringPowerTest(base_test.BaseTestClass): - - 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 teardown_class(self): - self.mon.usb("on") - wutils.wifi_toggle_state(self.hotspot_device, True) - - def on_fail(self, test_name, begin_time): - self.hotspot_device.take_bug_report(test_name, begin_time) - - def on_pass(self, test_name, begin_time): - self.hotspot_device.take_bug_report(test_name, begin_time) - - """ Helper functions """ - def _measure_and_process_result(self): - """ Measure the current drawn by the device for the period of - self.duration, at the frequency of self.hz. - """ - tag = self.current_test_name - result = self.mon.measure_power(self.hz, - self.duration, - tag=tag, - offset=self.offset) - asserts.assert_true(result, - "Got empty measurement data set in %s." % tag) - self.log.info(repr(result)) - data_path = os.path.join(self.mon_data_path, "%s.txt" % tag) - monsoon.MonsoonData.save_to_text_file([result], data_path) - actual_current = result.average_current - actual_current_str = "%.2fmA" % actual_current - result_extra = {"Average Current": actual_current_str} - - def _start_wifi_tethering(self, wifi_band): - """ Start wifi tethering on hotspot device - - Args: - 1. wifi_band: specifies the wifi band to start the hotspot - on. The current options are 2G and 5G - """ - wutils.start_wifi_tethering(self.hotspot_device, - self.ssid, - self.password, - wifi_band) - - def _start_traffic_on_device(self, ad): - """ Start traffic on the device by downloading data - Run the traffic continuosly for self.duration - - Args: - 1. ad device object - """ - timeout = time.time() + self.duration - while True: - if time.time() > timeout: - break - http_file_download_by_chrome(ad, self.url) - - def _start_traffic_measure_power(self, ad_list): - """ Start traffic on the tethered devices and measure power - - Args: - 1. ad_list: list of tethered devices to run traffic on - """ - threads = [] - for ad in ad_list: - t = threading.Thread(target = self._start_traffic_on_device, - args = (ad,)) - t.start() - threads.append(t) - try: - self._measure_and_process_result() - finally: - for t in threads: - t.join() - - - """ Tests begin """ - @test_tracker_info(uuid="ebb74144-e22a-46e1-b8c1-9ada22b13133") - def test_power_wifi_tethering_2ghz_no_devices_connected(self): - """ Steps: - 1. Start wifi hotspot with 2.4Ghz band - 2. No devices connected to hotspot - 3. Measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - self._measure_and_process_result() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="2560c088-4010-4354-ade3-6aaac83b1cfd") - def test_power_wifi_tethering_5ghz_no_devices_connected(self): - """ Steps: - 1. Start wifi hotspot with 5Ghz band - 2. No devices connected to hotspot - 3. Measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - self._measure_and_process_result() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="644795b0-cd30-4a8f-82ee-cc0618c41c6b") - def test_power_wifi_tethering_2ghz_connect_1device(self): - """ Steps: - 1. Start wifi hotspot with 2.4GHz band - 2. Connect 1 device to hotspot - 3. Measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - self._measure_and_process_result() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="8fca9898-f493-44c3-810f-d2262ac72187") - def test_power_wifi_tethering_5ghz_connect_1device(self): - """ Steps: - 1. Start wifi hotspot with 5GHz band - 2. Connect 1 device to hotspot - 3. Measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - self._measure_and_process_result() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="16ef5f63-1a7a-44ae-bf8d-c3a181c89b63") - def test_power_wifi_tethering_2ghz_connect_5devices(self): - """ Steps: - 1. Start wifi hotspot with 2GHz band - 2. Connect 5 devices to hotspot - 3. Measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - for ad in self.tethered_devices: - wutils.wifi_connect(ad, self.network) - self._measure_and_process_result() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="769aedfc-d309-40e0-95dd-51ff40f4e097") - def test_power_wifi_tethering_5ghz_connect_5devices(self): - """ Steps: - 1. Start wifi hotspot with 5GHz band - 2. Connect 5 devices to hotspot - 3. Measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - for ad in self.tethered_devices: - wutils.wifi_connect(ad, self.network) - self._measure_and_process_result() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="e5b71f34-1dc0-4045-a45e-48c1e9426ec3") - def test_power_wifi_tethering_2ghz_connect_1device_with_traffic(self): - """ Steps: - 1. Start wifi hotspot with 2GHz band - 2. Connect 1 device to hotspot device - 3. Start traffic and measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - self._start_traffic_measure_power(self.tethered_devices[0:1]) - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="29c5cd6e-8df1-46e5-a735-526dc9154f6e") - def test_power_wifi_tethering_5ghz_connect_1device_with_traffic(self): - """ Steps: - 1. Start wifi hotspot with 5GHz band - 2. Connect 1 device to hotspot device - 3. Start traffic and measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - self._start_traffic_measure_power(self.tethered_devices[0:1]) - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="da71b06f-7b98-4c14-a2e2-361f395b39a8") - def test_power_wifi_tethering_2ghz_connect_5devices_with_traffic(self): - """ Steps: - 1. Start wifi hotspot with 2GHz band - 2. Connect 5 devices to hotspot device - 3. Start traffic and measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - for ad in self.tethered_devices: - wutils.wifi_connect(ad, self.network) - self._start_traffic_measure_power(self.tethered_devices) - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="7f3173ab-fd8f-4579-8c45-f9a8c5cd17f7") - def test_power_wifi_tethering_5ghz_connect_5devices_with_traffic(self): - """ Steps: - 1. Start wifi hotspot with 2GHz band - 2. Connect 5 devices to hotspot device - 3. Start traffic and measure power - """ - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - for ad in self.tethered_devices: - wutils.wifi_connect(ad, self.network) - self._start_traffic_measure_power(self.tethered_devices) - wutils.stop_wifi_tethering(self.hotspot_device) diff --git a/acts/tests/google/wifi/WifiTetheringTest.py b/acts/tests/google/wifi/WifiTetheringTest.py index c33c964e21..c1e0b2327f 100644 --- a/acts/tests/google/wifi/WifiTetheringTest.py +++ b/acts/tests/google/wifi/WifiTetheringTest.py @@ -14,25 +14,17 @@ # limitations under the License. import logging -import random -import socket import time +import socket from acts import asserts from acts import base_test from acts import test_runner from acts.controllers import adb -from acts.test_decorators import test_tracker_info from acts.test_utils.tel import tel_data_utils +from acts.test_utils.tel import tel_test_utils from acts.test_utils.tel import tel_defines -from acts.test_utils.tel.tel_data_utils import toggle_airplane_mode -from acts.test_utils.tel.tel_data_utils import wait_for_cell_data_connection -from acts.test_utils.tel.tel_test_utils import get_operator_name -from acts.test_utils.tel.tel_test_utils import http_file_download_by_chrome -from acts.test_utils.tel.tel_test_utils import verify_http_connection -from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_2G -from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G -from acts.test_utils.wifi import wifi_test_utils as wutils +from acts.test_utils.wifi import wifi_test_utils class WifiTetheringTest(base_test.BaseTestClass): @@ -40,40 +32,33 @@ class WifiTetheringTest(base_test.BaseTestClass): def setup_class(self): """ Setup devices for tethering and unpack params """ - - self.convert_byte_to_mb = 1024.0 * 1024.0 - self.new_ssid = "wifi_tethering_test2" - self.data_usage_error = 0.3 - - self.hotspot_device = self.android_devices[0] - self.tethered_devices = self.android_devices[1:] - req_params = ("network", "url", "download_file", "file_size") + self.hotspot_device, self.tethered_device = self.android_devices[:2] + req_params = ("ssid", "password", "url") self.unpack_userparams(req_params) - self.file_size = int(self.file_size) - - wutils.wifi_toggle_state(self.hotspot_device, False) + asserts.assert_true( + tel_data_utils.toggle_airplane_mode(self.log, self.hotspot_device, False), + "Could not disable airplane mode") + wifi_test_utils.wifi_toggle_state(self.hotspot_device, False) self.hotspot_device.droid.telephonyToggleDataConnection(True) - wait_for_cell_data_connection(self.log, self.hotspot_device, True) + tel_data_utils.wait_for_cell_data_connection(self.log, self.hotspot_device, True) asserts.assert_true( - verify_http_connection(self.log, self.hotspot_device), + tel_data_utils.verify_http_connection(self.log, self.hotspot_device), "HTTP verification failed on cell data connection") asserts.assert_true( self.hotspot_device.droid.connectivityIsTetheringSupported(), "Tethering is not supported for the provider") - for ad in self.tethered_devices: - wutils.wifi_test_device_init(ad) + wifi_test_utils.wifi_test_device_init(self.tethered_device) + self.tethered_device.droid.telephonyToggleDataConnection(False) def teardown_class(self): """ Reset devices """ - wutils.wifi_toggle_state(self.hotspot_device, True) - - def on_fail(self, test_name, begin_time): - """ Collect bug report on failure """ - self.hotspot_device.take_bug_report(test_name, begin_time) + wifi_test_utils.wifi_toggle_state(self.hotspot_device, True) + self.hotspot_device.droid.telephonyToggleDataConnection(True) + self.tethered_device.droid.telephonyToggleDataConnection(True) """ Helper functions """ - def _is_ipaddress_ipv6(self, ip_address): + def _is_ipaddress_ipv6(self,ip_address): """ Verify if the given string is a valid IPv6 address Args: @@ -99,21 +84,9 @@ class WifiTetheringTest(base_test.BaseTestClass): """ # Currently only Verizon support IPv6 tethering carrier_supports_tethering = ["vzw"] - operator = get_operator_name(self.log, dut) + operator = tel_test_utils.get_operator_name(self.log, dut) return operator in carrier_supports_tethering - def _carrier_supports_ipv6(self,dut): - """ Verify if carrier supports ipv6 - Currently, only verizon and t-mobile supports IPv6 - - Returns: - True: if carrier supports ipv6 - False: if not - """ - carrier_supports_ipv6 = ["vzw", "tmo"] - operator = get_operator_name(self.log, dut) - return operator in carrier_supports_ipv6 - def _find_ipv6_default_route(self, dut): """ Checks if IPv6 default route exists in the link properites @@ -125,13 +98,12 @@ class WifiTetheringTest(base_test.BaseTestClass): link_properties = dut.droid.connectivityGetActiveLinkProperties() return link_properties and default_route_substr in link_properties - def _verify_ipv6_tethering(self, dut): + def _verify_ipv6_tethering(self,dut): """ Verify IPv6 tethering """ http_response = dut.droid.httpRequestString(self.url) link_properties = dut.droid.connectivityGetActiveLinkProperties() self.log.info("IP address %s " % http_response) - if dut==self.hotspot_device and self._carrier_supports_ipv6(dut)\ - or self._supports_ipv6_tethering(self.hotspot_device): + if dut==self.hotspot_device or self._supports_ipv6_tethering(self.hotspot_device): asserts.assert_true(self._is_ipaddress_ipv6(http_response), "The http response did not return IPv6 address") asserts.assert_true(link_properties and http_response in link_properties, @@ -142,132 +114,42 @@ class WifiTetheringTest(base_test.BaseTestClass): asserts.assert_true(not self._find_ipv6_default_route(dut), "Found IPv6 default route in link properties") - def _start_wifi_tethering(self, wifi_band=WIFI_CONFIG_APBAND_2G): - """ Start wifi tethering on hotspot device - - Args: - 1. wifi_band: specifies the wifi band to start the hotspot - on. The current options are 2G and 5G - """ - wutils.start_wifi_tethering(self.hotspot_device, - self.network[wutils.WifiEnums.SSID_KEY], - self.network[wutils.WifiEnums.PWD_KEY], - wifi_band) - - def _connect_disconnect_devices(self): - """ Randomly connect and disconnect devices from the - self.tethered_devices list to hotspot device - """ - device_connected = [ False ] * len(self.tethered_devices) - for _ in range(50): - dut_id = random.randint(0, len(self.tethered_devices)-1) - dut = self.tethered_devices[dut_id] - if device_connected[dut_id]: - wutils.wifi_forget_network(dut, self.network["SSID"]) - else: - wutils.wifi_connect(dut, self.network) - device_connected[dut_id] = not device_connected[dut_id] - - def _verify_ping(self, dut, ip): - """ Verify ping works from the dut to IP/hostname - - Args: - 1. dut - ad object to check ping from - 2. ip - ip/hostname to ping (IPv4 and IPv6) - - Returns: - True - if ping is successful - False - if not - """ - self.log.info("Pinging %s from dut %s" % (ip, dut.serial)) - if self._is_ipaddress_ipv6(ip): - return dut.droid.pingHost(ip, 5, "ping6") - return dut.droid.pingHost(ip) - - def _return_ip_for_interface(self, dut, iface_name): - """ Return list of IP addresses for an interface - - Args: - 1. dut - ad object - 2. iface_name - interface name - - Returns: - List of IPv4 and IPv6 addresses - """ - return dut.droid.connectivityGetIPv4Addresses(iface_name) + \ - dut.droid.connectivityGetIPv6Addresses(iface_name) - - def _test_traffic_between_two_tethered_devices(self, dut1, dut2): - """ Verify pinging interfaces of one DUT from another - - Args: - 1. dut1 - tethered device 1 - 2. dut2 - tethered device 2 - """ - wutils.wifi_connect(dut1, self.network) - wutils.wifi_connect(dut2, self.network) - - dut1_ipaddrs = dut1.droid.connectivityGetIPv4Addresses("wlan0") + \ - dut1.droid.connectivityGetIPv6Addresses("wlan0") - dut2_ipaddrs = dut2.droid.connectivityGetIPv4Addresses("wlan0") + \ - dut2.droid.connectivityGetIPv6Addresses("wlan0") - - for ip in dut1_ipaddrs: - asserts.assert_true(self._verify_ping(dut2, ip), "%s " % ip) - for ip in dut2_ipaddrs: - asserts.assert_true(self._verify_ping(dut1, ip), "%s " % ip) - - def _ping_hotspot_interfaces_from_tethered_device(self, dut): - """ Ping hotspot interfaces from tethered device - - Args: - 1. dut - tethered device - - Returns: - True - if all IP addresses are pingable - False - if not - """ - ifaces = self.hotspot_device.droid.connectivityGetNetworkInterfaces() - return_result = True - for interface in ifaces: - iface_name = interface.split()[0].split(':')[1] - if iface_name == "lo": - continue - ip_list = self._return_ip_for_interface( - self.hotspot_device, iface_name) - for ip in ip_list: - ping_result = self._verify_ping(dut, ip) - self.log.info("Ping result: %s %s %s" % - (iface_name, ip, ping_result)) - return_result = return_result and ping_result - - return return_result """ Test Cases """ - @test_tracker_info(uuid="36d03295-bea3-446e-8342-b9f8f1962a32") def test_ipv6_tethering(self): """ IPv6 tethering test Steps: - 1. Start wifi tethering on hotspot device - 2. Verify IPv6 address on hotspot device - 3. Connect tethered device to hotspot device - 4. Verify IPv6 address on the client's link properties - 5. Verify ping on client using ping6 which should pass - 6. Disable mobile data on provider and verify that link properties + 1. Start wifi tethering on provider + 2. Client connects to wifi tethering SSID + 3. Verify IPv6 address on the client's link properties + 4. Verify ping on client using ping6 which should pass + 5. Disable mobile data on provider and verify that link properties does not have IPv6 address and default route """ # Start wifi tethering on the hotspot device - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering() + self.log.info("Start tethering on provider: {}" + .format(self.hotspot_device.serial)) + wifi_test_utils.start_wifi_tethering(self.hotspot_device, + self.ssid, + self.password) + time.sleep(tel_defines.WAIT_TIME_ANDROID_STATE_SETTLING) + asserts.assert_true( + tel_data_utils.verify_http_connection(self.log,self.hotspot_device), + "Could not verify http connection on the provider") # Verify link properties on hotspot device self.log.info("Check IPv6 properties on the hotspot device") self._verify_ipv6_tethering(self.hotspot_device) # Connect the client to the SSID - wutils.wifi_connect(self.tethered_devices[0], self.network) + asserts.assert_true( + tel_test_utils.WifiUtils.wifi_connect(self.log, + self.tethered_device, + self.ssid, + self.password), + "Unable to connect to the hotspot SSID") # Need to wait atleast 2 seconds for IPv6 address to # show up in the link properties @@ -275,11 +157,12 @@ class WifiTetheringTest(base_test.BaseTestClass): # Verify link properties on tethered device self.log.info("Check IPv6 properties on the tethered device") - self._verify_ipv6_tethering(self.tethered_devices[0]) + self._verify_ipv6_tethering(self.tethered_device) # Verify ping6 on tethered device - ping_result = self._verify_ping(self.tethered_devices[0], - "www.google.com") + ping_result = self.tethered_device.droid.pingHost("www.google.com", + 5, + "ping6") if self._supports_ipv6_tethering(self.hotspot_device): asserts.assert_true(ping_result, "Ping6 failed on the client") else: @@ -287,253 +170,11 @@ class WifiTetheringTest(base_test.BaseTestClass): # Disable mobile data on hotspot device # and verify the link properties on tethered device - self.log.info("Disabling mobile data to verify ipv6 default route") + self.log.info("Disabling mobile data on hotspot device") self.hotspot_device.droid.telephonyToggleDataConnection(False) - asserts.assert_equal( - self.hotspot_device.droid.telephonyGetDataConnectionState(), - tel_defines.DATA_STATE_CONNECTED, - "Could not disable cell data") - + asserts.assert_equal(self.hotspot_device.droid.telephonyGetDataConnectionState(), + tel_defines.DATA_STATE_CONNECTED, + "Could not disable cell data") time.sleep(2) # wait until the IPv6 is removed from link properties - - result = self._find_ipv6_default_route(self.tethered_devices[0]) - self.hotspot_device.droid.telephonyToggleDataConnection(True) - if not result: - asserts.fail("Found IPv6 default route in link properties:Data off") - - # Disable wifi tethering - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="110b61d1-8af2-4589-8413-11beac7a3025") - def test_wifi_tethering_2ghz_traffic_between_2tethered_devices(self): - """ Steps: - - 1. Start wifi hotspot with 2G band - 2. Connect 2 tethered devices to the hotspot device - 3. Ping interfaces between the tethered devices - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - self._test_traffic_between_two_tethered_devices(self.tethered_devices[0], - self.tethered_devices[1]) - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="953f6e2e-27bd-4b73-85a6-d2eaa4e755d5") - def test_wifi_tethering_5ghz_traffic_between_2tethered_devices(self): - """ Steps: - - 1. Start wifi hotspot with 5ghz band - 2. Connect 2 tethered devices to the hotspot device - 3. Send traffic between the tethered devices - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - self._test_traffic_between_two_tethered_devices(self.tethered_devices[0], - self.tethered_devices[1]) - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="d7d5aa51-682d-4882-a334-61966d93b68c") - def test_wifi_tethering_2ghz_connect_disconnect_devices(self): - """ Steps: - - 1. Start wifi hotspot with 2ghz band - 2. Connect and disconnect multiple devices randomly - 3. Verify the correct functionality - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - self._connect_disconnect_devices() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="34abd6c9-c7f1-4d89-aa2b-a66aeabed9aa") - def test_wifi_tethering_5ghz_connect_disconnect_devices(self): - """ Steps: - - 1. Start wifi hotspot with 5ghz band - 2. Connect and disconnect multiple devices randomly - 3. Verify the correct functionality - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - self._connect_disconnect_devices() - wutils.stop_wifi_tethering(self.hotspot_device) - - @test_tracker_info(uuid="7edfb220-37f8-42ea-8d7c-39712fbe9be5") - def test_wifi_tethering_2ghz_ping_hotspot_interfaces(self): - """ Steps: - - 1. Start wifi hotspot with 2ghz band - 2. Connect tethered device to hotspot device - 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4 - and IPv6 interfaces on hotspot device from tethered device - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - result = self._ping_hotspot_interfaces_from_tethered_device( - self.tethered_devices[0]) - wutils.stop_wifi_tethering(self.hotspot_device) - return result - - @test_tracker_info(uuid="17e450f4-795f-4e67-adab-984940dffedc") - def test_wifi_tethering_5ghz_ping_hotspot_interfaces(self): - """ Steps: - - 1. Start wifi hotspot with 5ghz band - 2. Connect tethered device to hotspot device - 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4 - and IPv6 interfaces on hotspot device from tethered device - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - result = self._ping_hotspot_interfaces_from_tethered_device( - self.tethered_devices[0]) - wutils.stop_wifi_tethering(self.hotspot_device) - return result - - @test_tracker_info(uuid="d4e18031-0af0-4b29-a574-8707cd4029b7") - def test_wifi_tethering_verify_received_bytes(self): - """ Steps: - - 1. Start wifi hotspot and connect tethered device to it - 2. Get the data usage on hotspot device - 3. Download data on tethered device - 4. Get the new data usage on hotspot device - 5. Verify that hotspot device's data usage - increased by downloaded file size - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - dut = self.hotspot_device - self._start_wifi_tethering() - wutils.wifi_connect(self.tethered_devices[0], self.network) - subscriber_id = dut.droid.telephonyGetSubscriberId() - - # get data usage limit - end_time = int(time.time() * 1000) - bytes_before_download = dut.droid.connectivityGetRxBytesForDevice( - subscriber_id, 0, end_time) - self.log.info("Bytes before download %s" % bytes_before_download) - - # download file - http_file_download_by_chrome(self.tethered_devices[0], - self.download_file) - - # get data usage limit after download - end_time = int(time.time() * 1000) - bytes_after_download = dut.droid.connectivityGetRxBytesForDevice( - subscriber_id, 0, end_time) - self.log.info("Bytes after download %s" % bytes_after_download) - - bytes_diff = bytes_after_download - bytes_before_download - wutils.stop_wifi_tethering(self.hotspot_device) - - # verify data usage update is correct - bytes_used = bytes_diff/self.convert_byte_to_mb - return bytes_used > self.file_size \ - and bytes_used < self.file_size + self.data_usage_error - - @test_tracker_info(uuid="07a00c96-4770-44a1-a9db-b3d02d6a12b6") - def test_wifi_tethering_data_usage_limit(self): - """ Steps: - - 1. Set the data usage limit to current data usage + 2MB - 2. Start wifi tethering and connect a dut to the SSID - 3. Download 5MB data on tethered device - a. file download should stop - b. tethered device will lose internet connectivity - c. data usage limit reached message should be displayed - on the hotspot device - 4. Verify data usage limit - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - dut = self.hotspot_device - data_usage_2mb = 2 * self.convert_byte_to_mb - subscriber_id = dut.droid.telephonyGetSubscriberId() - - self._start_wifi_tethering() - wutils.wifi_connect(self.tethered_devices[0], self.network) - - # get current data usage - end_time = int(time.time() * 1000) - old_data_usage = dut.droid.connectivityQuerySummaryForDevice( - subscriber_id, 0, end_time) - - # set data usage limit to current usage limit + 2MB - dut.droid.connectivitySetDataUsageLimit( - subscriber_id, str(int(old_data_usage + data_usage_2mb))) - - # download file - size 5MB - http_file_download_by_chrome(self.tethered_devices[0], - self.download_file, - timeout=120) - end_time = int(time.time() * 1000) - new_data_usage = dut.droid.connectivityQuerySummaryForDevice( - subscriber_id, 0, end_time) - - # test network connectivity on tethered device - asserts.assert_true( - not wutils.validate_connection(self.tethered_devices[0]), - "Tethered device has internet connectivity after data usage" - "limit is reached on hotspot device") - dut.droid.connectivityFactoryResetNetworkPolicies(subscriber_id) - wutils.stop_wifi_tethering(self.hotspot_device) - - old_data_usage = (old_data_usage+data_usage_2mb)/self.convert_byte_to_mb - new_data_usage = new_data_usage/self.convert_byte_to_mb - - return (new_data_usage-old_data_usage) < self.data_usage_error - - @test_tracker_info(uuid="2bc344cb-0277-4f06-b6cc-65b3972086ed") - def test_change_wifi_hotspot_ssid_when_hotspot_enabled(self): - """ Steps: - - 1. Start wifi tethering - 2. Verify wifi Ap configuration - 3. Change the SSID of the wifi hotspot while hotspot is on - 4. Verify the new SSID in wifi ap configuration - 5. Restart tethering and verify that the tethered device is able - to connect to the new SSID - """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - dut = self.hotspot_device - - # start tethering and verify the wifi ap configuration settings - self._start_wifi_tethering() - wifi_ap = dut.droid.wifiGetApConfiguration() - asserts.assert_true( - wifi_ap[wutils.WifiEnums.SSID_KEY] == \ - self.network[wutils.WifiEnums.SSID_KEY], - "Configured wifi hotspot SSID did not match with the expected SSID") - wutils.wifi_connect(self.tethered_devices[0], self.network) - - # update the wifi ap configuration with new ssid - config = {wutils.WifiEnums.SSID_KEY: self.new_ssid} - config[wutils.WifiEnums.PWD_KEY] = self.network[wutils.WifiEnums.PWD_KEY] - config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G - asserts.assert_true( - dut.droid.wifiSetWifiApConfiguration(config), - "Failed to update WifiAp Configuration") - wifi_ap = dut.droid.wifiGetApConfiguration() - asserts.assert_true( - wifi_ap[wutils.WifiEnums.SSID_KEY] == self.new_ssid, - "Configured wifi hotspot SSID does not match with the expected SSID") - - # start wifi tethering with new wifi ap configuration - wutils.stop_wifi_tethering(dut) - dut.droid.wifiStartTrackingTetherStateChange() - dut.droid.connectivityStartTethering(tel_defines.TETHERING_WIFI, False) - try: - dut.ed.pop_event("ConnectivityManagerOnTetheringStarted") - dut.ed.wait_for_event("TetherStateChanged", - lambda x: x["data"]["ACTIVE_TETHER"], 30) - except: - asserts.fail("Didn't receive wifi tethering starting confirmation") - dut.droid.wifiStopTrackingTetherStateChange() - - # verify dut can connect to new wifi ap configuration - new_network = {wutils.WifiEnums.SSID_KEY: self.new_ssid, - wutils.WifiEnums.PWD_KEY: \ - self.network[wutils.WifiEnums.PWD_KEY]} - wutils.wifi_connect(self.tethered_devices[0], new_network) - wutils.stop_wifi_tethering(self.hotspot_device) + asserts.assert_true(not self._find_ipv6_default_route(self.tethered_device), + "Found IPv6 default route in link properties - Data off") |