1#!/usr/bin/env python3.4 2# 3# Copyright 2018 - 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 IMS Settings 18""" 19 20import time 21 22from acts import signals 23from acts.test_decorators import test_tracker_info 24from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 25from acts.test_utils.tel.tel_defines import CarrierConfigs 26from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE 27from acts.test_utils.tel.tel_defines import CAPABILITY_WFC 28from acts.test_utils.tel.tel_defines import CAPABILITY_WFC_MODE_CHANGE 29from acts.test_utils.tel.tel_defines import GEN_4G 30from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_WIFI_CONNECTION 31from acts.test_utils.tel.tel_defines import NETWORK_SERVICE_DATA 32from acts.test_utils.tel.tel_defines import NETWORK_SERVICE_VOICE 33from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_IMS_REGISTRATION 34from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_WFC_ENABLED 35from acts.test_utils.tel.tel_defines import RAT_FAMILY_WLAN 36from acts.test_utils.tel.tel_defines import RAT_LTE 37from acts.test_utils.tel.tel_defines import RAT_UNKNOWN 38from acts.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED 39from acts.test_utils.tel.tel_defines import WFC_MODE_DISABLED 40from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_ONLY 41from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED 42from acts.test_utils.tel.tel_subscription_utils import get_outgoing_voice_sub_id 43from acts.test_utils.tel.tel_test_utils import call_setup_teardown 44from acts.test_utils.tel.tel_test_utils import dumpsys_carrier_config 45from acts.test_utils.tel.tel_test_utils import ensure_phone_subscription 46from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected 47from acts.test_utils.tel.tel_test_utils import fastboot_wipe 48from acts.test_utils.tel.tel_test_utils import get_user_config_profile 49from acts.test_utils.tel.tel_test_utils import is_droid_in_rat_family 50from acts.test_utils.tel.tel_test_utils import revert_default_telephony_setting 51from acts.test_utils.tel.tel_test_utils import set_wfc_mode 52from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode_by_adb 53from acts.test_utils.tel.tel_test_utils import toggle_volte 54from acts.test_utils.tel.tel_test_utils import toggle_wfc 55from acts.test_utils.tel.tel_test_utils import verify_default_telephony_setting 56from acts.test_utils.tel.tel_test_utils import verify_internet_connection 57from acts.test_utils.tel.tel_test_utils import wait_for_ims_registered 58from acts.test_utils.tel.tel_test_utils import wait_for_network_rat 59from acts.test_utils.tel.tel_test_utils import wait_for_not_network_rat 60from acts.test_utils.tel.tel_test_utils import wait_for_state 61from acts.test_utils.tel.tel_test_utils import wait_for_voice_attach 62from acts.test_utils.tel.tel_test_utils import wait_for_volte_enabled 63from acts.test_utils.tel.tel_test_utils import wait_for_wfc_disabled 64from acts.test_utils.tel.tel_test_utils import wait_for_wfc_enabled 65from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection 66from acts.test_utils.tel.tel_test_utils import wifi_reset 67from acts.test_utils.tel.tel_test_utils import wifi_toggle_state 68from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan 69from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte 70from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g 71from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb 72from acts.test_utils.tel.tel_voice_utils import phone_setup_volte 73from acts.test_utils.tel.tel_test_utils import WIFI_SSID_KEY 74from acts.test_utils.tel.tel_test_utils import WIFI_PWD_KEY 75 76 77class TelLiveImsSettingsTest(TelephonyBaseTest): 78 def setup_class(self): 79 TelephonyBaseTest.setup_class(self) 80 self.dut = self.android_devices[0] 81 self.number_of_devices = 1 82 self.skip_reset_between_cases = False 83 subid = get_outgoing_voice_sub_id(self.dut) 84 self.carrier_configs = dumpsys_carrier_config(self.dut)[subid] 85 self.dut_capabilities = self.dut.telephony["subscription"][ 86 subid].get("capabilities", []) 87 self.dut.log.info("DUT capabilities: %s", self.dut_capabilities) 88 if CAPABILITY_VOLTE not in self.dut_capabilities: 89 raise signals.TestAbortClass("VoLTE is not supported") 90 if CAPABILITY_WFC not in self.dut_capabilities: 91 raise signals.TestAbortClass("WFC is not supported") 92 93 self.default_volte = (CAPABILITY_VOLTE in self.dut_capabilities) and ( 94 self.carrier_configs[CarrierConfigs. 95 ENHANCED_4G_LTE_ON_BY_DEFAULT_BOOL]) 96 self.default_wfc_enabled = ( 97 CAPABILITY_WFC in self.dut_capabilities 98 ) and ( 99 self.carrier_configs[CarrierConfigs.DEFAULT_WFC_IMS_ENABLED_BOOL]) 100 self.default_wfc_mode = self.carrier_configs.get( 101 CarrierConfigs.DEFAULT_WFC_IMS_MODE_INT, None) 102 self.dut_wfc_modes = self.dut.telephony[ 103 "subscription"][subid].get("wfc_modes", []) 104 105 def check_call_in_wfc(self): 106 result = True 107 if not call_setup_teardown(self.log, self.android_devices[1], self.dut, 108 self.dut, None, is_phone_in_call_iwlan): 109 if not call_setup_teardown(self.log, self.android_devices[1], 110 self.dut, self.dut, None, 111 is_phone_in_call_iwlan): 112 self.dut.log.error("MT WFC call failed") 113 result = False 114 if not call_setup_teardown(self.log, self.dut, self.android_devices[1], 115 self.dut, is_phone_in_call_iwlan): 116 self.dut.log.error("MO WFC call failed") 117 result = False 118 return result 119 120 def check_call_in_volte(self): 121 result = True 122 if not call_setup_teardown(self.log, self.android_devices[1], self.dut, 123 self.dut, None, is_phone_in_call_volte): 124 if not call_setup_teardown(self.log, self.android_devices[1], 125 self.dut, self.dut, None, 126 is_phone_in_call_volte): 127 self.dut.log.error("MT VoLTE call failed") 128 result = False 129 if not call_setup_teardown(self.log, self.dut, self.android_devices[1], 130 self.dut, is_phone_in_call_volte): 131 self.dut.log.error("MO VoLTE call failed") 132 result = False 133 return result 134 135 def check_call(self): 136 result = True 137 if not call_setup_teardown(self.log, self.android_devices[1], self.dut, 138 self.dut): 139 if not call_setup_teardown(self.log, self.android_devices[1], 140 self.dut, self.dut): 141 self.dut.log.error("MT call failed") 142 result = False 143 if not call_setup_teardown(self.log, self.dut, self.android_devices[1], 144 self.dut): 145 self.dut.log.error("MO call failed") 146 result = False 147 return result 148 149 def change_ims_setting(self, 150 airplane_mode, 151 wifi_enabled, 152 volte_enabled, 153 wfc_enabled, 154 wfc_mode=None): 155 result = True 156 self.dut.log.info( 157 "Setting APM %s, WIFI %s, VoLTE %s, WFC %s, WFC mode %s", 158 airplane_mode, wifi_enabled, volte_enabled, wfc_enabled, wfc_mode) 159 toggle_airplane_mode_by_adb(self.log, self.dut, airplane_mode) 160 if wifi_enabled: 161 if not ensure_wifi_connected(self.log, self.dut, 162 self.wifi_network_ssid, 163 self.wifi_network_pass, 164 apm=airplane_mode): 165 self.dut.log.error("Fail to connected to WiFi") 166 result = False 167 else: 168 if not wifi_toggle_state(self.log, self.dut, False): 169 self.dut.log.error("Failed to turn off WiFi.") 170 result = False 171 toggle_volte(self.log, self.dut, volte_enabled) 172 toggle_wfc(self.log, self.dut, wfc_enabled) 173 if wfc_mode: 174 set_wfc_mode(self.log, self.dut, wfc_mode) 175 wfc_mode = self.dut.droid.imsGetWfcMode() 176 if wifi_enabled or not airplane_mode: 177 if not ensure_phone_subscription(self.log, self.dut): 178 self.dut.log.error("Failed to find valid subscription") 179 result = False 180 if airplane_mode: 181 if (CAPABILITY_WFC in self.dut_capabilities) and (wifi_enabled 182 and wfc_enabled): 183 if not wait_for_wfc_enabled(self.log, self.dut): 184 result = False 185 elif not self.check_call_in_wfc(): 186 result = False 187 else: 188 if not wait_for_state( 189 self.dut.droid.telephonyGetCurrentVoiceNetworkType, 190 RAT_UNKNOWN): 191 self.dut.log.error( 192 "Voice RAT is %s not UNKNOWN", 193 self.dut.droid.telephonyGetCurrentVoiceNetworkType()) 194 result = False 195 else: 196 self.dut.log.info("Voice RAT is in UNKKNOWN") 197 else: 198 if (wifi_enabled and wfc_enabled) and ( 199 wfc_mode == WFC_MODE_WIFI_PREFERRED) and ( 200 CAPABILITY_WFC in self.dut_capabilities): 201 if not wait_for_wfc_enabled(self.log, self.dut): 202 result = False 203 if not wait_for_state( 204 self.dut.droid.telephonyGetCurrentVoiceNetworkType, 205 RAT_UNKNOWN): 206 self.dut.log.error( 207 "Voice RAT is %s, not UNKNOWN", 208 self.dut.droid.telephonyGetCurrentVoiceNetworkType()) 209 if not self.check_call_in_wfc(): 210 result = False 211 else: 212 if not wait_for_wfc_disabled(self.log, self.dut): 213 self.dut.log.error("WFC is not disabled") 214 result = False 215 if volte_enabled and CAPABILITY_VOLTE in self.dut_capabilities: 216 if not wait_for_volte_enabled(self.log, self.dut): 217 result = False 218 if not self.check_call_in_volte(): 219 result = False 220 else: 221 if not wait_for_not_network_rat( 222 self.log, 223 self.dut, 224 RAT_LTE, 225 voice_or_data=NETWORK_SERVICE_VOICE): 226 self.dut.log.error( 227 "Voice RAT is %s", 228 self.dut.droid.telephonyGetCurrentVoiceNetworkType( 229 )) 230 result = False 231 if not wait_for_voice_attach(self.log, self.dut): 232 result = False 233 if not self.check_call(): 234 result = False 235 user_config_profile = get_user_config_profile(self.dut) 236 self.dut.log.info("user_config_profile: %s ", 237 sorted(user_config_profile.items())) 238 return result 239 240 def verify_default_ims_setting(self): 241 result = True 242 airplane_mode = self.dut.droid.connectivityCheckAirplaneMode() 243 default_wfc_mode = self.carrier_configs.get( 244 CarrierConfigs.DEFAULT_WFC_IMS_MODE_INT, WFC_MODE_DISABLED) 245 if self.default_wfc_enabled: 246 wait_for_wfc_enabled(self.log, self.dut) 247 else: 248 wait_for_wfc_disabled(self.log, self.dut) 249 if airplane_mode: 250 wait_for_network_rat( 251 self.log, 252 self.dut, 253 RAT_UNKNOWN, 254 voice_or_data=NETWORK_SERVICE_VOICE) 255 else: 256 if self.default_volte: 257 wait_for_volte_enabled(self.log, self.dut) 258 else: 259 wait_for_not_network_rat( 260 self.log, 261 self.dut, 262 RAT_UNKNOWN, 263 voice_or_data=NETWORK_SERVICE_VOICE) 264 if not ensure_phone_subscription(self.log, self.dut): 265 ad.log.error("Failed to find valid subscription") 266 result = False 267 user_config_profile = get_user_config_profile(self.dut) 268 self.dut.log.info("user_config_profile = %s ", 269 sorted(user_config_profile.items())) 270 if user_config_profile["VoLTE Enabled"] != self.default_volte: 271 self.dut.log.error("VoLTE mode is not %s", self.default_volte) 272 result = False 273 else: 274 self.dut.log.info("VoLTE mode is %s as expected", 275 self.default_volte) 276 if user_config_profile["WFC Enabled"] != self.default_wfc_enabled: 277 self.dut.log.error("WFC enabled is not %s", default_wfc_enabled) 278 if user_config_profile["WFC Enabled"]: 279 if user_config_profile["WFC Mode"] != default_wfc_mode: 280 self.dut.log.error( 281 "WFC mode is not %s after IMS factory reset", 282 default_wfc_mode) 283 result = False 284 else: 285 self.dut.log.info("WFC mode is %s as expected", 286 default_wfc_mode) 287 if self.default_wfc_enabled and \ 288 default_wfc_mode == WFC_MODE_WIFI_PREFERRED: 289 if not self.check_call_in_wfc(): 290 result = False 291 elif not airplane_mode: 292 if self.default_volte: 293 if not self.check_call_in_volte(): 294 result = False 295 else: 296 if not self.check_call(): 297 result = False 298 if result == False: 299 user_config_profile = get_user_config_profile(self.dut) 300 self.dut.log.info("user_config_profile = %s ", 301 sorted(user_config_profile.items())) 302 return result 303 304 @test_tracker_info(uuid="a3a680ba-d1e0-4770-a38c-4de8f15f9171") 305 @TelephonyBaseTest.tel_test_wrap 306 def test_lte_volte_wifi_connected_toggle_wfc(self): 307 """Test for WiFi Calling settings: 308 LTE + VoLTE Enabled + WiFi Connected, Toggling WFC 309 310 Steps: 311 1. Setup DUT Idle, LTE network type, VoLTE enabled. 312 2. Make sure DUT WiFi connected, WFC disabled. 313 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 314 report iwlan rat. 315 4. Set DUT WFC disabled, verify DUT WFC unavailable, 316 not report iwlan rat. 317 318 Expected Results: 319 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 320 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 321 """ 322 if not phone_setup_volte(self.log, self.dut): 323 self.log.error("Failed to setup VoLTE") 324 return False 325 if not self.change_ims_setting(False, True, True, True, 326 self.default_wfc_mode): 327 return False 328 if not self.change_ims_setting(False, True, True, False, None): 329 return False 330 return self.change_ims_setting(False, True, True, True, None) 331 332 @test_tracker_info(uuid="d3ffae75-ae4a-4ed8-9337-9155c413311d") 333 @TelephonyBaseTest.tel_test_wrap 334 def test_lte_wifi_connected_toggle_wfc(self): 335 """Test for WiFi Calling settings: 336 LTE + VoLTE Disabled + WiFi Connected, Toggling WFC 337 338 Steps: 339 1. Setup DUT Idle, LTE network type, VoLTE disabled. 340 2. Make sure DUT WiFi connected, WFC disabled. 341 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 342 report iwlan rat. 343 4. Set DUT WFC disabled, verify DUT WFC unavailable, 344 not report iwlan rat. 345 346 Expected Results: 347 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 348 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 349 """ 350 if not phone_setup_csfb(self.log, self.dut): 351 self.log.error("Failed to setup LTE") 352 return False 353 if not self.change_ims_setting(False, True, False, True, 354 self.default_wfc_mode): 355 return False 356 if not self.change_ims_setting(False, True, False, False, None): 357 return False 358 return self.change_ims_setting(False, True, False, True, None) 359 360 @test_tracker_info(uuid="29d2d7b7-1c31-4a2c-896a-3f6756c620ac") 361 @TelephonyBaseTest.tel_test_wrap 362 def test_3g_wifi_connected_toggle_wfc(self): 363 """Test for WiFi Calling settings: 364 3G + WiFi Connected, Toggling WFC 365 366 Steps: 367 1. Setup DUT Idle, 3G network type. 368 2. Make sure DUT WiFi connected, WFC disabled. 369 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 370 report iwlan rat. 371 4. Set DUT WFC disabled, verify DUT WFC unavailable, 372 not report iwlan rat. 373 374 Expected Results: 375 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 376 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 377 """ 378 if not phone_setup_voice_3g(self.log, self.dut): 379 self.log.error("Failed to setup 3G") 380 return False 381 if not self.change_ims_setting(False, True, False, True, 382 self.default_wfc_mode): 383 return False 384 if not self.change_ims_setting(False, True, False, False, None): 385 return False 386 return self.change_ims_setting(False, True, False, True, None) 387 388 @test_tracker_info(uuid="ce2c0208-9ea0-4b31-91f4-d06a62cb927a") 389 @TelephonyBaseTest.tel_test_wrap 390 def test_apm_wifi_connected_toggle_wfc(self): 391 """Test for WiFi Calling settings: 392 APM + WiFi Connected, Toggling WFC 393 394 Steps: 395 1. Setup DUT Idle, Airplane mode. 396 2. Make sure DUT WiFi connected, WFC disabled. 397 3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available, 398 report iwlan rat. 399 4. Set DUT WFC disabled, verify DUT WFC unavailable, 400 not report iwlan rat. 401 402 Expected Results: 403 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 404 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 405 """ 406 if not self.change_ims_setting(True, True, True, True, 407 self.default_wfc_mode): 408 return False 409 if not self.change_ims_setting(True, True, True, False, None): 410 return False 411 return self.change_ims_setting(True, True, True, True, None) 412 413 @test_tracker_info(uuid="681e2448-32a2-434d-abd6-0bc2ab5afd9c") 414 @TelephonyBaseTest.tel_test_wrap 415 def test_lte_volte_wfc_enabled_toggle_wifi(self): 416 """Test for WiFi Calling settings: 417 LTE + VoLTE Enabled + WFC enabled, Toggling WiFi 418 419 Steps: 420 1. Setup DUT Idle, LTE network type, VoLTE enabled. 421 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 422 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 423 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 424 425 Expected Results: 426 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 427 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 428 """ 429 if not phone_setup_volte(self.log, self.dut): 430 self.log.error("Failed to setup VoLTE") 431 return False 432 if not self.change_ims_setting(False, True, True, True, 433 self.default_wfc_mode): 434 return False 435 if not self.change_ims_setting(False, True, True, False, None): 436 return False 437 return self.change_ims_setting(False, True, True, True, None) 438 439 @test_tracker_info(uuid="63922066-9caa-42e6-bc9f-49f5ac01cbe2") 440 @TelephonyBaseTest.tel_test_wrap 441 def test_lte_wfc_enabled_toggle_wifi(self): 442 """Test for WiFi Calling settings: 443 LTE + VoLTE Disabled + WFC enabled, Toggling WiFi 444 445 Steps: 446 1. Setup DUT Idle, LTE network type, VoLTE disabled. 447 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 448 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 449 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 450 451 Expected Results: 452 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 453 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 454 """ 455 if not phone_setup_csfb(self.log, self.dut): 456 self.log.error("Failed to setup CSFB") 457 return False 458 if not self.change_ims_setting(False, True, False, True, 459 self.default_wfc_mode): 460 return False 461 if not self.change_ims_setting(False, False, False, True, None): 462 return False 463 return self.change_ims_setting(False, True, False, True, None) 464 465 @test_tracker_info(uuid="8a80a446-2116-4b19-b0ef-f771f30a6d15") 466 @TelephonyBaseTest.tel_test_wrap 467 def test_3g_wfc_enabled_toggle_wifi(self): 468 """Test for WiFi Calling settings: 469 3G + WFC enabled, Toggling WiFi 470 471 Steps: 472 1. Setup DUT Idle, 3G network type. 473 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 474 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 475 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 476 477 Expected Results: 478 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 479 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 480 """ 481 if not phone_setup_voice_3g(self.log, self.dut): 482 self.log.error("Failed to setup 3G") 483 return False 484 if not self.change_ims_setting(False, True, False, True, 485 self.default_wfc_mode): 486 return False 487 if not self.change_ims_setting(False, False, False, True, None): 488 return False 489 return self.change_ims_setting(False, True, False, True, None) 490 491 @test_tracker_info(uuid="9889eebf-cde6-4f47-aec0-9cb204fdf2e5") 492 @TelephonyBaseTest.tel_test_wrap 493 def test_apm_wfc_enabled_toggle_wifi(self): 494 """Test for WiFi Calling settings: 495 APM + WFC enabled, Toggling WiFi 496 497 Steps: 498 1. Setup DUT Idle, Airplane mode. 499 2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred). 500 3. DUT connect WiFi, verify DUT WFC available, report iwlan rat. 501 4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat. 502 503 Expected Results: 504 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 505 4. DUT WiFi Calling feature bit return False, network rat is not iwlan. 506 """ 507 if not self.change_ims_setting(True, True, True, True, 508 self.default_wfc_mode): 509 return False 510 if not self.change_ims_setting(True, False, True, True, None): 511 return False 512 return self.change_ims_setting(True, True, True, True, None) 513 514 @test_tracker_info(uuid="9b23e04b-4f70-4e73-88e7-6376262c739d") 515 @TelephonyBaseTest.tel_test_wrap 516 def test_lte_wfc_enabled_wifi_connected_toggle_volte(self): 517 """Test for WiFi Calling settings: 518 LTE + VoLTE Enabled + WiFi Connected + WFC enabled, toggle VoLTE setting 519 520 Steps: 521 1. Setup DUT Idle, LTE network type, VoLTE enabled. 522 2. Make sure DUT WiFi connected, WFC enabled (WiFi Preferred). 523 Verify DUT WFC available, report iwlan rat. 524 3. Disable VoLTE on DUT, verify in 2 minutes period, 525 DUT does not lost WiFi Calling, DUT still report WFC available, 526 rat iwlan. 527 4. Enable VoLTE on DUT, verify in 2 minutes period, 528 DUT does not lost WiFi Calling, DUT still report WFC available, 529 rat iwlan. 530 531 Expected Results: 532 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 533 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 534 4. DUT WiFi Calling feature bit return True, network rat is iwlan. 535 """ 536 if not phone_setup_volte(self.log, self.dut): 537 self.dut.log.error("Failed to setup VoLTE.") 538 return False 539 if not self.change_ims_setting(False, True, True, True, 540 self.default_wfc_mode): 541 return False 542 if not self.change_ims_setting(False, True, False, True, None): 543 return False 544 return self.change_ims_setting(False, True, True, True, None) 545 546 @test_tracker_info(uuid="04bdfda4-06f7-41df-9352-a8534bc2a67a") 547 @TelephonyBaseTest.tel_test_wrap 548 def test_lte_volte_wfc_wifi_preferred_to_cellular_preferred(self): 549 """Test for WiFi Calling settings: 550 LTE + VoLTE Enabled + WiFi Connected + WiFi Preferred, 551 change WFC to Cellular Preferred 552 553 Steps: 554 1. Setup DUT Idle, LTE network type, VoLTE enabled. 555 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 556 Verify DUT WFC available, report iwlan rat. 557 3. Change WFC setting to Cellular Preferred. 558 4. Verify DUT report WFC not available. 559 560 Expected Results: 561 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 562 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 563 """ 564 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 565 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 566 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 567 raise signals.TestSkip( 568 "WFC_MODE_CELLULAR_PREFERRED is not supported") 569 if not phone_setup_volte(self.log, self.dut): 570 self.dut.log.error("Failed to setup VoLTE.") 571 return False 572 if not self.change_ims_setting(False, True, True, True, 573 WFC_MODE_WIFI_PREFERRED): 574 return False 575 return self.change_ims_setting(False, True, True, True, 576 WFC_MODE_CELLULAR_PREFERRED) 577 578 @test_tracker_info(uuid="80d26bdb-992a-4b30-ad51-68308d5af168") 579 @TelephonyBaseTest.tel_test_wrap 580 def test_lte_wfc_wifi_preferred_to_cellular_preferred(self): 581 """Test for WiFi Calling settings: 582 LTE + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred 583 584 Steps: 585 1. Setup DUT Idle, LTE network type, VoLTE disabled. 586 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 587 Verify DUT WFC available, report iwlan rat. 588 3. Change WFC setting to Cellular Preferred. 589 4. Verify DUT report WFC not available. 590 591 Expected Results: 592 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 593 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 594 """ 595 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 596 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 597 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 598 raise signals.TestSkip( 599 "WFC_MODE_CELLULAR_PREFERRED is not supported") 600 if not phone_setup_csfb(self.log, self.dut): 601 self.dut.log.error("Failed to setup LTE.") 602 return False 603 if not self.change_ims_setting(False, True, False, True, 604 WFC_MODE_WIFI_PREFERRED): 605 return False 606 return self.change_ims_setting(False, True, False, True, 607 WFC_MODE_CELLULAR_PREFERRED) 608 609 @test_tracker_info(uuid="d486c7e3-3d2b-4552-8af8-7b19f6347427") 610 @TelephonyBaseTest.tel_test_wrap 611 def test_3g_wfc_wifi_preferred_to_cellular_preferred(self): 612 """Test for WiFi Calling settings: 613 3G + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred 614 615 Steps: 616 1. Setup DUT Idle, 3G network type. 617 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 618 Verify DUT WFC available, report iwlan rat. 619 3. Change WFC setting to Cellular Preferred. 620 4. Verify DUT report WFC not available. 621 622 Expected Results: 623 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 624 4. DUT WiFI Calling feature bit return False, network rat is not iwlan. 625 """ 626 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 627 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 628 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 629 raise signals.TestSkip( 630 "WFC_MODE_CELLULAR_PREFERRED is not supported") 631 if not phone_setup_voice_3g(self.dut.log, self.dut): 632 self.dut.log.error("Failed to setup 3G.") 633 return False 634 if not self.change_ims_setting(False, True, False, True, 635 WFC_MODE_WIFI_PREFERRED): 636 return False 637 return self.change_ims_setting(False, True, False, True, 638 WFC_MODE_CELLULAR_PREFERRED) 639 640 @test_tracker_info(uuid="0feb0add-8e22-4c86-b13e-be68659cdd87") 641 @TelephonyBaseTest.tel_test_wrap 642 def test_apm_wfc_wifi_preferred_to_cellular_preferred(self): 643 """Test for WiFi Calling settings: 644 APM + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred 645 646 Steps: 647 1. Setup DUT Idle, airplane mode. 648 2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred. 649 Verify DUT WFC available, report iwlan rat. 650 3. Change WFC setting to Cellular Preferred. 651 4. Verify DUT report WFC not available. 652 653 Expected Results: 654 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 655 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 656 """ 657 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 658 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 659 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 660 raise signals.TestSkip( 661 "WFC_MODE_CELLULAR_PREFERRED is not supported") 662 if not self.change_ims_setting(True, True, True, True, 663 WFC_MODE_WIFI_PREFERRED): 664 return False 665 return self.change_ims_setting(True, True, True, True, 666 WFC_MODE_CELLULAR_PREFERRED) 667 668 @test_tracker_info(uuid="9c8f359f-a084-4413-b8a9-34771af166c5") 669 @TelephonyBaseTest.tel_test_wrap 670 def test_lte_volte_wfc_cellular_preferred_to_wifi_preferred(self): 671 """Test for WiFi Calling settings: 672 LTE + VoLTE Enabled + WiFi Connected + Cellular Preferred, 673 change WFC to WiFi Preferred 674 675 Steps: 676 1. Setup DUT Idle, LTE network type, VoLTE enabled. 677 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 678 Verify DUT WFC not available. 679 3. Change WFC setting to WiFi Preferred. 680 4. Verify DUT report WFC available. 681 682 Expected Results: 683 2. DUT WiFi Calling feature bit return False, network rat is not iwlan. 684 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 685 """ 686 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 687 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 688 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 689 raise signals.TestSkip( 690 "WFC_MODE_CELLULAR_PREFERRED is not supported") 691 if not phone_setup_volte(self.log, self.dut): 692 self.dut.log.error("Failed to setup VoLTE.") 693 return False 694 if not self.change_ims_setting(False, True, True, True, 695 WFC_MODE_CELLULAR_PREFERRED): 696 return False 697 return self.change_ims_setting(False, True, True, True, 698 WFC_MODE_WIFI_PREFERRED) 699 700 @test_tracker_info(uuid="1894e685-63cf-43aa-91ed-938782ca35a9") 701 @TelephonyBaseTest.tel_test_wrap 702 def test_lte_wfc_cellular_preferred_to_wifi_preferred(self): 703 """Test for WiFi Calling settings: 704 LTE + WiFi Connected + Cellular Preferred, change WFC to WiFi Preferred 705 706 Steps: 707 1. Setup DUT Idle, LTE network type, VoLTE disabled. 708 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 709 Verify DUT WFC not available. 710 3. Change WFC setting to WiFi Preferred. 711 4. Verify DUT report WFC available. 712 713 Expected Results: 714 2. DUT WiFi Calling feature bit return False, network rat is not iwlan. 715 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 716 """ 717 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 718 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 719 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 720 raise signals.TestSkip( 721 "WFC_MODE_CELLULAR_PREFERRED is not supported") 722 if not phone_setup_csfb(self.log, self.dut): 723 self.dut.log.error("Failed to setup LTE.") 724 return False 725 if not self.change_ims_setting(False, True, False, True, 726 WFC_MODE_CELLULAR_PREFERRED): 727 return False 728 return self.change_ims_setting(False, True, False, True, 729 WFC_MODE_WIFI_PREFERRED) 730 731 @test_tracker_info(uuid="e7fb6a6c-4672-44da-bca2-78b4d96dea9e") 732 @TelephonyBaseTest.tel_test_wrap 733 def test_3g_wfc_cellular_preferred_to_wifi_preferred(self): 734 """Test for WiFi Calling settings: 735 3G + WiFi Connected + Cellular Preferred, change WFC to WiFi Preferred 736 737 Steps: 738 1. Setup DUT Idle, 3G network type. 739 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 740 Verify DUT WFC not available. 741 3. Change WFC setting to WiFi Preferred. 742 4. Verify DUT report WFC available. 743 744 Expected Results: 745 2. DUT WiFi Calling feature bit return False, network rat is not iwlan. 746 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 747 """ 748 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 749 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 750 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 751 raise signals.TestSkip( 752 "WFC_MODE_CELLULAR_PREFERRED is not supported") 753 if not phone_setup_voice_3g(self.log, self.dut): 754 self.dut.log.error("Failed to setup 3G.") 755 return False 756 if not self.change_ims_setting(False, True, False, True, 757 WFC_MODE_CELLULAR_PREFERRED): 758 return False 759 return self.change_ims_setting(False, True, False, True, 760 WFC_MODE_WIFI_PREFERRED) 761 762 @test_tracker_info(uuid="46262b2d-5de9-4984-87e8-42f44469289e") 763 @TelephonyBaseTest.tel_test_wrap 764 def test_apm_wfc_cellular_preferred_to_wifi_preferred(self): 765 """Test for WiFi Calling settings: 766 APM + WiFi Connected + Cellular Preferred, change WFC to WiFi Preferred 767 768 Steps: 769 1. Setup DUT Idle, airplane mode. 770 2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred. 771 Verify DUT WFC not available. 772 3. Change WFC setting to WiFi Preferred. 773 4. Verify DUT report WFC available. 774 775 Expected Results: 776 2. DUT WiFi Calling feature bit return True, network rat is iwlan. 777 4. DUT WiFI Calling feature bit return True, network rat is iwlan. 778 """ 779 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes: 780 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported") 781 if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes: 782 raise signals.TestSkip( 783 "WFC_MODE_CELLULAR_PREFERRED is not supported") 784 if not self.change_ims_setting(True, True, True, True, 785 WFC_MODE_CELLULAR_PREFERRED): 786 return False 787 return self.change_ims_setting(True, True, True, True, 788 WFC_MODE_WIFI_PREFERRED) 789 790 @test_tracker_info(uuid="5b514f51-fed9-475e-99d3-17d2165e11a1") 791 @TelephonyBaseTest.tel_test_wrap 792 def test_apm_wfc_wifi_preferred_turn_off_apm(self): 793 """Test for WiFi Calling settings: 794 APM + WiFi Connected + WiFi Preferred + turn off APM 795 796 Steps: 797 1. Setup DUT Idle in Airplane mode. 798 2. Make sure DUT WiFi connected, set WFC mode to WiFi preferred. 799 3. verify DUT WFC available, report iwlan rat. 800 4. Turn off airplane mode. 801 5. Verify DUT WFC still available, report iwlan rat 802 803 Expected Results: 804 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 805 5. DUT WiFI Calling feature bit return True, network rat is iwlan. 806 """ 807 if not self.change_ims_setting(True, True, True, True, 808 WFC_MODE_WIFI_PREFERRED): 809 return False 810 return self.change_ims_setting(False, True, True, True, None) 811 812 @test_tracker_info(uuid="f328cff2-9dec-44b3-ba74-a662b76fcf2a") 813 @TelephonyBaseTest.tel_test_wrap 814 def test_apm_wfc_cellular_preferred_turn_off_apm(self): 815 """Test for WiFi Calling settings: 816 APM + WiFi Connected + Cellular Preferred + turn off APM 817 818 Steps: 819 1. Setup DUT Idle in Airplane mode. 820 2. Make sure DUT WiFi connected, set WFC mode to Cellular preferred. 821 3. verify DUT WFC available, report iwlan rat. 822 4. Turn off airplane mode. 823 5. Verify DUT WFC not available, not report iwlan rat 824 825 Expected Results: 826 3. DUT WiFi Calling feature bit return True, network rat is iwlan. 827 5. DUT WiFI Calling feature bit return False, network rat is not iwlan. 828 """ 829 if not self.change_ims_setting(True, True, True, True, 830 WFC_MODE_CELLULAR_PREFERRED): 831 return False 832 return self.change_ims_setting(False, True, True, True, None) 833 834 @test_tracker_info(uuid="7e30d219-42ee-4309-a95c-2b45b8831d26") 835 @TelephonyBaseTest.tel_test_wrap 836 def test_wfc_setup_timing(self): 837 """ Measures the time delay in enabling WiFi calling 838 839 Steps: 840 1. Make sure DUT idle. 841 2. Turn on Airplane Mode, Set WiFi Calling to WiFi_Preferred. 842 3. Turn on WiFi, connect to WiFi AP and measure time delay. 843 4. Wait for WiFi connected, verify Internet and measure time delay. 844 5. Wait for rat to be reported as iwlan and measure time delay. 845 6. Wait for ims registered and measure time delay. 846 7. Wait for WiFi Calling feature bit to be True and measure time delay. 847 848 Expected results: 849 Time Delay in each step should be within pre-defined limit. 850 851 Returns: 852 Currently always return True. 853 """ 854 # TODO: b/26338119 Set pass/fail criteria 855 time_values = { 856 'start': 0, 857 'wifi_enabled': 0, 858 'wifi_connected': 0, 859 'wifi_data': 0, 860 'iwlan_rat': 0, 861 'ims_registered': 0, 862 'wfc_enabled': 0, 863 'mo_call_success': 0 864 } 865 866 wifi_reset(self.log, self.dut) 867 toggle_airplane_mode_by_adb(self.log, self.dut, True) 868 869 set_wfc_mode(self.log, self.dut, WFC_MODE_WIFI_PREFERRED) 870 871 time_values['start'] = time.time() 872 873 self.dut.log.info("Start Time %ss", time_values['start']) 874 875 wifi_toggle_state(self.log, self.dut, True) 876 time_values['wifi_enabled'] = time.time() 877 self.dut.log.info("WiFi Enabled After %ss", 878 time_values['wifi_enabled'] - time_values['start']) 879 880 network = {WIFI_SSID_KEY: self.wifi_network_ssid} 881 if self.wifi_network_pass: 882 network[WIFI_PWD_KEY] = self.wifi_network_pass 883 try: 884 self.dut.droid.wifiConnectByConfig(network) 885 except Exception: 886 self.dut.log.info("Connecting to wifi by RPC wifiConnect instead") 887 self.dut.droid.wifiConnect(network) 888 self.dut.droid.wakeUpNow() 889 890 if not wait_for_wifi_data_connection(self.log, self.dut, True, 891 MAX_WAIT_TIME_WIFI_CONNECTION): 892 self.dut.log.error("Failed WiFi connection, aborting!") 893 return False 894 time_values['wifi_connected'] = time.time() 895 896 self.dut.log.info( 897 "WiFi Connected After %ss", 898 time_values['wifi_connected'] - time_values['wifi_enabled']) 899 900 if not verify_internet_connection(self.log, self.dut, retries=3): 901 self.dut.log.error("Failed to get user-plane traffic, aborting!") 902 return False 903 904 time_values['wifi_data'] = time.time() 905 self.dut.log.info( 906 "WifiData After %ss", 907 time_values['wifi_data'] - time_values['wifi_connected']) 908 909 if not wait_for_network_rat( 910 self.log, 911 self.dut, 912 RAT_FAMILY_WLAN, 913 voice_or_data=NETWORK_SERVICE_DATA): 914 self.dut.log.error("Failed to set-up iwlan, aborting!") 915 if is_droid_in_rat_family(self.log, self.dut, RAT_FAMILY_WLAN, 916 NETWORK_SERVICE_DATA): 917 self.dut.log.error( 918 "Never received the event, but droid in iwlan") 919 else: 920 return False 921 time_values['iwlan_rat'] = time.time() 922 self.dut.log.info("iWLAN Reported After %ss", 923 time_values['iwlan_rat'] - time_values['wifi_data']) 924 925 if not wait_for_ims_registered(self.log, self.dut, 926 MAX_WAIT_TIME_IMS_REGISTRATION): 927 self.dut.log.error("Never received IMS registered, aborting") 928 return False 929 time_values['ims_registered'] = time.time() 930 self.dut.log.info( 931 "Ims Registered After %ss", 932 time_values['ims_registered'] - time_values['iwlan_rat']) 933 934 if not wait_for_wfc_enabled(self.log, self.dut, 935 MAX_WAIT_TIME_WFC_ENABLED): 936 self.dut.log.error("Never received WFC feature, aborting") 937 return False 938 939 time_values['wfc_enabled'] = time.time() 940 self.dut.log.info( 941 "Wifi Calling Feature Enabled After %ss", 942 time_values['wfc_enabled'] - time_values['ims_registered']) 943 944 set_wfc_mode(self.log, self.dut, WFC_MODE_DISABLED) 945 946 wait_for_not_network_rat( 947 self.log, 948 self.dut, 949 RAT_FAMILY_WLAN, 950 voice_or_data=NETWORK_SERVICE_DATA) 951 952 self.dut.log.info("\n\n------------------summary-----------------") 953 self.dut.log.info("WiFi Enabled After %.2f seconds", 954 time_values['wifi_enabled'] - time_values['start']) 955 self.dut.log.info( 956 "WiFi Connected After %.2f seconds", 957 time_values['wifi_connected'] - time_values['wifi_enabled']) 958 self.dut.log.info( 959 "WifiData After %.2f s", 960 time_values['wifi_data'] - time_values['wifi_connected']) 961 self.dut.log.info("iWLAN Reported After %.2f seconds", 962 time_values['iwlan_rat'] - time_values['wifi_data']) 963 self.dut.log.info( 964 "Ims Registered After %.2f seconds", 965 time_values['ims_registered'] - time_values['iwlan_rat']) 966 self.dut.log.info( 967 "Wifi Calling Feature Enabled After %.2f seconds", 968 time_values['wfc_enabled'] - time_values['ims_registered']) 969 self.dut.log.info("\n\n") 970 return True 971 972 @test_tracker_info(uuid="135301ea-6d00-4233-98fd-cda706d61eb2") 973 @TelephonyBaseTest.tel_test_wrap 974 def test_ims_factory_reset(self): 975 """Test VOLTE and WFC reset to factory default. 976 977 Steps: 978 1. Setup VoLTE, WFC, APM is various mode. 979 2. Call IMS factory reset. 980 3. Verify VoLTE and WFC are back to factory default. 981 4. Verify VoLTE, WFC Voice call can be made successful if enabled. 982 983 """ 984 result = True 985 wifi_enabled = True 986 for airplane_mode in (True, False): 987 for volte_enabled in (True, False): 988 for wfc_enabled in (True, False): 989 if wfc_enabled: 990 wfc_modes = self.dut_wfc_modes 991 else: 992 wfc_modes = [None] 993 for wfc_mode in wfc_modes: 994 if not self.change_ims_setting( 995 airplane_mode, wifi_enabled, volte_enabled, 996 wfc_enabled, wfc_mode): 997 result = False 998 self.dut.log.info("Call IMS factory reset") 999 self.dut.droid.telephonyFactoryReset() 1000 if not self.verify_default_ims_setting(): 1001 result = False 1002 return result 1003 1004 @test_tracker_info(uuid="ce60740f-4d8e-4013-a7cf-65589e8a0893") 1005 @TelephonyBaseTest.tel_test_wrap 1006 def test_factory_reset_by_fastboot_wipe(self): 1007 """Verify the network setting after factory reset by wipe. 1008 1009 Steps: 1010 1. Config VoLTE, WFC, APM, data_roamingn, mobile_data, 1011 preferred_network_mode to non-factory default. 1012 2. Factory reset by fastboot wipe. 1013 3. Verify network configs back to factory default. 1014 1015 """ 1016 self.dut.log.info("Set VoLTE off, WFC wifi preferred, APM on") 1017 toggle_volte(self.log, self.dut, False) 1018 revert_default_telephony_setting(self.dut) 1019 self.change_ims_setting(True, True, False, True, 1020 WFC_MODE_WIFI_PREFERRED) 1021 self.dut.log.info("Wipe in fastboot") 1022 fastboot_wipe(self.dut) 1023 return verify_default_telephony_setting( 1024 self.dut) and (self.verify_default_ims_setting()) 1025