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