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