blob: 1f77a69152e4929fde8b11276834976b7ba5ad42 [file] [log] [blame]
tturney1bdf77d2015-12-28 17:46:13 -08001#!/usr/bin/env python3.4
Ang Li73697b32015-12-03 00:41:53 +00002#
tturney1bdf77d2015-12-28 17:46:13 -08003# Copyright 2016 - Google
Ang Li73697b32015-12-03 00:41:53 +00004#
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
Ang Li73697b32015-12-03 00:41:53 +000021from queue import Empty
Yang Liu52cc0202015-12-28 14:08:52 -080022from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
Ang Li73697b32015-12-03 00:41:53 +000023from 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
Yang Liudf164e32016-01-07 16:49:32 -080030from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_NW_SELECTION
Ang Li73697b32015-12-03 00:41:53 +000031from 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
Ang Li73697b32015-12-03 00:41:53 +000035from acts.test_utils.tel.tel_lookup_tables import device_capabilities
36from acts.test_utils.tel.tel_lookup_tables import operator_capabilities
Yang Liud7727092016-05-24 14:38:36 -070037from acts.test_utils.tel.tel_test_utils import WifiUtils
Yang Liu52cc0202015-12-28 14:08:52 -080038from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state
Yang Liud7727092016-05-24 14:38:36 -070039from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected
Yang Liu52cc0202015-12-28 14:08:52 -080040from acts.test_utils.tel.tel_test_utils import get_operator_name
Yang Liu52cc0202015-12-28 14:08:52 -080041from 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
Yang Liud7727092016-05-24 14:38:36 -070045from acts.test_utils.tel.tel_test_utils import verify_http_connection
Yang Liu52cc0202015-12-28 14:08:52 -080046from acts.test_utils.tel.tel_test_utils import wait_for_voice_attach_for_subscription
Yang Liud7727092016-05-24 14:38:36 -070047from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection
Yang Liu52cc0202015-12-28 14:08:52 -080048from acts.test_utils.tel.tel_voice_utils import phone_setup_volte
Yang Liud7727092016-05-24 14:38:36 -070049from acts.asserts import abort_all
Ang Li73697b32015-12-03 00:41:53 +000050
Ang Li73697b32015-12-03 00:41:53 +000051
Nathan Harold0f76cf22015-12-30 16:33:25 -080052class TelLivePreflightTest(TelephonyBaseTest):
Ang Li73697b32015-12-03 00:41:53 +000053 def __init__(self, controllers):
54 TelephonyBaseTest.__init__(self, controllers)
Ang Li73697b32015-12-03 00:41:53 +000055
Yang Liud7727092016-05-24 14:38:36 -070056 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
Ang Li73697b32015-12-03 00:41:53 +000062 """ Tests Begin """
Nathan Haroldb1487af2016-07-19 16:05:37 -070063
Yang Liud7727092016-05-24 14:38:36 -070064 @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):
Nathan Haroldb1487af2016-07-19 16:05:37 -070074 self._preflight_fail("WiFi connect fail.")
Yang Liud7727092016-05-24 14:38:36 -070075 if (not wait_for_wifi_data_connection(self.log, ad, True) or
76 not verify_http_connection(self.log, ad)):
Nathan Haroldb1487af2016-07-19 16:05:37 -070077 self._preflight_fail("Data not available on WiFi.")
Yang Liud7727092016-05-24 14:38:36 -070078 finally:
79 WifiUtils.wifi_toggle_state(self.log, ad, False)
80 # TODO: add more environment check here.
81 return True
Nathan Harold0f76cf22015-12-30 16:33:25 -080082
Ang Li73697b32015-12-03 00:41:53 +000083 @TelephonyBaseTest.tel_test_wrap
84 def test_pre_flight_check(self):
Nathan Haroldb1487af2016-07-19 16:05:37 -070085 for ad in self.android_devices:
Ang Li73697b32015-12-03 00:41:53 +000086 #check for sim and service
87 subInfo = ad.droid.subscriptionGetAllSubInfoList()
88 if not subInfo or len(subInfo) < 1:
Nathan Haroldb1487af2016-07-19 16:05:37 -070089 self._preflight_fail("Unable to find A valid subscription!")
90 toggle_airplane_mode(self.log, ad, False)
Ang Li73697b32015-12-03 00:41:53 +000091 sub_id = ad.droid.subscriptionGetDefaultVoiceSubId()
Nathan Harold0f76cf22015-12-30 16:33:25 -080092 if not wait_for_voice_attach_for_subscription(
Nathan Haroldb1487af2016-07-19 16:05:37 -070093 self.log, ad, sub_id, MAX_WAIT_TIME_NW_SELECTION):
94 self._preflight_fail("{} didn't find a cell network".format(
Nathan Harold0f76cf22015-12-30 16:33:25 -080095 ad.serial))
Ang Li73697b32015-12-03 00:41:53 +000096 return True
Nathan Harold0f76cf22015-12-30 16:33:25 -080097
Nathan Haroldb1487af2016-07-19 16:05:37 -070098 def _preflight_fail(self, message):
99 self.log.error(
100 "Aborting all ongoing tests due to preflight check failure.")
101 abort_all(message)
102
Nathan Harold0f76cf22015-12-30 16:33:25 -0800103
Ang Li73697b32015-12-03 00:41:53 +0000104""" Tests End """