Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 1 | #/usr/bin/env python3.4 |
| 2 | # |
| 3 | # Copyright 2016 - The Android Open Source Project |
| 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 | Sanity tests for voice tests in telephony |
| 18 | """ |
Jaineel | 5eba0e9 | 2017-03-10 15:56:17 -0800 | [diff] [blame] | 19 | import time |
| 20 | |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 21 | from acts.controllers.anritsu_lib._anritsu_utils import AnritsuError |
| 22 | from acts.controllers.anritsu_lib.md8475a import MD8475A |
| 23 | from acts.controllers.anritsu_lib.md8475a import CBCHSetup |
| 24 | from acts.controllers.anritsu_lib.md8475a import CTCHSetup |
| 25 | from acts.test_utils.tel.anritsu_utils import ETWS_WARNING_EARTHQUAKETSUNAMI |
| 26 | from acts.test_utils.tel.anritsu_utils import ETWS_WARNING_OTHER_EMERGENCY |
| 27 | from acts.test_utils.tel.anritsu_utils import cb_serial_number |
| 28 | from acts.test_utils.tel.anritsu_utils import etws_receive_verify_message_lte_wcdma |
| 29 | from acts.test_utils.tel.anritsu_utils import set_system_model_gsm |
| 30 | from acts.test_utils.tel.anritsu_utils import set_system_model_lte |
| 31 | from acts.test_utils.tel.anritsu_utils import set_system_model_wcdma |
Patrick Chiang | 8324da7 | 2017-04-07 17:02:17 -0700 | [diff] [blame] | 32 | from acts.test_utils.tel.anritsu_utils import set_usim_parameters |
Jaineel | 1b6e84c | 2017-10-03 13:58:04 -0700 | [diff] [blame] | 33 | from acts.test_utils.tel.anritsu_utils import set_post_sim_params |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 34 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_CDMA |
| 35 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY |
| 36 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_UMTS |
| 37 | from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_GSM_WCDMA |
| 38 | from acts.test_utils.tel.tel_defines import RAT_1XRTT |
| 39 | from acts.test_utils.tel.tel_defines import RAT_GSM |
| 40 | from acts.test_utils.tel.tel_defines import RAT_LTE |
| 41 | from acts.test_utils.tel.tel_defines import RAT_WCDMA |
| 42 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_CDMA2000 |
| 43 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_GSM |
| 44 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_LTE |
| 45 | from acts.test_utils.tel.tel_defines import RAT_FAMILY_UMTS |
| 46 | from acts.test_utils.tel.tel_test_utils import ensure_network_rat |
| 47 | from acts.test_utils.tel.tel_test_utils import ensure_phones_idle |
| 48 | from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode |
Jaineel | e47ea0c | 2017-11-01 12:11:56 -0700 | [diff] [blame^] | 49 | from acts.test_utils.tel.tel_test_utils import start_qxdm_loggers |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 50 | from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest |
Jaineel | e299ac1 | 2017-04-19 12:23:52 -0700 | [diff] [blame] | 51 | from acts.test_decorators import test_tracker_info |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 52 | |
Jaineel | 5eba0e9 | 2017-03-10 15:56:17 -0800 | [diff] [blame] | 53 | WAIT_TIME_BETWEEN_REG_AND_MSG = 15 # default 15 sec |
| 54 | |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 55 | |
| 56 | class TelLabEtwsTest(TelephonyBaseTest): |
| 57 | SERIAL_NO = cb_serial_number() |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 58 | |
| 59 | def __init__(self, controllers): |
| 60 | TelephonyBaseTest.__init__(self, controllers) |
| 61 | self.ad = self.android_devices[0] |
Patrick Chiang | 8324da7 | 2017-04-07 17:02:17 -0700 | [diff] [blame] | 62 | self.ad.sim_card = getattr(self.ad, "sim_card", None) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 63 | self.md8475a_ip_address = self.user_params[ |
| 64 | "anritsu_md8475a_ip_address"] |
Patrick Chiang | 2f7d8f9 | 2017-03-17 15:42:28 -0700 | [diff] [blame] | 65 | self.wlan_option = self.user_params.get("anritsu_wlan_option", False) |
Betty Zhou | b499fe1 | 2017-03-01 19:38:42 -0800 | [diff] [blame] | 66 | self.ad.adb.shell("settings put secure cmas_additional_broadcast_pkg " |
| 67 | "com.googlecode.android_scripting") |
Jaineel | 5eba0e9 | 2017-03-10 15:56:17 -0800 | [diff] [blame] | 68 | self.wait_time_between_reg_and_msg = self.user_params.get( |
| 69 | "wait_time_between_reg_and_msg", WAIT_TIME_BETWEEN_REG_AND_MSG) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 70 | |
| 71 | def setup_class(self): |
| 72 | try: |
Patrick Chiang | 2f7d8f9 | 2017-03-17 15:42:28 -0700 | [diff] [blame] | 73 | self.anritsu = MD8475A(self.md8475a_ip_address, self.log, |
| 74 | self.wlan_option) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 75 | except AnritsuError: |
| 76 | self.log.error("Error in connecting to Anritsu Simulator") |
| 77 | return False |
| 78 | return True |
| 79 | |
| 80 | def setup_test(self): |
Jaineel | e47ea0c | 2017-11-01 12:11:56 -0700 | [diff] [blame^] | 81 | if getattr(self, "qxdm_log", True): |
| 82 | start_qxdm_loggers(self.log, self.android_devices) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 83 | ensure_phones_idle(self.log, self.android_devices) |
| 84 | toggle_airplane_mode(self.log, self.ad, True) |
| 85 | return True |
| 86 | |
| 87 | def teardown_test(self): |
| 88 | self.log.info("Stopping Simulation") |
| 89 | self.anritsu.stop_simulation() |
| 90 | toggle_airplane_mode(self.log, self.ad, True) |
| 91 | |
| 92 | def teardown_class(self): |
| 93 | self.anritsu.disconnect() |
| 94 | return True |
| 95 | |
| 96 | def _send_receive_etws_message(self, set_simulation_func, rat, message_id, |
| 97 | warning_message): |
| 98 | try: |
Patrick Chiang | 8324da7 | 2017-04-07 17:02:17 -0700 | [diff] [blame] | 99 | [self.bts1] = set_simulation_func(self.anritsu, self.user_params, |
| 100 | self.ad.sim_card) |
| 101 | set_usim_parameters(self.anritsu, self.ad.sim_card) |
Jaineel | 2eeef43 | 2017-10-23 16:58:30 -0700 | [diff] [blame] | 102 | if rat == RAT_LTE: |
| 103 | set_post_sim_params(self.anritsu, self.user_params, |
| 104 | self.ad.sim_card) |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 105 | self.anritsu.start_simulation() |
| 106 | |
| 107 | if rat == RAT_LTE: |
| 108 | preferred_network_setting = NETWORK_MODE_LTE_GSM_WCDMA |
| 109 | rat_family = RAT_FAMILY_LTE |
| 110 | elif rat == RAT_WCDMA: |
| 111 | self.bts1.wcdma_ctch = CTCHSetup.CTCH_ENABLE |
| 112 | self.ad.droid.telephonyToggleDataConnection(False) |
| 113 | preferred_network_setting = NETWORK_MODE_GSM_UMTS |
| 114 | rat_family = RAT_FAMILY_UMTS |
| 115 | elif rat == RAT_GSM: |
| 116 | self.bts1.gsm_cbch = CBCHSetup.CBCH_ENABLE |
| 117 | self.ad.droid.telephonyToggleDataConnection(False) |
| 118 | preferred_network_setting = NETWORK_MODE_GSM_ONLY |
| 119 | rat_family = RAT_FAMILY_GSM |
| 120 | elif rat == RAT_1XRTT: |
| 121 | preferred_network_setting = NETWORK_MODE_CDMA |
| 122 | rat_family = RAT_FAMILY_CDMA2000 |
| 123 | else: |
| 124 | self.log.error("No valid RAT provided for ETWS test.") |
| 125 | return False |
| 126 | |
Betty Zhou | b499fe1 | 2017-03-01 19:38:42 -0800 | [diff] [blame] | 127 | if not ensure_network_rat( |
| 128 | self.log, |
| 129 | self.ad, |
| 130 | preferred_network_setting, |
| 131 | rat_family, |
| 132 | toggle_apm_after_setting=True): |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 133 | self.log.error( |
| 134 | "Failed to set rat family {}, preferred network:{}".format( |
| 135 | rat_family, preferred_network_setting)) |
| 136 | return False |
| 137 | |
| 138 | self.anritsu.wait_for_registration_state() |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 139 | if not etws_receive_verify_message_lte_wcdma( |
| 140 | self.log, self.ad, self.anritsu, |
| 141 | next(TelLabEtwsTest.SERIAL_NO), message_id, |
| 142 | warning_message): |
| 143 | self.log.error("Phone {} Failed to receive ETWS message" |
| 144 | .format(self.ad.serial)) |
| 145 | return False |
| 146 | except AnritsuError as e: |
| 147 | self.log.error("Error in connection with Anritsu Simulator: " + |
| 148 | str(e)) |
| 149 | return False |
| 150 | except Exception as e: |
| 151 | self.log.error("Exception during ETWS send/receive: " + str(e)) |
| 152 | return False |
| 153 | return True |
| 154 | |
| 155 | """ Tests Begin """ |
| 156 | |
Jaineel | e299ac1 | 2017-04-19 12:23:52 -0700 | [diff] [blame] | 157 | @test_tracker_info(uuid="af4a00d0-9a91-45d5-9f65-9541e64a57f2") |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 158 | @TelephonyBaseTest.tel_test_wrap |
| 159 | def test_etws_earthquake_tsunami_lte(self): |
| 160 | """ETWS Earthquake and Tsunami warning message reception on LTE |
| 161 | |
| 162 | Tests the capability of device to receive and inform the user |
| 163 | about the ETWS Earthquake and Tsunami warning message when camped on |
| 164 | LTE newtork |
| 165 | |
| 166 | Steps: |
| 167 | 1. Make Sure Phone is camped on LTE network |
| 168 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 169 | |
| 170 | Expected Result: |
| 171 | Phone receives ETWS Earthquake and Tsunami warning message |
| 172 | |
| 173 | Returns: |
| 174 | True if pass; False if fail |
| 175 | """ |
| 176 | return self._send_receive_etws_message(set_system_model_lte, RAT_LTE, |
| 177 | ETWS_WARNING_EARTHQUAKETSUNAMI, |
| 178 | "LTE Earthquake and Tsunami") |
| 179 | |
Jaineel | e299ac1 | 2017-04-19 12:23:52 -0700 | [diff] [blame] | 180 | @test_tracker_info(uuid="03785878-0319-413c-9190-d4e08f0edc33") |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 181 | @TelephonyBaseTest.tel_test_wrap |
| 182 | def test_etws_other_emergency_lte(self): |
| 183 | """ETWS Other emergency warning message reception on LTE |
| 184 | |
| 185 | Tests the capability of device to receive and inform the user |
| 186 | about the ETWS Other emergency warning message when camped on |
| 187 | LTE newtork |
| 188 | |
| 189 | Steps: |
| 190 | 1. Make Sure Phone is camped on LTE network |
| 191 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 192 | |
| 193 | Expected Result: |
| 194 | Phone receives ETWS Earthquake and Tsunami warning message |
| 195 | |
| 196 | Returns: |
| 197 | True if pass; False if fail |
| 198 | """ |
| 199 | return self._send_receive_etws_message(set_system_model_lte, RAT_LTE, |
| 200 | ETWS_WARNING_OTHER_EMERGENCY, |
| 201 | "LTE ETWS Other Emergency") |
| 202 | |
Jaineel | e299ac1 | 2017-04-19 12:23:52 -0700 | [diff] [blame] | 203 | @test_tracker_info(uuid="1ef4a5d7-9ceb-49eb-8ec7-5538625c8bd4") |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 204 | @TelephonyBaseTest.tel_test_wrap |
| 205 | def test_etws_earthquake_tsunami_wcdma(self): |
| 206 | """ETWS Earthquake and Tsunami warning message reception on WCDMA |
| 207 | |
| 208 | Tests the capability of device to receive and inform the user |
| 209 | about the ETWS Earthquake and Tsunami warning message when camped on |
| 210 | WCDMA newtork |
| 211 | |
| 212 | Steps: |
| 213 | 1. Make Sure Phone is camped on WCDMA network |
| 214 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 215 | |
| 216 | Expected Result: |
| 217 | Phone receives ETWS Earthquake and Tsunami warning message |
| 218 | |
| 219 | Returns: |
| 220 | True if pass; False if fail |
| 221 | """ |
| 222 | return self._send_receive_etws_message( |
| 223 | set_system_model_wcdma, RAT_WCDMA, ETWS_WARNING_EARTHQUAKETSUNAMI, |
| 224 | "WCDMA Earthquake and Tsunami") |
| 225 | |
Jaineel | e299ac1 | 2017-04-19 12:23:52 -0700 | [diff] [blame] | 226 | @test_tracker_info(uuid="71dc9650-d00a-4533-99f5-5cc301c21334") |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 227 | @TelephonyBaseTest.tel_test_wrap |
| 228 | def test_etws_other_emergency_wcdma(self): |
| 229 | """ETWS Other emergency warning message reception on WCDMA |
| 230 | |
| 231 | Tests the capability of device to receive and inform the user |
| 232 | about the ETWS Other emergency warning message when camped on |
| 233 | WCDMA newtork |
| 234 | |
| 235 | Steps: |
| 236 | 1. Make Sure Phone is camped on WCDMA network |
| 237 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 238 | |
| 239 | Expected Result: |
| 240 | Phone receives ETWS Earthquake and Tsunami warning message |
| 241 | |
| 242 | Returns: |
| 243 | True if pass; False if fail |
| 244 | """ |
| 245 | return self._send_receive_etws_message( |
| 246 | set_system_model_wcdma, RAT_WCDMA, ETWS_WARNING_OTHER_EMERGENCY, |
| 247 | "WCDMA ETWS Other Emergency") |
| 248 | |
Jaineel | e299ac1 | 2017-04-19 12:23:52 -0700 | [diff] [blame] | 249 | @test_tracker_info(uuid="a9fd9c0e-21bf-41d1-81d2-c34679052fe0") |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 250 | @TelephonyBaseTest.tel_test_wrap |
| 251 | def test_etws_earthquake_tsunami_gsm(self): |
| 252 | """ETWS Earthquake and Tsunami warning message reception on GSM |
| 253 | |
| 254 | Tests the capability of device to receive and inform the user |
| 255 | about the ETWS Earthquake and Tsunami warning message when camped on |
| 256 | GSM newtork |
| 257 | |
| 258 | Steps: |
| 259 | 1. Make Sure Phone is camped on GSM network |
| 260 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 261 | |
| 262 | Expected Result: |
| 263 | Phone receives ETWS Earthquake and Tsunami warning message |
| 264 | |
| 265 | Returns: |
| 266 | True if pass; False if fail |
| 267 | """ |
| 268 | return self._send_receive_etws_message(set_system_model_gsm, RAT_GSM, |
| 269 | ETWS_WARNING_EARTHQUAKETSUNAMI, |
| 270 | "GSM Earthquake and Tsunami") |
| 271 | |
Jaineel | e299ac1 | 2017-04-19 12:23:52 -0700 | [diff] [blame] | 272 | @test_tracker_info(uuid="0ae42f8d-1720-449c-9200-e88f7f1d2cbe") |
Betty Zhou | ecac263 | 2016-12-08 20:31:05 -0800 | [diff] [blame] | 273 | @TelephonyBaseTest.tel_test_wrap |
| 274 | def test_etws_other_emergency_gsm(self): |
| 275 | """ETWS Other emergency warning message reception on GSM |
| 276 | |
| 277 | Tests the capability of device to receive and inform the user |
| 278 | about the ETWS Other emergency warning message when camped on |
| 279 | GSM newtork |
| 280 | |
| 281 | Steps: |
| 282 | 1. Make Sure Phone is camped on GSM network |
| 283 | 2. Send ETWS Earthquake and Tsunami warning message from Anritsu |
| 284 | |
| 285 | Expected Result: |
| 286 | Phone receives ETWS Earthquake and Tsunami warning message |
| 287 | |
| 288 | Returns: |
| 289 | True if pass; False if fail |
| 290 | """ |
| 291 | return self._send_receive_etws_message(set_system_model_gsm, RAT_GSM, |
| 292 | ETWS_WARNING_OTHER_EMERGENCY, |
| 293 | "GSM ETWS Other Emergency") |
| 294 | |
| 295 | """ Tests End """ |