1# 2# Copyright 2021 - The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16from acts import asserts 17import acts.signals as signals 18from acts.test_decorators import test_tracker_info 19from acts_contrib.test_utils.wifi import wifi_test_utils as wutils 20from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest 21from WifiStaApConcurrencyTest import WifiStaApConcurrencyTest 22 23WifiEnums = wutils.WifiEnums 24WIFI_CONFIG_SOFTAP_BAND_2G = WifiEnums.WIFI_CONFIG_SOFTAP_BAND_2G 25WIFI_CONFIG_SOFTAP_BAND_5G = WifiEnums.WIFI_CONFIG_SOFTAP_BAND_5G 26WIFI_CONFIG_SOFTAP_BAND_2G_5G = WifiEnums.WIFI_CONFIG_SOFTAP_BAND_2G_5G 27 28 29class WifiStaApConcurrency6eTest(WifiStaApConcurrencyTest): 30 """Tests for sta+ap concurrency for 6ghz. 31 32 Test Bed Requirement: 33 2 Android devices, 1 Asus AXE11000 Access Point. 34 """ 35 36 def __init__(self, configs): 37 super().__init__(configs) 38 self.tests = ( 39 "test_wifi_connection_6G_softap_2G", 40 "test_wifi_connection_6G_softap_5G", 41 "test_wifi_connection_6G_softap_2G_with_location_scan_on", 42 "test_softap_2G_wifi_connection_6G", 43 "test_softap_5G_wifi_connection_6G", 44 "test_softap_5G_wifi_connection_6G_with_location_scan_on", 45 "test_wifi_connection_6G_softap_2G_to_softap_5G", 46 ) 47 48 def setup_class(self): 49 WifiBaseTest.setup_class(self) 50 51 self.dut = self.android_devices[0] 52 self.dut_client = self.android_devices[1] 53 req_params = [ 54 "iperf_server_address", "iperf_server_port", "wifi6_models", 55 "dbs_supported_models" 56 ] 57 self.unpack_userparams(req_param_names=req_params,) 58 self.ap1 = self.access_points[0] 59 self.wifi_network_6g = self.ap1.get_wifi_network("6g") 60 61 def teardown_test(self): 62 try: 63 wutils.stop_wifi_tethering(self.dut) 64 except signals.TestFailure: 65 pass 66 for ad in self.android_devices: 67 ad.droid.wakeLockRelease() 68 ad.droid.goToSleepNow() 69 wutils.reset_wifi(ad) 70 wutils.wifi_toggle_state(ad, True) 71 self.turn_location_on_and_scan_toggle_on() 72 73 ### Helper Methods ### 74 75 def _verify_softap_band(self, expected_band): 76 """Verify softap band is correctly set. 77 78 Args: 79 expected_band: Expected softap band. 80 """ 81 configured_band = self.dut.droid.wifiGetApConfiguration()["apBand"] 82 asserts.assert_true(configured_band == expected_band, 83 "Expected softap band: %s, Configured softap band: %s", 84 (expected_band, configured_band)) 85 86 ### Tests ### 87 88 @test_tracker_info(uuid="bdd8cbf0-526d-4a20-b10b-3796f648f8d0") 89 def test_wifi_connection_6G_softap_2G(self): 90 """Test connection to 6G network followed by SoftAp on 2G.""" 91 self.connect_to_wifi_network_and_start_softap(self.wifi_network_6g, 92 WIFI_CONFIG_SOFTAP_BAND_2G) 93 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G) 94 95 @test_tracker_info(uuid="94946b34-7cff-4582-a311-3e4e3690324b") 96 def test_wifi_connection_6G_softap_5G(self): 97 """Test connection to 6G network followed by SoftAp on 5G.""" 98 self.connect_to_wifi_network_and_start_softap(self.wifi_network_6g, 99 WIFI_CONFIG_SOFTAP_BAND_5G) 100 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G_5G) 101 102 @test_tracker_info(uuid="34e85416-42b5-44b0-b97a-a4b0818e6cae") 103 def test_wifi_connection_6G_softap_2G_with_location_scan_on(self): 104 """Test connection to 6G network, SoftAp on 2G with location scan on.""" 105 self.turn_location_on_and_scan_toggle_on() 106 self.connect_to_wifi_network_and_start_softap(self.wifi_network_6g, 107 WIFI_CONFIG_SOFTAP_BAND_2G) 108 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G) 109 # Now toggle wifi off & ensure we can still scan. 110 wutils.wifi_toggle_state(self.dut, False) 111 wutils.start_wifi_connection_scan_and_ensure_network_found( 112 self.dut, self.wifi_network_6g[WifiEnums.SSID_KEY]) 113 114 @test_tracker_info(uuid="9de42708-fa93-4901-8704-1411f435b256") 115 def test_softap_2G_wifi_connection_6G(self): 116 """Test SoftAp on 2G followed by connection to 6G network.""" 117 self.start_softap_and_connect_to_wifi_network(self.wifi_network_6g, 118 WIFI_CONFIG_SOFTAP_BAND_2G) 119 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G) 120 121 @test_tracker_info(uuid="9cdafc82-e971-4610-9989-e1c1d39ad18f") 122 def test_softap_5G_wifi_connection_6G(self): 123 """Test SoftAp on 5G followed by connection to 6G network.""" 124 self.start_softap_and_connect_to_wifi_network(self.wifi_network_6g, 125 WIFI_CONFIG_SOFTAP_BAND_5G) 126 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G_5G) 127 128 @test_tracker_info(uuid="bfad2e86-d1d7-44b3-b8c8-eb49f3f97742") 129 def test_softap_5G_wifi_connection_6G_with_location_scan_on(self): 130 """Test SoftAp on 5G, connection to 6G network with location scan on.""" 131 self.turn_location_on_and_scan_toggle_on() 132 self.start_softap_and_connect_to_wifi_network(self.wifi_network_6g, 133 WIFI_CONFIG_SOFTAP_BAND_5G) 134 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G_5G) 135 # Now toggle wifi off & ensure we can still scan. 136 wutils.wifi_toggle_state(self.dut, False) 137 wutils.start_wifi_connection_scan_and_ensure_network_found( 138 self.dut, self.wifi_network_6g[WifiEnums.SSID_KEY]) 139 140 @test_tracker_info(uuid="e50a0901-e07c-4b6f-9343-35e0dec14f2b") 141 def test_wifi_connection_6G_softap_2G_to_softap_5G(self): 142 """Test connection to 6G network, softap on 2G and switch to 5G.""" 143 self.connect_to_wifi_network_and_start_softap(self.wifi_network_6g, 144 WIFI_CONFIG_SOFTAP_BAND_2G) 145 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G) 146 self.softap_change_band(self.dut) 147 self._verify_softap_band(WIFI_CONFIG_SOFTAP_BAND_2G_5G) 148