Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions betocq/nearby_connection/betocq_aqt_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# increment this version number when adding new tests or changing the config
# parameters of existing tests.
# LINT.IfChange(suite_version)
_SUITE_VERSION = '5'
_SUITE_VERSION = '6'
# LINT.ThenChange()


Expand Down Expand Up @@ -77,11 +77,6 @@ def _assert_config_parameters(self, config):
not test_params.wifi_dfs_5g_ssid, 'wifi_dfs_5g_ssid is not set'
)

asserts.abort_all_if(
not test_params.abort_all_if_any_ap_not_ready,
'do not change testbed parameters, abort_all_if_any_ap_not_ready is'
' expected to be True',
)
asserts.abort_all_if(
test_params.skip_default_flag_override,
'do not change testbed parameters, skip_default_flag_override is'
Expand Down
5 changes: 4 additions & 1 deletion betocq/nearby_connection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ def _report_error(error_message: str) -> None:
wifi_dfs_5g_ssid,
freq_5g_dfs,
)
wifi_scan_results_list = setup_utils.check_wifi_env(advertiser)
wifi_scan_results_list = setup_utils.check_wifi_env(
advertiser,
wifi_scan_wait_time_sec=setup_utils.WIFI_SCAN_WAIT_TIME_SEC * 2
)
if wifi_scan_results_list:
freq_by_ssids = {
result['SSID']: result['Frequency']
Expand Down
6 changes: 4 additions & 2 deletions betocq/setup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
\s+
(\d+) # Captures Frequency
\s+
[-\d.]+ # Matches RSSI (skipped)
[-\d()./:]+ # Matches RSSI (skipped)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The regex for the RSSI field is being expanded to include more characters, but it remains brittle as it still excludes alphabetic characters (e.g., for 'N/A' or 'unknown' values) and other potential punctuation. Since this field is explicitly skipped and not captured, using \S+ (matching any non-whitespace characters) would be more robust and maintainable, preventing the need for future updates when encountering different output formats from various devices.

Suggested change
[-\d()./:]+ # Matches RSSI (skipped)
\S+ # Matches RSSI (skipped)

\s+
[\d.]+ # Matches Age (skipped)
\s*
Expand Down Expand Up @@ -738,11 +738,13 @@ def _parse_wifi_scan(scan_results: Iterable[str]) -> Sequence[dict[str, Any]]:

def check_wifi_env(
ad: android_device.AndroidDevice,
wifi_scan_wait_time_sec: int = WIFI_SCAN_WAIT_TIME_SEC,
) -> Sequence[dict[str, Any]] | None:
"""Let WI-FI scan and get scan results. Check if the environment is clean.

Args:
ad: AndroidDevice, Mobly Android Device.
wifi_scan_wait_time_sec: The time to wait for Wi-Fi scan to complete.

Returns:
Wi-Fi scan results as a list of SSID and Frequency or None if it fails to
Expand All @@ -754,7 +756,7 @@ def check_wifi_env(
# Start wifi scan.
try:
ad.adb.shell('cmd wifi start-scan')
time.sleep(WIFI_SCAN_WAIT_TIME_SEC)
time.sleep(wifi_scan_wait_time_sec)
except adb.AdbError:
ad.log.warning('Failed to start wifi scan.', exc_info=True)
return None
Expand Down
1 change: 1 addition & 0 deletions betocq/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
# '2.6.1': ('Add XCC test cases for AQT.'
# 'Update the snippet SDK version to 35 and other bug fixes.')
# '2.6.2': ('Optimize tests for AQT and fix some bugs.')
# '2.6.3': ('Fix some bugs.')