summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-02-14 15:25:23 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-02-14 15:25:23 +0000
commit64055a915e39610692f92e575e6a63759c482d60 (patch)
treeaeb9c4bbbafd2aced9e7b1b5375c5c4094ba2614
parentb4a063920742a15f5a395ad99cb1c60792bf56cd (diff)
parenteba6c2165a8ee0fada51178d84cf058424989ab0 (diff)
downloadplatform_testing-64055a915e39610692f92e575e6a63759c482d60.tar.gz
Merge "Add telephony country code overriding" into main
-rw-r--r--tests/bettertogether/quickstart/performance_test/nc_base_test.py2
-rw-r--r--tests/bettertogether/quickstart/performance_test/setup_utils.py20
2 files changed, 16 insertions, 6 deletions
diff --git a/tests/bettertogether/quickstart/performance_test/nc_base_test.py b/tests/bettertogether/quickstart/performance_test/nc_base_test.py
index c64656dba..0d540413f 100644
--- a/tests/bettertogether/quickstart/performance_test/nc_base_test.py
+++ b/tests/bettertogether/quickstart/performance_test/nc_base_test.py
@@ -137,7 +137,7 @@ class NCBaseTestClass(base_test.BaseTestClass):
setup_utils.enable_wifi_aware(ad)
if self.test_parameters.wifi_country_code:
- setup_utils.set_wifi_country_code(
+ setup_utils.set_country_code(
ad, self.test_parameters.wifi_country_code
)
diff --git a/tests/bettertogether/quickstart/performance_test/setup_utils.py b/tests/bettertogether/quickstart/performance_test/setup_utils.py
index 9b8ac4b52..3e530f506 100644
--- a/tests/bettertogether/quickstart/performance_test/setup_utils.py
+++ b/tests/bettertogether/quickstart/performance_test/setup_utils.py
@@ -38,10 +38,10 @@ LOG_TAGS = [
]
-def set_wifi_country_code(
+def set_country_code(
ad: android_device.AndroidDevice, country_code: str
) -> None:
- """Sets Wi-Fi country code to shrink Wi-Fi 5GHz available channels.
+ """Sets Wi-Fi and Telephony country code.
When you set the phone to EU or JP, the available 5GHz channels shrinks.
Some phones, like Pixel 2, can't use Wi-Fi Direct or Hotspot on 5GHz
@@ -51,21 +51,31 @@ def set_wifi_country_code(
Args:
ad: AndroidDevice, Mobly Android Device.
- country_code: WiFi Country Code.
+ country_code: WiFi and Telephony Country Code.
"""
if (not ad.is_adb_root):
ad.log.info(f'Skipped setting wifi country code on device "{ad.serial}" '
- 'because we do not set wifi country code on unrooted phone.')
+ 'because we do not set country code on unrooted phone.')
return
- ad.log.info(f'Set Wi-Fi country code to {country_code}.')
+ ad.log.info(f'Set Wi-Fi and Telephony country code to {country_code}.')
ad.adb.shell('cmd wifi set-wifi-enabled disabled')
time.sleep(WIFI_COUNTRYCODE_CONFIG_TIME_SEC)
+ ad.adb.shell(
+ 'am broadcast -a com.android.internal.telephony.action.COUNTRY_OVERRIDE'
+ f' --es country {country_code}'
+ )
ad.adb.shell(f'cmd wifi force-country-code enabled {country_code}')
enable_airplane_mode(ad)
time.sleep(WIFI_COUNTRYCODE_CONFIG_TIME_SEC)
disable_airplane_mode(ad)
ad.adb.shell('cmd wifi set-wifi-enabled enabled')
+ telephony_country_code = (
+ ad.adb.shell('dumpsys wifi | grep mTelephonyCountryCode')
+ .decode('utf-8')
+ .strip()
+ )
+ ad.log.info(f'Telephony country code: {telephony_country_code}')
def enable_logs(ad: android_device.AndroidDevice) -> None: