blob: f7c973b911b75973aa65e215f28244b058a8f0b5 [file] [log] [blame]
Ang Li73697b32015-12-03 00:41:53 +00001#!/usr/bin/python3.4
2#
3# Copyright 2014 - 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 acts.base_test import BaseTestClass
22from queue import Empty
23from acts.test_utils.tel.tel_voice_utils import phone_setup_volte
24from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state
25from acts.test_utils.tel.tel_test_utils import get_operator_name
26from acts.test_utils.tel.tel_test_utils import get_sub_ids_for_sim_slots
27from acts.test_utils.tel.tel_test_utils import setup_droid_properties
28from acts.test_utils.tel.tel_test_utils import set_phone_screen_on
29from acts.test_utils.tel.tel_test_utils import set_phone_silent_mode
30from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode
31from acts.test_utils.tel.tel_test_utils import wait_for_voice_attach_for_subscription
32from acts.test_utils.tel.tel_defines import AOSP_PREFIX
33from acts.test_utils.tel.tel_defines import CAPABILITY_PHONE
34from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE
35from acts.test_utils.tel.tel_defines import CAPABILITY_VT
36from acts.test_utils.tel.tel_defines import CAPABILITY_WFC
37from acts.test_utils.tel.tel_defines import CAPABILITY_MSIM
38from acts.test_utils.tel.tel_defines import CAPABILITY_OMADM
39from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND
40from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND
41from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING
42from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT
43from acts.test_utils.tel.tel_defines import WAIT_TIME_NW_SELECTION
44from acts.test_utils.tel.tel_lookup_tables import device_capabilities
45from acts.test_utils.tel.tel_lookup_tables import operator_capabilities
46from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
47
48
49from acts.utils import load_config
50
51
52
53class TelLivePreflightTest(TelephonyBaseTest):
54
55 def __init__(self, controllers):
56 TelephonyBaseTest.__init__(self, controllers)
57 self.tests = (
58 "test_pre_flight_check",
59 )
60
61 self.simconf = load_config(self.user_params["sim_conf_file"])
62
63 """ Tests Begin """
64 @TelephonyBaseTest.tel_test_wrap
65 def test_pre_flight_check(self):
66 def droid_has_phone(log, ad):
67 #check for sim and service
68 subInfo = ad.droid.subscriptionGetAllSubInfoList()
69 if not subInfo or len(subInfo) < 1:
70 return False
71 toggle_airplane_mode(log, ad, False)
72 sub_id = ad.droid.subscriptionGetDefaultVoiceSubId()
73 if not wait_for_voice_attach_for_subscription(log, ad, sub_id,
74 WAIT_TIME_NW_SELECTION):
75 log.error("{} didn't find a cell network".format(ad.serial))
76 return False
77 return True
78 def droid_has_provisioning(log, ad):
79 if not ad.droid.imsIsVolteProvisionedOnDevice():
80 log.error("{}: VoLTE Not Provisioned on the Platform".
81 format(ad.serial))
82 return False
83 else:
84 log.info("{} VoLTE Provisioned".format(ad.serial))
85 return True
86
87 def droid_has_volte(log, ad):
88 if not ad.droid.imsIsEnhanced4gLteModeSettingEnabledByPlatform():
89 log.error("{}: VoLTE Not Enabled on the Platform".
90 format(ad.serial))
91 return False
92 else:
93 log.info("{} VoLTE Enabled by platform".format(ad.serial))
94 return True
95
96 def droid_has_wifi_calling(log, ad):
97 if not ad.droid.imsIsWfcEnabledByPlatform():
98 log.error("{}: WFC Not Enabled on the Platform".
99 format(ad.serial))
100 return False
101 else:
102 log.info("{} WFC Enabled by platform".format(ad.serial))
103 return True
104
105 def droid_has_vt(log, ad):
106 if not ad.droid.imsIsVtEnabledByPlatform():
107 log.error("{}: VT Not Enabled on the Platform".
108 format(ad.serial))
109 return False
110 else:
111 log.info("{} VT Enabled by platform".format(ad.serial))
112 return True
113
114 try:
115 for ad in self.android_devices:
116 model = ad.model
117 # Remove aosp prefix
118 if model.startswith(AOSP_PREFIX):
119 model = model[len(AOSP_PREFIX):]
120
121 # Special capability phone, needed to get SIM Operator
122 if not CAPABILITY_PHONE in device_capabilities[model]:
123 self.log.info("Skipping {}:{}: not a phone".
124 format(ad.serial, model))
125 return True
126
127 operator = get_operator_name(self.log, ad)
128 self.log.info("Pre-flight check for <{}>, <{}:{}>, build<{}>".
129 format(operator, model, ad.serial,
130 ad.droid.getBuildID()))
131
132 if("force_provisioning" in self.user_params and
133 CAPABILITY_OMADM in device_capabilities[model] and
134 CAPABILITY_OMADM in operator_capabilities[operator] and
135 not droid_has_provisioning(self.log, ad)):
136 self.log.info("{} not IMS Provisioned!!".format(ad.serial))
137 self.log.info("{} Forcing IMS Provisioning!".format(ad.serial))
138 ad.droid.imsSetVolteProvisioning(True)
139 self.log.info("{} reboot!".format(ad.serial))
140 ad.reboot()
141 self.log.info("{} wait {}s for radio up.".
142 format(ad.serial, WAIT_TIME_AFTER_REBOOT))
143 # This sleep WAIT_TIME_AFTER_REBOOT seconds is waiting for
144 # radio to initiate after phone reboot.
145 time.sleep(WAIT_TIME_AFTER_REBOOT)
146
147 active_capabilities = [CAPABILITY_PHONE, CAPABILITY_OMADM,
148 CAPABILITY_VOLTE, CAPABILITY_WFC]
149 for capability in active_capabilities:
150 if(capability in device_capabilities[model] and
151 capability in operator_capabilities[operator]):
152 if not {
153 # FIXME: make the check table global
154 CAPABILITY_PHONE: droid_has_phone,
155 CAPABILITY_OMADM: droid_has_provisioning,
156 CAPABILITY_VOLTE: droid_has_volte,
157 CAPABILITY_WFC: droid_has_wifi_calling,
158 CAPABILITY_VT: droid_has_vt
159 }[capability](self.log, ad):
160 self.abort_all("Pre-flight check FAILED for <{}>, <{}:{}>".
161 format(operator, model, ad.serial))
162 except Exception as e:
163 self.abort_all("Pre-flight check exception: {}".format(e))
164 return True
165""" Tests End """