• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17from acts.controllers.ap_lib import hostapd_constants
18import acts_contrib.test_utils.wifi.wifi_test_utils as wutils
19from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest
20from WifiSoftApAcsTest import WifiSoftApAcsTest
21
22
23class WifiSoftApAcs11axTest(WifiSoftApAcsTest):
24  """Tests for Automatic Channel Selection for 11ax."""
25
26  def __init__(self, configs):
27    super().__init__(configs)
28    self.tests = (
29        "test_softap_2G_clean_env",
30        "test_softap_5G_clean_env",
31        "test_softap_auto_clean_env",
32        "test_softap_2G_avoid_channel_6",
33        "test_softap_5G_avoid_channel_6",
34        "test_softap_2G_avoid_channel_36",
35        "test_softap_5G_avoid_channel_36",
36        "test_softap_2G_avoid_channel_1",
37        "test_softap_5G_avoid_channel_1",
38        "test_softap_2G_avoid_channel_2",
39        "test_softap_5G_avoid_channel_2",
40        "test_softap_2G_avoid_channel_3",
41        "test_softap_5G_avoid_channel_3",
42        "test_softap_2G_avoid_channel_4",
43        "test_softap_5G_avoid_channel_4",
44        "test_softap_2G_avoid_channel_5",
45        "test_softap_5G_avoid_channel_5",
46        "test_softap_2G_avoid_channel_7",
47        "test_softap_5G_avoid_channel_7",
48        "test_softap_2G_avoid_channel_8",
49        "test_softap_5G_avoid_channel_8",
50        "test_softap_2G_avoid_channel_9",
51        "test_softap_5G_avoid_channel_9",
52        "test_softap_2G_avoid_channel_10",
53        "test_softap_5G_avoid_channel_10",
54        "test_softap_2G_avoid_channel_11",
55        "test_softap_5G_avoid_channel_11",
56        "test_softap_2G_avoid_channel_40",
57        "test_softap_5G_avoid_channel_40",
58        "test_softap_2G_avoid_channel_44",
59        "test_softap_5G_avoid_channel_44",
60        "test_softap_2G_avoid_channel_48",
61        "test_softap_5G_avoid_channel_48",
62        "test_softap_2G_avoid_channel_149",
63        "test_softap_5G_avoid_channel_149",
64        "test_softap_2G_avoid_channel_153",
65        "test_softap_5G_avoid_channel_153",
66        "test_softap_2G_avoid_channel_157",
67        "test_softap_5G_avoid_channel_157",
68        "test_softap_2G_avoid_channel_161",
69        "test_softap_5G_avoid_channel_161",
70        "test_softap_2G_avoid_channel_165",
71        "test_softap_5G_avoid_channel_165",
72    )
73
74  def setup_class(self):
75    WifiBaseTest.setup_class(self)
76
77    self.dut = self.android_devices[0]
78    self.dut_client = self.android_devices[1]
79    for ad in self.android_devices:
80      # Enable verbose logging on the duts
81      ad.droid.wifiEnableVerboseLogging(1)
82      asserts.assert_equal(ad.droid.wifiGetVerboseLoggingLevel(), 1,
83                           "Failed to enable WiFi verbose logging.")
84    req_params = ["reference_networks", "wifi6_models",]
85    opt_params = ["iperf_server_address", "iperf_server_port"]
86    self.unpack_userparams(
87        req_param_names=req_params, opt_param_names=opt_params)
88    self.ap = self.access_points[0]
89    self.chan_map = {v: k for k, v in hostapd_constants.CHANNEL_MAP.items()}
90
91  def setup_test(self):
92    WifiBaseTest.setup_test(self)
93    self.dut.droid.wakeLockAcquireBright()
94    self.dut.droid.wakeUpNow()
95
96  def teardown_test(self):
97    WifiBaseTest.teardown_test(self)
98    self.dut.droid.wakeLockRelease()
99    self.dut.droid.goToSleepNow()
100    wutils.stop_wifi_tethering(self.dut)
101    for ad in self.android_devices:
102      wutils.reset_wifi(ad)
103
104  ### Helper Methods ###
105
106  def configure_ap(self, channel_2g=None, channel_5g=None):
107    """Configure and bring up AP on required channel.
108
109    Args:
110      channel_2g: The channel number to use for 2GHz network.
111      channel_5g: The channel number to use for 5GHz network.
112    """
113    if not channel_2g:
114      channel_2g = hostapd_constants.AP_DEFAULT_CHANNEL_2G
115    if not channel_5g:
116      channel_5g = hostapd_constants.AP_DEFAULT_CHANNEL_5G
117    if int(self.ap.get_configured_channel("5g")) != channel_5g:
118      self.ap.set_channel_and_apply("5g", channel_5g)
119    if int(self.ap.get_configured_channel("2g")) != channel_2g:
120      self.ap.set_channel_and_apply("2g", channel_2g)
121