• 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.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G
20from acts.test_utils.wifi import wifi_test_utils as wutils
21from acts.test_utils.wifi.rtt import rtt_const as rconsts
22from acts.test_utils.wifi.rtt import rtt_test_utils as rutils
23from acts.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    def __init__(self, controllers):
39        RttBaseTest.__init__(self, controllers)
40
41    #########################################################################
42
43    @test_tracker_info(uuid="578f0725-31e3-4e60-ad62-0212d93cf5b8")
44    def test_rtt_to_soft_ap(self):
45        """Set up a Soft AP on one device and try performing an RTT ranging to it
46    from another device. The attempt must fail - RTT on Soft AP must be
47    disabled."""
48        sap = self.android_devices[0]
49        sap.pretty_name = "SoftAP"
50        client = self.android_devices[1]
51        client.pretty_name = "Client"
52
53        # start Soft AP
54        wutils.start_wifi_tethering(
55            sap,
56            self.SOFT_AP_SSID,
57            self.SOFT_AP_PASSWORD,
58            band=WIFI_CONFIG_APBAND_5G,
59            hidden=False)
60
61        try:
62            # start scanning on the client
63            wutils.start_wifi_connection_scan_and_ensure_network_found(
64                client, self.SOFT_AP_SSID)
65            scans = client.droid.wifiGetScanResults()
66            scanned_softap = None
67            for scanned_ap in scans:
68                if scanned_ap[wutils.WifiEnums.SSID_KEY] == self.SOFT_AP_SSID:
69                    scanned_softap = scanned_ap
70                    break
71
72            asserts.assert_false(
73                scanned_softap == None,
74                "Soft AP not found in scan!",
75                extras=scans)
76
77            # validate that Soft AP does not advertise 802.11mc support
78            asserts.assert_false(
79                rconsts.SCAN_RESULT_KEY_RTT_RESPONDER in scanned_softap
80                and scanned_softap[rconsts.SCAN_RESULT_KEY_RTT_RESPONDER],
81                "Soft AP advertises itself as supporting 802.11mc!",
82                extras=scanned_softap)
83
84            # falsify the SoftAP's support for IEEE 802.11 so we try a 2-sided RTT
85            scanned_softap[
86                rconsts.SCAN_RESULT_KEY_RTT_RESPONDER] = True  # falsify
87
88            # actually try ranging to the Soft AP
89            events = rutils.run_ranging(client, [scanned_softap],
90                                        self.NUM_ITER, 0)
91            stats = rutils.analyze_results(
92                events, self.rtt_reference_distance_mm,
93                self.rtt_reference_distance_margin_mm,
94                self.rtt_min_expected_rssi_dbm, self.lci_reference,
95                self.lcr_reference)
96
97            asserts.assert_equal(
98                stats[scanned_ap[wutils.WifiEnums.BSSID_KEY]]['num_failures'],
99                self.NUM_ITER,
100                "Some RTT operations to Soft AP succeed!?",
101                extras=stats)
102
103            asserts.explicit_pass(
104                "SoftAP + RTT validation done", extras=events)
105        finally:
106            wutils.stop_wifi_tethering(sap)
107