• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3#   Copyright 2016 - Google
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"""
17    Test Script for Telephony Pre Flight check.
18"""
19
20import time
21from queue import Empty
22from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
23from acts.test_utils.tel.tel_defines import AOSP_PREFIX
24from acts.test_utils.tel.tel_defines import CAPABILITY_PHONE
25from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE
26from acts.test_utils.tel.tel_defines import CAPABILITY_VT
27from acts.test_utils.tel.tel_defines import CAPABILITY_WFC
28from acts.test_utils.tel.tel_defines import CAPABILITY_MSIM
29from acts.test_utils.tel.tel_defines import CAPABILITY_OMADM
30from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_NW_SELECTION
31from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND
32from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND
33from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING
34from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT
35from acts.test_utils.tel.tel_lookup_tables import device_capabilities
36from acts.test_utils.tel.tel_lookup_tables import operator_capabilities
37from acts.test_utils.tel.tel_test_utils import WifiUtils
38from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state
39from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected
40from acts.test_utils.tel.tel_test_utils import get_operator_name
41from acts.test_utils.tel.tel_test_utils import setup_droid_properties
42from acts.test_utils.tel.tel_test_utils import set_phone_screen_on
43from acts.test_utils.tel.tel_test_utils import set_phone_silent_mode
44from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode
45from acts.test_utils.tel.tel_test_utils import verify_http_connection
46from acts.test_utils.tel.tel_test_utils import wait_for_voice_attach_for_subscription
47from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection
48from acts.test_utils.tel.tel_voice_utils import phone_setup_volte
49from acts.asserts import abort_all
50
51
52class TelLivePreflightTest(TelephonyBaseTest):
53    def __init__(self, controllers):
54        TelephonyBaseTest.__init__(self, controllers)
55
56        self.wifi_network_ssid = self.user_params["wifi_network_ssid"]
57        try:
58            self.wifi_network_pass = self.user_params["wifi_network_pass"]
59        except KeyError:
60            self.wifi_network_pass = None
61
62    """ Tests Begin """
63
64    @TelephonyBaseTest.tel_test_wrap
65    def test_check_environment(self):
66        ad = self.android_devices[0]
67        # Check WiFi environment.
68        # 1. Connect to WiFi.
69        # 2. Check WiFi have Internet access.
70        toggle_airplane_mode(self.log, ad, True)
71        try:
72            if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid,
73                                         self.wifi_network_pass):
74                self._preflight_fail("WiFi connect fail.")
75            if (not wait_for_wifi_data_connection(self.log, ad, True) or
76                    not verify_http_connection(self.log, ad)):
77                self._preflight_fail("Data not available on WiFi.")
78        finally:
79            WifiUtils.wifi_toggle_state(self.log, ad, False)
80        # TODO: add more environment check here.
81        return True
82
83    @TelephonyBaseTest.tel_test_wrap
84    def test_pre_flight_check(self):
85        for ad in self.android_devices:
86            #check for sim and service
87            subInfo = ad.droid.subscriptionGetAllSubInfoList()
88            if not subInfo or len(subInfo) < 1:
89                self._preflight_fail("Unable to find A valid subscription!")
90            toggle_airplane_mode(self.log, ad, False)
91            sub_id = ad.droid.subscriptionGetDefaultVoiceSubId()
92            if not wait_for_voice_attach_for_subscription(
93                    self.log, ad, sub_id, MAX_WAIT_TIME_NW_SELECTION):
94                self._preflight_fail("{} didn't find a cell network".format(
95                    ad.serial))
96        return True
97
98    def _preflight_fail(self, message):
99        self.log.error(
100            "Aborting all ongoing tests due to preflight check failure.")
101        abort_all(message)
102
103
104""" Tests End """
105