diff options
author | 2024-12-04 06:48:29 +0000 | |
---|---|---|
committer | 2024-12-04 06:48:29 +0000 | |
commit | 45da8d4f2e7363d3ee40dafbedea035e05f86677 (patch) | |
tree | f94a5587e1db961452de9a9b0d3e74b1470dcdad | |
parent | 9084a1a44b609db52c52ea03e4101f2e7a94869d (diff) | |
parent | 310d5165d48cd74d23739ab06ac82a51cb341556 (diff) |
Merge "[CTS-V Migration] Replace current Wi-Fi utility adb commands with MBS WiFi APIs." into main am: 310d5165d4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Wifi/+/3382167
Change-Id: I341cdbe653cfb9a438259d309cbb24678ac0884c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
8 files changed, 51 insertions, 16 deletions
diff --git a/tests/hostsidetests/multidevices/com.google.snippet.wifi/Android.bp b/tests/hostsidetests/multidevices/com.google.snippet.wifi/Android.bp index f27af2c272..bcbcb8532c 100644 --- a/tests/hostsidetests/multidevices/com.google.snippet.wifi/Android.bp +++ b/tests/hostsidetests/multidevices/com.google.snippet.wifi/Android.bp @@ -17,7 +17,8 @@ android_test { "compatibility-device-util-axt", "guava", "mobly-snippet-lib", + "mobly-bundled-snippets-lib", ], - min_sdk_version: "30", + min_sdk_version: "31", target_sdk_version: "35", } diff --git a/tests/hostsidetests/multidevices/com.google.snippet.wifi/AndroidManifest.xml b/tests/hostsidetests/multidevices/com.google.snippet.wifi/AndroidManifest.xml index f7c7d4b818..b8e9f824c8 100644 --- a/tests/hostsidetests/multidevices/com.google.snippet.wifi/AndroidManifest.xml +++ b/tests/hostsidetests/multidevices/com.google.snippet.wifi/AndroidManifest.xml @@ -1,8 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" package="com.google.snippet.wifi"> - <uses-sdk android:minSdkVersion="30"/> + <uses-sdk android:minSdkVersion="31"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> @@ -20,9 +21,11 @@ <application> <meta-data android:name="mobly-snippets" + tools:replace="android:value" android:value="com.google.snippet.wifi.aware.WifiAwareManagerSnippet, com.google.snippet.wifi.aware.ConnectivityManagerSnippet, - com.google.snippet.wifi.direct.WifiP2pManagerSnippet,"/> + com.google.snippet.wifi.direct.WifiP2pManagerSnippet, + com.google.android.mobly.snippet.bundled.WifiManagerSnippet"/> <meta-data android:name="mobly-object-converter" android:value="com.google.snippet.wifi.aware.WifiAwareSnippetConverter"/> diff --git a/tests/hostsidetests/multidevices/test/Android.bp b/tests/hostsidetests/multidevices/test/Android.bp index cade7f713b..9956fa590e 100644 --- a/tests/hostsidetests/multidevices/test/Android.bp +++ b/tests/hostsidetests/multidevices/test/Android.bp @@ -28,6 +28,11 @@ python_library_host { libs: ["wifi_aware_constants"], } +python_library_host { + name: "wifi_test_utils", + srcs: ["wifi_test_utils.py"], +} + python_defaults { name: "CtsWifiMultiDevicePythonDefaults", libs: [ @@ -64,11 +69,12 @@ python_test_host { name: "WifiAwareManagerTestCases", main: "aware/wifi_aware_manager_test.py", srcs: ["aware/wifi_aware_manager_test.py"], - device_common_data: [":wifi_aware_snippet_new"], + device_common_data: [":wifi_mobly_snippet"], libs: [ "aware_lib_utils", "mobly", "wifi_aware_constants", + "wifi_test_utils", ], test_suites: [ "general-tests", @@ -112,6 +118,7 @@ python_test_host { libs: [ "mobly", "wifi_direct_constants", + "wifi_test_utils", ], device_common_data: [":wifi_mobly_snippet"], test_options: { diff --git a/tests/hostsidetests/multidevices/test/aware/aware_lib_utils.py b/tests/hostsidetests/multidevices/test/aware/aware_lib_utils.py index b5aed7629c..b445c10856 100644 --- a/tests/hostsidetests/multidevices/test/aware/aware_lib_utils.py +++ b/tests/hostsidetests/multidevices/test/aware/aware_lib_utils.py @@ -392,13 +392,3 @@ def create_discovery_config(service_name, config[constants.TTL_SEC] = ttl config[constants.TERMINATE_NOTIFICATION_ENABLED] = term_cb_enable return config - -def set_screen_on_and_unlock(ad: android_device.AndroidDevice): - """Set the screen to stay on and unlock the device. - - Args: - ad: AndroidDevice instance. - """ - ad.adb.shell("svc power stayon true") - ad.adb.shell("input keyevent KEYCODE_WAKEUP") - ad.adb.shell("wm dismiss-keyguard") diff --git a/tests/hostsidetests/multidevices/test/aware/constants.py b/tests/hostsidetests/multidevices/test/aware/constants.py index 9a90876071..9742b436d5 100644 --- a/tests/hostsidetests/multidevices/test/aware/constants.py +++ b/tests/hostsidetests/multidevices/test/aware/constants.py @@ -24,6 +24,7 @@ from mobly import utils # Package name for the Wi-Fi Aware snippet application WIFI_AWARE_SNIPPET_PACKAGE_NAME = "com.google.snippet.wifi.aware" +WIFI_SNIPPET_PACKAGE_NAME = "com.google.snippet.wifi" # Timeout duration for Wi-Fi state change operations WAIT_WIFI_STATE_TIME_OUT = datetime.timedelta(seconds=30) AWARE_NETWORK_INFO_CLASS_NAME = "android.net.wifi.aware.WifiAwareNetworkInfo" diff --git a/tests/hostsidetests/multidevices/test/aware/wifi_aware_manager_test.py b/tests/hostsidetests/multidevices/test/aware/wifi_aware_manager_test.py index e548ada878..e6c24cce2e 100644 --- a/tests/hostsidetests/multidevices/test/aware/wifi_aware_manager_test.py +++ b/tests/hostsidetests/multidevices/test/aware/wifi_aware_manager_test.py @@ -30,11 +30,12 @@ from mobly import utils from mobly.controllers import android_device from mobly.controllers.android_device_lib import callback_handler_v2 from mobly.snippet import callback_event +import wifi_test_utils from aware import constants from aware import aware_lib_utils -PACKAGE_NAME = constants.WIFI_AWARE_SNIPPET_PACKAGE_NAME +PACKAGE_NAME = constants.WIFI_SNIPPET_PACKAGE_NAME _DEFAULT_TIMEOUT = constants.WAIT_WIFI_STATE_TIME_OUT.total_seconds() _REQUEST_NETWORK_TIMEOUT_MS = 15 * 1000 _MSG_ID_SUB_TO_PUB = random.randint(1000, 5000) @@ -99,7 +100,7 @@ class WifiAwareManagerTest(base_test.BaseTestClass): not device.wifi_aware_snippet.wifiAwareIsSupported(), f'{device} does not support Wi-Fi Aware.', ) - aware_lib_utils.set_screen_on_and_unlock(device) + wifi_test_utils.set_screen_on_and_unlock(device) asserts.abort_all_if( not device.wifi_aware_snippet.wifiAwareIsAvailable(), f'{device} Wi-Fi Aware is not available.', diff --git a/tests/hostsidetests/multidevices/test/direct/group_owner_negotiation_test.py b/tests/hostsidetests/multidevices/test/direct/group_owner_negotiation_test.py index d5196302e0..6742bdf8d9 100644 --- a/tests/hostsidetests/multidevices/test/direct/group_owner_negotiation_test.py +++ b/tests/hostsidetests/multidevices/test/direct/group_owner_negotiation_test.py @@ -27,6 +27,7 @@ from mobly import utils from mobly.controllers import android_device from mobly.controllers.android_device_lib import callback_handler_v2 from mobly.snippet import errors +import wifi_test_utils from direct import constants @@ -407,6 +408,11 @@ class GroupOwnerNegotiationTest(base_test.BaseTestClass): def _setup_device(self, ad: android_device.AndroidDevice) -> DeviceState: ad.load_snippet('wifi', constants.WIFI_SNIPPET_PACKAGE_NAME) + wifi_test_utils.set_screen_on_and_unlock(ad) + # Clear all saved Wi-Fi networks. + ad.wifi.wifiDisable() + ad.wifi.wifiClearConfiguredNetworks() + ad.wifi.wifiEnable() def test_group_owner_negotiation_with_push_button(self) -> None: """Test against group owner negotiation and WPS PBC (push button). diff --git a/tests/hostsidetests/multidevices/test/wifi_test_utils.py b/tests/hostsidetests/multidevices/test/wifi_test_utils.py new file mode 100644 index 0000000000..304e52f4de --- /dev/null +++ b/tests/hostsidetests/multidevices/test/wifi_test_utils.py @@ -0,0 +1,26 @@ +# Copyright (C) 2024 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 mobly.controllers import android_device + + +def set_screen_on_and_unlock(ad: android_device.AndroidDevice): + """Sets the screen to stay on and unlocks the device. + + Args: + ad: AndroidDevice instance. + """ + ad.adb.shell("svc power stayon true") + ad.adb.shell("input keyevent KEYCODE_WAKEUP") + ad.adb.shell("wm dismiss-keyguard") |