diff --git a/tests/cts/multidevices/connectivity_multi_devices_test.py b/tests/cts/multidevices/connectivity_multi_devices_test.py index 417db99711..1d6fb51292 100644 --- a/tests/cts/multidevices/connectivity_multi_devices_test.py +++ b/tests/cts/multidevices/connectivity_multi_devices_test.py @@ -34,6 +34,9 @@ class ConnectivityMultiDevicesTest(base_test.BaseTestClass): ) def test_hotspot_upstream_wifi(self): + tether_utils.assume_hotspot_test_preconditions( + self.serverDevice, self.clientDevice, UpstreamType.WIFI + ) try: # Connectivity of the client verified by asserting the validated capability. tether_utils.setup_hotspot_and_client_for_upstream_type( @@ -45,6 +48,9 @@ class ConnectivityMultiDevicesTest(base_test.BaseTestClass): ) def test_hotspot_upstream_cellular(self): + tether_utils.assume_hotspot_test_preconditions( + self.serverDevice, self.clientDevice, UpstreamType.CELLULAR + ) try: # Connectivity of the client verified by asserting the validated capability. tether_utils.setup_hotspot_and_client_for_upstream_type( diff --git a/tests/cts/multidevices/snippet/ConnectivityMultiDevicesSnippet.kt b/tests/cts/multidevices/snippet/ConnectivityMultiDevicesSnippet.kt index 8805edd818..f4ad2c4288 100644 --- a/tests/cts/multidevices/snippet/ConnectivityMultiDevicesSnippet.kt +++ b/tests/cts/multidevices/snippet/ConnectivityMultiDevicesSnippet.kt @@ -77,9 +77,9 @@ class ConnectivityMultiDevicesSnippet : Snippet { ctsNetUtils.expectNetworkIsSystemDefault(network) } - @Rpc(description = "Unrequest cellular connection.") - fun unrequestCellular() { - cbHelper.unrequestCell() + @Rpc(description = "Unregister all connections.") + fun unregisterAll() { + cbHelper.unregisterAll() } @Rpc(description = "Ensure any wifi is connected and is the default network.") diff --git a/tests/cts/multidevices/tether_utils.py b/tests/cts/multidevices/tether_utils.py index a2d703ca56..61f5c43f0e 100644 --- a/tests/cts/multidevices/tether_utils.py +++ b/tests/cts/multidevices/tether_utils.py @@ -46,6 +46,32 @@ def generate_uuid32_base64() -> str: return base64.b64encode(uuid.uuid1().bytes).decode("utf-8").strip("=") +def assume_hotspot_test_preconditions( + server_device: android_device, + client_device: android_device, + upstream_type: UpstreamType, +) -> None: + server = server_device.connectivity_multi_devices_snippet + client = client_device.connectivity_multi_devices_snippet + + # Assert pre-conditions specific to each upstream type. + asserts.skip_if(not client.hasWifiFeature(), "Client requires Wifi feature") + asserts.skip_if( + not server.hasHotspotFeature(), "Server requires hotspot feature" + ) + if upstream_type == UpstreamType.CELLULAR: + asserts.skip_if( + not server.hasTelephonyFeature(), "Server requires Telephony feature" + ) + elif upstream_type == UpstreamType.WIFI: + asserts.skip_if( + not server.isStaApConcurrencySupported(), + "Server requires Wifi AP + STA concurrency", + ) + else: + raise ValueError(f"Invalid upstream type: {upstream_type}") + + def setup_hotspot_and_client_for_upstream_type( server_device: android_device, client_device: android_device, @@ -60,21 +86,9 @@ def setup_hotspot_and_client_for_upstream_type( server = server_device.connectivity_multi_devices_snippet client = client_device.connectivity_multi_devices_snippet - # Assert pre-conditions specific to each upstream type. - asserts.skip_if(not client.hasWifiFeature(), "Client requires Wifi feature") - asserts.skip_if( - not server.hasHotspotFeature(), "Server requires hotspot feature" - ) if upstream_type == UpstreamType.CELLULAR: - asserts.skip_if( - not server.hasTelephonyFeature(), "Server requires Telephony feature" - ) server.requestCellularAndEnsureDefault() elif upstream_type == UpstreamType.WIFI: - asserts.skip_if( - not server.isStaApConcurrencySupported(), - "Server requires Wifi AP + STA concurrency", - ) server.ensureWifiIsDefault() else: raise ValueError(f"Invalid upstream type: {upstream_type}") @@ -98,6 +112,6 @@ def cleanup_tethering_for_upstream_type( ) -> None: server = server_device.connectivity_multi_devices_snippet if upstream_type == UpstreamType.CELLULAR: - server.unrequestCellular() + server.unregisterAll() # Teardown the hotspot. server.stopAllTethering()