• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python3.4
2#
3#   Copyright 2018 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17from acts import asserts
18from acts.test_decorators import test_tracker_info
19from acts_contrib.test_utils.tel.tel_wifi_utils import WIFI_CONFIG_APBAND_5G
20from acts_contrib.test_utils.wifi import wifi_test_utils as wutils
21from acts_contrib.test_utils.wifi.rtt import rtt_const as rconsts
22from acts_contrib.test_utils.wifi.rtt import rtt_test_utils as rutils
23from acts_contrib.test_utils.wifi.rtt.RttBaseTest import RttBaseTest
24
25
26class RangeSoftApTest(RttBaseTest):
27    """Test class for RTT ranging to an Android Soft AP."""
28
29    # Soft AP SSID
30    SOFT_AP_SSID = "RTT_TEST_SSID"
31
32    # Soft AP Password (irrelevant)
33    SOFT_AP_PASSWORD = "ABCDEFGH"
34
35    # Number of RTT iterations
36    NUM_ITER = 10
37
38    #########################################################################
39
40    @test_tracker_info(uuid="578f0725-31e3-4e60-ad62-0212d93cf5b8")
41    def test_rtt_to_soft_ap(self):
42        """Set up a Soft AP on one device and try performing an RTT ranging to it
43    from another device. The attempt must fail - RTT on Soft AP must be
44    disabled."""
45        sap = self.android_devices[0]
46        sap.pretty_name = "SoftAP"
47        client = self.android_devices[1]
48        client.pretty_name = "Client"
49
50        # start Soft AP
51        wutils.start_wifi_tethering(
52            sap,
53            self.SOFT_AP_SSID,
54            self.SOFT_AP_PASSWORD,
55            band=WIFI_CONFIG_APBAND_5G,
56            hidden=False)
57
58        try:
59            # start scanning on the client
60            wutils.start_wifi_connection_scan_and_ensure_network_found(
61                client, self.SOFT_AP_SSID)
62            scans = client.droid.wifiGetScanResults()
63            scanned_softap = None
64            for scanned_ap in scans:
65                if scanned_ap[wutils.WifiEnums.SSID_KEY] == self.SOFT_AP_SSID:
66                    scanned_softap = scanned_ap
67                    break
68
69            asserts.assert_false(
70                scanned_softap == None,
71                "Soft AP not found in scan!",
72                extras=scans)
73
74            # validate that Soft AP does not advertise 802.11mc support
75            asserts.assert_false(
76                rconsts.SCAN_RESULT_KEY_RTT_RESPONDER in scanned_softap
77                and scanned_softap[rconsts.SCAN_RESULT_KEY_RTT_RESPONDER],
78                "Soft AP advertises itself as supporting 802.11mc!",
79                extras=scanned_softap)
80
81            # falsify the SoftAP's support for IEEE 802.11 so we try a 2-sided RTT
82            scanned_softap[
83                rconsts.SCAN_RESULT_KEY_RTT_RESPONDER] = True  # falsify
84
85            # actually try ranging to the Soft AP
86            events = rutils.run_ranging(client, [scanned_softap],
87                                        self.NUM_ITER, 0)
88            stats = rutils.analyze_results(
89                events, self.rtt_reference_distance_mm,
90                self.rtt_reference_distance_margin_mm,
91                self.rtt_min_expected_rssi_dbm, self.lci_reference,
92                self.lcr_reference)
93
94            asserts.assert_equal(
95                stats[scanned_ap[wutils.WifiEnums.BSSID_KEY]]['num_failures'],
96                self.NUM_ITER,
97                "Some RTT operations to Soft AP succeed!?",
98                extras=stats)
99
100            asserts.explicit_pass(
101                "SoftAP + RTT validation done", extras=events)
102        finally:
103            wutils.stop_wifi_tethering(sap)
104