summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-02-14 16:21:34 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-02-14 16:21:34 +0000
commit653ac29aa955e321086e365544c939f00538bfd6 (patch)
treea3f9a750e103fc0e7c5e74eaf3eef7dd69dd243c
parenta3c6d3823f788869948606a7ae04465fe2a9f594 (diff)
parent64055a915e39610692f92e575e6a63759c482d60 (diff)
downloadplatform_testing-653ac29aa955e321086e365544c939f00538bfd6.tar.gz
Merge "Add telephony country code overriding" into main am: 64055a915e
Original change: https://android-review.googlesource.com/c/platform/platform_testing/+/2959192 Change-Id: I03af10f7ff34245114adbcb1ea342c96f810b581 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-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: