1#!/usr/bin/env python3.4 2# 3# Copyright 2016 - 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 epdg RF shield box related tests. 18""" 19 20import time 21from acts.test_decorators import test_tracker_info 22from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 23from acts_contrib.test_utils.tel.tel_atten_utils import set_rssi 24from acts_contrib.test_utils.tel.tel_defines import CELL_WEAK_RSSI_VALUE 25from acts_contrib.test_utils.tel.tel_defines import INVALID_WIFI_RSSI 26from acts_contrib.test_utils.tel.tel_defines import MAX_RSSI_RESERVED_VALUE 27from acts_contrib.test_utils.tel.tel_defines import MIN_RSSI_RESERVED_VALUE 28from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_WIFI_RSSI_CALIBRATION_SCREEN_ON 29from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_WIFI_RSSI_CALIBRATION_WIFI_CONNECTED 30from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED 31from acts_contrib.test_utils.tel.tel_defines import WIFI_WEAK_RSSI_VALUE 32from acts_contrib.test_utils.tel.tel_defines import SignalStrengthContainer 33from acts_contrib.test_utils.tel.tel_data_utils import wait_for_wifi_data_connection 34from acts_contrib.test_utils.tel.tel_ims_utils import set_wfc_mode 35from acts_contrib.test_utils.tel.tel_phone_setup_utils import ensure_phones_default_state 36from acts_contrib.test_utils.tel.tel_phone_setup_utils import ensure_phone_subscription 37from acts_contrib.test_utils.tel.tel_test_utils import verify_internet_connection 38from acts_contrib.test_utils.tel.tel_wifi_utils import ensure_wifi_connected 39from TelLiveConnectivityMonitorBaseTest import TelLiveConnectivityMonitorBaseTest 40 41# Attenuator name 42ATTEN_NAME_FOR_WIFI_2G = 'wifi0' 43ATTEN_NAME_FOR_WIFI_5G = 'wifi1' 44ATTEN_NAME_FOR_CELL_3G = 'cell0' 45ATTEN_NAME_FOR_CELL_4G = 'cell1' 46 47# WiFi RSSI settings for ROVE_IN test 48WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN = -60 49WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN = -70 50 51# WiFi RSSI settings for ROVE_OUT test 52WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE = -60 53WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT = -70 54WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT = -90 55 56# WiFi RSSI settings for HAND_IN test 57WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN = -80 58WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN = -50 59 60# WiFi RSSI settings for HAND_OUT test 61WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_NOT_HAND_OUT = -60 62WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT = -85 63 64CS_LINK_LOST = "Radio Link Lost" 65IMS_LINK_LOST = "Media Timeout" 66 67 68class TelLiveConnectivityMonitorMobilityTest( 69 TelLiveConnectivityMonitorBaseTest): 70 def setup_class(self): 71 TelLiveConnectivityMonitorBaseTest.setup_class(self) 72 73 self.attens = {} 74 for atten in self.attenuators: 75 self.attens[atten.path] = atten 76 atten.set_atten(atten.get_max_atten()) # Default all attens to max 77 78 79 # Do WiFi RSSI calibration. 80 self.set_wifi_strong_cell_strong() 81 82 if not ensure_phone_subscription(self.log, self.dut): 83 self.dut.log.error("Failed to find valid subscription") 84 return False 85 if not ensure_wifi_connected(self.log, self.dut, 86 self.wifi_network_ssid, 87 self.wifi_network_pass): 88 self.dut.log.error("Fail to connect to WiFI") 89 return False 90 if (not wait_for_wifi_data_connection(self.log, self.dut, True) 91 or not verify_internet_connection(self.log, self.dut)): 92 self.dut.log.error("No Data on Wifi") 93 return False 94 95 # Delay WAIT_TIME_WIFI_RSSI_CALIBRATION_WIFI_CONNECTED after WiFi 96 # Connected to make sure WiFi RSSI reported value is correct. 97 time.sleep(WAIT_TIME_WIFI_RSSI_CALIBRATION_WIFI_CONNECTED) 98 # Turn On Screen and delay WAIT_TIME_WIFI_RSSI_CALIBRATION_SCREEN_ON 99 # then get WiFi RSSI to avoid WiFi RSSI report -127(invalid value). 100 self.dut.droid.wakeUpNow() 101 time.sleep(WAIT_TIME_WIFI_RSSI_CALIBRATION_SCREEN_ON) 102 103 setattr(self, "wifi_rssi_with_no_atten", 104 self.dut.droid.wifiGetConnectionInfo()['rssi']) 105 if self.wifi_rssi_with_no_atten == INVALID_WIFI_RSSI: 106 self.dut.log.error( 107 "Initial WiFi RSSI calibration value is wrong: -127.") 108 return False 109 self.dut.log.info("WiFi RSSI calibration info: atten=0, RSSI=%s", 110 self.wifi_rssi_with_no_atten) 111 ensure_phones_default_state(self.log, [self.dut]) 112 113 # Do Cellular RSSI calibration. 114 setattr(self, "cell_rssi_with_no_atten", 115 self.dut.droid.telephonyGetSignalStrength()[ 116 SignalStrengthContainer.SIGNAL_STRENGTH_LTE_DBM]) 117 self.dut.log.info("Cellular RSSI calibration info: atten=0, RSSI=%s", 118 self.cell_rssi_with_no_atten) 119 return True 120 121 def teardown_class(self): 122 self.dut.droid.telephonyStopTrackingSignalStrengthChange() 123 super().teardown_class() 124 return True 125 126 def setup_test(self): 127 super().setup_test() 128 self.set_wifi_strong_cell_strong() 129 return True 130 131 def teardown_test(self): 132 super().teardown_test() 133 self.set_wifi_strong_cell_strong() 134 return True 135 136 def set_wifi_strong_cell_strong(self): 137 self.log.info("--->Setting WiFi strong cell strong<---") 138 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0, 139 MAX_RSSI_RESERVED_VALUE) 140 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0, 141 MAX_RSSI_RESERVED_VALUE) 142 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0, 143 MAX_RSSI_RESERVED_VALUE) 144 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0, 145 MAX_RSSI_RESERVED_VALUE) 146 return True 147 148 def set_wifi_strong_cell_weak(self): 149 self.log.info("--->Setting WiFi strong cell weak<---") 150 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0, 151 MAX_RSSI_RESERVED_VALUE) 152 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0, 153 MAX_RSSI_RESERVED_VALUE) 154 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 155 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE) 156 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 157 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE) 158 return True 159 160 def set_wifi_strong_cell_absent(self): 161 self.log.info("--->Setting WiFi strong cell absent<---") 162 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0, 163 MAX_RSSI_RESERVED_VALUE) 164 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0, 165 MAX_RSSI_RESERVED_VALUE) 166 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0, 167 MIN_RSSI_RESERVED_VALUE) 168 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0, 169 MIN_RSSI_RESERVED_VALUE) 170 return True 171 172 def set_wifi_weak_cell_strong(self): 173 self.log.info("--->Setting WiFi weak cell strong<---") 174 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 175 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE) 176 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 177 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE) 178 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0, 179 MAX_RSSI_RESERVED_VALUE) 180 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0, 181 MAX_RSSI_RESERVED_VALUE) 182 return True 183 184 def set_wifi_weak_cell_weak(self): 185 self.log.info("--->Setting WiFi weak cell weak<---") 186 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 187 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE) 188 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 189 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE) 190 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 191 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE) 192 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 193 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE) 194 return True 195 196 def set_wifi_weak_cell_absent(self): 197 self.log.info("--->Setting WiFi weak cell absent<---") 198 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 199 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE) 200 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 201 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE) 202 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0, 203 MIN_RSSI_RESERVED_VALUE) 204 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0, 205 MIN_RSSI_RESERVED_VALUE) 206 return True 207 208 def set_wifi_absent_cell_strong(self): 209 self.log.info("--->Setting WiFi absent cell strong<---") 210 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0, 211 MIN_RSSI_RESERVED_VALUE) 212 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0, 213 MIN_RSSI_RESERVED_VALUE) 214 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0, 215 MAX_RSSI_RESERVED_VALUE) 216 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0, 217 MAX_RSSI_RESERVED_VALUE) 218 return True 219 220 def set_wifi_absent_cell_weak(self): 221 self.log.info("--->Setting WiFi absent cell weak<---") 222 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0, 223 MIN_RSSI_RESERVED_VALUE) 224 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0, 225 MIN_RSSI_RESERVED_VALUE) 226 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 227 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE) 228 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 229 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE) 230 return True 231 232 def set_wifi_absent_cell_absent(self): 233 self.log.info("--->Setting WiFi absent cell absent<---") 234 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0, 235 MIN_RSSI_RESERVED_VALUE) 236 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0, 237 MIN_RSSI_RESERVED_VALUE) 238 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0, 239 MIN_RSSI_RESERVED_VALUE) 240 set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0, 241 MIN_RSSI_RESERVED_VALUE) 242 return True 243 244 """ Tests Begin """ 245 246 @test_tracker_info(uuid="d474725b-c34d-4686-8b5f-c0d4733a0cc1") 247 @TelephonyBaseTest.tel_test_wrap 248 def test_volte_call_drop_by_poor_signals(self): 249 return self.forced_call_drop_test( 250 setup="volte", 251 triggers=[ 252 "set_wifi_absent_cell_absent", "set_wifi_strong_cell_strong" 253 ], 254 expected_drop_reason=IMS_LINK_LOST) 255 256 @test_tracker_info(uuid="7f62f1c0-6d9e-4e7e-812f-b1c60d2f4b41") 257 @TelephonyBaseTest.tel_test_wrap 258 def test_csfb_call_drop_by_poor_signals(self): 259 return self.forced_call_drop_test( 260 setup="csfb", 261 triggers=[ 262 "set_wifi_absent_cell_absent", "set_wifi_strong_cell_strong" 263 ], 264 expected_drop_reason=CS_LINK_LOST) 265 266 @test_tracker_info(uuid="8d1c8c44-be54-43ec-892c-c3f41855c7c8") 267 @TelephonyBaseTest.tel_test_wrap 268 def test_3g_call_drop_by_poor_signal(self): 269 return self.forced_call_drop_test( 270 setup="3g", 271 triggers=[ 272 "set_wifi_absent_cell_absent", "set_wifi_strong_cell_strong" 273 ], 274 expected_drop_reason=CS_LINK_LOST) 275 276 @test_tracker_info(uuid="66e01cb3-3bea-4d08-9ab4-7f22790c57b1") 277 @TelephonyBaseTest.tel_test_wrap 278 def test_wfc_apm_call_drop_by_poor_signal(self): 279 return self.forced_call_drop_test( 280 setup="wfc_apm", 281 triggers=[ 282 "set_wifi_absent_cell_absent", "set_wifi_strong_cell_strong" 283 ], 284 expected_drop_reason=IMS_LINK_LOST) 285 286 @test_tracker_info(uuid="669e9f97-6931-403a-a13d-4f179bd4406f") 287 @TelephonyBaseTest.tel_test_wrap 288 def test_wfc_non_apm_call_drop_by_poor_signal(self): 289 self.setup_wfc_non_apm() 290 return self.forced_call_drop_test( 291 setup="wfc_non_apm", 292 triggers=[ 293 "set_wifi_absent_cell_absent", "set_wifi_strong_cell_strong" 294 ], 295 expected_drop_reason=IMS_LINK_LOST) 296 297 @test_tracker_info(uuid="c7619788-2357-4c49-a754-50ffaf433d59") 298 @TelephonyBaseTest.tel_test_wrap 299 def test_volte_handover_to_wfc_then_hangup(self): 300 self.connect_to_wifi() 301 self.enable_wfc() 302 set_wfc_mode(self.log, self.dut, WFC_MODE_CELLULAR_PREFERRED) 303 self.setup_volte() 304 return self.call_setup_and_connectivity_monitor_checking( 305 setup="volte", 306 handover="wfc_non_apm", 307 triggers=["set_wifi_strong_cell_absent"], 308 expected_drop_reason=None, 309 expected_trouble=None, 310 expected_action=None) 311 312 @test_tracker_info(uuid="c10c8406-6a0c-4039-b2ce-3782593774f2") 313 @TelephonyBaseTest.tel_test_wrap 314 def test_csfb_handover_to_wfc_then_hangup(self): 315 self.setup_csfb() 316 self.connect_to_wifi() 317 self.enable_wfc() 318 self.set_wifi_absent_cell_strong() 319 return self.call_setup_and_connectivity_monitor_checking( 320 setup="csfb", 321 handover="wfc_non_apm", 322 triggers=[ 323 "set_wifi_strong_cell_strong", "connect_to_wifi", 324 "is_wfc_enabled", "set_wifi_strong_cell_absent" 325 ], 326 expected_drop_reason=None, 327 expected_trouble=None, 328 expected_action=None) 329 330 @test_tracker_info(uuid="fcb62ea3-3a39-407c-90d8-21896c981ef4") 331 @TelephonyBaseTest.tel_test_wrap 332 def test_3g_handover_to_wfc_then_hangup(self): 333 self.setup_3g() 334 self.connect_to_wifi() 335 self.enable_wfc() 336 set_wfc_mode(self.log, self.dut, WFC_MODE_CELLULAR_PREFERRED) 337 if not self.is_wfc_enabled(): 338 self.dut.log.error("WFC is not enabled") 339 return False 340 return self.call_setup_and_connectivity_monitor_checking( 341 setup="3g", 342 handover="wfc_non_apm", 343 triggers=["set_wifi_strong_cell_absent"], 344 expected_drop_reason=None, 345 expected_trouble=None, 346 expected_action=None) 347 348 @test_tracker_info(uuid="85f32373-d1b2-4763-8812-d7ff43a9b3e6") 349 @TelephonyBaseTest.tel_test_wrap 350 def test_wfc_handover_to_volte_then_hangup(self): 351 self.setup_volte() 352 self.connect_to_wifi() 353 self.enable_wfc() 354 self.set_wifi_strong_cell_absent() 355 if not self.is_wfc_enabled(): 356 self.dut.log.error("WFC is not enabled") 357 return False 358 return self.call_setup_and_connectivity_monitor_checking( 359 setup="wfc_non_apm", 360 handover="volte", 361 triggers=[ 362 "set_wifi_strong_cell_strong", "set_wifi_absent_cell_strong" 363 ], 364 expected_drop_reason=None, 365 expected_trouble=None, 366 expected_action=None) 367 368 @test_tracker_info(uuid="c3dee2ba-1637-4382-97a7-ec9ca795f3dc") 369 @TelephonyBaseTest.tel_test_wrap 370 def test_wfc_handover_to_volte_then_call_drop(self): 371 self.setup_volte() 372 self.connect_to_wifi() 373 self.enable_wfc() 374 self.set_wifi_strong_cell_absent() 375 if not self.is_wfc_enabled(): 376 self.dut.log.error("WFC is not enabled") 377 return False 378 return self.call_drop_test( 379 setup="wfc_non_apm", 380 handover="volte", 381 count=1, 382 triggers=[ 383 "set_wifi_strong_cell_strong", "set_wifi_absent_cell_strong", 384 "set_wifi_absent_cell_absent" 385 ], 386 expected_drop_reason=IMS_LINK_LOST, 387 expected_trouble=None, 388 expected_action=None) 389 390 @test_tracker_info(uuid="90bc318a-b8ba-45c9-8d8f-e642eeb00460") 391 @TelephonyBaseTest.tel_test_wrap 392 def test_wfc_handover_to_csfb_then_call_drop(self): 393 self.setup_csfb() 394 self.set_wifi_strong_cell_absent() 395 self.connect_to_wifi() 396 self.enable_wfc() 397 if not self.is_wfc_enabled(): 398 self.dut.log.error("WFC is not enabled") 399 return False 400 return self.call_drop_test( 401 setup="wfc_apm", 402 handover="csfb", 403 count=1, 404 triggers=[ 405 "set_wifi_strong_cell_strong", "set_wifi_absent_cell_strong", 406 "set_wifi_absent_cell_absent" 407 ], 408 expected_drop_reason=CS_LINK_LOST, 409 expected_trouble=None, 410 expected_action=None) 411 412 @test_tracker_info(uuid="0557709e-6d82-4c66-b622-6f36db8bdcc2") 413 @TelephonyBaseTest.tel_test_wrap 414 def test_volte_handover_to_wfc_then_call_drop(self): 415 self.setup_volte() 416 self.connect_to_wifi() 417 self.enable_wfc() 418 self.set_wifi_absent_cell_strong() 419 return self.call_drop_test( 420 setup="volte", 421 handover="wfc_non_apm", 422 count=1, 423 triggers=[ 424 "set_wifi_strong_cell_strong", "connect_to_wifi", 425 "is_wfc_enabled", "set_wifi_strong_cell_absent", 426 "set_wifi_absent_cell_absent" 427 ], 428 expected_drop_reason=IMS_LINK_LOST, 429 expected_trouble=None, 430 expected_action=None) 431 432 @test_tracker_info(uuid="3453ed14-8227-4050-96f1-e9ac7973df3b") 433 @TelephonyBaseTest.tel_test_wrap 434 def test_csfb_handover_to_wfc_then_call_drop(self): 435 self.setup_csfb() 436 self.connect_to_wifi() 437 self.enable_wfc() 438 self.set_wifi_absent_cell_strong() 439 return self.call_drop_test( 440 setup="csfb", 441 handover="wfc", 442 count=1, 443 triggers=[ 444 "set_wifi_strong_cell_strong", "connect_to_wifi", 445 "is_wfc_enabled", "set_wifi_strong_cell_absent", 446 "set_wifi_absent_cell_absent" 447 ], 448 expected_drop_reason=IMS_LINK_LOST, 449 expected_trouble=None, 450 expected_action=None) 451 452 @test_tracker_info(uuid="68cc68db-c60b-4c4a-a974-8e0d1fa211f2") 453 @TelephonyBaseTest.tel_test_wrap 454 def test_3g_handover_to_wfc_then_call_drop(self): 455 self.setup_3g() 456 self.connect_to_wifi() 457 self.enable_wfc() 458 self.set_wifi_absent_cell_strong() 459 return self.call_drop_test( 460 setup="3g", 461 handover="wfc_non_apm", 462 count=1, 463 triggers=[ 464 "set_wifi_strong_cell_strong", "connect_to_wifi", 465 "is_wfc_enabled", "set_wifi_strong_cell_absent", 466 "set_wifi_absent_cell_absent" 467 ], 468 expected_drop_reason=IMS_LINK_LOST, 469 expected_trouble=None, 470 expected_action=None) 471 472 473""" Tests End """ 474