1#!/usr/bin/env python3.4 2# 3# Copyright 2017 - 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 Locked SIM Emergency Call Test 18""" 19 20from acts import signals 21from acts.test_decorators import test_tracker_info 22from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 23from acts.test_utils.tel.tel_defines import CAPABILITY_WFC 24from acts.test_utils.tel.tel_defines import DEFAULT_DEVICE_PASSWORD 25from acts.test_utils.tel.tel_defines import GEN_2G 26from acts.test_utils.tel.tel_defines import GEN_3G 27from acts.test_utils.tel.tel_defines import GEN_4G 28from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED 29from acts.test_utils.tel.tel_lookup_tables import \ 30 network_preference_for_generation 31from acts.test_utils.tel.tel_lookup_tables import operator_capabilities 32from acts.test_utils.tel.tel_test_utils import fastboot_wipe 33from acts.test_utils.tel.tel_test_utils import get_sim_state 34from acts.test_utils.tel.tel_test_utils import is_sim_lock_enabled 35from acts.test_utils.tel.tel_test_utils import is_sim_locked 36from acts.test_utils.tel.tel_test_utils import reboot_device 37from acts.test_utils.tel.tel_test_utils import reset_device_password 38from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode_by_adb 39from acts.test_utils.tel.tel_test_utils import unlock_sim 40from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan 41from TelLiveEmergencyBase import TelLiveEmergencyBase 42 43EXPECTED_CALL_TEST_RESULT = False 44 45 46class TelLiveLockedSimTest(TelLiveEmergencyBase): 47 def setup_class(self): 48 TelephonyBaseTest.setup_class(self) 49 for ad in self.my_devices: 50 if not is_sim_lock_enabled(ad): 51 ad.log.info("SIM is not locked") 52 else: 53 ad.log.info("SIM is locked") 54 self.setup_dut(ad) 55 return True 56 #if there is no locked SIM, reboot the device and check again 57 for ad in self.my_devices: 58 reboot_device(ad) 59 reset_device_password(ad, None) 60 if not is_sim_lock_enabled(ad): 61 ad.log.info("SIM is not locked") 62 else: 63 ad.log.info("SIM is locked, set as DUT") 64 self.setup_dut(ad) 65 return True 66 self.log.error("There is no locked SIM in this testbed") 67 raise signals.TestAbortClass("No device meets locked SIM requirement") 68 69 def setup_test(self): 70 self.expected_call_result = False 71 if "wfc" in self.test_name: 72 if CAPABILITY_WFC not in operator_capabilities.get( 73 self.dut_operator, operator_capabilities["default"]): 74 raise signals.TestSkip( 75 "WFC is not supported for carrier %s" % self.dut_operator) 76 unlock_sim(self.dut) 77 if "apm_off" not in self.test_name: 78 if self.dut_operator != "tmo": 79 raise signals.TestSkip( 80 "WFC in non-APM is not supported for carrier %s" % 81 self.dut_operator) 82 if not phone_setup_iwlan( 83 self.log, self.dut, False, WFC_MODE_WIFI_PREFERRED, 84 self.wifi_network_ssid, self.wifi_network_pass): 85 self.dut.log.error("Failed to setup WFC in non-APM.") 86 return False 87 else: 88 if not phone_setup_iwlan( 89 self.log, self.dut, True, WFC_MODE_WIFI_PREFERRED, 90 self.wifi_network_ssid, self.wifi_network_pass): 91 self.dut.log.error("Failed to setup WFC in APM.") 92 return False 93 if not is_sim_locked(self.dut): 94 self.dut.reboot(stop_at_lock_screen=True) 95 try: 96 droid, ed = self.dut.get_droid() 97 ed.start() 98 except: 99 self.dut.log.warning("Failed to start sl4a!") 100 self.dut.log.info("SIM at state %s", get_sim_state(self.dut)) 101 102 """ Tests Begin """ 103 104 @test_tracker_info(uuid="fd7fb69c-6fd4-4874-a4ca-769353b9db25") 105 @TelephonyBaseTest.tel_test_wrap 106 def test_fake_emergency_call_by_emergency_dialer_locked_sim(self): 107 """Test emergency call with emergency dialer in user account. 108 109 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 110 Add storyline number to system emergency number list. 111 Use the emergency dialer to call "611". 112 Verify DUT has in call activity. 113 114 Returns: 115 True if success. 116 False if failed. 117 """ 118 toggle_airplane_mode_by_adb(self.log, self.dut, False) 119 return self.fake_emergency_call_test() and self.check_normal_call() 120 121 @test_tracker_info(uuid="a0b3e7dd-93e0-40e2-99a9-5564d34712fc") 122 @TelephonyBaseTest.tel_test_wrap 123 def test_fake_emergency_call_by_emergency_dialer_csfb_locked_sim(self): 124 """Test emergency call with emergency dialer in user account. 125 126 Configure DUT in CSFB 127 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 128 Add system emergency number list with storyline number. 129 Use the emergency dialer to call storyline. 130 Verify DUT has in call activity. 131 132 Returns: 133 True if success. 134 False if failed. 135 """ 136 network_preference = network_preference_for_generation( 137 GEN_4G, None, self.dut.droid.telephonyGetPhoneType()) 138 self.dut.log.info("Set network preference to %s", network_preference) 139 self.dut.droid.telephonySetPreferredNetworkTypes(network_preference) 140 self.set_ims_first("false") 141 142 return self.fake_emergency_call_test() and self.check_normal_call() 143 144 @test_tracker_info(uuid="b5a5b550-49e6-4026-902a-b155d1209f6d") 145 @TelephonyBaseTest.tel_test_wrap 146 def test_fake_emergency_call_by_emergency_dialer_3g_locked_sim(self): 147 """Test emergency call with emergency dialer in user account. 148 149 Configure DUT in 3G 150 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 151 Add a fake emergency number. 152 Use the emergency dialer to call storyline. 153 Verify DUT has in call activity. 154 Verify DUT in emergency call back mode. 155 156 Returns: 157 True if success. 158 False if failed. 159 """ 160 network_preference = network_preference_for_generation( 161 GEN_3G, None, self.dut.droid.telephonyGetPhoneType()) 162 self.dut.log.info("Set network preference to %s", network_preference) 163 self.dut.droid.telephonySetPreferredNetworkTypes(network_preference) 164 self.set_ims_first("false") 165 return self.fake_emergency_call_test() and self.check_normal_call() 166 167 @test_tracker_info(uuid="5f083fa7-ddea-44de-8479-4da88d53da65") 168 @TelephonyBaseTest.tel_test_wrap 169 def test_fake_emergency_call_by_emergency_dialer_2g_locked_sim(self): 170 """Test emergency call with emergency dialer in user account. 171 172 Configure DUT in 2G 173 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 174 Add system emergency number list with fake emergency number. 175 Use the emergency dialer to call fake emergency. 176 Verify DUT has in call activity. 177 Verify DUT in emergency call back mode. 178 179 Returns: 180 True if success. 181 False if failed. 182 """ 183 network_preference = network_preference_for_generation( 184 GEN_2G, None, self.dut.droid.telephonyGetPhoneType()) 185 self.dut.log.info("Set network preference to %s", network_preference) 186 self.dut.droid.telephonySetPreferredNetworkTypes(network_preference) 187 self.set_ims_first("false") 188 return self.fake_emergency_call_test() and self.check_normal_call() 189 190 @test_tracker_info(uuid="e01870d7-89a6-4641-84c6-8e71142773f8") 191 @TelephonyBaseTest.tel_test_wrap 192 def test_fake_emergency_call_by_emergency_dialer_wfc_apm_locked_sim(self): 193 """Test emergency call with emergency dialer in user account. 194 195 Configure DUT in WFC APM on. 196 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 197 Add system emergency number list with fake emergency number. 198 Use the emergency dialer to call storyline. 199 Verify DUT has in call activity. 200 Verify DUT in emergency call back mode. 201 202 Returns: 203 True if success. 204 False if failed. 205 """ 206 self.set_ims_first("false") 207 return self.fake_emergency_call_test() and self.check_normal_call() 208 209 @test_tracker_info(uuid="b2c3de31-79ec-457a-a947-50c28caec214") 210 @TelephonyBaseTest.tel_test_wrap 211 def test_fake_emergency_call_by_emergency_dialer_wfc_apm_off_locked_sim( 212 self): 213 """Test emergency call with emergency dialer in user account. 214 215 Configure DUT in WFC APM off. 216 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 217 Add system emergency number list with fake emergency number. 218 Use the emergency dialer to call storyline. 219 Verify DUT has in call activity. 220 Verify DUT in emergency call back mode. 221 222 Returns: 223 True if success. 224 False if failed. 225 """ 226 self.set_ims_first("false") 227 return self.fake_emergency_call_test() and self.check_normal_call() 228 229 @test_tracker_info(uuid="669cf1d9-9513-4f90-b0fd-2f0e8f1cc941") 230 @TelephonyBaseTest.tel_test_wrap 231 def test_fake_emergency_call_by_dialer_locked_sim(self): 232 """Test emergency call with dialer. 233 234 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 235 Add system emergency number list with fake emergency number. 236 Call storyline by dialer. 237 Verify DUT has in call activity. 238 239 Returns: 240 True if success. 241 False if failed. 242 """ 243 toggle_airplane_mode_by_adb(self.log, self.dut, False) 244 return self.fake_emergency_call_test( 245 by_emergency_dialer=True) and self.check_normal_call() 246 247 @test_tracker_info(uuid="1990f166-66a7-4092-b448-c179a9194371") 248 @TelephonyBaseTest.tel_test_wrap 249 def test_fake_emergency_call_in_apm_locked_sim(self): 250 """Test emergency call with emergency dialer in airplane mode. 251 252 Enable airplane mode. 253 Enable SIM lock on the SIM. Reboot device to SIM pin request page. 254 Add system emergency number list with fake emergency number. 255 Use the emergency dialer to call storyline. 256 Verify DUT has in call activity. 257 258 Returns: 259 True if success. 260 False if failed. 261 """ 262 toggle_airplane_mode_by_adb(self.log, self.dut, True) 263 return self.fake_emergency_call_test() and self.check_normal_call() 264 265 @test_tracker_info(uuid="7ffdad34-b8fb-41b0-b0fd-2def5adc67bc") 266 @TelephonyBaseTest.tel_test_wrap 267 def test_fake_emergency_call_in_screen_lock_locked_sim(self): 268 """Test emergency call with emergency dialer in screen lock phase. 269 270 Enable SIM lock on the SIM. 271 Enable device password and then reboot upto password and pin query stage. 272 Add system emergency number list with storyline number. 273 Use the emergency dialer to call storyline. 274 Verify DUT has in call activity. 275 276 Returns: 277 True if success. 278 False if failed. 279 """ 280 self.dut.log.info("Set screen lock pin") 281 reset_device_password(self.dut, DEFAULT_DEVICE_PASSWORD) 282 self.dut.log.info("Reboot device to screen lock screen") 283 self.dut.reboot(stop_at_lock_screen=True) 284 return self.fake_emergency_call_test() and self.check_normal_call() 285 286 @test_tracker_info(uuid="12dc1eb6-50ed-4ad9-b195-5d96c6b6952e") 287 @TelephonyBaseTest.tel_test_wrap 288 def test_fake_emergency_call_in_screen_lock_apm_locked_sim(self): 289 """Test emergency call with emergency dialer in screen lock phase. 290 291 Enable device password and airplane mode 292 Enable SIM lock on the SIM. 293 Reboot upto pin query window. 294 Add system emergency number list with story line. 295 Use the emergency dialer to call story line. 296 Verify DUT has in call activity. 297 298 Returns: 299 True if success. 300 False if failed. 301 """ 302 toggle_airplane_mode_by_adb(self.log, self.dut, True) 303 self.dut.log.info("Set screen lock pin") 304 reset_device_password(self.dut, DEFAULT_DEVICE_PASSWORD) 305 self.dut.log.info("Reboot device to screen lock screen") 306 self.dut.reboot(stop_at_lock_screen=True) 307 return self.fake_emergency_call_test() and self.check_normal_call() 308 309 @test_tracker_info(uuid="1e01927a-a077-466d-8bf8-52dca87ab87c") 310 @TelephonyBaseTest.tel_test_wrap 311 def test_fake_emergency_call_in_setupwizard_locked_sim(self): 312 """Test emergency call with emergency dialer in setupwizard. 313 314 Enable SIM lock on the SIM. 315 Wipe the device and then reboot upto setupwizard. 316 Add system emergency number list with story line. 317 Use the emergency dialer to call story line. 318 Verify DUT has in call activity. 319 320 Returns: 321 True if success. 322 False if failed. 323 """ 324 if not fastboot_wipe(self.dut, skip_setup_wizard=False): 325 return False 326 return self.fake_emergency_call_test() and self.check_normal_call() 327 328 329""" Tests End """ 330