1#!/usr/bin/env python3
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"""
17Sanity tests for voice tests in telephony
18"""
19import time
20
21from acts.controllers.anritsu_lib._anritsu_utils import AnritsuError
22from acts.controllers.anritsu_lib.md8475a import CsfbType
23from acts.controllers.anritsu_lib.md8475a import MD8475A
24from acts.controllers.anritsu_lib.md8475a import VirtualPhoneAutoAnswer
25from acts.controllers.anritsu_lib.md8475a import VirtualPhoneStatus
26from acts.test_utils.tel.anritsu_utils import WAIT_TIME_ANRITSU_REG_AND_CALL
27from acts.test_utils.tel.anritsu_utils import call_mo_setup_teardown
28from acts.test_utils.tel.anritsu_utils import ims_call_cs_teardown
29from acts.test_utils.tel.anritsu_utils import call_mt_setup_teardown
30from acts.test_utils.tel.anritsu_utils import set_system_model_1x
31from acts.test_utils.tel.anritsu_utils import set_system_model_1x_evdo
32from acts.test_utils.tel.anritsu_utils import set_system_model_gsm
33from acts.test_utils.tel.anritsu_utils import set_system_model_lte
34from acts.test_utils.tel.anritsu_utils import set_system_model_lte_1x
35from acts.test_utils.tel.anritsu_utils import set_system_model_lte_wcdma
36from acts.test_utils.tel.anritsu_utils import set_system_model_lte_gsm
37from acts.test_utils.tel.anritsu_utils import set_system_model_wcdma
38from acts.test_utils.tel.anritsu_utils import set_usim_parameters
39from acts.test_utils.tel.anritsu_utils import set_post_sim_params
40from acts.test_utils.tel.tel_defines import CALL_TEARDOWN_PHONE
41from acts.test_utils.tel.tel_defines import DEFAULT_EMERGENCY_CALL_NUMBER
42from acts.test_utils.tel.tel_defines import EMERGENCY_CALL_NUMBERS
43from acts.test_utils.tel.tel_defines import RAT_FAMILY_CDMA2000
44from acts.test_utils.tel.tel_defines import RAT_FAMILY_GSM
45from acts.test_utils.tel.tel_defines import RAT_FAMILY_LTE
46from acts.test_utils.tel.tel_defines import RAT_FAMILY_UMTS
47from acts.test_utils.tel.tel_defines import RAT_1XRTT
48from acts.test_utils.tel.tel_defines import NETWORK_MODE_CDMA
49from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY
50from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_UMTS
51from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_CDMA_EVDO
52from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
53from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_GSM_WCDMA
54from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL
55from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_FOR_IMS
56from acts.test_utils.tel.tel_test_utils import ensure_network_rat
57from acts.test_utils.tel.tel_test_utils import ensure_phone_default_state
58from acts.test_utils.tel.tel_test_utils import ensure_phones_idle
59from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode_by_adb
60from acts.test_utils.tel.tel_test_utils import toggle_volte
61from acts.test_utils.tel.tel_test_utils import check_apm_mode_on_by_serial
62from acts.test_utils.tel.tel_test_utils import set_apm_mode_on_by_serial
63from acts.test_utils.tel.tel_test_utils import set_preferred_apn_by_adb
64from acts.test_utils.tel.tel_test_utils import start_qxdm_loggers
65from acts.test_utils.tel.tel_voice_utils import phone_idle_volte
66from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
67from acts.test_decorators import test_tracker_info
68from acts.utils import exe_cmd
69
70
71class TelLabEmergencyCallTest(TelephonyBaseTest):
72    def setup_class(self):
73        super().setup_class()
74        try:
75            self.stress_test_number = int(
76                self.user_params["stress_test_number"])
77            self.log.info("Executing {} calls per test in stress test mode".
78                          format(self.stress_test_number))
79        except KeyError:
80            self.stress_test_number = 0
81            self.log.info(
82                "No 'stress_test_number' defined: running single iteration tests"
83            )
84
85        self.ad = self.android_devices[0]
86        self.ad.sim_card = getattr(self.ad, "sim_card", None)
87        self.md8475a_ip_address = self.user_params[
88            "anritsu_md8475a_ip_address"]
89        self.wlan_option = self.user_params.get("anritsu_wlan_option", False)
90        self.md8475_version = self.user_params.get("md8475", "A")
91
92        setattr(self, 'emergency_call_number', DEFAULT_EMERGENCY_CALL_NUMBER)
93        if 'emergency_call_number' in self.user_params:
94            self.emergency_call_number = self.user_params[
95                'emergency_call_number']
96            self.log.info("Using provided emergency call number: {}".format(
97                self.emergency_call_number))
98        if not self.emergency_call_number in EMERGENCY_CALL_NUMBERS:
99            self.log.warning("Unknown Emergency Number {}".format(
100                self.emergency_call_number))
101
102        # Check for all adb devices on the linux machine, and set APM ON
103        cmd = "|".join(("adb devices", "grep -i device$", "cut -f1"))
104        output = exe_cmd(cmd)
105        list_of_devices = output.decode("utf-8").split("\n")
106        if len(list_of_devices) > 1:
107            for i in range(len(list_of_devices) - 1):
108                self.log.info("Serial %s", list_of_devices[i])
109                if check_apm_mode_on_by_serial(self.ad, list_of_devices[i]):
110                    self.log.info("Device is already in APM ON")
111                else:
112                    self.log.info("Device is not in APM, turning it ON")
113                    set_apm_mode_on_by_serial(self.ad, list_of_devices[i])
114                    if check_apm_mode_on_by_serial(self.ad,
115                                                   list_of_devices[i]):
116                        self.log.info("Device is now in APM ON")
117
118        if self.ad.sim_card == "VzW12349":
119            set_preferred_apn_by_adb(self.ad, "VZWINTERNET")
120
121        try:
122            self.anritsu = MD8475A(self.md8475a_ip_address, self.wlan_option,
123                                   self.md8475_version)
124        except AnritsuError:
125            self.log.error("Error in connecting to Anritsu Simulator")
126            return False
127        return True
128
129    def setup_test(self):
130        if getattr(self, "qxdm_log", True):
131            start_qxdm_loggers(self.log, self.android_devices)
132        ensure_phone_default_state(self.log, self.ad, check_subscription=False)
133        toggle_airplane_mode_by_adb(self.log, self.ad, True)
134        try:
135            if self.ad.sim_card == "VzW12349":
136                self.ad.droid.imsSetVolteProvisioning(True)
137        except Exception as e:
138            self.ad.log.error(e)
139        # get a handle to virtual phone
140        self.virtualPhoneHandle = self.anritsu.get_VirtualPhone()
141        return True
142
143    def teardown_test(self):
144        self.log.info("Stopping Simulation")
145        self.anritsu.stop_simulation()
146        toggle_airplane_mode_by_adb(self.log, self.ad, True)
147        return True
148
149    def teardown_class(self):
150        self.anritsu.disconnect()
151        return True
152
153    def _setup_emergency_call(self,
154                              set_simulation_func,
155                              phone_setup_func,
156                              phone_idle_func_after_registration=None,
157                              is_ims_call=False,
158                              is_wait_for_registration=True,
159                              csfb_type=None,
160                              srlte_csfb=None,
161                              srvcc=None,
162                              emergency_number=DEFAULT_EMERGENCY_CALL_NUMBER,
163                              teardown_side=CALL_TEARDOWN_PHONE,
164                              wait_time_in_call=WAIT_TIME_IN_CALL):
165        try:
166            set_simulation_func(self.anritsu, self.user_params,
167                                self.ad.sim_card)
168            set_usim_parameters(self.anritsu, self.ad.sim_card)
169            if is_ims_call or srvcc or csfb_type:
170                set_post_sim_params(self.anritsu, self.user_params,
171                                    self.ad.sim_card)
172            self.virtualPhoneHandle.auto_answer = (VirtualPhoneAutoAnswer.ON,
173                                                   2)
174            if csfb_type:
175                self.anritsu.csfb_type = csfb_type
176            if srlte_csfb == "lte_call_failure":
177                self.anritsu.send_command("IMSPSAPAUTOANSWER 1,DISABLE")
178                self.anritsu.start_simulation()
179                self.anritsu.send_command("IMSSTARTVN 1")
180                check_ims_reg = True
181                check_ims_calling = True
182            elif srlte_csfb == "ims_unregistered":
183                self.anritsu.start_simulation()
184                self.anritsu.send_command("IMSSTARTVN 1")
185                self.anritsu.send_command(
186                    "IMSCSCFBEHAVIOR 1,SENDERRORRESPONSE603")
187                check_ims_reg = False
188                check_ims_calling = False
189            elif srlte_csfb == "ps911_unsupported":
190                self.anritsu.send_command("EMCBS NOTSUPPORT,BTS1")
191                self.anritsu.start_simulation()
192                self.anritsu.send_command("IMSSTARTVN 1")
193                check_ims_reg = True
194                check_ims_calling = False
195            elif srlte_csfb == "emc_barred":
196                self.anritsu.send_command("ACBARRED USERSPECIFIC,BTS1")
197                self.anritsu.send_command("LTEEMERGENCYACBARRED BARRED,BTS1")
198                self.anritsu.start_simulation()
199                self.anritsu.send_command("IMSSTARTVN 1")
200                check_ims_reg = True
201                check_ims_calling = False
202            elif srvcc == "InCall":
203                self.anritsu.start_simulation()
204                self.anritsu.send_command("IMSSTARTVN 1")
205                self.anritsu.send_command("IMSSTARTVN 2")
206                self.anritsu.send_command("IMSSTARTVN 3")
207                check_ims_reg = True
208                check_ims_calling = True
209            else:
210                self.anritsu.start_simulation()
211            if is_ims_call or csfb_type:
212                self.anritsu.send_command("IMSSTARTVN 1")
213                self.anritsu.send_command("IMSSTARTVN 2")
214                self.anritsu.send_command("IMSSTARTVN 3")
215
216            iterations = 1
217            if self.stress_test_number > 0:
218                iterations = self.stress_test_number
219            successes = 0
220            for i in range(1, iterations + 1):
221                if self.stress_test_number:
222                    self.log.info(
223                        "Running iteration {} of {}".format(i, iterations))
224                # FIXME: There's no good reason why this must be true;
225                # I can only assume this was done to work around a problem
226                self.ad.droid.telephonyToggleDataConnection(False)
227
228                # turn off all other BTS to ensure UE registers on BTS1
229                sim_model = (self.anritsu.get_simulation_model()).split(",")
230                no_of_bts = len(sim_model)
231                for i in range(2, no_of_bts + 1):
232                    self.anritsu.send_command(
233                        "OUTOFSERVICE OUT,BTS{}".format(i))
234
235                if phone_setup_func is not None:
236                    if not phone_setup_func(self.ad):
237                        self.log.warning(
238                            "phone_setup_func failed. Rebooting UE")
239                        self.ad.reboot()
240                        time.sleep(30)
241                        if self.ad.sim_card == "VzW12349":
242                            set_preferred_apn_by_adb(self.ad, "VZWINTERNET")
243                        if not phone_setup_func(self.ad):
244                            self.log.error("phone_setup_func failed.")
245                            continue
246
247                if is_wait_for_registration:
248                    self.anritsu.wait_for_registration_state()
249
250                if phone_idle_func_after_registration:
251                    if not phone_idle_func_after_registration(self.log,
252                                                              self.ad):
253                        continue
254
255                for i in range(2, no_of_bts + 1):
256                    self.anritsu.send_command(
257                        "OUTOFSERVICE IN,BTS{}".format(i))
258
259                time.sleep(WAIT_TIME_ANRITSU_REG_AND_CALL)
260                if srlte_csfb or srvcc:
261                    if not ims_call_cs_teardown(
262                            self.log, self.ad, self.anritsu, emergency_number,
263                            CALL_TEARDOWN_PHONE, True, check_ims_reg,
264                            check_ims_calling, srvcc,
265                            WAIT_TIME_IN_CALL_FOR_IMS, WAIT_TIME_IN_CALL):
266                        self.log.error(
267                            "Phone {} Failed to make emergency call to {}"
268                            .format(self.ad.serial, emergency_number))
269                        continue
270                else:
271                    if not call_mo_setup_teardown(
272                            self.log, self.ad, self.anritsu, emergency_number,
273                            CALL_TEARDOWN_PHONE, True, WAIT_TIME_IN_CALL,
274                            is_ims_call):
275                        self.log.error(
276                            "Phone {} Failed to make emergency call to {}"
277                            .format(self.ad.serial, emergency_number))
278                        continue
279                successes += 1
280                if self.stress_test_number:
281                    self.log.info("Passed iteration {}".format(i))
282            if self.stress_test_number:
283                self.log.info("Total of {} successes out of {} attempts".
284                              format(successes, iterations))
285            return True if successes == iterations else False
286
287        except AnritsuError as e:
288            self.log.error("Error in connection with Anritsu Simulator: " +
289                           str(e))
290            return False
291        except Exception as e:
292            self.log.error("Exception during emergency call procedure: " + str(
293                e))
294            return False
295        return True
296
297    def _phone_setup_lte_wcdma(self, ad):
298        toggle_volte(self.log, ad, False)
299        return ensure_network_rat(
300            self.log,
301            ad,
302            NETWORK_MODE_LTE_GSM_WCDMA,
303            RAT_FAMILY_LTE,
304            toggle_apm_after_setting=True)
305
306    def _phone_setup_lte_1x(self, ad):
307        return ensure_network_rat(
308            self.log,
309            ad,
310            NETWORK_MODE_LTE_CDMA_EVDO,
311            RAT_FAMILY_LTE,
312            toggle_apm_after_setting=True)
313
314    def _phone_setup_wcdma(self, ad):
315        return ensure_network_rat(
316            self.log,
317            ad,
318            NETWORK_MODE_GSM_UMTS,
319            RAT_FAMILY_UMTS,
320            toggle_apm_after_setting=True)
321
322    def _phone_setup_gsm(self, ad):
323        return ensure_network_rat(
324            self.log,
325            ad,
326            NETWORK_MODE_GSM_ONLY,
327            RAT_FAMILY_GSM,
328            toggle_apm_after_setting=True)
329
330    def _phone_setup_1x(self, ad):
331        return ensure_network_rat(
332            self.log,
333            ad,
334            NETWORK_MODE_CDMA,
335            RAT_FAMILY_CDMA2000,
336            toggle_apm_after_setting=True)
337
338    def _phone_setup_airplane_mode(self, ad):
339        return toggle_airplane_mode_by_adb(self.log, ad, True)
340
341    def _phone_disable_airplane_mode(self, ad):
342        return toggle_airplane_mode_by_adb(self.log, ad, False)
343
344    def _phone_setup_volte_airplane_mode(self, ad):
345        toggle_volte(self.log, ad, True)
346        return toggle_airplane_mode_by_adb(self.log, ad, True)
347
348    def _phone_setup_volte(self, ad):
349        ad.droid.telephonyToggleDataConnection(True)
350        toggle_volte(self.log, ad, True)
351        return ensure_network_rat(
352            self.log,
353            ad,
354            NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA,
355            RAT_FAMILY_LTE,
356            toggle_apm_after_setting=True)
357
358    """ Tests Begin """
359
360    @test_tracker_info(uuid="f5c93228-3b43-48a3-b509-796d41625171")
361    @TelephonyBaseTest.tel_test_wrap
362    def test_emergency_call_lte_wcdma_csfb_redirection(self):
363        """ Test Emergency call functionality on LTE.
364            CSFB type is REDIRECTION
365
366        Steps:
367        1. Setup CallBox on LTE and WCDMA network, make sure DUT register on LTE network.
368        2. Make an emergency call to 911. Make sure DUT does not CSFB to WCDMA.
369        3. Make sure Anritsu receives the call and accept.
370        4. Tear down the call.
371
372        Expected Results:
373        2. Emergency call succeed. DUT does not CSFB to WCDMA.
374        3. Anritsu can accept the call.
375        4. Tear down call succeed.
376
377        Returns:
378            True if pass; False if fail
379        """
380        return self._setup_emergency_call(
381            set_system_model_lte_wcdma,
382            self._phone_setup_lte_wcdma,
383            emergency_number=self.emergency_call_number,
384            csfb_type=CsfbType.CSFB_TYPE_REDIRECTION,
385            is_ims_call=True)
386
387    @test_tracker_info(uuid="8deb6b21-2cb0-4241-bcad-6cd62a340b07")
388    @TelephonyBaseTest.tel_test_wrap
389    def test_emergency_call_lte_wcdma_csfb_handover(self):
390        """ Test Emergency call functionality on LTE.
391            CSFB type is HANDOVER
392
393        Steps:
394        1. Setup CallBox on LTE and WCDMA network, make sure DUT register on LTE network.
395        2. Make an emergency call to 911. Make sure DUT does not CSFB to WCDMA.
396        3. Make sure Anritsu receives the call and accept.
397        4. Tear down the call.
398
399        Expected Results:
400        2. Emergency call succeed. DUT does not CSFB to WCDMA.
401        3. Anritsu can accept the call.
402        4. Tear down call succeed.
403
404        Returns:
405            True if pass; False if fail
406        """
407        return self._setup_emergency_call(
408            set_system_model_lte_wcdma,
409            self._phone_setup_lte_wcdma,
410            emergency_number=self.emergency_call_number,
411            csfb_type=CsfbType.CSFB_TYPE_HANDOVER,
412            is_ims_call=True)
413
414    @test_tracker_info(uuid="52b6b783-de77-497d-87e0-63c930e6c9bb")
415    @TelephonyBaseTest.tel_test_wrap
416    def test_emergency_call_lte_1x_csfb(self):
417        """ Test Emergency call functionality on LTE (CSFB to 1x).
418
419        Steps:
420        1. Setup CallBox on LTE and CDMA 1X network, make sure DUT register on LTE network.
421        2. Make an emergency call to 911. Make sure DUT CSFB to 1x.
422        3. Make sure Anritsu receives the call and accept.
423        4. Tear down the call.
424
425        Expected Results:
426        2. Emergency call succeed. DUT CSFB to 1x.
427        3. Anritsu can accept the call.
428        4. Tear down call succeed.
429
430        Returns:
431            True if pass; False if fail
432        """
433        return self._setup_emergency_call(
434            set_system_model_lte_1x,
435            self._phone_setup_lte_1x,
436            emergency_number=self.emergency_call_number)
437
438    @test_tracker_info(uuid="fcdd5a4f-fdf2-44dc-b1b2-44ab175791ce")
439    @TelephonyBaseTest.tel_test_wrap
440    def test_emergency_call_wcdma(self):
441        """ Test Emergency call functionality on WCDMA
442
443        Steps:
444        1. Setup CallBox on WCDMA network, make sure DUT register on WCDMA network.
445        2. Make an emergency call to 911.
446        3. Make sure Anritsu receives the call and accept.
447        4. Tear down the call.
448
449        Expected Results:
450        2. Emergency call succeed.
451        3. Anritsu can accept the call.
452        4. Tear down call succeed.
453
454        Returns:
455            True if pass; False if fail
456        """
457        return self._setup_emergency_call(
458            set_system_model_wcdma,
459            self._phone_setup_wcdma,
460            emergency_number=self.emergency_call_number)
461
462    @test_tracker_info(uuid="295c3188-24e2-4c53-80c6-3d3001e2ff16")
463    @TelephonyBaseTest.tel_test_wrap
464    def test_emergency_call_gsm(self):
465        """ Test Emergency call functionality on GSM
466
467        Steps:
468        1. Setup CallBox on GSM network, make sure DUT register on GSM network.
469        2. Make an emergency call to 911.
470        3. Make sure Anritsu receives the call and accept.
471        4. Tear down the call.
472
473        Expected Results:
474        2. Emergency call succeed.
475        3. Anritsu can accept the call.
476        4. Tear down call succeed.
477
478        Returns:
479            True if pass; False if fail
480        """
481        return self._setup_emergency_call(
482            set_system_model_gsm,
483            self._phone_setup_gsm,
484            emergency_number=self.emergency_call_number)
485
486    @test_tracker_info(uuid="4f21bfc0-a0a9-43b8-9285-dcfb131a3a04")
487    @TelephonyBaseTest.tel_test_wrap
488    def test_emergency_call_1x(self):
489        """ Test Emergency call functionality on CDMA 1X
490
491        Steps:
492        1. Setup CallBox on 1x network, make sure DUT register on 1x network.
493        2. Make an emergency call to 911.
494        3. Make sure Anritsu receives the call and accept.
495        4. Tear down the call.
496
497        Expected Results:
498        2. Emergency call succeed.
499        3. Anritsu can accept the call.
500        4. Tear down call succeed.
501
502        Returns:
503            True if pass; False if fail
504        """
505        return self._setup_emergency_call(
506            set_system_model_1x,
507            self._phone_setup_1x,
508            emergency_number=self.emergency_call_number)
509
510    @test_tracker_info(uuid="6dfd3e1d-7faa-426f-811a-ebd5e54f9c9a")
511    @TelephonyBaseTest.tel_test_wrap
512    def test_emergency_call_1x_evdo(self):
513        """ Test Emergency call functionality on CDMA 1X with EVDO
514
515        Steps:
516        1. Setup CallBox on 1x and EVDO network, make sure DUT register on 1x network.
517        2. Make an emergency call to 911.
518        3. Make sure Anritsu receives the call and accept.
519        4. Tear down the call.
520
521        Expected Results:
522        2. Emergency call succeed.
523        3. Anritsu can accept the call.
524        4. Tear down call succeed.
525
526        Returns:
527            True if pass; False if fail
528        """
529        return self._setup_emergency_call(
530            set_system_model_1x_evdo,
531            self._phone_setup_1x,
532            emergency_number=self.emergency_call_number)
533
534    @test_tracker_info(uuid="40f9897e-4924-4896-9f2c-0b4f45331251")
535    @TelephonyBaseTest.tel_test_wrap
536    def test_emergency_call_1x_apm(self):
537        """ Test Emergency call functionality on Airplane mode
538
539        Steps:
540        1. Setup CallBox on 1x network.
541        2. Turn on Airplane mode on DUT. Make an emergency call to 911.
542        3. Make sure Anritsu receives the call and accept.
543        4. Tear down the call.
544
545        Expected Results:
546        2. Emergency call succeed.
547        3. Anritsu can accept the call.
548        4. Tear down call succeed.
549
550        Returns:
551            True if pass; False if fail
552        """
553        return self._setup_emergency_call(
554            set_system_model_1x,
555            self._phone_setup_airplane_mode,
556            is_wait_for_registration=False,
557            emergency_number=self.emergency_call_number)
558
559    @test_tracker_info(uuid="5997c004-449b-4a5e-816e-2ff0c0eb928d")
560    @TelephonyBaseTest.tel_test_wrap
561    def test_emergency_call_wcdma_apm(self):
562        """ Test Emergency call functionality on Airplane mode
563
564        Steps:
565        1. Setup CallBox on WCDMA network.
566        2. Make an emergency call to 911.
567        3. Make sure Anritsu receives the call and accept.
568        4. Tear down the call.
569
570        Expected Results:
571        2. Emergency call succeed.
572        3. Anritsu can accept the call.
573        4. Tear down call succeed.
574
575        Returns:
576            True if pass; False if fail
577        """
578        return self._setup_emergency_call(
579            set_system_model_wcdma,
580            self._phone_setup_airplane_mode,
581            is_wait_for_registration=False,
582            emergency_number=self.emergency_call_number)
583
584    @test_tracker_info(uuid="9afde8d3-bdf0-41d9-af8c-2a8f36aae169")
585    @TelephonyBaseTest.tel_test_wrap
586    def test_emergency_call_volte_wcdma_srvcc(self):
587        """ Test Emergency call functionality,
588        VoLTE to WCDMA SRVCC
589        Steps:
590        1. Setup CallBox on VoLTE network with WCDMA.
591        2. Turn on DUT and enable VoLTE. Make an emergency call to 911.
592        3. Check if VoLTE emergency call connected successfully.
593        4. Handover the call to WCDMA and check if the call is still up.
594        5. Tear down the call.
595
596        Expected Results:
597        1. VoLTE Emergency call is made successfully.
598        2. After SRVCC, the 911 call is not dropped.
599        3. Tear down call succeed.
600
601        Returns:
602            True if pass; False if fail
603        """
604        return self._setup_emergency_call(
605            set_system_model_lte_wcdma,
606            self._phone_setup_volte,
607            phone_idle_volte,
608            srvcc="InCall",
609            emergency_number=self.emergency_call_number,
610            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
611
612    @test_tracker_info(uuid="2e454f11-e77d-452a-bcac-7271378953ed")
613    @TelephonyBaseTest.tel_test_wrap
614    def test_emergency_call_volte_gsm_srvcc(self):
615        """ Test Emergency call functionality,
616        VoLTE to GSM SRVCC
617        Steps:
618        1. Setup CallBox on VoLTE network with GSM.
619        2. Turn on DUT and enable VoLTE. Make an emergency call to 911.
620        3. Check if VoLTE emergency call connected successfully.
621        4. Handover the call to GSM and check if the call is still up.
622        5. Tear down the call.
623
624        Expected Results:
625        1. VoLTE Emergency call is made successfully.
626        2. After SRVCC, the 911 call is not dropped.
627        3. Tear down call succeed.
628
629        Returns:
630            True if pass; False if fail
631        """
632        return self._setup_emergency_call(
633            set_system_model_lte_gsm,
634            self._phone_setup_volte,
635            phone_idle_volte,
636            srvcc="InCall",
637            emergency_number=self.emergency_call_number,
638            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
639
640    @test_tracker_info(uuid="4dae7e62-b73e-4ba1-92ee-ecc121b898b3")
641    @TelephonyBaseTest.tel_test_wrap
642    def test_emergency_call_csfb_1x_lte_call_failure(self):
643        """ Test Emergency call functionality,
644        CSFB to CDMA1x after VoLTE call failure
645        Ref: VzW LTE E911 test plan, 2.23, VZ_TC_LTEE911_7481
646        Steps:
647        1. Setup CallBox on VoLTE network with CDMA1x.
648        2. Turn on DUT and enable VoLTE. Make an emergency call to 911.
649        3. Make sure Anritsu IMS server does not answer the call
650        4. The DUT requests CSFB to 1XCDMA and Anritsu accepts the call.
651        5. Tear down the call.
652
653        Expected Results:
654        1. VoLTE Emergency call is made.
655        2. Anritsu receive the call but does not answer.
656        3. The 911 call CSFB to CDMA1x and answered successfully.
657        4. Tear down call succeed.
658
659        Returns:
660            True if pass; False if fail
661        """
662        return self._setup_emergency_call(
663            set_system_model_lte_1x,
664            self._phone_setup_volte,
665            phone_idle_volte,
666            srlte_csfb="lte_call_failure",
667            emergency_number=self.emergency_call_number,
668            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
669
670    @test_tracker_info(uuid="e98c9101-1ab6-497e-9d67-a4ff62d28fea")
671    @TelephonyBaseTest.tel_test_wrap
672    def test_emergency_call_csfb_1x_ims_unregistered(self):
673        """ Test Emergency call functionality,
674        CSFB to CDMA1x because ims registration delcined
675        Ref: VzW LTE E911 test plan, 2.25, VZ_TC_LTEE911_7483
676        Steps:
677        1. Setup CallBox on VoLTE network with CDMA1x.
678        2. Setup Anritsu IMS server to decline IMS registration
679        3. Turn on DUT and enable VoLTE. Make an emergency call to 911.
680        4. The DUT requests CSFB to 1XCDMA and Anritsu accepts the call.
681        5. Tear down the call.
682
683        Expected Results:
684        1. Phone registers on LTE network with VoLTE enabled.
685        2. When Emergency call is made, phone request CSFB to CDMA1x.
686        3. The 911 call on CDMA1x is answered successfully.
687        4. Tear down call succeed.
688
689        Returns:
690            True if pass; False if fail
691        """
692        return self._setup_emergency_call(
693            set_system_model_lte_1x,
694            self._phone_setup_volte,
695            None,
696            srlte_csfb="ims_unregistered",
697            emergency_number=self.emergency_call_number,
698            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
699
700    @test_tracker_info(uuid="d96e1b9b-2f6d-49f3-a203-f4277056869e")
701    @TelephonyBaseTest.tel_test_wrap
702    def test_emergency_call_csfb_1x_ps911_unsupported(self):
703        """ Test Emergency call functionality,
704        CSFB to CDMA1x because MME does not support PS911, by setting
705        Emergency Bearer Service not supported in EPS network feature
706        Ref: VzW LTE E911 test plan, 2.26, VZ_TC_LTEE911_8357
707        Steps:
708        1. Setup CallBox on VoLTE network with CDMA1x.
709        2. Setup Emergency Bearer Service not supported in EPS network feature
710        3. Turn on DUT and enable VoLTE. Make an emergency call to 911.
711        4. The DUT requests CSFB to 1XCDMA and Anritsu accepts the call.
712        5. Tear down the call.
713
714        Expected Results:
715        1. Phone registers on LTE network with VoLTE enabled.
716        2. When Emergency call is made, phone request CSFB to CDMA1x.
717        3. The 911 call on CDMA1x is answered successfully.
718        4. Tear down call succeed.
719
720        Returns:
721            True if pass; False if fail
722        """
723        return self._setup_emergency_call(
724            set_system_model_lte_1x,
725            self._phone_setup_volte,
726            phone_idle_volte,
727            srlte_csfb="ps911_unsupported",
728            emergency_number=self.emergency_call_number,
729            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
730
731    @test_tracker_info(uuid="f7d48841-b8ef-4031-99de-28534aaf4c44")
732    @TelephonyBaseTest.tel_test_wrap
733    def test_emergency_call_csfb_1x_emc_barred(self):
734        """ Test Emergency call functionality,
735        CSFB to CDMA1x because SIB2 Emergency Barred,
736        by setting Access Class Barred for Emergency
737        Ref: VzW LTE E911 test plan, 2.27, VZ_TC_LTEE911_8358
738        Steps:
739        1. Setup CallBox on VoLTE network with CDMA1x.
740        2. Set Access Class Barred for Emergency in SIB2
741        3. Turn on DUT and enable VoLTE. Make an emergency call to 911.
742        4. The DUT requests CSFB to 1XCDMA and Anritsu accepts the call.
743        5. Tear down the call.
744
745        Expected Results:
746        1. Phone registers on LTE network with VoLTE enabled.
747        2. When Emergency call is made, phone request CSFB to CDMA1x.
748        3. The 911 call on CDMA1x is answered successfully.
749        4. Tear down call succeed.
750
751        Returns:
752            True if pass; False if fail
753        """
754        return self._setup_emergency_call(
755            set_system_model_lte_1x,
756            self._phone_setup_volte,
757            phone_idle_volte,
758            srlte_csfb="emc_barred",
759            emergency_number=self.emergency_call_number,
760            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
761
762    @test_tracker_info(uuid="5bbbecec-0fef-430b-acbd-01ef7c7055c0")
763    @TelephonyBaseTest.tel_test_wrap
764    def test_emergency_call_volte_1x(self):
765        """ Test Emergency call functionality on VoLTE with CDMA1x
766        Ref: VzW LTE E911 test plan, 2.24, VZ_TC_LTEE911_7482
767        Steps:
768        1. Setup CallBox on VoLTE network with CDMA1x.
769        2. Turn on DUT and enable VoLTE. Make an emergency call to 911.
770        3. Make sure Anritsu receives the call and accept.
771        4. Tear down the call.
772
773        Expected Results:
774        2. Emergency call succeed.
775        3. Anritsu can accept the call.
776        4. Tear down call succeed.
777
778        Returns:
779            True if pass; False if fail
780        """
781        return self._setup_emergency_call(
782            set_system_model_lte_1x,
783            self._phone_setup_volte,
784            phone_idle_volte,
785            is_ims_call=True,
786            emergency_number=self.emergency_call_number,
787            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
788
789    @test_tracker_info(uuid="e32862e0-ec11-4de8-8b9a-851bab9feb29")
790    @TelephonyBaseTest.tel_test_wrap
791    def test_emergency_call_volte(self):
792        """ Test Emergency call functionality on VoLTE
793
794        Steps:
795        1. Setup CallBox on VoLTE network.
796        2. Turn on DUT and enable VoLTE. Make an emergency call to 911.
797        3. Make sure Anritsu receives the call and accept.
798        4. Tear down the call.
799
800        Expected Results:
801        2. Emergency call succeed.
802        3. Anritsu can accept the call.
803        4. Tear down call succeed.
804
805        Returns:
806            True if pass; False if fail
807        """
808        return self._setup_emergency_call(
809            set_system_model_lte,
810            self._phone_setup_volte,
811            phone_idle_volte,
812            is_ims_call=True,
813            emergency_number=self.emergency_call_number,
814            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
815
816    @test_tracker_info(uuid="fa5b4e52-c249-42ec-a9d3-9523336f88f7")
817    @TelephonyBaseTest.tel_test_wrap
818    def test_emergency_call_volte_apm(self):
819        """ Test Emergency call functionality on VoLTE
820
821        Steps:
822        1. Setup CallBox on VoLTE network.
823        2. Turn on Airplane mode on DUT. Make an emergency call to 911.
824        3. Make sure Anritsu receives the call and accept.
825        4. Tear down the call.
826
827        Expected Results:
828        2. Emergency call succeed.
829        3. Anritsu can accept the call.
830        4. Tear down call succeed.
831
832        Returns:
833            True if pass; False if fail
834        """
835        return self._setup_emergency_call(
836            set_system_model_lte,
837            self._phone_setup_volte_airplane_mode,
838            is_ims_call=True,
839            is_wait_for_registration=False,
840            emergency_number=self.emergency_call_number,
841            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
842
843    @test_tracker_info(uuid="260e4892-fdae-4d49-bfc6-04fe72a5a715")
844    @TelephonyBaseTest.tel_test_wrap
845    def test_emergency_call_no_sim_wcdma(self):
846        """ Test Emergency call functionality with no SIM.
847
848        Steps:
849        1. Setup CallBox on WCDMA network.
850        2. Make an emergency call to 911.
851        3. Make sure Anritsu receives the call and accept.
852        4. Tear down the call.
853
854        Expected Results:
855        2. Emergency call succeed.
856        3. Anritsu can accept the call.
857        4. Tear down call succeed.
858
859        Returns:
860            True if pass; False if fail
861        """
862        return self._setup_emergency_call(
863            set_system_model_wcdma,
864            self._phone_disable_airplane_mode,
865            emergency_number=self.emergency_call_number,
866            is_wait_for_registration=False)
867
868    @test_tracker_info(uuid="2dbbbde5-c298-4a2d-ae65-b739d1dd1445")
869    @TelephonyBaseTest.tel_test_wrap
870    def test_emergency_call_no_sim_1x(self):
871        """ Test Emergency call functionality with no SIM.
872
873        Steps:
874        1. Setup CallBox on 1x network.
875        2. Make an emergency call to 911.
876        3. Make sure Anritsu receives the call and accept.
877        4. Tear down the call.
878
879        Expected Results:
880        2. Emergency call succeed.
881        3. Anritsu can accept the call.
882        4. Tear down call succeed.
883
884        Returns:
885            True if pass; False if fail
886        """
887        return self._setup_emergency_call(
888            set_system_model_1x,
889            self._phone_disable_airplane_mode,
890            emergency_number=self.emergency_call_number,
891            is_wait_for_registration=False)
892
893    @test_tracker_info(uuid="fa77dee2-3235-42e0-b24d-c8fdb3fbef2f")
894    @TelephonyBaseTest.tel_test_wrap
895    def test_emergency_call_no_sim_gsm(self):
896        """ Test Emergency call functionality with no SIM.
897
898        Steps:
899        1. Setup CallBox on GSM network.
900        2. Make an emergency call to 911.
901        3. Make sure Anritsu receives the call and accept.
902        4. Tear down the call.
903
904        Expected Results:
905        2. Emergency call succeed.
906        3. Anritsu can accept the call.
907        4. Tear down call succeed.
908
909        Returns:
910            True if pass; False if fail
911        """
912        return self._setup_emergency_call(
913            set_system_model_gsm,
914            self._phone_disable_airplane_mode,
915            emergency_number=self.emergency_call_number,
916            is_wait_for_registration=False)
917
918    @test_tracker_info(uuid="9ead5c6a-b4cb-40d5-80b0-54d3c7ad31ff")
919    @TelephonyBaseTest.tel_test_wrap
920    def test_emergency_call_no_sim_volte(self):
921        """ Test Emergency call functionality with no SIM.
922
923        Steps:
924        1. Setup CallBox on VoLTE network.
925        2. Make an emergency call to 911.
926        3. Make sure Anritsu receives the call and accept.
927        4. Tear down the call.
928
929        Expected Results:
930        2. Emergency call succeed.
931        3. Anritsu can accept the call.
932        4. Tear down call succeed.
933
934        Returns:
935            True if pass; False if fail
936        """
937        return self._setup_emergency_call(
938            set_system_model_lte,
939            self._phone_disable_airplane_mode,
940            is_wait_for_registration=False,
941            is_ims_call=True,
942            emergency_number=self.emergency_call_number,
943            wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS)
944
945    @test_tracker_info(uuid="d6bdc1d7-0a08-4e6e-9de8-4084abb48bad")
946    @TelephonyBaseTest.tel_test_wrap
947    def test_emergency_call_no_sim_1x_ecbm(self):
948        """ Test Emergency call functionality with no SIM.
949
950        Steps:
951        1. Setup CallBox on 1x network.
952        2. Make an emergency call to 911.
953        3. Make sure Anritsu receives the call and accept.
954        4. Tear down the call.
955        5. Make a call from Callbox to DUT.
956        6. Verify DUT receive the incoming call.
957        7. Answer on DUT, verify DUT can answer the call correctly.
958        8. Hangup the call on DUT.
959
960        Expected Results:
961        2. Emergency call succeed.
962        3. Anritsu can accept the call.
963        4. Tear down call succeed.
964        6. DUT receive incoming call.
965        7. DUT answer the call correctly.
966        8. Tear down call succeed.
967
968        Returns:
969            True if pass; False if fail
970        """
971        if not self._setup_emergency_call(
972                set_system_model_1x,
973                self._phone_disable_airplane_mode,
974                emergency_number=self.emergency_call_number,
975                is_wait_for_registration=False):
976            self.log.error("Failed to make 911 call.")
977            return False
978        return call_mt_setup_teardown(self.log, self.ad,
979                                      self.anritsu.get_VirtualPhone(), None,
980                                      CALL_TEARDOWN_PHONE, RAT_1XRTT)
981
982    """ Tests End """
983