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
16import acts.utils as utils
17import acts_contrib.test_utils.wifi.wifi_test_utils as wutils
18from acts_contrib.test_utils.wifi.WifiBaseTest import WifiBaseTest
19from ..WifiStaConcurrencyNetworkRequestTest import WifiStaConcurrencyNetworkRequestTest
20
21
22class WifiStaConcurrencyNetworkRequest11axTest(
23    WifiStaConcurrencyNetworkRequestTest):
24  """Tests for STA concurrency network request 11ax.
25
26  Test Bed Requirement:
27    One Android device, 2 Asus AXE11000 Access Points.
28  """
29
30  def __init__(self, configs):
31    super().__init__(configs)
32    self.tests = (
33        "test_connect_to_2g_p2p_while_connected_to_5g_internet",
34        "test_connect_to_2g_internet_while_connected_to_5g_p2p",
35        "test_connect_to_2g_internet_while_connected_to_2g_p2p",
36        "test_connect_to_5g_internet_while_connected_to_5g_p2p",
37        "test_connect_to_5g_dfs_internet_while_connected_to_5g_dfs_p2p",
38        "test_connect_to_2g_internet_while_connected_to_2g_p2p_same_ssid",
39        "test_connect_to_5g_p2p_while_connected_to_5g_internet_same_ssid",
40    )
41
42  def setup_class(self):
43    WifiBaseTest.setup_class(self)
44
45    self.dut = self.android_devices[0]
46    wutils.wifi_test_device_init(self.dut)
47    req_params = ["sta_concurrency_supported_models", "wifi6_models"]
48    self.unpack_userparams(req_param_names=req_params,)
49    self.ap1 = self.access_points[0]
50    self.ap2 = self.access_points[1]
51
52  def teardown_test(self):
53    WifiBaseTest.teardown_test(self)
54    self.disconnect_both()
55    self.dut.droid.wakeLockRelease()
56    self.dut.droid.goToSleepNow()
57    self.dut.droid.wifiDisconnect()
58    wutils.reset_wifi(self.dut)
59    # Ensure we disconnected from the current network before the next test.
60    if self.dut.droid.wifiGetConnectionInfo(
61    )["supplicant_state"] != "disconnected":
62      wutils.wait_for_disconnect(self.dut)
63    wutils.wifi_toggle_state(self.dut, False)
64    self.dut.ed.clear_all_events()
65
66  def configure_ap(self,
67                   channel_2g=None,
68                   channel_5g=None,
69                   channel_2g_ap2=None,
70                   channel_5g_ap2=None,
71                   mirror_ap=False,
72                   ap_count=1):
73    """Configure AP based on test case requirements."""
74    if ap_count == 1:
75      self.ap1.set_channel_and_apply("2g", channel_2g)
76      self.ap1.set_channel_and_apply("5g", channel_5g)
77    elif ap_count == 2 and channel_2g_ap2:
78      ssid1 = "test_2g_1"
79      ssid2 = "test_2g_2"
80      if mirror_ap:
81        ssid1 = "test_%s" % utils.rand_ascii_str(4)
82        ssid2 = ssid1
83      self.ap1.set_channel_and_apply("2g", channel_2g)
84      self.ap2.set_channel_and_apply("2g", channel_2g_ap2)
85      self.ap1.configure_ap({"2g": {"ssid": ssid1},})
86      self.ap2.configure_ap({"2g": {"ssid": ssid2},})
87    elif ap_count == 2 and channel_5g_ap2:
88      ssid1 = "test_5g_1"
89      ssid2 = "test_5g_2"
90      if mirror_ap:
91        ssid1 = "test_%s" % utils.rand_ascii_str(4)
92        ssid2 = ssid1
93      self.ap1.set_channel_and_apply("5g", channel_5g)
94      self.ap2.set_channel_and_apply("5g", channel_5g_ap2)
95      self.ap1.configure_ap({"5g": {"ssid": ssid1},})
96      self.ap2.configure_ap({"5g": {"ssid": ssid2},})
97
98