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