• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3#   Copyright 2018 - The Android Open Source Project
48
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
17import acts.test_utils.power.PowerBTBaseTest as PBtBT
18import acts.test_utils.power.PowerWiFiBaseTest as PWBT
19from acts import utils
20from acts.test_utils.wifi import wifi_test_utils as wutils
21
22
23class PowerCoexBaseTest(PBtBT.PowerBTBaseTest, PWBT.PowerWiFiBaseTest):
24    """Base class for BT power related tests.
25
26    Inherited from the PowerBaseTest class
27    """
28
29    def coex_test_phone_setup(self, Screen_status, WiFi_status, WiFi_band,
30                              BT_status, BLE_status, Cellular_status,
31                              Celluar_band):
32        """Setup the phone in desired state for coex tests.
33
34        Args:
35            Screen_status: 'ON' or 'OFF'
36            WiFi_status: 'ON', 'Connected', 'Disconnected', or 'OFF'
37            WiFi_band: '2g', '5g' or None, the band of AP
38            BT_status: 'ON' or 'OFF'
39            BLE_status: 'ON' or 'OFF'
40            Cellular_status: 'ON' or 'OFF'
41            Celluar_band: 'Verizon', 'Tmobile', or 'ATT' for live network,
42                actual band for callbox setup; 'None' when celluar is OFF
43        """
44        # Setup WiFi
45        if WiFi_status is 'ON':
46            wutils.wifi_toggle_state(self.dut, True)
47        elif WiFi_status is 'Connected':
48            self.setup_ap_connection(self.main_network[WiFi_band])
49        elif WiFi_status is 'Disconnected':
50            self.setup_ap_connection(
51                self.main_network[WiFi_band], connect=False)
52
53        # Setup BT/BLE
54        self.phone_setup_for_BT(BT_status, BLE_status, Screen_status)
55
56        # Setup Cellular
57        if Cellular_status is 'ON':
58            self.dut.droid.connectivityToggleAirplaneMode(False)
59            utils.set_mobile_data_always_on(self.dut, True)
60
61    def coex_scan_setup(self, WiFi_scan, BLE_scan_mode, wifi_scan_command):
62        """Setup for scan activities on WiFi, BT/BLE, and cellular.
63
64        Args:
65            WiFi_scan: 'ON', 'OFF' or 'PNO'
66            BLE_scan_mode: 'balanced', 'opportunistic', 'low_power', or 'low_latency'
67        """
68        if WiFi_scan is 'ON':
69            self.dut.adb.shell(wifi_scan_command)
70        if WiFi_scan is 'PNO':
71            self.log.info(
72                'Set attenuation so device loses connection to trigger PNO scans'
73            )
74            # Set to maximum attenuation 95 dB to cut down connection
75            [self.attenuators[i].set_atten(95) for i in range(self.num_atten)]
76        if BLE_scan_mode is not None:
77            self.start_pmc_ble_scan(BLE_scan_mode, self.mon_info.offset,
78                                    self.mon_info.duration)
79