• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3#   Copyright 2022 - 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 Telephony Pre Check In Sanity
18"""
19
20import time
21
22from acts import signals
23from acts.test_decorators import test_tracker_info
24from acts_contrib.test_utils.tel.loggers.protos.telephony_metric_pb2 import TelephonyVoiceTestResult
25from acts_contrib.test_utils.tel.loggers.telephony_metric_logger import TelephonyMetricLogger
26from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
27from acts_contrib.test_utils.tel.tel_data_utils import get_mobile_data_usage
28from acts_contrib.test_utils.tel.tel_data_utils import remove_mobile_data_usage_limit
29from acts_contrib.test_utils.tel.tel_data_utils import set_mobile_data_usage_limit
30from acts_contrib.test_utils.tel.tel_data_utils import test_call_setup_in_active_data_transfer
31from acts_contrib.test_utils.tel.tel_data_utils import test_call_setup_in_active_youtube_video
32from acts_contrib.test_utils.tel.tel_data_utils import call_epdg_to_epdg_wfc
33from acts_contrib.test_utils.tel.tel_data_utils import test_wifi_cell_switching_in_call
34from acts_contrib.test_utils.tel.tel_defines import CARRIER_VZW
35from acts_contrib.test_utils.tel.tel_defines import DIRECTION_MOBILE_ORIGINATED
36from acts_contrib.test_utils.tel.tel_defines import DIRECTION_MOBILE_TERMINATED
37from acts_contrib.test_utils.tel.tel_defines import GEN_2G
38from acts_contrib.test_utils.tel.tel_defines import GEN_4G
39from acts_contrib.test_utils.tel.tel_defines import GEN_3G
40from acts_contrib.test_utils.tel.tel_defines import PHONE_TYPE_CDMA
41from acts_contrib.test_utils.tel.tel_defines import PHONE_TYPE_GSM
42from acts_contrib.test_utils.tel.tel_defines import TOTAL_LONG_CALL_DURATION
43from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL
44from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_FOR_IMS
45from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING
46from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED
47from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_ONLY
48from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
49from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_2g
50from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_3g
51from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_csfb
52from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_iwlan
53from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_volte
54from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_csfb
55from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_iwlan
56from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_iwlan_cellular_preferred
57from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_2g
58from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_3g
59from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_general
60from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_volte
61from acts_contrib.test_utils.tel.tel_subscription_utils import get_incoming_voice_sub_id
62from acts_contrib.test_utils.tel.tel_subscription_utils import get_outgoing_voice_sub_id
63from acts_contrib.test_utils.tel.tel_test_utils import get_phone_number
64from acts_contrib.test_utils.tel.tel_test_utils import install_dialer_apk
65from acts_contrib.test_utils.tel.tel_test_utils import num_active_calls
66from acts_contrib.test_utils.tel.tel_test_utils import STORY_LINE
67from acts_contrib.test_utils.tel.tel_voice_utils import hangup_call
68from acts_contrib.test_utils.tel.tel_voice_utils import hold_unhold_test
69from acts_contrib.test_utils.tel.tel_voice_utils import initiate_call
70from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call
71from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_1x
72from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_2g
73from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_3g
74from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
75from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
76from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_not_iwlan
77from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_wcdma
78from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
79from acts_contrib.test_utils.tel.tel_voice_utils import _test_call_long_duration
80from acts_contrib.test_utils.tel.tel_voice_utils import call_setup_teardown
81from acts_contrib.test_utils.tel.tel_voice_utils import call_voicemail_erase_all_pending_voicemail
82from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_leave_voice_mail
83from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_long_seq
84from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_short_seq
85from acts_contrib.test_utils.tel.tel_voice_utils import wait_and_answer_call
86from acts_contrib.test_utils.tel.tel_voice_utils import wait_for_in_call_active
87from acts_contrib.test_utils.tel.tel_voice_utils import wait_for_ringing_call
88from acts_contrib.test_utils.tel.tel_wifi_utils import set_wifi_to_default
89from acts_contrib.test_utils.tel.tel_wifi_utils import wifi_toggle_state
90from acts.libs.utils.multithread import multithread_func
91
92DEFAULT_PING_DURATION = 120  # in seconds
93
94CallResult = TelephonyVoiceTestResult.CallResult.Value
95
96
97class TelLiveVoiceTest(TelephonyBaseTest):
98    def setup_class(self):
99        super().setup_class()
100
101        self.stress_test_number = self.get_stress_test_number()
102        self.long_call_duration = self.user_params.get(
103            "long_call_duration",
104            TOTAL_LONG_CALL_DURATION)
105        self.number_of_devices = 2
106        self.call_server_number = self.user_params.get(
107                "call_server_number", STORY_LINE)
108        self.tel_logger = TelephonyMetricLogger.for_test_case()
109        self.dialer_util = self.user_params.get("dialer_apk", None)
110        if isinstance(self.dialer_util, list):
111            self.dialer_util = self.dialer_util[0]
112
113        if self.dialer_util:
114            ads = self.android_devices
115            for ad in ads:
116                install_dialer_apk(ad, self.dialer_util)
117
118    def get_carrier_name(self, ad):
119        return ad.adb.getprop("gsm.sim.operator.alpha")
120
121    def check_band_support(self,ad):
122        carrier = ad.adb.getprop("gsm.sim.operator.alpha")
123
124        if int(ad.adb.getprop("ro.product.first_api_level")) > 30 and (
125                carrier == CARRIER_VZW):
126            raise signals.TestSkip(
127                "Device Doesn't Support 2g/3G Band.")
128
129    def _is_phone_in_call_not_iwlan(self):
130        return is_phone_in_call_not_iwlan(self.log, self.android_devices[0])
131
132    def _is_phone_in_call_iwlan(self):
133        return is_phone_in_call_iwlan(self.log, self.android_devices[0])
134
135
136    """ Tests Begin """
137
138    @TelephonyBaseTest.tel_test_wrap
139    @test_tracker_info(uuid="c5009f8c-eb1d-4cd9-85ce-604298bbeb3e")
140    def test_call_to_answering_machine(self):
141        """ Voice call to an answering machine.
142
143        1. Make Sure PhoneA attached to voice network.
144        2. Call from PhoneA to Storyline
145        3. Verify call is in ACTIVE state
146        4. Hangup Call from PhoneA
147
148        Raises:
149            TestFailure if not success.
150        """
151        ad = self.android_devices[0]
152
153        if not phone_setup_voice_general(ad.log, ad):
154            ad.log.error("Phone Failed to Set Up Properly for Voice.")
155            return False
156        for iteration in range(3):
157            result = True
158            ad.log.info("Attempt %d", iteration + 1)
159            if not initiate_call(ad.log, ad, self.call_server_number):
160                ad.log.error("Call Failed to Initiate")
161                result = False
162                continue
163            if not wait_for_in_call_active(ad, 60, 3):
164                ad.log.error("Waiting for Call in Active Failed")
165                result = False
166            time.sleep(WAIT_TIME_IN_CALL)
167            if not is_phone_in_call(ad.log, ad):
168                ad.log.error("Call Dropped")
169                result = False
170            if not hangup_call(ad.log, ad):
171                ad.log.error("Call Failed to Hangup")
172                result = False
173            if result:
174                ad.log.info("Call test PASS in iteration %d", iteration + 1)
175                return True
176            time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)
177        ad.log.info("Call test FAIL in all 3 iterations")
178        return False
179
180
181    @TelephonyBaseTest.tel_test_wrap
182    @test_tracker_info(uuid="fca3f9e1-447a-416f-9a9c-50b7161981bf")
183    def test_call_mo_voice_general(self):
184        """ General voice to voice call.
185
186        1. Make Sure PhoneA attached to voice network.
187        2. Make Sure PhoneB attached to voice network.
188        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
189        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
190
191        Raises:
192            TestFailure if not success.
193        """
194        ads = self.android_devices
195
196        tasks = [(phone_setup_voice_general, (self.log, ads[0])),
197                 (phone_setup_voice_general, (self.log, ads[1]))]
198        if not multithread_func(self.log, tasks):
199            self.log.error("Phone Failed to Set Up Properly.")
200            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
201            raise signals.TestFailure("Failed",
202                extras={"fail_reason": "Phone Failed to Set Up Properly."})
203
204        result = two_phone_call_short_seq(self.log, ads[0], None, None, ads[1],
205                                        None, None)
206        self.tel_logger.set_result(result.result_value)
207        if not result:
208            raise signals.TestFailure("Failed",
209                extras={"fail_reason": str(result.result_value)})
210
211    @TelephonyBaseTest.tel_test_wrap
212    @test_tracker_info(uuid="69faeb84-3830-47c0-ad80-dc657381a83b")
213    def test_call_mt_voice_general(self):
214        """ General voice to voice call.
215
216        1. Make Sure PhoneA attached to voice network.
217        2. Make Sure PhoneB attached to voice network.
218        3. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
219        4. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
220
221        Raises:
222            TestFailure if not success.
223        """
224        ads = self.android_devices
225
226        tasks = [(phone_setup_voice_general, (self.log, ads[0])),
227                 (phone_setup_voice_general, (self.log, ads[1]))]
228        if not multithread_func(self.log, tasks):
229            self.log.error("Phone Failed to Set Up Properly.")
230            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
231            raise signals.TestFailure("Failed",
232                extras={"fail_reason": "Phone Failed to Set Up Properly."})
233
234        result = two_phone_call_short_seq(self.log, ads[1], None, None, ads[0],
235                                        None, None)
236        self.tel_logger.set_result(result.result_value)
237        if not result:
238            raise signals.TestFailure("Failed",
239                extras={"fail_reason": str(result.result_value)})
240
241    @test_tracker_info(uuid="b2de097b-70e1-4242-b555-c1aa0a5acd8c")
242    @TelephonyBaseTest.tel_test_wrap
243    def test_call_volte_to_volte(self):
244        """ VoLTE to VoLTE call test
245
246        1. Make Sure PhoneA is in LTE mode (with VoLTE).
247        2. Make Sure PhoneB is in LTE mode (with VoLTE).
248        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
249        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
250
251        Raises:
252            TestFailure if not success.
253        """
254        ads = self.android_devices
255
256        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
257                                                           (self.log, ads[1]))]
258        if not multithread_func(self.log, tasks):
259            self.log.error("Phone Failed to Set Up Properly.")
260            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
261            raise signals.TestFailure("Failed",
262                extras={"fail_reason": "Phone Failed to Set Up Properly."})
263
264        result = two_phone_call_short_seq(
265            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
266            phone_idle_volte, is_phone_in_call_volte, None,
267            WAIT_TIME_IN_CALL_FOR_IMS)
268        self.tel_logger.set_result(result.result_value)
269        if not result:
270            raise signals.TestFailure("Failed",
271                extras={"fail_reason": str(result.result_value)})
272
273    @test_tracker_info(uuid="3c7f5a09-0177-4469-9994-cd5e7dd7c7fe")
274    @TelephonyBaseTest.tel_test_wrap
275    def test_call_volte_to_volte_7_digit_dialing(self):
276        """ VoLTE to VoLTE call test, dial with 7 digit number
277
278        1. Make Sure PhoneA is in LTE mode (with VoLTE).
279        2. Make Sure PhoneB is in LTE mode (with VoLTE).
280        3. Call from PhoneA to PhoneB by 7-digit phone number, accept on PhoneB.
281
282        Returns:
283            True if pass; False if fail.
284        """
285        ads = self.android_devices
286        if ads[0].droid.telephonyGetSimCountryIso() == "ca":
287            raise signals.TestSkip("7 digit dialing not supported")
288        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
289                                                           (self.log, ads[1]))]
290        if not multithread_func(self.log, tasks):
291            self.log.error("Phone Failed to Set Up Properly.")
292            return False
293
294        return call_setup_teardown(
295            self.log,
296            ads[0],
297            ads[1],
298            ads[0],
299            is_phone_in_call_volte,
300            is_phone_in_call_volte,
301            WAIT_TIME_IN_CALL_FOR_IMS,
302            dialing_number_length=7)
303
304    @test_tracker_info(uuid="721ef935-a03c-4d0f-85b9-4753d857162f")
305    @TelephonyBaseTest.tel_test_wrap
306    def test_call_volte_to_volte_10_digit_dialing(self):
307        """ VoLTE to VoLTE call test, dial with 10 digit number
308
309        1. Make Sure PhoneA is in LTE mode (with VoLTE).
310        2. Make Sure PhoneB is in LTE mode (with VoLTE).
311        3. Call from PhoneA to PhoneB by 10-digit phone number, accept on PhoneB.
312
313        Returns:
314            True if pass; False if fail.
315        """
316        if self.android_devices[0].droid.telephonyGetSimCountryIso() == "ca":
317            raise signals.TestSkip("10 digit dialing not supported")
318
319        ads = self.android_devices
320
321        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
322                                                           (self.log, ads[1]))]
323        if not multithread_func(self.log, tasks):
324            self.log.error("Phone Failed to Set Up Properly.")
325            return False
326
327        if not call_setup_teardown(
328            self.log,
329            ads[0],
330            ads[1],
331            ads[0],
332            is_phone_in_call_volte,
333            is_phone_in_call_volte,
334            WAIT_TIME_IN_CALL_FOR_IMS,
335            dialing_number_length=10):
336            return False
337
338        return True
339
340    @test_tracker_info(uuid="4fd3aa62-2398-4cee-994e-7fc5cadbcbc1")
341    @TelephonyBaseTest.tel_test_wrap
342    def test_call_volte_to_volte_11_digit_dialing(self):
343        """ VoLTE to VoLTE call test, dial with 11 digit number
344
345        1. Make Sure PhoneA is in LTE mode (with VoLTE).
346        2. Make Sure PhoneB is in LTE mode (with VoLTE).
347        3. Call from PhoneA to PhoneB by 11-digit phone number, accept on PhoneB.
348
349        Returns:
350            True if pass; False if fail.
351        """
352        ads = self.android_devices
353
354        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
355                                                           (self.log, ads[1]))]
356        if not multithread_func(self.log, tasks):
357            self.log.error("Phone Failed to Set Up Properly.")
358            return False
359
360        return call_setup_teardown(
361            self.log,
362            ads[0],
363            ads[1],
364            ads[0],
365            is_phone_in_call_volte,
366            is_phone_in_call_volte,
367            WAIT_TIME_IN_CALL_FOR_IMS,
368            dialing_number_length=11)
369
370    @test_tracker_info(uuid="969abdac-6a57-442a-9c40-48199bd8d556")
371    @TelephonyBaseTest.tel_test_wrap
372    def test_call_volte_to_volte_12_digit_dialing(self):
373        """ VoLTE to VoLTE call test, dial with 12 digit number
374
375        1. Make Sure PhoneA is in LTE mode (with VoLTE).
376        2. Make Sure PhoneB is in LTE mode (with VoLTE).
377        3. Call from PhoneA to PhoneB by 12-digit phone number, accept on PhoneB.
378
379        Returns:
380            True if pass; False if fail.
381        """
382        ads = self.android_devices
383
384        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
385                                                           (self.log, ads[1]))]
386        if not multithread_func(self.log, tasks):
387            self.log.error("Phone Failed to Set Up Properly.")
388            return False
389
390        return call_setup_teardown(
391            self.log,
392            ads[0],
393            ads[1],
394            ads[0],
395            is_phone_in_call_volte,
396            is_phone_in_call_volte,
397            WAIT_TIME_IN_CALL_FOR_IMS,
398            dialing_number_length=12)
399
400    @test_tracker_info(uuid="6b13a03d-c9ff-43d7-9798-adbead7688a4")
401    @TelephonyBaseTest.tel_test_wrap
402    def test_call_volte_to_csfb_3g(self):
403        """ VoLTE to CSFB 3G call test
404
405        1. Make Sure PhoneA is in LTE mode (with VoLTE).
406        2. Make Sure PhoneB is in LTE mode (without VoLTE).
407        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
408        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
409
410        Raises:
411            TestFailure if not success.
412        """
413        ads = self.android_devices
414        self.check_band_support(ads[0])
415
416        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_csfb,
417                                                           (self.log, ads[1]))]
418        if not multithread_func(self.log, tasks):
419            self.log.error("Phone Failed to Set Up Properly.")
420            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
421            raise signals.TestFailure("Failed",
422                extras={"fail_reason": "Phone Failed to Set Up Properly."})
423
424        result = two_phone_call_short_seq(
425            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
426            phone_idle_csfb, is_phone_in_call_csfb, None)
427        self.tel_logger.set_result(result.result_value)
428        if not result:
429            raise signals.TestFailure("Failed",
430                extras={"fail_reason": str(result.result_value)})
431
432    @test_tracker_info(uuid="38096fdb-324a-4ce0-8836-8bbe713cffc2")
433    @TelephonyBaseTest.tel_test_wrap
434    def test_call_volte_to_csfb_for_tmo(self):
435        """ VoLTE to CSFB 3G call test for TMobile
436
437        1. Make Sure PhoneA is in LTE mode (with VoLTE).
438        2. Make Sure PhoneB is in LTE mode (without VoLTE, CSFB to WCDMA/GSM).
439        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
440        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
441
442        Raises:
443            TestFailure if not success.
444        """
445        ads = self.android_devices
446        self.check_band_support(ads[0])
447
448        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_csfb,
449                                                           (self.log, ads[1]))]
450        if not multithread_func(self.log, tasks):
451            self.log.error("Phone Failed to Set Up Properly.")
452            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
453            raise signals.TestFailure("Failed",
454                extras={"fail_reason": "Phone Failed to Set Up Properly."})
455
456        result = two_phone_call_short_seq(self.log, ads[0], phone_idle_volte,
457                                        None, ads[1], phone_idle_csfb,
458                                        is_phone_in_call_csfb, None)
459        self.tel_logger.set_result(result.result_value)
460        if not result:
461            raise signals.TestFailure("Failed",
462                extras={"fail_reason": str(result.result_value)})
463
464    @test_tracker_info(uuid="82f9515d-a52b-4dec-93a5-997ffdbca76c")
465    @TelephonyBaseTest.tel_test_wrap
466    def test_call_volte_to_csfb_1x_long(self):
467        """ VoLTE to CSFB 1x call test
468
469        1. Make Sure PhoneA is in LTE mode (with VoLTE).
470        2. Make Sure PhoneB is in LTE mode (without VoLTE, CSFB to 1x).
471        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
472        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
473        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
474        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
475
476        Raises:
477            TestFailure if not success.
478        """
479        ads = self.android_devices
480        # Make Sure PhoneB is CDMA phone.
481        if ads[1].droid.telephonyGetPhoneType() != PHONE_TYPE_CDMA:
482            self.log.error(
483                "PhoneB not cdma phone, can not csfb 1x. Stop test.")
484            self.tel_logger.set_result(CallResult("UNAVAILABLE_NETWORK_TYPE"))
485            raise signals.TestFailure("Failed",
486                extras={"fail_reason": "PhoneB not cdma, cannot csfb 1x."})
487
488        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_csfb,
489                                                           (self.log, ads[1]))]
490        if not multithread_func(self.log, tasks):
491            self.log.error("Phone Failed to Set Up Properly.")
492            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
493            raise signals.TestFailure("Failed",
494                extras={"fail_reason": "Phone Failed to Set Up Properly."})
495
496        result = two_phone_call_long_seq(
497            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
498            phone_idle_csfb, is_phone_in_call_1x, None)
499        self.tel_logger.set_result(result.result_value)
500        if not result:
501            raise signals.TestFailure("Failed",
502                extras={"fail_reason": str(result.result_value)})
503
504    @test_tracker_info(uuid="2e57fad6-5eaf-4e7d-8353-8aa6f4c52776")
505    @TelephonyBaseTest.tel_test_wrap
506    def test_call_volte_to_csfb_long(self):
507        """ VoLTE to CSFB WCDMA call test
508
509        1. Make Sure PhoneA is in LTE mode (with VoLTE).
510        2. Make Sure PhoneB is in LTE mode (without VoLTE, CSFB to WCDMA/GSM).
511        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
512        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
513        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
514        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
515
516        Raises:
517            TestFailure if not success.
518        """
519        ads = self.android_devices
520        # Make Sure PhoneB is GSM phone.
521        if ads[1].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM:
522            self.log.error(
523                "PhoneB not gsm phone, can not csfb wcdma. Stop test.")
524            self.tel_logger.set_result(CallResult("UNAVAILABLE_NETWORK_TYPE"))
525            raise signals.TestFailure("Failed",
526                extras={"fail_reason": "PhoneB not gsm, cannot csfb wcdma."})
527
528        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_csfb,
529                                                           (self.log, ads[1]))]
530        if not multithread_func(self.log, tasks):
531            self.log.error("Phone Failed to Setup Properly")
532            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
533            raise signals.TestFailure("Failed",
534                extras={"fail_reason": "Phone Failed to Setup Properly"})
535
536        result = two_phone_call_long_seq(
537            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
538            phone_idle_csfb, is_phone_in_call_csfb, None)
539        self.tel_logger.set_result(result.result_value)
540        if not result:
541            raise signals.TestFailure("Failed",
542                extras={"fail_reason": str(result.result_value)})
543
544    @test_tracker_info(uuid="4bab759f-7610-4cec-893c-0a8aed95f70c")
545    @TelephonyBaseTest.tel_test_wrap
546    def test_call_volte_to_3g(self):
547        """ VoLTE to 3G call test
548
549        1. Make Sure PhoneA is in LTE mode (with VoLTE).
550        2. Make Sure PhoneB is in 3G mode.
551        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
552        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
553
554        Raises:
555            TestFailure if not success.
556        """
557        ads = self.android_devices
558        self.check_band_support(ads[0])
559
560        tasks = [(phone_setup_volte, (self.log, ads[0])),
561                 (phone_setup_voice_3g, (self.log, ads[1]))]
562        if not multithread_func(self.log, tasks):
563            self.log.error("Phone Failed to Set Up Properly.")
564            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
565            raise signals.TestFailure("Failed",
566                extras={"fail_reason": str(result.result_value)})
567
568        result = two_phone_call_short_seq(
569            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
570            phone_idle_3g, is_phone_in_call_3g, None)
571        self.tel_logger.set_result(result.result_value)
572        if not result:
573            raise signals.TestFailure("Failed",
574                extras={"fail_reason": str(result.result_value)})
575
576    @test_tracker_info(uuid="b394cdc5-d88d-4659-8a26-0e58fde69974")
577    @TelephonyBaseTest.tel_test_wrap
578    def test_call_volte_to_3g_1x_long(self):
579        """ VoLTE to 3G 1x call test
580
581        1. Make Sure PhoneA is in LTE mode (with VoLTE).
582        2. Make Sure PhoneB is in 3G 1x mode.
583        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
584        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
585        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
586        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
587
588        Raises:
589            TestFailure if not success.
590        """
591        ads = self.android_devices
592        self.check_band_support(ads[0])
593        # Make Sure PhoneB is CDMA phone.
594        if ads[1].droid.telephonyGetPhoneType() != PHONE_TYPE_CDMA:
595            self.log.error("PhoneB not cdma phone, can not 3g 1x. Stop test.")
596            self.tel_logger.set_result(CallResult("UNAVAILABLE_NETWORK_TYPE"))
597            raise signals.TestFailure("Failed",
598                extras={"fail_reason": "PhoneB not cdma phone, can not 3g 1x."})
599
600        tasks = [(phone_setup_volte, (self.log, ads[0])),
601                 (phone_setup_voice_3g, (self.log, ads[1]))]
602        if not multithread_func(self.log, tasks):
603            self.log.error("Phone Failed to Set Up Properly.")
604            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
605            raise signals.TestFailure("Failed",
606                extras={"fail_reason": "Phone Failed to Set Up Properly."})
607
608        result = two_phone_call_long_seq(
609            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
610            phone_idle_3g, is_phone_in_call_1x, None)
611        self.tel_logger.set_result(result.result_value)
612        if not result:
613            raise signals.TestFailure("Failed",
614                extras={"fail_reason": str(result.result_value)})
615
616    @test_tracker_info(uuid="b39a74a9-2a89-4c0b-ac4e-71ed9317bd75")
617    @TelephonyBaseTest.tel_test_wrap
618    def test_call_volte_to_3g_wcdma_long(self):
619        """ VoLTE to 3G WCDMA call test
620
621        1. Make Sure PhoneA is in LTE mode (with VoLTE).
622        2. Make Sure PhoneB is in 3G WCDMA mode.
623        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
624        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
625        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
626        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
627
628        Raises:
629            TestFailure if not success.
630        """
631        ads = self.android_devices
632        self.check_band_support(ads[0])
633        # Make Sure PhoneB is GSM phone.
634        if ads[1].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM:
635            self.log.error(
636                "PhoneB not gsm phone, can not 3g wcdma. Stop test.")
637            self.tel_logger.set_result(CallResult('UNAVAILABLE_NETWORK_TYPE'))
638            raise signals.TestFailure("Failed",
639                extras={"fail_reason": "PhoneB not gsm phone, can not 3g wcdma."})
640
641        tasks = [(phone_setup_volte, (self.log, ads[0])),
642                 (phone_setup_voice_3g, (self.log, ads[1]))]
643        if not multithread_func(self.log, tasks):
644            self.log.error("Phone Failed to Set Up Properly.")
645            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
646            raise signals.TestFailure("Failed",
647                extras={"fail_reason": "PhoneB not gsm phone, can not 3g wcdma."})
648
649        result = two_phone_call_long_seq(
650            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
651            phone_idle_3g, is_phone_in_call_wcdma, None)
652        self.tel_logger.set_result(result.result_value)
653        if not result:
654            raise signals.TestFailure("Failed",
655                extras={"fail_reason": str(result.result_value)})
656
657    @test_tracker_info(uuid="573bbcf1-6cbd-4084-9cb7-e14fb6c9521e")
658    @TelephonyBaseTest.tel_test_wrap
659    def test_call_volte_to_2g(self):
660        """ VoLTE to 2G call test
661
662        1. Make Sure PhoneA is in LTE mode (with VoLTE).
663        2. Make Sure PhoneB is in 2G mode.
664        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
665        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
666
667        Raises:
668            TestFailure if not success.
669        """
670        ads = self.android_devices
671        self.check_band_support(ads[0])
672
673        tasks = [(phone_setup_volte, (self.log, ads[0])),
674                 (phone_setup_voice_2g, (self.log, ads[1]))]
675        if not multithread_func(self.log, tasks):
676            self.log.error("Phone Failed to Set Up Properly.")
677            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
678            raise signals.TestFailure("Failed",
679                extras={"fail_reason": "Phone Failed to Set Up Properly."})
680
681        result = two_phone_call_short_seq(
682            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
683            phone_idle_2g, is_phone_in_call_2g, None)
684        self.tel_logger.set_result(result.result_value)
685        if not result:
686            raise signals.TestFailure("Failed",
687                extras={"fail_reason": str(result.result_value)})
688
689    @test_tracker_info(uuid="a4a043c0-f4ba-4405-9262-42c752cc4487")
690    @TelephonyBaseTest.tel_test_wrap
691    def test_call_epdg_to_epdg_wfc_wifi_only(self):
692        """ WiFi Only, WiFi calling to WiFi Calling test
693
694        1. Setup PhoneA WFC mode: WIFI_ONLY.
695        2. Setup PhoneB WFC mode: WIFI_ONLY.
696        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
697        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
698
699        Returns:
700            True if pass; False if fail.
701        """
702        return call_epdg_to_epdg_wfc(self.log,
703                                     self.android_devices,
704                                     False,
705                                     WFC_MODE_WIFI_ONLY,
706                                     self.wifi_network_ssid,
707                                     self.wifi_network_pass)
708
709    @test_tracker_info(uuid="ae171d58-d4c1-43f7-aa93-4860b4b28d53")
710    @TelephonyBaseTest.tel_test_wrap
711    def test_call_epdg_to_epdg_wfc_wifi_preferred(self):
712        """ WiFi Preferred, WiFi calling to WiFi Calling test
713
714        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
715        2. Setup PhoneB WFC mode: WIFI_PREFERRED.
716        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
717        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
718
719        Returns:
720            True if pass; False if fail.
721        """
722        return call_epdg_to_epdg_wfc(self.log,
723                                     self.android_devices,
724                                     False,
725                                     WFC_MODE_WIFI_PREFERRED,
726                                     self.wifi_network_ssid,
727                                     self.wifi_network_pass)
728
729    @test_tracker_info(uuid="ece58857-fedc-49a9-bf10-b76bd78a51f2")
730    @TelephonyBaseTest.tel_test_wrap
731    def test_call_epdg_to_epdg_wfc_cellular_preferred(self):
732        """ Cellular Preferred, WiFi calling to WiFi Calling test
733
734        1. Setup PhoneA WFC mode: CELLULAR_PREFERRED.
735        2. Setup PhoneB WFC mode: CELLULAR_PREFERRED.
736        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
737        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
738
739        Raises:
740            TestFailure if not success.
741        """
742        ads = [self.android_devices[0], self.android_devices[1]]
743        tasks = [(phone_setup_iwlan_cellular_preferred,
744                  (self.log, ads[0], self.wifi_network_ssid,
745                   self.wifi_network_pass)),
746                 (phone_setup_iwlan_cellular_preferred,
747                  (self.log, ads[1], self.wifi_network_ssid,
748                   self.wifi_network_pass))]
749        if not multithread_func(self.log, tasks):
750            self.log.error("Phone Failed to Set Up Properly.")
751            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
752            raise signals.TestFailure("Failed",
753                extras={"fail_reason": "Phone Failed to Set Up Properly."})
754
755        result = two_phone_call_short_seq(
756            self.log, ads[0], None, is_phone_in_call_not_iwlan, ads[1], None,
757            is_phone_in_call_not_iwlan, None, WAIT_TIME_IN_CALL_FOR_IMS)
758        self.tel_logger.set_result(result.result_value)
759        if not result:
760            raise signals.TestFailure("Failed",
761                extras={"fail_reason": str(result.result_value)})
762
763    @test_tracker_info(uuid="0d63c250-d9e7-490c-8c48-0a6afbad5f88")
764    @TelephonyBaseTest.tel_test_wrap
765    def test_call_epdg_to_epdg_apm_wfc_wifi_only(self):
766        """ Airplane + WiFi Only, WiFi calling to WiFi Calling test
767
768        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
769        2. Setup PhoneB in airplane mode, WFC mode: WIFI_ONLY.
770        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
771        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
772
773        Returns:
774            True if pass; False if fail.
775        """
776        return call_epdg_to_epdg_wfc(self.log,
777                                     self.android_devices,
778                                     True,
779                                     WFC_MODE_WIFI_ONLY,
780                                     self.wifi_network_ssid,
781                                     self.wifi_network_pass)
782
783    @test_tracker_info(uuid="7678e4ee-29c6-4319-93ab-d555501d1876")
784    @TelephonyBaseTest.tel_test_wrap
785    def test_call_epdg_to_epdg_apm_wfc_wifi_preferred(self):
786        """ Airplane + WiFi Preferred, WiFi calling to WiFi Calling test
787
788        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
789        2. Setup PhoneB in airplane mode, WFC mode: WIFI_PREFERRED.
790        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
791        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
792
793        Returns:
794            True if pass; False if fail.
795        """
796        return call_epdg_to_epdg_wfc(self.log,
797                                     self.android_devices,
798                                     True,
799                                     WFC_MODE_WIFI_PREFERRED,
800                                     self.wifi_network_ssid,
801                                     self.wifi_network_pass)
802
803    @test_tracker_info(uuid="8f5c637e-683a-448d-9443-b2b39626ab19")
804    @TelephonyBaseTest.tel_test_wrap
805    def test_call_epdg_to_epdg_apm_wfc_cellular_preferred(self):
806        """ Airplane + Cellular Preferred, WiFi calling to WiFi Calling test
807
808        1. Setup PhoneA in airplane mode, WFC mode: CELLULAR_PREFERRED.
809        2. Setup PhoneB in airplane mode, WFC mode: CELLULAR_PREFERRED.
810        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
811        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
812
813        Returns:
814            True if pass; False if fail.
815        """
816        return call_epdg_to_epdg_wfc(self.log,
817                                     self.android_devices,
818                                     True,
819                                     WFC_MODE_CELLULAR_PREFERRED,
820                                     self.wifi_network_ssid,
821                                     self.wifi_network_pass)
822
823    @test_tracker_info(uuid="0b51666e-c83c-40b5-ba0f-737e64bc82a2")
824    @TelephonyBaseTest.tel_test_wrap
825    def test_call_epdg_to_volte_wfc_wifi_only(self):
826        """ WiFi Only, WiFi calling to VoLTE test
827
828        1. Setup PhoneA WFC mode: WIFI_ONLY.
829        2. Make Sure PhoneB is in LTE mode (with VoLTE enabled).
830        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
831        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
832
833        Raises:
834            TestFailure if not success.
835        """
836        ads = self.android_devices
837        tasks = [(phone_setup_iwlan,
838                  (self.log, ads[0], False, WFC_MODE_WIFI_ONLY,
839                   self.wifi_network_ssid, self.wifi_network_pass)),
840                 (phone_setup_volte, (self.log, ads[1]))]
841        if not multithread_func(self.log, tasks):
842            self.log.error("Phone Failed to Set Up Properly.")
843            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
844            raise signals.TestFailure("Failed",
845                extras={"fail_reason": "Phone Failed to Set Up Properly."})
846
847        result = two_phone_call_short_seq(
848            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
849            phone_idle_volte, is_phone_in_call_volte, None,
850            WAIT_TIME_IN_CALL_FOR_IMS)
851        self.tel_logger.set_result(result.result_value)
852        if not result:
853            raise signals.TestFailure("Failed",
854                extras={"fail_reason": str(result.result_value)})
855
856    @test_tracker_info(uuid="6e0630a9-63b2-4ea1-8ec9-6560f001905c")
857    @TelephonyBaseTest.tel_test_wrap
858    def test_call_epdg_to_volte_wfc_wifi_preferred(self):
859        """ WiFi Preferred, WiFi calling to VoLTE test
860
861        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
862        2. Make Sure PhoneB is in LTE mode (with VoLTE enabled).
863        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
864        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
865
866        Raises:
867            TestFailure if not success.
868        """
869        ads = self.android_devices
870        tasks = [(phone_setup_iwlan,
871                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
872                   self.wifi_network_ssid, self.wifi_network_pass)),
873                 (phone_setup_volte, (self.log, ads[1]))]
874        if not multithread_func(self.log, tasks):
875            self.log.error("Phone Failed to Set Up Properly.")
876            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
877            raise signals.TestFailure("Failed",
878                extras={"fail_reason": "Phone Failed to Set Up Properly."})
879
880        result = two_phone_call_short_seq(
881            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
882            phone_idle_volte, is_phone_in_call_volte, None,
883            WAIT_TIME_IN_CALL_FOR_IMS)
884        self.tel_logger.set_result(result.result_value)
885        if not result:
886            raise signals.TestFailure("Failed",
887                extras={"fail_reason": str(result.result_value)})
888
889    @test_tracker_info(uuid="51077985-2229-491f-9a54-1ff53871758c")
890    @TelephonyBaseTest.tel_test_wrap
891    def test_call_epdg_to_volte_apm_wfc_wifi_only(self):
892        """ Airplane + WiFi Only, WiFi calling to VoLTE test
893
894        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
895        2. Make Sure PhoneB is in LTE mode (with VoLTE enabled).
896        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
897        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
898
899        Raises:
900            TestFailure if not success.
901        """
902        ads = self.android_devices
903        tasks = [(phone_setup_iwlan,
904                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
905                   self.wifi_network_ssid, self.wifi_network_pass)),
906                 (phone_setup_volte, (self.log, ads[1]))]
907        if not multithread_func(self.log, tasks):
908            self.log.error("Phone Failed to Set Up Properly.")
909            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
910            raise signals.TestFailure("Failed",
911                extras={"fail_reason": "Phone Failed to Set Up Properly."})
912
913        result = two_phone_call_short_seq(
914            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
915            phone_idle_volte, is_phone_in_call_volte, None,
916            WAIT_TIME_IN_CALL_FOR_IMS)
917        self.tel_logger.set_result(result.result_value)
918        if not result:
919            raise signals.TestFailure("Failed",
920                extras={"fail_reason": str(result.result_value)})
921
922    @test_tracker_info(uuid="fff9edcd-1ace-4f2d-a09b-06f3eea56cca")
923    @TelephonyBaseTest.tel_test_wrap
924    def test_call_epdg_to_volte_apm_wfc_wifi_preferred(self):
925        """ Airplane + WiFi Preferred, WiFi calling to VoLTE test
926
927        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
928        2. Make Sure PhoneB is in LTE mode (with VoLTE enabled).
929        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
930        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
931
932        Raises:
933            TestFailure if not success.
934        """
935        ads = self.android_devices
936        tasks = [(phone_setup_iwlan,
937                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
938                   self.wifi_network_ssid, self.wifi_network_pass)),
939                 (phone_setup_volte, (self.log, ads[1]))]
940        if not multithread_func(self.log, tasks):
941            self.log.error("Phone Failed to Set Up Properly.")
942            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
943            raise signals.TestFailure("Failed",
944                extras={"fail_reason": "Phone Failed to Set Up Properly."})
945
946        result = two_phone_call_short_seq(
947            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
948            phone_idle_volte, is_phone_in_call_volte, None,
949            WAIT_TIME_IN_CALL_FOR_IMS)
950        self.tel_logger.set_result(result.result_value)
951        if not result:
952            raise signals.TestFailure("Failed",
953                extras={"fail_reason": str(result.result_value)})
954
955    @test_tracker_info(uuid="8591554e-4e38-406c-97bf-8921d5329c47")
956    @TelephonyBaseTest.tel_test_wrap
957    def test_call_epdg_to_csfb_3g_wfc_wifi_only(self):
958        """ WiFi Only, WiFi calling to CSFB 3G test
959
960        1. Setup PhoneA WFC mode: WIFI_ONLY.
961        2. Make Sure PhoneB is in LTE mode (with VoLTE disabled).
962        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
963        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
964
965        Raises:
966             TestFailure if not success.
967        """
968        ads = self.android_devices
969        self.check_band_support(ads[0])
970        # Turn OFF WiFi for Phone B
971        set_wifi_to_default(self.log, ads[1])
972        tasks = [(phone_setup_iwlan,
973                  (self.log, ads[0], False, WFC_MODE_WIFI_ONLY,
974                   self.wifi_network_ssid, self.wifi_network_pass)),
975                 (phone_setup_csfb, (self.log, ads[1]))]
976        if not multithread_func(self.log, tasks):
977            self.log.error("Phone Failed to Set Up Properly.")
978            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
979            raise signals.TestFailure("Failed",
980                extras={"fail_reason": "Phone Failed to Set Up Properly."})
981
982        result = two_phone_call_short_seq(
983            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
984            phone_idle_csfb, is_phone_in_call_csfb, None)
985        self.tel_logger.set_result(result.result_value)
986        if not result:
987            raise signals.TestFailure("Failed",
988                extras={"fail_reason": str(result.result_value)})
989
990    @test_tracker_info(uuid="9711888d-5b1e-4d05-86e9-98f94f46098b")
991    @TelephonyBaseTest.tel_test_wrap
992    def test_call_epdg_to_csfb_3g_wfc_wifi_preferred(self):
993        """ WiFi Preferred, WiFi calling to CSFB 3G test
994
995        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
996        2. Make Sure PhoneB is in LTE mode (with VoLTE disabled).
997        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
998        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
999
1000        Raises:
1001            TestFailure if not success.
1002        """
1003        ads = self.android_devices
1004        self.check_band_support(ads[0])
1005        # Turn OFF WiFi for Phone B
1006        set_wifi_to_default(self.log, ads[1])
1007        tasks = [(phone_setup_iwlan,
1008                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
1009                   self.wifi_network_ssid, self.wifi_network_pass)),
1010                 (phone_setup_csfb, (self.log, ads[1]))]
1011        if not multithread_func(self.log, tasks):
1012            self.log.error("Phone Failed to Set Up Properly.")
1013            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1014            raise signals.TestFailure("Failed",
1015                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1016
1017        result = two_phone_call_short_seq(
1018            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1019            phone_idle_csfb, is_phone_in_call_csfb, None)
1020        self.tel_logger.set_result(result.result_value)
1021        if not result:
1022            raise signals.TestFailure("Failed",
1023                extras={"fail_reason": str(result.result_value)})
1024
1025    @test_tracker_info(uuid="902c96a4-858f-43ff-bd56-6d7d27004320")
1026    @TelephonyBaseTest.tel_test_wrap
1027    def test_call_epdg_to_csfb_3g_apm_wfc_wifi_only(self):
1028        """ Airplane + WiFi Only, WiFi calling to CSFB 3G test
1029
1030        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
1031        2. Make Sure PhoneB is in LTE mode (with VoLTE disabled).
1032        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1033        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1034
1035        Raises:
1036            TestFailure if not success.
1037        """
1038        ads = self.android_devices
1039        self.check_band_support(ads[0])
1040        # Turn OFF WiFi for Phone B
1041        set_wifi_to_default(self.log, ads[1])
1042        tasks = [(phone_setup_iwlan,
1043                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
1044                   self.wifi_network_ssid, self.wifi_network_pass)),
1045                 (phone_setup_csfb, (self.log, ads[1]))]
1046        if not multithread_func(self.log, tasks):
1047            self.log.error("Phone Failed to Set Up Properly.")
1048            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1049            raise signals.TestFailure("Failed",
1050                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1051
1052        result = two_phone_call_short_seq(
1053            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1054            phone_idle_csfb, is_phone_in_call_csfb, None)
1055        self.tel_logger.set_result(result.result_value)
1056        if not result:
1057            raise signals.TestFailure("Failed",
1058                extras={"fail_reason": str(result.result_value)})
1059
1060    @test_tracker_info(uuid="362a5396-ebda-4706-a73a-d805e5028fd7")
1061    @TelephonyBaseTest.tel_test_wrap
1062    def test_call_epdg_to_csfb_3g_apm_wfc_wifi_preferred(self):
1063        """ Airplane + WiFi Preferred, WiFi calling to CSFB 3G test
1064
1065        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
1066        2. Make Sure PhoneB is in LTE mode (with VoLTE disabled).
1067        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1068        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1069
1070        Raises:
1071            TestFailure if not success.
1072        """
1073        ads = self.android_devices
1074        self.check_band_support(ads[0])
1075        # Turn OFF WiFi for Phone B
1076        set_wifi_to_default(self.log, ads[1])
1077        tasks = [(phone_setup_iwlan,
1078                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
1079                   self.wifi_network_ssid, self.wifi_network_pass)),
1080                 (phone_setup_csfb, (self.log, ads[1]))]
1081        if not multithread_func(self.log, tasks):
1082            self.log.error("Phone Failed to Set Up Properly.")
1083            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1084            raise signals.TestFailure("Failed",
1085                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1086
1087        result = two_phone_call_short_seq(
1088            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1089            phone_idle_csfb, is_phone_in_call_csfb, None)
1090        self.tel_logger.set_result(result.result_value)
1091        if not result:
1092            raise signals.TestFailure("Failed",
1093                extras={"fail_reason": str(result.result_value)})
1094
1095    @test_tracker_info(uuid="647bb859-46bc-4e3e-b6ab-7944d3bbcc26")
1096    @TelephonyBaseTest.tel_test_wrap
1097    def test_call_epdg_to_3g_wfc_wifi_only(self):
1098        """ WiFi Only, WiFi calling to 3G test
1099
1100        1. Setup PhoneA WFC mode: WIFI_ONLY.
1101        2. Make Sure PhoneB is in 3G mode.
1102        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1103        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1104
1105        Raises:
1106            TestFailure if not success.
1107        """
1108        ads = self.android_devices
1109        self.check_band_support(ads[0])
1110        # Turn OFF WiFi for Phone B
1111        set_wifi_to_default(self.log, ads[1])
1112        tasks = [(phone_setup_iwlan,
1113                  (self.log, ads[0], False, WFC_MODE_WIFI_ONLY,
1114                   self.wifi_network_ssid, self.wifi_network_pass)),
1115                 (phone_setup_voice_3g, (self.log, ads[1]))]
1116        if not multithread_func(self.log, tasks):
1117            self.log.error("Phone Failed to Set Up Properly.")
1118            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1119            raise signals.TestFailure("Failed",
1120                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1121
1122        result = two_phone_call_short_seq(
1123            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1124            phone_idle_3g, is_phone_in_call_3g, None)
1125        self.tel_logger.set_result(result.result_value)
1126        if not result:
1127            raise signals.TestFailure("Failed",
1128                extras={"fail_reason": str(result.result_value)})
1129
1130    @test_tracker_info(uuid="3688ea1f-a52d-4a35-9df4-d5ed0985e49b")
1131    @TelephonyBaseTest.tel_test_wrap
1132    def test_call_epdg_to_3g_wfc_wifi_preferred(self):
1133        """ WiFi Preferred, WiFi calling to 3G test
1134
1135        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
1136        2. Make Sure PhoneB is in 3G mode.
1137        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1138        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1139
1140        Raises:
1141            TestFailure if not success.
1142        """
1143        ads = self.android_devices
1144        self.check_band_support(ads[0])
1145        # Turn OFF WiFi for Phone B
1146        set_wifi_to_default(self.log, ads[1])
1147        tasks = [(phone_setup_iwlan,
1148                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
1149                   self.wifi_network_ssid, self.wifi_network_pass)),
1150                 (phone_setup_voice_3g, (self.log, ads[1]))]
1151        if not multithread_func(self.log, tasks):
1152            self.log.error("Phone Failed to Set Up Properly.")
1153            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1154            raise signals.TestFailure("Failed",
1155                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1156
1157        result = two_phone_call_short_seq(
1158            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1159            phone_idle_3g, is_phone_in_call_3g, None)
1160        self.tel_logger.set_result(result.result_value)
1161        if not result:
1162            raise signals.TestFailure("Failed",
1163                extras={"fail_reason": str(result.result_value)})
1164
1165    @test_tracker_info(uuid="f4efc821-fbaf-4ec2-b89b-5a47354344f0")
1166    @TelephonyBaseTest.tel_test_wrap
1167    def test_call_epdg_to_3g_apm_wfc_wifi_only(self):
1168        """ Airplane + WiFi Only, WiFi calling to 3G test
1169
1170        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
1171        2. Make Sure PhoneB is in 3G mode.
1172        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1173        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1174
1175        Raises:
1176            TestFailure if not success.
1177        """
1178        ads = self.android_devices
1179        self.check_band_support(ads[0])
1180        # Turn OFF WiFi for Phone B
1181        set_wifi_to_default(self.log, ads[1])
1182        tasks = [(phone_setup_iwlan,
1183                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
1184                   self.wifi_network_ssid, self.wifi_network_pass)),
1185                 (phone_setup_voice_3g, (self.log, ads[1]))]
1186        if not multithread_func(self.log, tasks):
1187            self.log.error("Phone Failed to Set Up Properly.")
1188            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1189            raise signals.TestFailure("Failed",
1190                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1191
1192        result = two_phone_call_short_seq(
1193            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1194            phone_idle_3g, is_phone_in_call_3g, None)
1195        self.tel_logger.set_result(result.result_value)
1196        if not result:
1197            raise signals.TestFailure("Failed",
1198                extras={"fail_reason": str(result.result_value)})
1199
1200    @test_tracker_info(uuid="2b1345b7-3b62-44bd-91ad-9c5a4925b0e1")
1201    @TelephonyBaseTest.tel_test_wrap
1202    def test_call_epdg_to_3g_apm_wfc_wifi_preferred(self):
1203        """ Airplane + WiFi Preferred, WiFi calling to 3G test
1204
1205        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
1206        2. Make Sure PhoneB is in 3G mode.
1207        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1208        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1209
1210        Raises:
1211            TestFailure if not success.
1212        """
1213        ads = self.android_devices
1214        self.check_band_support(ads[0])
1215        # Turn OFF WiFi for Phone B
1216        set_wifi_to_default(self.log, ads[1])
1217        tasks = [(phone_setup_iwlan,
1218                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
1219                   self.wifi_network_ssid, self.wifi_network_pass)),
1220                 (phone_setup_voice_3g, (self.log, ads[1]))]
1221        if not multithread_func(self.log, tasks):
1222            self.log.error("Phone Failed to Set Up Properly.")
1223            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1224            raise signals.TestFailure("Failed",
1225                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1226
1227        result = two_phone_call_short_seq(
1228            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1229            phone_idle_3g, is_phone_in_call_3g, None)
1230        self.tel_logger.set_result(result.result_value)
1231        if not result:
1232            raise signals.TestFailure("Failed",
1233                extras={"fail_reason": str(result.result_value)})
1234
1235    @test_tracker_info(uuid="7b3fea22-114a-442e-aa12-dde3b6001681")
1236    @TelephonyBaseTest.tel_test_wrap
1237    def test_call_csfb_3g_to_csfb_3g(self):
1238        """ CSFB 3G to CSFB 3G call test
1239
1240        1. Make Sure PhoneA is in LTE mode, VoLTE disabled.
1241        2. Make Sure PhoneB is in LTE mode, VoLTE disabled.
1242        3. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneA.
1243        4. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneB.
1244
1245        Raises:
1246            TestFailure if not success.
1247        """
1248        ads = self.android_devices
1249        self.check_band_support(ads[0])
1250        # Turn OFF WiFi for Phone B
1251        set_wifi_to_default(self.log, ads[1])
1252        tasks = [(phone_setup_csfb, (self.log, ads[0])), (phone_setup_csfb,
1253                                                          (self.log, ads[1]))]
1254        if not multithread_func(self.log, tasks):
1255            self.log.error("Phone Failed to Set Up Properly.")
1256            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1257            raise signals.TestFailure("Failed",
1258                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1259
1260        result = two_phone_call_short_seq(
1261            self.log, ads[0], phone_idle_csfb, is_phone_in_call_csfb, ads[1],
1262            phone_idle_csfb, is_phone_in_call_csfb, None)
1263        self.tel_logger.set_result(result.result_value)
1264        if not result:
1265            raise signals.TestFailure("Failed",
1266                extras={"fail_reason": str(result.result_value)})
1267
1268    @test_tracker_info(uuid="91d751ea-40c8-4ffc-b9d3-03d0ad0902bd")
1269    @TelephonyBaseTest.tel_test_wrap
1270    def test_call_3g_to_3g(self):
1271        """ 3G to 3G call test
1272
1273        1. Make Sure PhoneA is in 3G mode.
1274        2. Make Sure PhoneB is in 3G mode.
1275        3. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneA.
1276        4. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneB.
1277
1278        Raises:
1279            TestFailure if not success.
1280        """
1281        ads = self.android_devices
1282        self.check_band_support(ads[0])
1283        # Turn OFF WiFi for Phone B
1284        set_wifi_to_default(self.log, ads[1])
1285        tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
1286                 (phone_setup_voice_3g, (self.log, ads[1]))]
1287        if not multithread_func(self.log, tasks):
1288            self.log.error("Phone Failed to Set Up Properly.")
1289            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1290            raise signals.TestFailure("Failed",
1291                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1292
1293        result = two_phone_call_short_seq(
1294            self.log, ads[0], phone_idle_3g, is_phone_in_call_3g, ads[1],
1295            phone_idle_3g, is_phone_in_call_3g, None)
1296        self.tel_logger.set_result(result.result_value)
1297        if not result:
1298            raise signals.TestFailure("Failed",
1299                extras={"fail_reason": str(result.result_value)})
1300
1301    @test_tracker_info(uuid="df57c481-010a-4d21-a5c1-5116917871b2")
1302    @TelephonyBaseTest.tel_test_wrap
1303    def test_call_volte_to_volte_long(self):
1304        """ VoLTE to VoLTE call test
1305
1306        1. Make Sure PhoneA is in LTE mode (with VoLTE).
1307        2. Make Sure PhoneB is in LTE mode (with VoLTE).
1308        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1309        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1310        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1311        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1312
1313        Raises:
1314            TestFailure if not success.
1315        """
1316        ads = self.android_devices
1317
1318        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
1319                                                           (self.log, ads[1]))]
1320        if not multithread_func(self.log, tasks):
1321            self.log.error("Phone Failed to Set Up Properly.")
1322            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1323            raise signals.TestFailure("Failed",
1324                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1325
1326        result = two_phone_call_long_seq(
1327            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
1328            phone_idle_volte, is_phone_in_call_volte, None,
1329            WAIT_TIME_IN_CALL_FOR_IMS)
1330        self.tel_logger.set_result(result.result_value)
1331        if not result:
1332            raise signals.TestFailure("Failed",
1333                extras={"fail_reason": str(result.result_value)})
1334
1335    @test_tracker_info(uuid="b0712d8a-71cf-405f-910c-8592da082660")
1336    @TelephonyBaseTest.tel_test_wrap
1337    def test_call_epdg_to_epdg_long_wfc_wifi_only(self):
1338        """ WiFi Only, WiFi calling to WiFi Calling test
1339
1340        1. Setup PhoneA WFC mode: WIFI_ONLY.
1341        2. Setup PhoneB WFC mode: WIFI_ONLY.
1342        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1343        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1344        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1345        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1346
1347        Raises:
1348            TestFailure if not success.
1349        """
1350        ads = self.android_devices
1351
1352        tasks = [(phone_setup_iwlan,
1353                  (self.log, ads[0], False, WFC_MODE_WIFI_ONLY,
1354                   self.wifi_network_ssid, self.wifi_network_pass)),
1355                 (phone_setup_iwlan,
1356                  (self.log, ads[1], False, WFC_MODE_WIFI_ONLY,
1357                   self.wifi_network_ssid, self.wifi_network_pass))]
1358        if not multithread_func(self.log, tasks):
1359            self.log.error("Phone Failed to Set Up Properly.")
1360            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1361            raise signals.TestFailure("Failed",
1362                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1363
1364        result = two_phone_call_long_seq(
1365            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1366            phone_idle_iwlan, is_phone_in_call_iwlan, None,
1367            WAIT_TIME_IN_CALL_FOR_IMS)
1368        self.tel_logger.set_result(result.result_value)
1369        if not result:
1370            raise signals.TestFailure("Failed",
1371                extras={"fail_reason": str(result.result_value)})
1372
1373    @test_tracker_info(uuid="a7293d6c-0fdb-4842-984a-e4c6395fd41d")
1374    @TelephonyBaseTest.tel_test_wrap
1375    def test_call_epdg_to_epdg_long_wfc_wifi_preferred(self):
1376        """ WiFi Preferred, WiFi calling to WiFi Calling test
1377
1378        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
1379        2. Setup PhoneB WFC mode: WIFI_PREFERRED.
1380        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1381        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1382        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1383        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1384
1385        Raises:
1386            TestFailure if not success.
1387        """
1388        ads = self.android_devices
1389
1390        tasks = [(phone_setup_iwlan,
1391                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
1392                   self.wifi_network_ssid, self.wifi_network_pass)),
1393                 (phone_setup_iwlan,
1394                  (self.log, ads[1], False, WFC_MODE_WIFI_PREFERRED,
1395                   self.wifi_network_ssid, self.wifi_network_pass))]
1396        if not multithread_func(self.log, tasks):
1397            self.log.error("Phone Failed to Set Up Properly.")
1398            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1399            raise signals.TestFailure("Failed",
1400                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1401
1402        result = two_phone_call_long_seq(
1403            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1404            phone_idle_iwlan, is_phone_in_call_iwlan, None,
1405            WAIT_TIME_IN_CALL_FOR_IMS)
1406        self.tel_logger.set_result(result.result_value)
1407        if not result:
1408            raise signals.TestFailure("Failed",
1409                extras={"fail_reason": str(result.result_value)})
1410
1411    @test_tracker_info(uuid="029af2a7-aba4-406b-9095-b32da57a7cdb")
1412    @TelephonyBaseTest.tel_test_wrap
1413    def test_call_epdg_to_epdg_long_apm_wfc_wifi_only(self):
1414        """ Airplane + WiFi Only, WiFi calling to WiFi Calling test
1415
1416        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
1417        2. Setup PhoneB in airplane mode, WFC mode: WIFI_ONLY.
1418        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1419        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1420        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1421        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1422
1423        Raises:
1424            TestFailure if not success.
1425        """
1426        ads = self.android_devices
1427
1428        tasks = [(phone_setup_iwlan,
1429                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
1430                   self.wifi_network_ssid, self.wifi_network_pass)),
1431                 (phone_setup_iwlan,
1432                  (self.log, ads[1], True, WFC_MODE_WIFI_ONLY,
1433                   self.wifi_network_ssid, self.wifi_network_pass))]
1434        if not multithread_func(self.log, tasks):
1435            self.log.error("Phone Failed to Set Up Properly.")
1436            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1437            raise signals.TestFailure("Failed",
1438                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1439
1440        result = two_phone_call_long_seq(
1441            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1442            phone_idle_iwlan, is_phone_in_call_iwlan, None,
1443            WAIT_TIME_IN_CALL_FOR_IMS)
1444        self.tel_logger.set_result(result.result_value)
1445        if not result:
1446            raise signals.TestFailure("Failed",
1447                extras={"fail_reason": str(result.result_value)})
1448
1449    @test_tracker_info(uuid="3c751d79-7159-4407-a63c-96f835dd6cb0")
1450    @TelephonyBaseTest.tel_test_wrap
1451    def test_call_epdg_to_epdg_long_apm_wfc_wifi_preferred(self):
1452        """ Airplane + WiFi Preferred, WiFi calling to WiFi Calling test
1453
1454        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
1455        2. Setup PhoneB in airplane mode, WFC mode: WIFI_PREFERRED.
1456        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1457        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1458        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1459        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1460
1461        Raises:
1462            TestFailure if not success.
1463        """
1464        ads = self.android_devices
1465
1466        tasks = [(phone_setup_iwlan,
1467                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
1468                   self.wifi_network_ssid, self.wifi_network_pass)),
1469                 (phone_setup_iwlan,
1470                  (self.log, ads[1], True, WFC_MODE_WIFI_PREFERRED,
1471                   self.wifi_network_ssid, self.wifi_network_pass))]
1472        if not multithread_func(self.log, tasks):
1473            self.log.error("Phone Failed to Set Up Properly.")
1474            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1475            raise signals.TestFailure("Failed",
1476                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1477
1478        result = two_phone_call_long_seq(
1479            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
1480            phone_idle_iwlan, is_phone_in_call_iwlan, None,
1481            WAIT_TIME_IN_CALL_FOR_IMS)
1482        self.tel_logger.set_result(result.result_value)
1483        if not result:
1484            raise signals.TestFailure("Failed",
1485                extras={"fail_reason": str(result.result_value)})
1486
1487    @test_tracker_info(uuid="9deab765-e2da-4826-bae8-ba8755551a1b")
1488    @TelephonyBaseTest.tel_test_wrap
1489    def test_call_csfb_3g_to_csfb_3g_long(self):
1490        """ CSFB 3G to CSFB 3G call test
1491
1492        1. Make Sure PhoneA is in LTE mode, VoLTE disabled.
1493        2. Make Sure PhoneB is in LTE mode, VoLTE disabled.
1494        3. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneA.
1495        4. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneB.
1496        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1497        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1498
1499        Raises:
1500            TestFailure if not success.
1501        """
1502        ads = self.android_devices
1503        self.check_band_support(ads[0])
1504        # Turn OFF WiFi for Phone B
1505        set_wifi_to_default(self.log, ads[1])
1506        tasks = [(phone_setup_csfb, (self.log, ads[0])), (phone_setup_csfb,
1507                                                          (self.log, ads[1]))]
1508        if not multithread_func(self.log, tasks):
1509            self.log.error("Phone Failed to Set Up Properly.")
1510            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1511            raise signals.TestFailure("Failed",
1512                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1513
1514        result = two_phone_call_long_seq(
1515            self.log, ads[0], phone_idle_csfb, is_phone_in_call_csfb, ads[1],
1516            phone_idle_csfb, is_phone_in_call_csfb, None)
1517        self.tel_logger.set_result(result.result_value)
1518        if not result:
1519            raise signals.TestFailure("Failed",
1520                extras={"fail_reason": str(result.result_value)})
1521
1522    @test_tracker_info(uuid="54768178-818f-4126-9e50-4f49e43a6fd3")
1523    @TelephonyBaseTest.tel_test_wrap
1524    def test_call_3g_to_3g_long(self):
1525        """ 3G to 3G call test
1526
1527        1. Make Sure PhoneA is in 3G mode.
1528        2. Make Sure PhoneB is in 3G mode.
1529        3. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneA.
1530        4. Call from PhoneA to PhoneB, accept on PhoneA, hang up on PhoneB.
1531        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1532        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1533
1534        Raises:
1535            TestFailure if not success.
1536        """
1537        ads = self.android_devices
1538        self.check_band_support(ads[0])
1539        # Turn OFF WiFi for Phone B
1540        set_wifi_to_default(self.log, ads[1])
1541        tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
1542                 (phone_setup_voice_3g, (self.log, ads[1]))]
1543        if not multithread_func(self.log, tasks):
1544            self.log.error("Phone Failed to Set Up Properly.")
1545            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1546            raise signals.TestFailure("Failed",
1547                extras={"fail_reason": "Phone Failed to Set Up Properly."})
1548
1549        result = two_phone_call_long_seq(
1550            self.log, ads[0], phone_idle_3g, is_phone_in_call_3g, ads[1],
1551            phone_idle_3g, is_phone_in_call_3g, None)
1552        self.tel_logger.set_result(result.result_value)
1553        if not result:
1554            raise signals.TestFailure("Failed",
1555                extras={"fail_reason": str(result.result_value)})
1556
1557    @test_tracker_info(uuid="")
1558    @TelephonyBaseTest.tel_test_wrap
1559    def test_call_volte_to_volte_loop(self):
1560        """ Stress test: VoLTE to VoLTE call test
1561
1562        1. Make Sure PhoneA is in LTE mode (with VoLTE).
1563        2. Make Sure PhoneB is in LTE mode (with VoLTE).
1564        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1565        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1566        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1567        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1568        7. Repeat step 3~6.
1569
1570        Returns:
1571            True if pass; False if fail.
1572        """
1573
1574        # TODO: b/26338422 Make this a parameter
1575        MINIMUM_SUCCESS_RATE = .95
1576        ads = self.android_devices
1577
1578        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
1579                                                           (self.log, ads[1]))]
1580        if not multithread_func(self.log, tasks):
1581            self.log.error("Phone Failed to Set Up Properly.")
1582            return False
1583
1584        success_count = 0
1585        fail_count = 0
1586
1587        for i in range(1, self.stress_test_number + 1):
1588
1589            if two_phone_call_long_seq(
1590                    self.log, ads[0], phone_idle_volte, is_phone_in_call_volte,
1591                    ads[1], phone_idle_volte, is_phone_in_call_volte, None,
1592                    WAIT_TIME_IN_CALL_FOR_IMS):
1593                success_count += 1
1594                result_str = "Succeeded"
1595
1596            else:
1597                fail_count += 1
1598                result_str = "Failed"
1599
1600            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
1601                          result_str, success_count, self.stress_test_number)
1602
1603        self.log.info("Final Count - Success: %s, Failure: %s - %s%",
1604                      success_count, fail_count,
1605                      str(100 * success_count / (success_count + fail_count)))
1606        if success_count / (
1607                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
1608            return True
1609        else:
1610            return False
1611
1612    @test_tracker_info(uuid="dfa2c1a7-0e9a-42f2-b3ba-7e196df87e1b")
1613    @TelephonyBaseTest.tel_test_wrap
1614    def test_call_epdg_to_epdg_loop_wfc_wifi_only(self):
1615        """ Stress test: WiFi Only, WiFi calling to WiFi Calling test
1616
1617        1. Setup PhoneA WFC mode: WIFI_ONLY.
1618        2. Setup PhoneB WFC mode: WIFI_ONLY.
1619        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1620        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1621        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1622        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1623        7. Repeat step 3~6.
1624
1625        Returns:
1626            True if pass; False if fail.
1627        """
1628
1629        # TODO: b/26338422 Make this a parameter
1630        MINIMUM_SUCCESS_RATE = .95
1631        ads = self.android_devices
1632
1633        tasks = [(phone_setup_iwlan,
1634                  (self.log, ads[0], False, WFC_MODE_WIFI_ONLY,
1635                   self.wifi_network_ssid, self.wifi_network_pass)),
1636                 (phone_setup_iwlan,
1637                  (self.log, ads[1], False, WFC_MODE_WIFI_ONLY,
1638                   self.wifi_network_ssid, self.wifi_network_pass))]
1639        if not multithread_func(self.log, tasks):
1640            self.log.error("Phone Failed to Set Up Properly.")
1641            return False
1642
1643        success_count = 0
1644        fail_count = 0
1645
1646        for i in range(1, self.stress_test_number + 1):
1647
1648            if two_phone_call_long_seq(
1649                    self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan,
1650                    ads[1], phone_idle_iwlan, is_phone_in_call_iwlan, None,
1651                    WAIT_TIME_IN_CALL_FOR_IMS):
1652                success_count += 1
1653                result_str = "Succeeded"
1654
1655            else:
1656                fail_count += 1
1657                result_str = "Failed"
1658
1659            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
1660                          result_str, success_count, self.stress_test_number)
1661
1662        self.log.info("Final Count - Success: %s, Failure: %s - %s%",
1663                      success_count, fail_count,
1664                      str(100 * success_count / (success_count + fail_count)))
1665        if success_count / (
1666                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
1667            return True
1668        else:
1669            return False
1670
1671    @test_tracker_info(uuid="382f97ad-65d4-4ebb-a31b-aa243e01bce4")
1672    @TelephonyBaseTest.tel_test_wrap
1673    def test_call_epdg_to_epdg_loop_wfc_wifi_preferred(self):
1674        """ Stress test: WiFi Preferred, WiFi Calling to WiFi Calling test
1675
1676        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
1677        2. Setup PhoneB WFC mode: WIFI_PREFERRED.
1678        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1679        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1680        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1681        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1682        7. Repeat step 3~6.
1683
1684        Returns:
1685            True if pass; False if fail.
1686        """
1687
1688        # TODO: b/26338422 Make this a parameter
1689        MINIMUM_SUCCESS_RATE = .95
1690        ads = self.android_devices
1691
1692        tasks = [(phone_setup_iwlan,
1693                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
1694                   self.wifi_network_ssid, self.wifi_network_pass)),
1695                 (phone_setup_iwlan,
1696                  (self.log, ads[1], False, WFC_MODE_WIFI_PREFERRED,
1697                   self.wifi_network_ssid, self.wifi_network_pass))]
1698        if not multithread_func(self.log, tasks):
1699            self.log.error("Phone Failed to Set Up Properly.")
1700            return False
1701
1702        success_count = 0
1703        fail_count = 0
1704
1705        for i in range(1, self.stress_test_number + 1):
1706
1707            if two_phone_call_long_seq(
1708                    self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan,
1709                    ads[1], phone_idle_iwlan, is_phone_in_call_iwlan, None,
1710                    WAIT_TIME_IN_CALL_FOR_IMS):
1711                success_count += 1
1712                result_str = "Succeeded"
1713
1714            else:
1715                fail_count += 1
1716                result_str = "Failed"
1717
1718            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
1719                          result_str, success_count, self.stress_test_number)
1720
1721        self.log.info("Final Count - Success: %s, Failure: %s - %s%",
1722                      success_count, fail_count,
1723                      str(100 * success_count / (success_count + fail_count)))
1724        if success_count / (
1725                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
1726            return True
1727        else:
1728            return False
1729
1730    @test_tracker_info(uuid="c820e2ea-8a14-421c-b608-9074b716f7dd")
1731    @TelephonyBaseTest.tel_test_wrap
1732    def test_call_epdg_to_epdg_loop_apm_wfc_wifi_only(self):
1733        """ Stress test: Airplane + WiFi Only, WiFi Calling to WiFi Calling test
1734
1735        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
1736        2. Setup PhoneB in airplane mode, WFC mode: WIFI_ONLY.
1737        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1738        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1739        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1740        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1741        7. Repeat step 3~6.
1742
1743        Returns:
1744            True if pass; False if fail.
1745        """
1746
1747        # TODO: b/26338422 Make this a parameter
1748        MINIMUM_SUCCESS_RATE = .95
1749        ads = self.android_devices
1750
1751        tasks = [(phone_setup_iwlan,
1752                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
1753                   self.wifi_network_ssid, self.wifi_network_pass)),
1754                 (phone_setup_iwlan,
1755                  (self.log, ads[1], True, WFC_MODE_WIFI_ONLY,
1756                   self.wifi_network_ssid, self.wifi_network_pass))]
1757        if not multithread_func(self.log, tasks):
1758            self.log.error("Phone Failed to Set Up Properly.")
1759            return False
1760
1761        success_count = 0
1762        fail_count = 0
1763
1764        for i in range(1, self.stress_test_number + 1):
1765
1766            if two_phone_call_long_seq(
1767                    self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan,
1768                    ads[1], phone_idle_iwlan, is_phone_in_call_iwlan, None,
1769                    WAIT_TIME_IN_CALL_FOR_IMS):
1770                success_count += 1
1771                result_str = "Succeeded"
1772
1773            else:
1774                fail_count += 1
1775                result_str = "Failed"
1776
1777            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
1778                          result_str, success_count, self.stress_test_number)
1779
1780        self.log.info("Final Count - Success: %s, Failure: %s - %s%",
1781                      success_count, fail_count,
1782                      str(100 * success_count / (success_count + fail_count)))
1783        if success_count / (
1784                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
1785            return True
1786        else:
1787            return False
1788
1789    @test_tracker_info(uuid="3b8cb344-1551-4244-845d-b864501f2fb4")
1790    @TelephonyBaseTest.tel_test_wrap
1791    def test_call_epdg_to_epdg_loop_apm_wfc_wifi_preferred(self):
1792        """ Stress test: Airplane + WiFi Preferred, WiFi Calling to WiFi Calling test
1793
1794        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
1795        2. Setup PhoneB in airplane mode, WFC mode: WIFI_PREFERRED.
1796        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1797        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1798        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1799        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1800        7. Repeat step 3~6.
1801
1802        Returns:
1803            True if pass; False if fail.
1804        """
1805
1806        # TODO: b/26338422 Make this a parameter
1807        MINIMUM_SUCCESS_RATE = .95
1808        ads = self.android_devices
1809
1810        tasks = [(phone_setup_iwlan,
1811                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
1812                   self.wifi_network_ssid, self.wifi_network_pass)),
1813                 (phone_setup_iwlan,
1814                  (self.log, ads[1], True, WFC_MODE_WIFI_PREFERRED,
1815                   self.wifi_network_ssid, self.wifi_network_pass))]
1816        if not multithread_func(self.log, tasks):
1817            self.log.error("Phone Failed to Set Up Properly.")
1818            return False
1819
1820        success_count = 0
1821        fail_count = 0
1822
1823        for i in range(1, self.stress_test_number + 1):
1824
1825            if two_phone_call_long_seq(
1826                    self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan,
1827                    ads[1], phone_idle_iwlan, is_phone_in_call_iwlan, None,
1828                    WAIT_TIME_IN_CALL_FOR_IMS):
1829                success_count += 1
1830                result_str = "Succeeded"
1831
1832            else:
1833                fail_count += 1
1834                result_str = "Failed"
1835
1836            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
1837                          result_str, success_count, self.stress_test_number)
1838
1839        self.log.info("Final Count - Success: %s, Failure: %s - %s%",
1840                      success_count, fail_count,
1841                      str(100 * success_count / (success_count + fail_count)))
1842        if success_count / (
1843                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
1844            return True
1845        else:
1846            return False
1847
1848    @test_tracker_info(uuid="")
1849    @TelephonyBaseTest.tel_test_wrap
1850    def test_call_csfb_3g_to_csfb_3g_loop(self):
1851        """ Stress test: CSFB 3G to CSFB 3G call test
1852
1853        1. Make Sure PhoneA is in LTE mode, VoLTE disabled.
1854        2. Make Sure PhoneB is in LTE mode, VoLTE disabled.
1855        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1856        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1857        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1858        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1859        7. Repeat step 3~6.
1860
1861        Returns:
1862            True if pass; False if fail.
1863        """
1864
1865        # TODO: b/26338422 Make this a parameter
1866        MINIMUM_SUCCESS_RATE = .95
1867        ads = self.android_devices
1868        self.check_band_support(ads[0])
1869
1870        tasks = [(phone_setup_csfb, (self.log, ads[0])), (phone_setup_csfb,
1871                                                          (self.log, ads[1]))]
1872        if not multithread_func(self.log, tasks):
1873            self.log.error("Phone Failed to Set Up Properly.")
1874            return False
1875
1876        success_count = 0
1877        fail_count = 0
1878
1879        for i in range(1, self.stress_test_number + 1):
1880
1881            if two_phone_call_long_seq(
1882                    self.log, ads[0], phone_idle_csfb, is_phone_in_call_csfb,
1883                    ads[1], phone_idle_csfb, is_phone_in_call_csfb, None):
1884                success_count += 1
1885                result_str = "Succeeded"
1886
1887            else:
1888                fail_count += 1
1889                result_str = "Failed"
1890
1891            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
1892                          result_str, success_count, self.stress_test_number)
1893
1894        self.log.info("Final Count - Success: %s, Failure: %s", success_count,
1895                      fail_count)
1896        if success_count / (
1897                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
1898            return True
1899        else:
1900            return False
1901
1902    @test_tracker_info(uuid="")
1903    @TelephonyBaseTest.tel_test_wrap
1904    def test_call_3g_to_3g_loop(self):
1905        """ Stress test: 3G to 3G call test
1906
1907        1. Make Sure PhoneA is in 3G mode
1908        2. Make Sure PhoneB is in 3G mode
1909        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
1910        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
1911        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
1912        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
1913        7. Repeat step 3~6.
1914
1915        Returns:
1916            True if pass; False if fail.
1917        """
1918
1919        # TODO: b/26338422 Make this a parameter
1920        MINIMUM_SUCCESS_RATE = .95
1921        ads = self.android_devices
1922        self.check_band_support(ads[0])
1923
1924        tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
1925                 (phone_setup_voice_3g, (self.log, ads[1]))]
1926        if not multithread_func(self.log, tasks):
1927            self.log.error("Phone Failed to Set Up Properly.")
1928            return False
1929
1930        success_count = 0
1931        fail_count = 0
1932
1933        for i in range(1, self.stress_test_number + 1):
1934
1935            if two_phone_call_long_seq(
1936                    self.log, ads[0], phone_idle_3g, is_phone_in_call_3g,
1937                    ads[1], phone_idle_3g, is_phone_in_call_3g, None):
1938                success_count += 1
1939                result_str = "Succeeded"
1940
1941            else:
1942                fail_count += 1
1943                result_str = "Failed"
1944
1945            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
1946                          result_str, success_count, self.stress_test_number)
1947
1948        self.log.info("Final Count - Success: %s, Failure: %s", success_count,
1949                      fail_count)
1950        if success_count / (
1951                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
1952            return True
1953        else:
1954            return False
1955
1956    @test_tracker_info(uuid="4043c68a-c5d4-4e1d-9010-ef65b205cab1")
1957    @TelephonyBaseTest.tel_test_wrap
1958    def test_call_epdg_mo_hold_unhold_wfc_wifi_only(self):
1959        """ WiFi Only, WiFi calling MO call hold/unhold test
1960
1961        1. Setup PhoneA WFC mode: WIFI_ONLY.
1962        2. Make sure PhoneB can make/receive voice call.
1963        3. Call from PhoneA to PhoneB, accept on PhoneB.
1964        4. Hold and unhold on PhoneA.
1965
1966        Returns:
1967            True if pass; False if fail.
1968        """
1969        ads = self.android_devices
1970
1971        tasks = [(phone_setup_iwlan,
1972                  (self.log, ads[0], False, WFC_MODE_WIFI_ONLY,
1973                   self.wifi_network_ssid, self.wifi_network_pass)),
1974                 (phone_setup_voice_general, (self.log, ads[1]))]
1975        if not multithread_func(self.log, tasks):
1976            self.log.error("Phone Failed to Set Up Properly.")
1977            return False
1978
1979        ads[0].droid.telecomCallClearCallList()
1980        if num_active_calls(self.log, ads[0]) != 0:
1981            ads[0].log.error("Call List is not empty.")
1982            return False
1983
1984        self.log.info("Begin MO Call Hold/Unhold Test.")
1985        if not call_setup_teardown(
1986                self.log,
1987                ads[0],
1988                ads[1],
1989                ad_hangup=None,
1990                verify_caller_func=is_phone_in_call_iwlan,
1991                verify_callee_func=None):
1992            return False
1993
1994        if not hold_unhold_test(ads[0].log, ads)[0]:
1995            self.log.error("Hold/Unhold test fail.")
1996            return False
1997
1998        if not hangup_call(self.log, ads[0]):
1999            self.log.error("Call Hangup Failed")
2000            return False
2001
2002        return True
2003
2004    @test_tracker_info(uuid="0667535e-dcad-49f0-9b4b-fa45d6c75f5b")
2005    @TelephonyBaseTest.tel_test_wrap
2006    def test_call_epdg_mo_hold_unhold_wfc_wifi_preferred(self):
2007        """ WiFi Preferred, WiFi calling MO call hold/unhold test
2008
2009        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
2010        2. Make sure PhoneB can make/receive voice call.
2011        3. Call from PhoneA to PhoneB, accept on PhoneB.
2012        4. Hold and unhold on PhoneA.
2013
2014        Returns:
2015            True if pass; False if fail.
2016        """
2017        ads = self.android_devices
2018
2019        tasks = [(phone_setup_iwlan,
2020                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
2021                   self.wifi_network_ssid, self.wifi_network_pass)),
2022                 (phone_setup_voice_general, (self.log, ads[1]))]
2023        if not multithread_func(self.log, tasks):
2024            self.log.error("Phone Failed to Set Up Properly.")
2025            return False
2026
2027        ads[0].droid.telecomCallClearCallList()
2028        if num_active_calls(self.log, ads[0]) != 0:
2029            ads[0].log.error("Call List is not empty.")
2030            return False
2031
2032        self.log.info("Begin MO Call Hold/Unhold Test.")
2033        if not call_setup_teardown(
2034                self.log,
2035                ads[0],
2036                ads[1],
2037                ad_hangup=None,
2038                verify_caller_func=is_phone_in_call_iwlan,
2039                verify_callee_func=None):
2040            return False
2041
2042        if not hold_unhold_test(ads[0].log, ads)[0]:
2043            self.log.error("Hold/Unhold test fail.")
2044            return False
2045
2046        if not hangup_call(self.log, ads[0]):
2047            self.log.error("Call Hangup Failed")
2048            return False
2049
2050        return True
2051
2052    @test_tracker_info(uuid="cf318b4c-c920-4e80-b73f-2f092c03a144")
2053    @TelephonyBaseTest.tel_test_wrap
2054    def test_call_epdg_mo_hold_unhold_apm_wfc_wifi_only(self):
2055        """ Airplane + WiFi Only, WiFi calling MO call hold/unhold test
2056
2057        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
2058        2. Make sure PhoneB can make/receive voice call.
2059        3. Call from PhoneA to PhoneB, accept on PhoneB.
2060        4. Hold and unhold on PhoneA.
2061
2062        Returns:
2063            True if pass; False if fail.
2064        """
2065        ads = self.android_devices
2066
2067        tasks = [(phone_setup_iwlan,
2068                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
2069                   self.wifi_network_ssid, self.wifi_network_pass)),
2070                 (phone_setup_voice_general, (self.log, ads[1]))]
2071        if not multithread_func(self.log, tasks):
2072            self.log.error("Phone Failed to Set Up Properly.")
2073            return False
2074
2075        ads[0].droid.telecomCallClearCallList()
2076        if num_active_calls(self.log, ads[0]) != 0:
2077            ads[0].log.error("Call List is not empty.")
2078            return False
2079
2080        self.log.info("Begin MO Call Hold/Unhold Test.")
2081        if not call_setup_teardown(
2082                self.log,
2083                ads[0],
2084                ads[1],
2085                ad_hangup=None,
2086                verify_caller_func=is_phone_in_call_iwlan,
2087                verify_callee_func=None):
2088            return False
2089
2090        if not hold_unhold_test(ads[0].log, ads)[0]:
2091            self.log.error("Hold/Unhold test fail.")
2092            return False
2093
2094        if not hangup_call(self.log, ads[0]):
2095            self.log.error("Call Hangup Failed")
2096            return False
2097
2098        return True
2099
2100    @test_tracker_info(uuid="ace36801-1e7b-4f06-aa0b-17affc8df069")
2101    @TelephonyBaseTest.tel_test_wrap
2102    def test_call_epdg_mo_hold_unhold_apm_wfc_wifi_preferred(self):
2103        """ Airplane + WiFi Preferred, WiFi calling MO call hold/unhold test
2104
2105        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
2106        2. Make sure PhoneB can make/receive voice call.
2107        3. Call from PhoneA to PhoneB, accept on PhoneB.
2108        4. Hold and unhold on PhoneA.
2109
2110        Returns:
2111            True if pass; False if fail.
2112        """
2113        ads = self.android_devices
2114
2115        tasks = [(phone_setup_iwlan,
2116                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
2117                   self.wifi_network_ssid, self.wifi_network_pass)),
2118                 (phone_setup_voice_general, (self.log, ads[1]))]
2119        if not multithread_func(self.log, tasks):
2120            self.log.error("Phone Failed to Set Up Properly.")
2121            return False
2122
2123        ads[0].droid.telecomCallClearCallList()
2124        if num_active_calls(self.log, ads[0]) != 0:
2125            ads[0].log.error("Call List is not empty.")
2126            return False
2127
2128        self.log.info("Begin MO Call Hold/Unhold Test.")
2129        if not call_setup_teardown(
2130                self.log,
2131                ads[0],
2132                ads[1],
2133                ad_hangup=None,
2134                verify_caller_func=is_phone_in_call_iwlan,
2135                verify_callee_func=None):
2136            return False
2137
2138        if not hold_unhold_test(ads[0].log, ads)[0]:
2139            self.log.error("Hold/Unhold test fail.")
2140            return False
2141
2142        if not hangup_call(self.log, ads[0]):
2143            self.log.error("Call Hangup Failed")
2144            return False
2145
2146        return True
2147
2148    @test_tracker_info(uuid="2ad32874-0d39-4475-8ae3-d6dccda675f5")
2149    @TelephonyBaseTest.tel_test_wrap
2150    def test_call_epdg_mt_hold_unhold_wfc_wifi_only(self):
2151        """ WiFi Only, WiFi calling MT call hold/unhold test
2152
2153        1. Setup PhoneA WFC mode: WIFI_ONLY.
2154        2. Make sure PhoneB can make/receive voice call.
2155        3. Call from PhoneB to PhoneA, accept on PhoneA.
2156        4. Hold and unhold on PhoneA.
2157
2158        Returns:
2159            True if pass; False if fail.
2160        """
2161        ads = self.android_devices
2162
2163        tasks = [(phone_setup_iwlan,
2164                  (self.log, ads[0], False, WFC_MODE_WIFI_ONLY,
2165                   self.wifi_network_ssid, self.wifi_network_pass)),
2166                 (phone_setup_voice_general, (self.log, ads[1]))]
2167        if not multithread_func(self.log, tasks):
2168            self.log.error("Phone Failed to Set Up Properly.")
2169            return False
2170
2171        ads[0].droid.telecomCallClearCallList()
2172        if num_active_calls(self.log, ads[0]) != 0:
2173            ads[0].log.error("Call List is not empty.")
2174            return False
2175
2176        self.log.info("Begin MT Call Hold/Unhold Test.")
2177        if not call_setup_teardown(
2178                self.log,
2179                ads[1],
2180                ads[0],
2181                ad_hangup=None,
2182                verify_caller_func=None,
2183                verify_callee_func=is_phone_in_call_iwlan):
2184            return False
2185
2186        if not hold_unhold_test(ads[0].log, ads)[0]:
2187            self.log.error("Hold/Unhold test fail.")
2188            return False
2189
2190        if not hangup_call(self.log, ads[0]):
2191            self.log.error("Call Hangup Failed")
2192            return False
2193
2194        return True
2195
2196    @test_tracker_info(uuid="3efd5d59-30ee-45f5-8966-56ce8fadf9a1")
2197    @TelephonyBaseTest.tel_test_wrap
2198    def test_call_epdg_mt_hold_unhold_wfc_wifi_preferred(self):
2199        """ WiFi Preferred, WiFi calling MT call hold/unhold test
2200
2201        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
2202        2. Make sure PhoneB can make/receive voice call.
2203        3. Call from PhoneB to PhoneA, accept on PhoneA.
2204        4. Hold and unhold on PhoneA.
2205
2206        Returns:
2207            True if pass; False if fail.
2208        """
2209        ads = self.android_devices
2210
2211        tasks = [(phone_setup_iwlan,
2212                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
2213                   self.wifi_network_ssid, self.wifi_network_pass)),
2214                 (phone_setup_voice_general, (self.log, ads[1]))]
2215        if not multithread_func(self.log, tasks):
2216            self.log.error("Phone Failed to Set Up Properly.")
2217            return False
2218
2219        ads[0].droid.telecomCallClearCallList()
2220        if num_active_calls(self.log, ads[0]) != 0:
2221            ads[0].log.error("Call List is not empty.")
2222            return False
2223
2224        self.log.info("Begin MT Call Hold/Unhold Test.")
2225        if not call_setup_teardown(
2226                self.log,
2227                ads[1],
2228                ads[0],
2229                ad_hangup=None,
2230                verify_caller_func=None,
2231                verify_callee_func=is_phone_in_call_iwlan):
2232            return False
2233
2234        if not hold_unhold_test(ads[0].log, ads)[0]:
2235            self.log.error("Hold/Unhold test fail.")
2236            return False
2237
2238        return True
2239
2240    @test_tracker_info(uuid="35ed0f89-7435-4d3b-9ebc-c5cdc3f7e32b")
2241    @TelephonyBaseTest.tel_test_wrap
2242    def test_call_epdg_mt_hold_unhold_apm_wfc_wifi_only(self):
2243        """ Airplane + WiFi Only, WiFi calling MT call hold/unhold test
2244
2245        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
2246        2. Make sure PhoneB can make/receive voice call.
2247        3. Call from PhoneB to PhoneA, accept on PhoneA.
2248        4. Hold and unhold on PhoneA.
2249
2250        Returns:
2251            True if pass; False if fail.
2252        """
2253        ads = self.android_devices
2254
2255        tasks = [(phone_setup_iwlan,
2256                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
2257                   self.wifi_network_ssid, self.wifi_network_pass)),
2258                 (phone_setup_voice_general, (self.log, ads[1]))]
2259        if not multithread_func(self.log, tasks):
2260            self.log.error("Phone Failed to Set Up Properly.")
2261            return False
2262
2263        ads[0].droid.telecomCallClearCallList()
2264        if num_active_calls(self.log, ads[0]) != 0:
2265            ads[0].log.error("Call List is not empty.")
2266            return False
2267
2268        self.log.info("Begin MT Call Hold/Unhold Test.")
2269        if not call_setup_teardown(
2270                self.log,
2271                ads[1],
2272                ads[0],
2273                ad_hangup=None,
2274                verify_caller_func=None,
2275                verify_callee_func=is_phone_in_call_iwlan):
2276            return False
2277
2278        if not hold_unhold_test(ads[0].log, ads)[0]:
2279            self.log.error("Hold/Unhold test fail.")
2280            return False
2281
2282        if not hangup_call(self.log, ads[0]):
2283            self.log.error("Call Hangup Failed")
2284            return False
2285
2286        return True
2287
2288    @test_tracker_info("37ad003b-6426-42f7-b528-ec7c1842fd18")
2289    @TelephonyBaseTest.tel_test_wrap
2290    def test_call_epdg_mt_hold_unhold_apm_wfc_wifi_preferred(self):
2291        """ Airplane + WiFi Preferred, WiFi calling MT call hold/unhold test
2292
2293        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
2294        2. Make sure PhoneB can make/receive voice call.
2295        3. Call from PhoneB to PhoneA, accept on PhoneA.
2296        4. Hold and unhold on PhoneA.
2297
2298        Returns:
2299            True if pass; False if fail.
2300        """
2301        ads = self.android_devices
2302
2303        tasks = [(phone_setup_iwlan,
2304                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
2305                   self.wifi_network_ssid, self.wifi_network_pass)),
2306                 (phone_setup_voice_general, (self.log, ads[1]))]
2307        if not multithread_func(self.log, tasks):
2308            self.log.error("Phone Failed to Set Up Properly.")
2309            return False
2310
2311        ads[0].droid.telecomCallClearCallList()
2312        if num_active_calls(self.log, ads[0]) != 0:
2313            ads[0].log.error("Call List is not empty.")
2314            return False
2315
2316        self.log.info("Begin MT Call Hold/Unhold Test.")
2317        if not call_setup_teardown(
2318                self.log,
2319                ads[1],
2320                ads[0],
2321                ad_hangup=None,
2322                verify_caller_func=None,
2323                verify_callee_func=is_phone_in_call_iwlan):
2324            return False
2325
2326        if not hold_unhold_test(ads[0].log, ads)[0]:
2327            self.log.error("Hold/Unhold test fail.")
2328            return False
2329
2330        if not hangup_call(self.log, ads[0]):
2331            self.log.error("Call Hangup Failed")
2332            return False
2333
2334        return True
2335
2336    @test_tracker_info(uuid="fa37cd37-c30a-4caa-80b4-52507995ec77")
2337    @TelephonyBaseTest.tel_test_wrap
2338    def test_call_volte_mo_hold_unhold(self):
2339        """ VoLTE MO call hold/unhold test
2340
2341        1. Make Sure PhoneA is in LTE mode (with VoLTE).
2342        2. Make Sure PhoneB is able to make/receive call.
2343        3. Call from PhoneA to PhoneB, accept on PhoneB.
2344        4. Hold and unhold on PhoneA.
2345
2346        Returns:
2347            True if pass; False if fail.
2348        """
2349        ads = self.android_devices
2350
2351        tasks = [(phone_setup_volte, (self.log, ads[0])),
2352                 (phone_setup_voice_general, (self.log, ads[1]))]
2353        if not multithread_func(self.log, tasks):
2354            self.log.error("Phone Failed to Set Up Properly.")
2355            return False
2356
2357        ads[0].droid.telecomCallClearCallList()
2358        if num_active_calls(self.log, ads[0]) != 0:
2359            ads[0].log.error("Call List is not empty.")
2360            return False
2361
2362        self.log.info("Begin MO Call Hold/Unhold Test.")
2363        if not call_setup_teardown(
2364                self.log,
2365                ads[0],
2366                ads[1],
2367                ad_hangup=None,
2368                verify_caller_func=is_phone_in_call_volte,
2369                verify_callee_func=None):
2370            return False
2371
2372        if not hold_unhold_test(ads[0].log, ads)[0]:
2373            self.log.error("Hold/Unhold test fail.")
2374            return False
2375
2376        if not hangup_call(self.log, ads[0]):
2377            self.log.error("Call Hangup Failed")
2378            return False
2379
2380        return True
2381
2382    @test_tracker_info(uuid="28a9acb3-83e8-4dd1-82bf-173da8bd2eca")
2383    @TelephonyBaseTest.tel_test_wrap
2384    def test_call_volte_mt_hold_unhold(self):
2385        """ VoLTE MT call hold/unhold test
2386
2387        1. Make Sure PhoneA is in LTE mode (with VoLTE).
2388        2. Make Sure PhoneB is able to make/receive call.
2389        3. Call from PhoneB to PhoneA, accept on PhoneA.
2390        4. Hold and unhold on PhoneA.
2391
2392        Returns:
2393            True if pass; False if fail.
2394        """
2395        ads = self.android_devices
2396
2397        tasks = [(phone_setup_volte, (self.log, ads[0])),
2398                 (phone_setup_voice_general, (self.log, ads[1]))]
2399        if not multithread_func(self.log, tasks):
2400            self.log.error("Phone Failed to Set Up Properly.")
2401            return False
2402
2403        ads[0].droid.telecomCallClearCallList()
2404        if num_active_calls(self.log, ads[0]) != 0:
2405            ads[0].log.error("Call List is not empty.")
2406            return False
2407
2408        self.log.info("Begin MT Call Hold/Unhold Test.")
2409        if not call_setup_teardown(
2410                self.log,
2411                ads[1],
2412                ads[0],
2413                ad_hangup=None,
2414                verify_caller_func=None,
2415                verify_callee_func=is_phone_in_call_volte):
2416            return False
2417
2418        if not hold_unhold_test(ads[0].log, ads)[0]:
2419            self.log.error("Hold/Unhold test fail.")
2420            return False
2421
2422        if not hangup_call(self.log, ads[0]):
2423            self.log.error("Call Hangup Failed")
2424            return False
2425
2426        return True
2427
2428    @test_tracker_info(uuid="ffe724ae-4223-4c15-9fed-9aba17de9a63")
2429    @TelephonyBaseTest.tel_test_wrap
2430    def test_call_wcdma_mo_hold_unhold(self):
2431        """ MO WCDMA hold/unhold test
2432
2433        1. Make Sure PhoneA is in 3G WCDMA mode.
2434        2. Make Sure PhoneB is able to make/receive call.
2435        3. Call from PhoneA to PhoneB, accept on PhoneB.
2436        4. Hold and unhold on PhoneA.
2437
2438        Returns:
2439            True if pass; False if fail.
2440        """
2441        ads = self.android_devices
2442        self.check_band_support(ads[0])
2443        # make sure PhoneA is GSM phone before proceed.
2444        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
2445            ads[0].log.error(
2446                "Not GSM phone, abort this wcdma hold/unhold test.")
2447            raise signals.TestSkip(
2448                "Not GSM phone, abort this wcdma hold/unhold test")
2449
2450        tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
2451                 (phone_setup_voice_general, (self.log, ads[1]))]
2452        if not multithread_func(self.log, tasks):
2453            self.log.error("Phone Failed to Set Up Properly.")
2454            return False
2455
2456        ads[0].droid.telecomCallClearCallList()
2457        if num_active_calls(self.log, ads[0]) != 0:
2458            ads[0].log.error("Call List is not empty.")
2459            return False
2460
2461        self.log.info("Begin MO Call Hold/Unhold Test.")
2462        if not call_setup_teardown(
2463                self.log,
2464                ads[0],
2465                ads[1],
2466                ad_hangup=None,
2467                verify_caller_func=is_phone_in_call_3g,
2468                verify_callee_func=None):
2469            return False
2470
2471        if not hold_unhold_test(ads[0].log, ads)[0]:
2472            self.log.error("Hold/Unhold test fail.")
2473            return False
2474
2475        if not hangup_call(self.log, ads[0]):
2476            self.log.error("Call Hangup Failed")
2477            return False
2478
2479        return True
2480
2481    @test_tracker_info(uuid="23805165-01ce-4351-83d3-73c9fb3bda76")
2482    @TelephonyBaseTest.tel_test_wrap
2483    def test_call_wcdma_mt_hold_unhold(self):
2484        """ MT WCDMA hold/unhold test
2485
2486        1. Make Sure PhoneA is in 3G WCDMA mode.
2487        2. Make Sure PhoneB is able to make/receive call.
2488        3. Call from PhoneB to PhoneA, accept on PhoneA.
2489        4. Hold and unhold on PhoneA.
2490
2491        Returns:
2492            True if pass; False if fail.
2493        """
2494        ads = self.android_devices
2495        self.check_band_support(ads[0])
2496        # make sure PhoneA is GSM phone before proceed.
2497        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
2498            ads[0].log.error(
2499                "Not GSM phone, abort this wcdma hold/unhold test.")
2500            raise signals.TestSkip(
2501                "Not GSM phone, abort this wcdma hold/unhold test")
2502
2503        tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
2504                 (phone_setup_voice_general, (self.log, ads[1]))]
2505        if not multithread_func(self.log, tasks):
2506            self.log.error("Phone Failed to Set Up Properly.")
2507            return False
2508
2509        ads[0].droid.telecomCallClearCallList()
2510        if num_active_calls(self.log, ads[0]) != 0:
2511            ads[0].log.error("Call List is not empty.")
2512            return False
2513
2514        self.log.info("Begin MT Call Hold/Unhold Test.")
2515        if not call_setup_teardown(
2516                self.log,
2517                ads[1],
2518                ads[0],
2519                ad_hangup=None,
2520                verify_caller_func=None,
2521                verify_callee_func=is_phone_in_call_3g):
2522            return False
2523
2524        if not hold_unhold_test(ads[0].log, ads)[0]:
2525            self.log.error("Hold/Unhold test fail.")
2526            return False
2527
2528        if not hangup_call(self.log, ads[0]):
2529            self.log.error("Call Hangup Failed")
2530            return False
2531
2532        return True
2533
2534    @test_tracker_info(uuid="08c846c7-1978-4ece-8f2c-731129947699")
2535    @TelephonyBaseTest.tel_test_wrap
2536    def test_call_csfb_mo_hold_unhold(self):
2537        """ MO CSFB WCDMA/GSM hold/unhold test
2538
2539        1. Make Sure PhoneA is in LTE mode (VoLTE disabled).
2540        2. Make Sure PhoneB is able to make/receive call.
2541        3. Call from PhoneA to PhoneB, accept on PhoneB.
2542        4. Hold and unhold on PhoneA.
2543
2544        Returns:
2545            True if pass; False if fail.
2546        """
2547        ads = self.android_devices
2548        # make sure PhoneA is GSM phone before proceed.
2549        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
2550            self.log.error("Not GSM phone, abort this wcdma hold/unhold test.")
2551            raise signals.TestSkip(
2552                "Not GSM phone, abort this wcdma hold/unhold test")
2553
2554        tasks = [(phone_setup_csfb, (self.log, ads[0])),
2555                 (phone_setup_voice_general, (self.log, ads[1]))]
2556        if not multithread_func(self.log, tasks):
2557            self.log.error("Phone Failed to Set Up Properly.")
2558            return False
2559
2560        ads[0].droid.telecomCallClearCallList()
2561        if num_active_calls(self.log, ads[0]) != 0:
2562            ads[0].log.error("Call List is not empty.")
2563            return False
2564
2565        self.log.info("Begin MO Call Hold/Unhold Test.")
2566        if not call_setup_teardown(
2567                self.log,
2568                ads[0],
2569                ads[1],
2570                ad_hangup=None,
2571                verify_caller_func=is_phone_in_call_csfb,
2572                verify_callee_func=None):
2573            return False
2574
2575        if not hold_unhold_test(ads[0].log, ads)[0]:
2576            self.log.error("Hold/Unhold test fail.")
2577            return False
2578
2579        if not hangup_call(self.log, ads[0]):
2580            self.log.error("Call Hangup Failed")
2581            return False
2582
2583        return True
2584
2585    @test_tracker_info(uuid="a6405fe6-c732-4ae6-bbae-e912a124f4a2")
2586    @TelephonyBaseTest.tel_test_wrap
2587    def test_call_csfb_mt_hold_unhold(self):
2588        """ MT CSFB WCDMA/GSM hold/unhold test
2589
2590        1. Make Sure PhoneA is in LTE mode (VoLTE disabled).
2591        2. Make Sure PhoneB is able to make/receive call.
2592        3. Call from PhoneB to PhoneA, accept on PhoneA.
2593        4. Hold and unhold on PhoneA.
2594
2595        Returns:
2596            True if pass; False if fail.
2597        """
2598        ads = self.android_devices
2599        # make sure PhoneA is GSM phone before proceed.
2600        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
2601            ads[0].log.error(
2602                "Not GSM phone, abort this wcdma hold/unhold test.")
2603            raise signals.TestSkip(
2604                "Not GSM phone, abort this wcdma hold/unhold test")
2605
2606        tasks = [(phone_setup_csfb, (self.log, ads[0])),
2607                 (phone_setup_voice_general, (self.log, ads[1]))]
2608        if not multithread_func(self.log, tasks):
2609            self.log.error("Phone Failed to Set Up Properly.")
2610            return False
2611
2612        ads[0].droid.telecomCallClearCallList()
2613        if num_active_calls(self.log, ads[0]) != 0:
2614            ads[0].log.error("Call List is not empty.")
2615            return False
2616
2617        self.log.info("Begin MT Call Hold/Unhold Test.")
2618        if not call_setup_teardown(
2619                self.log,
2620                ads[1],
2621                ads[0],
2622                ad_hangup=None,
2623                verify_caller_func=None,
2624                verify_callee_func=is_phone_in_call_csfb):
2625            return False
2626
2627        if not hold_unhold_test(ads[0].log, ads)[0]:
2628            self.log.error("Hold/Unhold test fail.")
2629            return False
2630
2631        if not hangup_call(self.log, ads[0]):
2632            self.log.error("Call Hangup Failed")
2633            return False
2634
2635        return True
2636
2637    @test_tracker_info(uuid="5edc5034-90ef-4113-926f-05407ed60a87")
2638    @TelephonyBaseTest.tel_test_wrap
2639    def test_erase_all_pending_voicemail(self):
2640        """Script for TMO/ATT/SPT phone to erase all pending voice mail.
2641        This script only works if phone have already set up voice mail options,
2642        and phone should disable password protection for voice mail.
2643
2644        1. If phone don't have pending voice message, return True.
2645        2. Dial voice mail number.
2646            For TMO, the number is '123'.
2647            For ATT, the number is phone's number.
2648            For SPT, the number is phone's number.
2649        3. Use DTMF to delete all pending voice messages.
2650        4. Check telephonyGetVoiceMailCount result. it should be 0.
2651
2652        Returns:
2653            False if error happens. True is succeed.
2654        """
2655        ads = self.android_devices
2656
2657        tasks = [(phone_setup_voice_general, (self.log, ads[0])),
2658                 (phone_setup_voice_general, (self.log, ads[1]))]
2659        if not multithread_func(self.log, tasks):
2660            self.log.error("Phone Failed to Set Up Properly.")
2661            return False
2662
2663        return call_voicemail_erase_all_pending_voicemail(
2664            self.log, self.android_devices[0])
2665
2666    @test_tracker_info(uuid="c81156a2-089b-4b10-ba80-7afea61d06c6")
2667    @TelephonyBaseTest.tel_test_wrap
2668    def test_voicemail_indicator_volte(self):
2669        """Test Voice Mail notification in LTE (VoLTE enabled).
2670        This script currently only works for TMO now.
2671
2672        1. Make sure DUT (ads[0]) in VoLTE mode. Both PhoneB (ads[0]) and DUT idle.
2673        2. Make call from PhoneB to DUT, reject on DUT.
2674        3. On PhoneB, leave a voice mail to DUT.
2675        4. Verify DUT receive voice mail notification.
2676
2677        Returns:
2678            True if pass; False if fail.
2679        """
2680        ads = self.android_devices
2681
2682        tasks = [(phone_setup_voice_general, (self.log, ads[1])),
2683                 (phone_setup_volte, (self.log, ads[0]))]
2684        if not multithread_func(self.log, tasks):
2685            self.log.error("Phone Failed to Set Up Properly.")
2686            return False
2687        if not call_voicemail_erase_all_pending_voicemail(self.log, ads[0]):
2688            self.log.error("Failed to clear voice mail.")
2689            return False
2690
2691        return two_phone_call_leave_voice_mail(self.log, ads[1], None, None,
2692                                               ads[0], phone_idle_volte)
2693
2694    @test_tracker_info(uuid="529e12cb-3178-4d2c-b155-d5cfb1eac0c9")
2695    @TelephonyBaseTest.tel_test_wrap
2696    def test_voicemail_indicator_lte(self):
2697        """Test Voice Mail notification in LTE (VoLTE disabled).
2698        This script currently only works for TMO/ATT/SPT now.
2699
2700        1. Make sure DUT (ads[1]) in LTE (No VoLTE) mode. Both PhoneB (ads[0]) and DUT idle.
2701        2. Make call from PhoneB to DUT, reject on DUT.
2702        3. On PhoneB, leave a voice mail to DUT.
2703        4. Verify DUT receive voice mail notification.
2704
2705        Returns:
2706            True if pass; False if fail.
2707        """
2708        ads = self.android_devices
2709
2710        tasks = [(phone_setup_voice_general, (self.log, ads[0])),
2711                 (phone_setup_csfb, (self.log, ads[1]))]
2712        if not multithread_func(self.log, tasks):
2713            self.log.error("Phone Failed to Set Up Properly.")
2714            return False
2715        if not call_voicemail_erase_all_pending_voicemail(self.log, ads[0]):
2716            self.log.error("Failed to clear voice mail.")
2717            return False
2718
2719        return two_phone_call_leave_voice_mail(self.log, ads[0], None, None,
2720                                               ads[1], phone_idle_csfb)
2721
2722    @test_tracker_info(uuid="60cef7dd-f990-4913-af9a-75e9336fc80a")
2723    @TelephonyBaseTest.tel_test_wrap
2724    def test_voicemail_indicator_3g(self):
2725        """Test Voice Mail notification in 3G
2726        This script currently only works for TMO/ATT/SPT now.
2727
2728        1. Make sure DUT (ads[0]) in 3G mode. Both PhoneB and DUT idle.
2729        2. Make call from PhoneB to DUT, reject on DUT.
2730        3. On PhoneB, leave a voice mail to DUT.
2731        4. Verify DUT receive voice mail notification.
2732
2733        Returns:
2734            True if pass; False if fail.
2735        """
2736        ads = self.android_devices
2737        self.check_band_support(ads[0])
2738
2739        tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
2740                 (phone_setup_voice_general, (self.log, ads[1]))]
2741        if not multithread_func(self.log, tasks):
2742            self.log.error("Phone Failed to Set Up Properly.")
2743            return False
2744        if not call_voicemail_erase_all_pending_voicemail(self.log, ads[0]):
2745            self.log.error("Failed to clear voice mail.")
2746            return False
2747
2748        return two_phone_call_leave_voice_mail(self.log, ads[1], None, None,
2749                                               ads[0], phone_idle_3g)
2750
2751    @test_tracker_info(uuid="e4c83cfa-db60-4258-ab69-15f7de3614b0")
2752    @TelephonyBaseTest.tel_test_wrap
2753    def test_voicemail_indicator_2g(self):
2754        """Test Voice Mail notification in 2G
2755        This script currently only works for TMO/ATT/SPT now.
2756
2757        1. Make sure DUT (ads[0]) in 2G mode. Both PhoneB (ads[1]) and DUT idle.
2758        2. Make call from PhoneB to DUT, reject on DUT.
2759        3. On PhoneB, leave a voice mail to DUT.
2760        4. Verify DUT receive voice mail notification.
2761
2762        Returns:
2763            True if pass; False if fail.
2764        """
2765        ads = self.android_devices
2766        self.check_band_support(ads[0])
2767
2768        tasks = [(phone_setup_voice_general, (self.log, ads[1])),
2769                 (phone_setup_voice_2g, (self.log, ads[0]))]
2770        if not multithread_func(self.log, tasks):
2771            self.log.error("Phone Failed to Set Up Properly.")
2772            return False
2773        if not call_voicemail_erase_all_pending_voicemail(self.log, ads[0]):
2774            self.log.error("Failed to clear voice mail.")
2775            return False
2776
2777        return two_phone_call_leave_voice_mail(self.log, ads[1], None, None,
2778                                               ads[0], phone_idle_2g)
2779
2780    @test_tracker_info(uuid="f0cb02fb-a028-43da-9c87-5b21b2f8549b")
2781    @TelephonyBaseTest.tel_test_wrap
2782    def test_voicemail_indicator_iwlan(self):
2783        """Test Voice Mail notification in WiFI Calling
2784        This script currently only works for TMO now.
2785
2786        1. Make sure DUT (ads[0]) in WFC mode. Both PhoneB (ads[1]) and DUT idle.
2787        2. Make call from PhoneB to DUT, reject on DUT.
2788        3. On PhoneB, leave a voice mail to DUT.
2789        4. Verify DUT receive voice mail notification.
2790
2791        Returns:
2792            True if pass; False if fail.
2793        """
2794        ads = self.android_devices
2795
2796        tasks = [(phone_setup_voice_general, (self.log, ads[1])),
2797                 (phone_setup_iwlan,
2798                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
2799                   self.wifi_network_ssid, self.wifi_network_pass))]
2800        if not multithread_func(self.log, tasks):
2801            self.log.error("Phone Failed to Set Up Properly.")
2802            return False
2803        if not call_voicemail_erase_all_pending_voicemail(self.log, ads[0]):
2804            self.log.error("Failed to clear voice mail.")
2805            return False
2806
2807        return two_phone_call_leave_voice_mail(self.log, ads[1], None, None,
2808                                               ads[0], phone_idle_iwlan)
2809
2810    @test_tracker_info(uuid="9bd0550e-abfd-436b-912f-571810f973d7")
2811    @TelephonyBaseTest.tel_test_wrap
2812    def test_voicemail_indicator_apm_iwlan(self):
2813        """Test Voice Mail notification in WiFI Calling
2814        This script currently only works for TMO now.
2815
2816        1. Make sure DUT (ads[0]) in APM WFC mode. Both PhoneB (ads[1]) and DUT idle.
2817        2. Make call from PhoneB to DUT, reject on DUT.
2818        3. On PhoneB, leave a voice mail to DUT.
2819        4. Verify DUT receive voice mail notification.
2820
2821        Returns:
2822            True if pass; False if fail.
2823        """
2824        ads = self.android_devices
2825
2826        tasks = [(phone_setup_voice_general, (self.log, ads[1])),
2827                 (phone_setup_iwlan,
2828                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
2829                   self.wifi_network_ssid, self.wifi_network_pass))]
2830        if not multithread_func(self.log, tasks):
2831            self.log.error("Phone Failed to Set Up Properly.")
2832            return False
2833        if not call_voicemail_erase_all_pending_voicemail(self.log, ads[0]):
2834            self.log.error("Failed to clear voice mail.")
2835            return False
2836
2837        return two_phone_call_leave_voice_mail(self.log, ads[1], None, None,
2838                                               ads[0], phone_idle_iwlan)
2839
2840    @test_tracker_info(uuid="6bd5cf0f-522e-4e4a-99bf-92ae46261d8c")
2841    @TelephonyBaseTest.tel_test_wrap
2842    def test_call_2g_to_2g(self):
2843        """ Test 2g<->2g call functionality.
2844
2845        Make Sure PhoneA is in 2g mode.
2846        Make Sure PhoneB is in 2g mode.
2847        Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
2848        Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
2849
2850        Raises:
2851            TestFailure if not success.
2852        """
2853        ads = self.android_devices
2854        self.check_band_support(ads[0])
2855
2856        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
2857                 (phone_setup_voice_2g, (self.log, ads[1]))]
2858        if not multithread_func(self.log, tasks):
2859            self.log.error("Phone Failed to Set Up Properly.")
2860            self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
2861            raise signals.TestFailure("Failed",
2862                extras={"fail_reason": "Phone Failed to Set Up Properly."})
2863
2864        result = two_phone_call_short_seq(
2865            self.log, ads[0], phone_idle_2g, is_phone_in_call_2g, ads[1],
2866            phone_idle_2g, is_phone_in_call_2g, None)
2867        self.tel_logger.set_result(result.result_value)
2868        if not result:
2869            raise signals.TestFailure("Failed",
2870                extras={"fail_reason": str(result.result_value)})
2871
2872    @test_tracker_info(uuid="947f3178-735b-4ac2-877c-a06a94972457")
2873    @TelephonyBaseTest.tel_test_wrap
2874    def test_call_2g_to_2g_long(self):
2875        """ Test 2g<->2g call functionality.
2876
2877        Make Sure PhoneA is in 2g mode.
2878        Make Sure PhoneB is in 2g mode.
2879        Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
2880        Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
2881        Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
2882        Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
2883
2884        Raises:
2885            TestFailure if not success.
2886        """
2887        ads = self.android_devices
2888        self.check_band_support(ads[0])
2889
2890        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
2891                 (phone_setup_voice_2g, (self.log, ads[1]))]
2892        if not multithread_func(self.log, tasks):
2893            self.log.error("Phone Failed to Set Up Properly.")
2894            raise signals.TestFailure("Failed",
2895                extras={"fail_reason": "Phone Failed to Set Up Properly."})
2896
2897        result = two_phone_call_long_seq(
2898            self.log, ads[0], phone_idle_2g, is_phone_in_call_2g, ads[1],
2899            phone_idle_2g, is_phone_in_call_2g, None)
2900        self.tel_logger.set_result(result.result_value)
2901        if not result:
2902            raise signals.TestFailure("Failed",
2903                extras={"fail_reason": str(result.result_value)})
2904
2905    @test_tracker_info(uuid="d109df55-ac2f-493f-9324-9be1d3d7d6d3")
2906    @TelephonyBaseTest.tel_test_wrap
2907    def test_call_gsm_mo_hold_unhold(self):
2908        """ Test GSM call hold/unhold functionality.
2909
2910        Make Sure PhoneA is in 2g mode (GSM).
2911        Make Sure PhoneB is able to make/receive call.
2912        Call from PhoneA to PhoneB, accept on PhoneB, hold and unhold on PhoneA.
2913
2914        Returns:
2915            True if pass; False if fail.
2916        """
2917        ads = self.android_devices
2918        self.check_band_support(ads[0])
2919        # make sure PhoneA is GSM phone before proceed.
2920        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
2921            raise signals.TestSkip(
2922                "Not GSM phone, abort this gsm hold/unhold test")
2923
2924        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
2925                 (phone_setup_voice_general, (self.log, ads[1]))]
2926        if not multithread_func(self.log, tasks):
2927            self.log.error("Phone Failed to Set Up Properly.")
2928            return False
2929
2930        ads[0].droid.telecomCallClearCallList()
2931        if num_active_calls(self.log, ads[0]) != 0:
2932            ads[0].log.error("Call List is not empty.")
2933            return False
2934
2935        self.log.info("Begin MO Call Hold/Unhold Test.")
2936        if not call_setup_teardown(
2937                self.log,
2938                ads[0],
2939                ads[1],
2940                ad_hangup=None,
2941                verify_caller_func=is_phone_in_call_2g,
2942                verify_callee_func=None):
2943            return False
2944
2945        if not hold_unhold_test(ads[0].log, ads)[0]:
2946            self.log.error("Hold/Unhold test fail.")
2947            return False
2948
2949        return True
2950
2951    @test_tracker_info(uuid="a8279cda-73b3-470a-8ca7-a331ef99270b")
2952    @TelephonyBaseTest.tel_test_wrap
2953    def test_call_gsm_mt_hold_unhold(self):
2954        """ Test GSM call hold/unhold functionality.
2955
2956        Make Sure PhoneA is in 2g mode (GSM).
2957        Make Sure PhoneB is able to make/receive call.
2958        Call from PhoneB to PhoneA, accept on PhoneA, hold and unhold on PhoneA.
2959
2960        Returns:
2961            True if pass; False if fail.
2962        """
2963        ads = self.android_devices
2964        self.check_band_support(ads[0])
2965        # make sure PhoneA is GSM phone before proceed.
2966        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
2967            self.log.error("Not GSM phone, abort this wcdma hold/unhold test.")
2968            return False
2969
2970        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
2971                 (phone_setup_voice_general, (self.log, ads[1]))]
2972        if not multithread_func(self.log, tasks):
2973            self.log.error("Phone Failed to Set Up Properly.")
2974            return False
2975
2976        ads[0].droid.telecomCallClearCallList()
2977        if num_active_calls(self.log, ads[0]) != 0:
2978            ads[0].log.error("Call List is not empty.")
2979            return False
2980
2981        self.log.info("Begin MT Call Hold/Unhold Test.")
2982        if not call_setup_teardown(
2983                self.log,
2984                ads[1],
2985                ads[0],
2986                ad_hangup=None,
2987                verify_caller_func=None,
2988                verify_callee_func=is_phone_in_call_2g):
2989            return False
2990
2991        if not hold_unhold_test(ads[0].log, ads)[0]:
2992            self.log.error("Hold/Unhold test fail.")
2993            return False
2994
2995        return True
2996
2997    @test_tracker_info(uuid="d0008b51-25ed-414a-9b82-3ffb139a6e0d")
2998    @TelephonyBaseTest.tel_test_wrap
2999    def test_call_long_duration_volte(self):
3000        """ Test call drop rate for VoLTE long duration call.
3001
3002        Steps:
3003        1. Setup VoLTE for DUT.
3004        2. Make VoLTE call from DUT to PhoneB.
3005        3. For <total_duration> time, check if DUT drop call or not.
3006
3007        Expected Results:
3008        DUT should not drop call.
3009
3010        Returns:
3011        False if DUT call dropped during test.
3012        Otherwise True.
3013        """
3014        ads = self.android_devices
3015
3016        tasks = [(phone_setup_volte, (self.log, ads[0])),
3017                 (phone_setup_voice_general, (self.log, ads[1]))]
3018        if not multithread_func(self.log, tasks):
3019            self.log.error("Phone Failed to Set Up Properly.")
3020            return False
3021
3022        return _test_call_long_duration(self.log, ads,
3023            is_phone_in_call_volte, self.long_call_duration)
3024
3025    @test_tracker_info(uuid="d4c1aec0-df05-403f-954c-496faf18605a")
3026    @TelephonyBaseTest.tel_test_wrap
3027    def test_call_long_duration_wfc(self):
3028        """ Test call drop rate for WiFi Calling long duration call.
3029
3030        Steps:
3031        1. Setup WFC for DUT.
3032        2. Make WFC call from DUT to PhoneB.
3033        3. For <total_duration> time, check if DUT drop call or not.
3034
3035        Expected Results:
3036        DUT should not drop call.
3037
3038        Returns:
3039        False if DUT call dropped during test.
3040        Otherwise True.
3041        """
3042        ads = self.android_devices
3043
3044        tasks = [(phone_setup_iwlan,
3045                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
3046                   self.wifi_network_ssid, self.wifi_network_pass)),
3047                 (phone_setup_voice_general, (self.log, ads[1]))]
3048        if not multithread_func(self.log, tasks):
3049            self.log.error("Phone Failed to Set Up Properly.")
3050            return False
3051
3052        return _test_call_long_duration(self.log, ads,
3053            is_phone_in_call_iwlan, self.long_call_duration)
3054
3055    @test_tracker_info(uuid="bc44f3ca-2616-4024-b959-3a5a85503dfd")
3056    @TelephonyBaseTest.tel_test_wrap
3057    def test_call_long_duration_3g(self):
3058        """ Test call drop rate for 3G long duration call.
3059
3060        Steps:
3061        1. Setup 3G for DUT.
3062        2. Make CS call from DUT to PhoneB.
3063        3. For <total_duration> time, check if DUT drop call or not.
3064
3065        Expected Results:
3066        DUT should not drop call.
3067
3068        Returns:
3069        False if DUT call dropped during test.
3070        Otherwise True.
3071        """
3072        ads = self.android_devices
3073        self.check_band_support(ads[0])
3074
3075        tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
3076                 (phone_setup_voice_general, (self.log, ads[1]))]
3077        if not multithread_func(self.log, tasks):
3078            self.log.error("Phone Failed to Set Up Properly.")
3079            return False
3080
3081        return _test_call_long_duration(self.log, ads,
3082            is_phone_in_call_3g, self.long_call_duration)
3083
3084    def _test_call_hangup_while_ringing(self, ad_caller, ad_callee):
3085        """ Call a phone and verify ringing, then hangup from the originator
3086
3087        1. Setup PhoneA and PhoneB to ensure voice service.
3088        2. Call from PhoneA to PhoneB and wait for ringing.
3089        3. End the call on PhoneA.
3090
3091        Returns:
3092            True if pass; False if fail.
3093        """
3094
3095        caller_number = ad_caller.telephony['subscription'][
3096            get_outgoing_voice_sub_id(ad_caller)]['phone_num']
3097        callee_number = ad_callee.telephony['subscription'][
3098            get_incoming_voice_sub_id(ad_callee)]['phone_num']
3099
3100        tasks = [(phone_setup_voice_general, (self.log, ad_caller)),
3101                 (phone_setup_voice_general, (self.log, ad_callee))]
3102        if not multithread_func(self.log, tasks):
3103            self.log.error("Phone Failed to Set Up Properly.")
3104            return False
3105
3106        ad_caller.droid.telecomCallClearCallList()
3107        if num_active_calls(self.log, ad_caller) != 0:
3108            ad_caller.log.error("Phone has ongoing calls.")
3109            return False
3110
3111        if not initiate_call(self.log, ad_caller, callee_number):
3112            ad_caller.log.error("Phone was unable to initate a call")
3113            return False
3114
3115        if not wait_for_ringing_call(self.log, ad_callee, caller_number):
3116            ad_callee.log.error("Phone never rang.")
3117            return False
3118
3119        if not hangup_call(self.log, ad_caller):
3120            ad_caller.log.error("Unable to hang up the call")
3121            return False
3122
3123        return True
3124
3125    @test_tracker_info(uuid="ef4fb42d-9040-46f2-9626-d0a2e1dd854f")
3126    @TelephonyBaseTest.tel_test_wrap
3127    def test_call_mo_hangup_while_ringing(self):
3128        """ Call a phone and verify ringing, then hangup from the originator
3129
3130        1. Setup PhoneA and PhoneB to ensure voice service.
3131        2. Call from PhoneA to PhoneB and wait for ringing.
3132        3. End the call on PhoneA.
3133
3134        Returns:
3135            True if pass; False if fail.
3136        """
3137
3138        return self._test_call_hangup_while_ringing(self.android_devices[0],
3139                                                    self.android_devices[1])
3140
3141    @test_tracker_info(uuid="f514ac72-d551-4e21-b5af-bd87b6cdf34a")
3142    @TelephonyBaseTest.tel_test_wrap
3143    def test_call_mt_hangup_while_ringing(self):
3144        """ Call a phone and verify ringing, then hangup from the originator
3145
3146        1. Setup PhoneA and PhoneB to ensure voice service.
3147        2. Call from PhoneB to PhoneA and wait for ringing.
3148        3. End the call on PhoneB.
3149
3150        Returns:
3151            True if pass; False if fail.
3152        """
3153
3154        return self._test_call_hangup_while_ringing(self.android_devices[1],
3155                                                    self.android_devices[0])
3156
3157
3158    @test_tracker_info(uuid="aa40e7e1-e64a-480b-86e4-db2242449555")
3159    @TelephonyBaseTest.tel_test_wrap
3160    def test_call_mo_voice_general_in_active_data_transfer(self):
3161        """Test call can be established during active data connection.
3162
3163        Turn off airplane mode, disable WiFi, enable Cellular Data.
3164        Make sure phone in <nw_gen>.
3165        Starting downloading file from Internet.
3166        Initiate a MO voice call. Verify call can be established.
3167        Hangup Voice Call, verify file is downloaded successfully.
3168        Note: file download will be suspended when call is initiated if voice
3169              is using voice channel and voice channel and data channel are
3170              on different RATs.
3171
3172        Returns:
3173            True if success.
3174            False if failed.
3175        """
3176        return test_call_setup_in_active_data_transfer(
3177            self.log,
3178            self.android_devices,
3179            rat=None,
3180            call_direction=DIRECTION_MOBILE_ORIGINATED)
3181
3182    @test_tracker_info(uuid="d750d66b-2091-4e8d-baa2-084b9d2bbff5")
3183    @TelephonyBaseTest.tel_test_wrap
3184    def test_call_mt_voice_general_in_active_data_transfer(self):
3185        """Test call can be established during active data connection.
3186
3187        Turn off airplane mode, disable WiFi, enable Cellular Data.
3188        Make sure phone in <nw_gen>.
3189        Starting downloading file from Internet.
3190        Initiate a MT voice call. Verify call can be established.
3191        Hangup Voice Call, verify file is downloaded successfully.
3192        Note: file download will be suspended when call is initiated if voice
3193              is using voice channel and voice channel and data channel are
3194              on different RATs.
3195
3196        Returns:
3197            True if success.
3198            False if failed.
3199        """
3200        return test_call_setup_in_active_data_transfer(
3201            self.log,
3202            self.android_devices,
3203            rat=None,
3204            call_direction=DIRECTION_MOBILE_TERMINATED)
3205
3206    @test_tracker_info(uuid="35703e83-b3e6-40af-aeaf-6b983d6205f4")
3207    @TelephonyBaseTest.tel_test_wrap
3208    def test_call_mo_voice_volte_in_active_data_transfer(self):
3209        """Test call can be established during active data connection.
3210
3211        Turn off airplane mode, disable WiFi, enable Cellular Data.
3212        Make sure phone in <nw_gen>.
3213        Starting downloading file from Internet.
3214        Initiate a MO voice call. Verify call can be established.
3215        Hangup Voice Call, verify file is downloaded successfully.
3216        Note: file download will be suspended when call is initiated if voice
3217              is using voice channel and voice channel and data channel are
3218              on different RATs.
3219
3220        Returns:
3221            True if success.
3222            False if failed.
3223        """
3224        return test_call_setup_in_active_data_transfer(
3225            self.log,
3226            self.android_devices,
3227            rat='volte',
3228            call_direction=DIRECTION_MOBILE_ORIGINATED)
3229
3230    @test_tracker_info(uuid="a0f658d9-4212-44db-b3e8-7202f1eec04d")
3231    @TelephonyBaseTest.tel_test_wrap
3232    def test_call_mt_voice_volte_in_active_data_transfer(self):
3233        """Test call can be established during active data connection.
3234
3235        Turn off airplane mode, disable WiFi, enable Cellular Data.
3236        Make sure phone in <nw_gen>.
3237        Starting downloading file from Internet.
3238        Initiate a MT voice call. Verify call can be established.
3239        Hangup Voice Call, verify file is downloaded successfully.
3240        Note: file download will be suspended when call is initiated if voice
3241              is using voice channel and voice channel and data channel are
3242              on different RATs.
3243
3244        Returns:
3245            True if success.
3246            False if failed.
3247        """
3248        return test_call_setup_in_active_data_transfer(
3249            self.log,
3250            self.android_devices,
3251            rat='volte',
3252            call_direction=DIRECTION_MOBILE_TERMINATED)
3253
3254    @test_tracker_info(uuid="e0b264ec-fc29-411e-b018-684b7ff5a37e")
3255    @TelephonyBaseTest.tel_test_wrap
3256    def test_call_mo_voice_csfb_in_active_data_transfer(self):
3257        """Test call can be established during active data connection.
3258
3259        Turn off airplane mode, disable WiFi, enable Cellular Data.
3260        Make sure phone in <nw_gen>.
3261        Starting downloading file from Internet.
3262        Initiate a MO voice call. Verify call can be established.
3263        Hangup Voice Call, verify file is downloaded successfully.
3264        Note: file download will be suspended when call is initiated if voice
3265              is using voice channel and voice channel and data channel are
3266              on different RATs.
3267
3268        Returns:
3269            True if success.
3270            False if failed.
3271        """
3272        return test_call_setup_in_active_data_transfer(
3273            self.log,
3274            self.android_devices,
3275            rat='csfb',
3276            call_direction=DIRECTION_MOBILE_ORIGINATED,
3277            allow_data_transfer_interruption=True)
3278
3279    @test_tracker_info(uuid="98f04a27-74e1-474d-90d1-a4a45cdb6f5b")
3280    @TelephonyBaseTest.tel_test_wrap
3281    def test_call_mt_voice_csfb_in_active_data_transfer(self):
3282        """Test call can be established during active data connection.
3283
3284        Turn off airplane mode, disable WiFi, enable Cellular Data.
3285        Make sure phone in <nw_gen>.
3286        Starting downloading file from Internet.
3287        Initiate a MT voice call. Verify call can be established.
3288        Hangup Voice Call, verify file is downloaded successfully.
3289        Note: file download will be suspended when call is initiated if voice
3290              is using voice channel and voice channel and data channel are
3291              on different RATs.
3292
3293        Returns:
3294            True if success.
3295            False if failed.
3296        """
3297        return test_call_setup_in_active_data_transfer(
3298            self.log,
3299            self.android_devices,
3300            rat='csfb',
3301            call_direction=DIRECTION_MOBILE_TERMINATED,
3302            allow_data_transfer_interruption=True)
3303
3304    @test_tracker_info(uuid="359b1ee1-36a6-427b-9d9e-4d77231fcb09")
3305    @TelephonyBaseTest.tel_test_wrap
3306    def test_call_mo_voice_3g_in_active_data_transfer(self):
3307        """Test call can be established during active data connection.
3308
3309        Turn off airplane mode, disable WiFi, enable Cellular Data.
3310        Make sure phone in <nw_gen>.
3311        Starting downloading file from Internet.
3312        Initiate a MO voice call. Verify call can be established.
3313        Hangup Voice Call, verify file is downloaded successfully.
3314        Note: file download will be suspended when call is initiated if voice
3315              is using voice channel and voice channel and data channel are
3316              on different RATs.
3317
3318        Returns:
3319            True if success.
3320            False if failed.
3321        """
3322        self.check_band_support(self.android_devices[0])
3323        return test_call_setup_in_active_data_transfer(
3324            self.log,
3325            self.android_devices,
3326            rat='3g',
3327            call_direction=DIRECTION_MOBILE_ORIGINATED,
3328            allow_data_transfer_interruption=True)
3329
3330    @test_tracker_info(uuid="b172bbb4-2d6e-4d83-a381-ebfdf23bc30e")
3331    @TelephonyBaseTest.tel_test_wrap
3332    def test_call_mt_voice_3g_in_active_data_transfer(self):
3333        """Test call can be established during active data connection.
3334
3335        Turn off airplane mode, disable WiFi, enable Cellular Data.
3336        Make sure phone in <nw_gen>.
3337        Starting downloading file from Internet.
3338        Initiate a MT voice call. Verify call can be established.
3339        Hangup Voice Call, verify file is downloaded successfully.
3340        Note: file download will be suspended when call is initiated if voice
3341              is using voice channel and voice channel and data channel are
3342              on different RATs.
3343
3344        Returns:
3345            True if success.
3346            False if failed.
3347        """
3348        self.check_band_support(self.android_devices[0])
3349        return test_call_setup_in_active_data_transfer(
3350            self.log,
3351            self.android_devices,
3352            rat='3g',
3353            call_direction=DIRECTION_MOBILE_TERMINATED,
3354            allow_data_transfer_interruption=True)
3355
3356    @test_tracker_info(uuid="f5d9bfd0-0996-4c18-b11e-c6113dc201e2")
3357    @TelephonyBaseTest.tel_test_wrap
3358    def test_call_mo_voice_2g_in_active_data_transfer(self):
3359        """Test call can be established during active data connection.
3360
3361        Turn off airplane mode, disable WiFi, enable Cellular Data.
3362        Make sure phone in <nw_gen>.
3363        Starting downloading file from Internet.
3364        Initiate a MO voice call. Verify call can be established.
3365        Hangup Voice Call, verify file is downloaded successfully.
3366        Note: file download will be suspended when call is initiated if voice
3367              is using voice channel and voice channel and data channel are
3368              on different RATs.
3369
3370        Returns:
3371            True if success.
3372            False if failed.
3373        """
3374        self.check_band_support(self.android_devices[0])
3375        return test_call_setup_in_active_data_transfer(
3376            self.log,
3377            self.android_devices,
3378            rat='2g',
3379            call_direction=DIRECTION_MOBILE_ORIGINATED,
3380            allow_data_transfer_interruption=True)
3381
3382    @test_tracker_info(uuid="99cfd1be-b992-48bf-a50e-fc3eec8e5a67")
3383    @TelephonyBaseTest.tel_test_wrap
3384    def test_call_mt_voice_2g_in_active_data_transfer(self):
3385        """Test call can be established during active data connection.
3386
3387        Turn off airplane mode, disable WiFi, enable Cellular Data.
3388        Make sure phone in <nw_gen>.
3389        Starting downloading file from Internet.
3390        Initiate a MT voice call. Verify call can be established.
3391        Hangup Voice Call, verify file is downloaded successfully.
3392        Note: file download will be suspended when call is initiated if voice
3393              is using voice channel and voice channel and data channel are
3394              on different RATs.
3395
3396        Returns:
3397            True if success.
3398            False if failed.
3399        """
3400        self.check_band_support(self.android_devices[0])
3401        return test_call_setup_in_active_data_transfer(
3402            self.log,
3403            self.android_devices,
3404            rat='2g',
3405            call_direction=DIRECTION_MOBILE_TERMINATED,
3406            allow_data_transfer_interruption=True)
3407
3408    @test_tracker_info(uuid="12677cf2-40d3-4bb1-8afa-91ebcbd0f862")
3409    @TelephonyBaseTest.tel_test_wrap
3410    def test_call_mo_voice_wifi_wfc_in_active_data_transfer(self):
3411        """Test call can be established during active data connection.
3412
3413        Turn off airplane mode, turn on wfc and wifi.
3414        Starting downloading file from Internet.
3415        Initiate a MO voice call. Verify call can be established.
3416        Hangup Voice Call, verify file is downloaded successfully.
3417
3418        Returns:
3419            True if success.
3420            False if failed.
3421        """
3422        if not phone_setup_iwlan(self.log, self.android_devices[0], False,
3423                                 WFC_MODE_WIFI_PREFERRED,
3424                                 self.wifi_network_ssid,
3425                                 self.wifi_network_pass):
3426            self.android_devices[0].log.error(
3427                "Failed to setup IWLAN with NON-APM WIFI WFC on")
3428            return False
3429        return test_call_setup_in_active_data_transfer(
3430            self.log,
3431            self.android_devices,
3432            rat=None,
3433            call_direction=DIRECTION_MOBILE_ORIGINATED)
3434
3435    @test_tracker_info(uuid="84adcc19-43bb-4ea3-9284-7322ab139aac")
3436    @TelephonyBaseTest.tel_test_wrap
3437    def test_call_mt_voice_wifi_wfc_in_active_data_transfer(self):
3438        """Test call can be established during active data connection.
3439
3440        Turn off airplane mode, turn on wfc and wifi.
3441        Starting downloading file from Internet.
3442        Initiate a MT voice call. Verify call can be established.
3443        Hangup Voice Call, verify file is downloaded successfully.
3444
3445        Returns:
3446            True if success.
3447            False if failed.
3448        """
3449        if not phone_setup_iwlan(self.log, self.android_devices[0], False,
3450                                 WFC_MODE_WIFI_PREFERRED,
3451                                 self.wifi_network_ssid,
3452                                 self.wifi_network_pass):
3453            self.android_devices[0].log.error(
3454                "Failed to setup iwlan with APM off and WIFI and WFC on")
3455            return False
3456        return test_call_setup_in_active_data_transfer(
3457            self.log,
3458            self.android_devices,
3459            rat=None,
3460            call_direction=DIRECTION_MOBILE_TERMINATED)
3461
3462    @test_tracker_info(uuid="42566255-c33f-406c-abab-932a0aaa01a8")
3463    @TelephonyBaseTest.tel_test_wrap
3464    def test_call_mo_voice_apm_wifi_wfc_in_active_data_transfer(self):
3465        """Test call can be established during active data connection.
3466
3467        Turn on wifi-calling, airplane mode and wifi.
3468        Starting downloading file from Internet.
3469        Initiate a MO voice call. Verify call can be established.
3470        Hangup Voice Call, verify file is downloaded successfully.
3471
3472        Returns:
3473            True if success.
3474            False if failed.
3475        """
3476        carrier = self.get_carrier_name(self.android_devices[0])
3477        if carrier == CARRIER_VZW:
3478            wfc = WFC_MODE_CELLULAR_PREFERRED
3479        else:
3480            wfc = WFC_MODE_WIFI_PREFERRED
3481        if not phone_setup_iwlan(self.log, self.android_devices[0], True,
3482                                 wfc,
3483                                 self.wifi_network_ssid,
3484                                 self.wifi_network_pass):
3485            self.android_devices[0].log.error(
3486                "Failed to setup iwlan with APM, WIFI and WFC on")
3487            return False
3488        return test_call_setup_in_active_data_transfer(
3489            self.log,
3490            self.android_devices,
3491            rat=None,
3492            call_direction=DIRECTION_MOBILE_ORIGINATED)
3493
3494    @test_tracker_info(uuid="fbf52f60-449b-46f2-9486-36d338a1b070")
3495    @TelephonyBaseTest.tel_test_wrap
3496    def test_call_mt_voice_apm_wifi_wfc_in_active_data_transfer(self):
3497        """Test call can be established during active data connection.
3498
3499        Turn on wifi-calling, airplane mode and wifi.
3500        Starting downloading file from Internet.
3501        Initiate a MT voice call. Verify call can be established.
3502        Hangup Voice Call, verify file is downloaded successfully.
3503
3504        Returns:
3505            True if success.
3506            False if failed.
3507        """
3508        carrier = self.get_carrier_name(self.android_devices[0])
3509        if carrier == CARRIER_VZW:
3510            wfc = WFC_MODE_CELLULAR_PREFERRED
3511        else:
3512            wfc = WFC_MODE_WIFI_PREFERRED
3513        if not phone_setup_iwlan(self.log, self.android_devices[0], True,
3514                                 wfc,
3515                                 self.wifi_network_ssid,
3516                                 self.wifi_network_pass):
3517            self.android_devices[0].log.error(
3518                "Failed to setup iwlan with APM, WIFI and WFC on")
3519            return False
3520        return test_call_setup_in_active_data_transfer(
3521            self.log,
3522            self.android_devices,
3523            rat=None,
3524            call_direction=DIRECTION_MOBILE_TERMINATED)
3525
3526    @test_tracker_info(uuid="d1bf0739-ffb7-4bf8-ab94-570619f812a8")
3527    @TelephonyBaseTest.tel_test_wrap
3528    def test_call_mo_voice_apm_wifi_in_active_data_transfer_cellular(self):
3529        """Test call can be established during active data connection.
3530
3531        Turn on wifi, airplane mode and wifi.
3532        Starting downloading file from Internet.
3533        Initiate a MO voice call. Verify call can be established.
3534        Hangup Voice Call, verify file is downloaded successfully.
3535
3536        Returns:
3537            True if success.
3538            False if failed.
3539        """
3540        if not phone_setup_iwlan(self.log,
3541                                 self.android_devices[0],
3542                                 True,
3543                                 WFC_MODE_CELLULAR_PREFERRED,
3544                                 self.wifi_network_ssid,
3545                                 self.wifi_network_pass):
3546            self.android_devices[0].log.error(
3547                "Failed to setup iwlan with APM, WIFI")
3548            return False
3549        return test_call_setup_in_active_data_transfer(
3550            self.log,
3551            self.android_devices,
3552            rat=None,
3553            call_direction=DIRECTION_MOBILE_ORIGINATED)
3554
3555    @test_tracker_info(uuid="76b2cdaf-b783-4c1a-b91b-207f82ffa816")
3556    @TelephonyBaseTest.tel_test_wrap
3557    def test_call_mt_voice_apm_wifi_in_active_data_transfer_cellular(self):
3558        """Test call can be established during active data connection.
3559
3560        Turn on wifi, airplane mode and wifi.
3561        Starting downloading file from Internet.
3562        Initiate a MT voice call. Verify call can be established.
3563        Hangup Voice Call, verify file is downloaded successfully.
3564
3565        Returns:
3566            True if success.
3567            False if failed.
3568        """
3569        if not phone_setup_iwlan(self.log,
3570                                 self.android_devices[0],
3571                                 True,
3572                                 WFC_MODE_CELLULAR_PREFERRED,
3573                                 self.wifi_network_ssid,
3574                                 self.wifi_network_pass):
3575            self.android_devices[0].log.error(
3576                "Failed to setup iwlan with APM, WIFI and WFC on")
3577            return False
3578        return test_call_setup_in_active_data_transfer(
3579            self.log,
3580            self.android_devices,
3581            rat=None,
3582            call_direction=DIRECTION_MOBILE_TERMINATED)
3583
3584    @test_tracker_info(uuid="1dc9f03f-1b6c-4c17-993b-3acafdc26ea3")
3585    @TelephonyBaseTest.tel_test_wrap
3586    def test_call_mo_voice_general_in_active_youtube_video(self):
3587        """Test call can be established during active youtube video.
3588
3589        Turn off airplane mode, disable WiFi, enable Cellular Data.
3590        Make sure phone in <nw_gen>.
3591        Starting an youtube video.
3592        Initiate a MO voice call. Verify call can be established.
3593
3594        Returns:
3595            True if success.
3596            False if failed.
3597        """
3598        return test_call_setup_in_active_youtube_video(
3599            self.log,
3600            self.android_devices,
3601            rat=None,
3602            call_direction=DIRECTION_MOBILE_ORIGINATED)
3603
3604    @test_tracker_info(uuid="32bc8fab-a0b9-4d47-8afb-940d1fdcde02")
3605    @TelephonyBaseTest.tel_test_wrap
3606    def test_call_mt_voice_general_in_active_youtube_video(self):
3607        """Test call can be established during active youtube video.
3608
3609        Turn off airplane mode, disable WiFi, enable Cellular Data.
3610        Make sure phone in <nw_gen>.
3611        Starting an youtube video.
3612        Initiate a MT voice call. Verify call can be established.
3613
3614        Returns:
3615            True if success.
3616            False if failed.
3617        """
3618        return test_call_setup_in_active_youtube_video(
3619            self.log,
3620            self.android_devices,
3621            rat=None,
3622            call_direction=DIRECTION_MOBILE_TERMINATED)
3623
3624    @test_tracker_info(uuid="72204212-e0c8-4447-be3f-ae23b2a63a1c")
3625    @TelephonyBaseTest.tel_test_wrap
3626    def test_call_mo_voice_volte_in_active_youtube_video(self):
3627        """Test call can be established during active youtube video.
3628
3629        Turn off airplane mode, disable WiFi, enable Cellular Data.
3630        Make sure phone in <nw_gen>.
3631        Starting an youtube video.
3632        Initiate a MO voice call. Verify call can be established.
3633
3634        Returns:
3635            True if success.
3636            False if failed.
3637        """
3638        return test_call_setup_in_active_youtube_video(
3639            self.log,
3640            self.android_devices,
3641            rat='volte',
3642            call_direction=DIRECTION_MOBILE_ORIGINATED)
3643
3644    @test_tracker_info(uuid="84cd3ab9-a2b2-4ef9-b531-ee6201bec128")
3645    @TelephonyBaseTest.tel_test_wrap
3646    def test_call_mt_voice_volte_in_active_youtube_video(self):
3647        """Test call can be established during active youtube video.
3648
3649        Turn off airplane mode, disable WiFi, enable Cellular Data.
3650        Make sure phone in <nw_gen>.
3651        Starting an youtube video.
3652        Initiate a MT voice call. Verify call can be established.
3653
3654        Returns:
3655            True if success.
3656            False if failed.
3657        """
3658        return test_call_setup_in_active_youtube_video(
3659            self.log,
3660            self.android_devices,
3661            rat='volte',
3662            call_direction=DIRECTION_MOBILE_TERMINATED)
3663
3664    @test_tracker_info(uuid="a8dca8d3-c44c-40a6-be56-931b4be5499b")
3665    @TelephonyBaseTest.tel_test_wrap
3666    def test_call_mo_voice_csfb_in_active_youtube_video(self):
3667        """Test call can be established during active youbube video.
3668
3669        Turn off airplane mode, disable WiFi, enable Cellular Data.
3670        Make sure phone in <nw_gen>.
3671        Starting an youtube video.
3672        Initiate a MO voice call. Verify call can be established.
3673
3674        Returns:
3675            True if success.
3676            False if failed.
3677        """
3678        return test_call_setup_in_active_youtube_video(
3679            self.log,
3680            self.android_devices,
3681            rat='csfb',
3682            call_direction=DIRECTION_MOBILE_ORIGINATED)
3683
3684    @test_tracker_info(uuid="d11f7263-f51d-4ea3-916a-0df4f52023ce")
3685    @TelephonyBaseTest.tel_test_wrap
3686    def test_call_mt_voice_csfb_in_active_youtube_video(self):
3687        """Test call can be established during active youtube video.
3688
3689        Turn off airplane mode, disable WiFi, enable Cellular Data.
3690        Make sure phone in <nw_gen>.
3691        Starting an youtube video.
3692        Initiate a MT voice call. Verify call can be established.
3693
3694        Returns:
3695            True if success.
3696            False if failed.
3697        """
3698        return test_call_setup_in_active_youtube_video(
3699            self.log,
3700            self.android_devices,
3701            rat='csfb',
3702            call_direction=DIRECTION_MOBILE_TERMINATED)
3703
3704    @test_tracker_info(uuid="676378b4-94b7-4ad7-8242-7ccd2bf1efba")
3705    @TelephonyBaseTest.tel_test_wrap
3706    def test_call_mo_voice_3g_in_active_youtube_video(self):
3707        """Test call can be established during active youtube video.
3708
3709        Turn off airplane mode, disable WiFi, enable Cellular Data.
3710        Make sure phone in <nw_gen>.
3711        Starting an youtube video.
3712        Initiate a MO voice call. Verify call can be established.
3713
3714        Returns:
3715            True if success.
3716            False if failed.
3717        """
3718        self.check_band_support(self.android_devices[0])
3719        return test_call_setup_in_active_youtube_video(
3720            self.log,
3721            self.android_devices,
3722            rat='3g',
3723            call_direction=DIRECTION_MOBILE_ORIGINATED)
3724
3725    @test_tracker_info(uuid="6216fc6d-2aa2-4eb9-90e2-5791cb31c12e")
3726    @TelephonyBaseTest.tel_test_wrap
3727    def test_call_mt_voice_3g_in_active_youtube_video(self):
3728        """Test call can be established during active youtube video.
3729
3730        Turn off airplane mode, disable WiFi, enable Cellular Data.
3731        Make sure phone in <nw_gen>.
3732        Starting youtube video.
3733        Initiate a MT voice call. Verify call can be established.
3734
3735        Returns:
3736            True if success.
3737            False if failed.
3738        """
3739        self.check_band_support(self.android_devices[0])
3740        return test_call_setup_in_active_youtube_video(
3741            self.log,
3742            self.android_devices,
3743            rat='3g',
3744            call_direction=DIRECTION_MOBILE_TERMINATED)
3745
3746    @test_tracker_info(uuid="58ec9783-6f8e-49f6-8dae-9dd33108b6f9")
3747    @TelephonyBaseTest.tel_test_wrap
3748    def test_call_mo_voice_2g_in_active_youtube_video(self):
3749        """Test call can be established during active youtube video.
3750
3751        Turn off airplane mode, disable WiFi, enable Cellular Data.
3752        Make sure phone in <nw_gen>.
3753        Starting youtube video.
3754        Initiate a MO voice call. Verify call can be established.
3755
3756        Returns:
3757            True if success.
3758            False if failed.
3759        """
3760        self.check_band_support(self.android_devices[0])
3761        return test_call_setup_in_active_youtube_video(
3762            self.log,
3763            self.android_devices,
3764            rat='2g',
3765            call_direction=DIRECTION_MOBILE_ORIGINATED)
3766
3767    @test_tracker_info(uuid="e8ba7c0c-48a3-4fc6-aa34-a2e1c570521a")
3768    @TelephonyBaseTest.tel_test_wrap
3769    def test_call_mt_voice_2g_in_active_youtube_video(self):
3770        """Test call can be established during active youtube video.
3771
3772        Turn off airplane mode, disable WiFi, enable Cellular Data.
3773        Make sure phone in <nw_gen>.
3774        Starting an youtube video.
3775        Initiate a MT voice call. Verify call can be established.
3776
3777        Returns:
3778            True if success.
3779            False if failed.
3780        """
3781        self.check_band_support(self.android_devices[0])
3782        return test_call_setup_in_active_youtube_video(
3783            self.log,
3784            self.android_devices,
3785            rat='2g',
3786            call_direction=DIRECTION_MOBILE_TERMINATED)
3787
3788    @test_tracker_info(uuid="eb8971c1-b34a-430f-98df-0d4554c7ab12")
3789    @TelephonyBaseTest.tel_test_wrap
3790    def test_call_mo_voice_wifi_wfc_in_active_youtube_video(self):
3791        """Test call can be established during active youtube video.
3792
3793        Turn off airplane mode, turn on wfc and wifi.
3794        Starting youtube video.
3795        Initiate a MO voice call. Verify call can be established.
3796
3797        Returns:
3798            True if success.
3799            False if failed.
3800        """
3801        return test_call_setup_in_active_youtube_video(
3802            self.log,
3803            self.android_devices,
3804            rat="wfc",
3805            wfc_mode=WFC_MODE_WIFI_PREFERRED,
3806            wifi_ssid=self.wifi_network_ssid,
3807            wifi_pwd=self.wifi_network_pass,
3808            call_direction=DIRECTION_MOBILE_ORIGINATED)
3809
3810    @test_tracker_info(uuid="275a93d6-1f39-40c8-893f-ff77afd09e54")
3811    @TelephonyBaseTest.tel_test_wrap
3812    def test_call_mt_voice_wifi_wfc_in_active_youtube_video(self):
3813        """Test call can be established during active youtube_video.
3814
3815        Turn off airplane mode, turn on wfc and wifi.
3816        Starting an youtube video.
3817        Initiate a MT voice call. Verify call can be established.
3818
3819        Returns:
3820            True if success.
3821            False if failed.
3822        """
3823        return test_call_setup_in_active_youtube_video(
3824            self.log,
3825            self.android_devices,
3826            rat="wfc",
3827            wfc_mode=WFC_MODE_WIFI_PREFERRED,
3828            wifi_ssid=self.wifi_network_ssid,
3829            wifi_pwd=self.wifi_network_pass,
3830            call_direction=DIRECTION_MOBILE_TERMINATED)
3831
3832    @test_tracker_info(uuid="ea087709-d4df-4223-b80c-1b33bacbd5a2")
3833    @TelephonyBaseTest.tel_test_wrap
3834    def test_call_mo_voice_apm_wifi_wfc_in_active_youtube_video(self):
3835        """Test call can be established during active youtube video.
3836
3837        Turn on wifi-calling, airplane mode and wifi.
3838        Starting an youtube video.
3839        Initiate a MO voice call. Verify call can be established.
3840
3841        Returns:
3842            True if success.
3843            False if failed.
3844        """
3845        carrier = self.get_carrier_name(self.android_devices[0])
3846        if carrier == CARRIER_VZW:
3847            wfc = WFC_MODE_CELLULAR_PREFERRED
3848        else:
3849            wfc = WFC_MODE_WIFI_PREFERRED
3850
3851        return test_call_setup_in_active_youtube_video(
3852            self.log,
3853            self.android_devices,
3854            rat="wfc",
3855            is_airplane_mode=True,
3856            wfc_mode=wfc,
3857            wifi_ssid=self.wifi_network_ssid,
3858            wifi_pwd=self.wifi_network_pass,
3859            call_direction=DIRECTION_MOBILE_ORIGINATED)
3860
3861    @test_tracker_info(uuid="44cc14e0-60c7-4fdb-ad26-31fdc4e52aaf")
3862    @TelephonyBaseTest.tel_test_wrap
3863    def test_call_mt_voice_apm_wifi_wfc_in_active_youtube_video(self):
3864        """Test call can be established during active youtube video.
3865
3866        Turn on wifi-calling, airplane mode and wifi.
3867        Starting youtube video.
3868        Initiate a MT voice call. Verify call can be established.
3869
3870        Returns:
3871            True if success.
3872            False if failed.
3873        """
3874        carrier = self.get_carrier_name(self.android_devices[0])
3875        if carrier == CARRIER_VZW:
3876            wfc = WFC_MODE_CELLULAR_PREFERRED
3877        else:
3878            wfc = WFC_MODE_WIFI_PREFERRED
3879
3880        return test_call_setup_in_active_youtube_video(
3881            self.log,
3882            self.android_devices,
3883            rat="wfc",
3884            is_airplane_mode=True,
3885            wfc_mode=wfc,
3886            wifi_ssid=self.wifi_network_ssid,
3887            wifi_pwd=self.wifi_network_pass,
3888            call_direction=DIRECTION_MOBILE_TERMINATED)
3889
3890    @test_tracker_info(uuid="e115e8a6-25bf-41fc-aeb8-8f4c922c50e4")
3891    @TelephonyBaseTest.tel_test_wrap
3892    def test_call_mo_voice_apm_wifi_wfc_in_active_youtube_video_cellular(self):
3893        """Test call can be established during active youtube video.
3894
3895        Turn on wifi-calling, airplane mode and wifi.
3896        Starting an youtube video.
3897        Initiate a MO voice call. Verify call can be established.
3898
3899        Returns:
3900            True if success.
3901            False if failed.
3902        """
3903        return test_call_setup_in_active_youtube_video(
3904            self.log,
3905            self.android_devices,
3906            rat="wfc",
3907            is_airplane_mode=True,
3908            wfc_mode=WFC_MODE_CELLULAR_PREFERRED,
3909            wifi_ssid=self.wifi_network_ssid,
3910            wifi_pwd=self.wifi_network_pass,
3911            call_direction=DIRECTION_MOBILE_ORIGINATED)
3912
3913    @test_tracker_info(uuid="d754d3dd-0b02-4f13-bc65-fdafa254196b")
3914    @TelephonyBaseTest.tel_test_wrap
3915    def test_call_mt_voice_apm_wifi_wfc_in_active_youtube_video_cellular(self):
3916        """Test call can be established during active youtube video.
3917
3918        Turn on wifi-calling, airplane mode and wifi.
3919        Starting youtube video.
3920        Initiate a MT voice call. Verify call can be established.
3921
3922        Returns:
3923            True if success.
3924            False if failed.
3925        """
3926        return test_call_setup_in_active_youtube_video(
3927            self.log,
3928            self.android_devices,
3929            rat="wfc",
3930            is_airplane_mode=True,
3931            wfc_mode=WFC_MODE_CELLULAR_PREFERRED,
3932            wifi_ssid=self.wifi_network_ssid,
3933            wifi_pwd=self.wifi_network_pass,
3934            call_direction=DIRECTION_MOBILE_TERMINATED)
3935
3936    @test_tracker_info(uuid="88822edf-4c4a-4bc4-9280-2f27ee9e28d5")
3937    @TelephonyBaseTest.tel_test_wrap
3938    def test_call_mo_voice_apm_wifi_in_active_youtube_video_cellular(self):
3939        """Test call can be established during active youtube video.
3940
3941        Turn on wifi, Cellular Preferred, airplane mode and wifi.
3942        Starting an youtube video.
3943        Initiate a MO voice call. Verify call can be established.
3944
3945        Returns:
3946            True if success.
3947            False if failed.
3948        """
3949        return test_call_setup_in_active_youtube_video(
3950            self.log,
3951            self.android_devices,
3952            rat="wfc",
3953            is_airplane_mode=True,
3954            wfc_mode=WFC_MODE_CELLULAR_PREFERRED,
3955            wifi_ssid=self.wifi_network_ssid,
3956            wifi_pwd=self.wifi_network_pass,
3957            call_direction=DIRECTION_MOBILE_ORIGINATED)
3958
3959    @test_tracker_info(uuid="c4b066b0-3cfd-4831-9c61-5d6b132648c4")
3960    @TelephonyBaseTest.tel_test_wrap
3961    def test_call_mt_voice_apm_wifi_in_active_youtube_video_cellular(self):
3962        """Test call can be established during active youtube video.
3963
3964        Turn on cellular calling, airplane mode and wifi.
3965        Starting youtube video.
3966        Initiate a MT voice call. Verify call can be established.
3967
3968        Returns:
3969            True if success.
3970            False if failed.
3971        """
3972        return test_call_setup_in_active_youtube_video(
3973            self.log,
3974            self.android_devices,
3975            rat="wfc",
3976            is_airplane_mode=True,
3977            wfc_mode=WFC_MODE_CELLULAR_PREFERRED,
3978            wifi_ssid=self.wifi_network_ssid,
3979            wifi_pwd=self.wifi_network_pass,
3980            call_direction=DIRECTION_MOBILE_TERMINATED)
3981
3982    @test_tracker_info(uuid="f367de12-1fd8-488d-816f-091deaacb791")
3983    @TelephonyBaseTest.tel_test_wrap
3984    def test_call_wfc_wifi_preferred_after_mobile_data_usage_limit_reached(
3985            self):
3986        """ WiFi Preferred, WiFi calling test after data limit reached
3987
3988        1. Set the data limit to the current usage
3989        2. Setup PhoneA WFC mode: WIFI_PREFERRED.
3990        3. Make Sure PhoneB is in general mode.
3991        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
3992        5. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
3993
3994        Raises:
3995            TestFailure is not success.
3996        """
3997        ads = self.android_devices
3998        self.check_band_support(ads[0])
3999        try:
4000            subscriber_id = ads[0].droid.telephonyGetSubscriberId()
4001            data_usage = get_mobile_data_usage(ads[0], subscriber_id)
4002            set_mobile_data_usage_limit(ads[0], data_usage, subscriber_id)
4003
4004            # Turn OFF WiFi for Phone B
4005            set_wifi_to_default(self.log, ads[1])
4006            tasks = [(phone_setup_iwlan,
4007                      (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
4008                       self.wifi_network_ssid, self.wifi_network_pass)),
4009                     (phone_setup_voice_general, (self.log, ads[1]))]
4010            if not multithread_func(self.log, tasks):
4011                self.log.error("Phone Failed to Set Up Properly.")
4012                self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
4013                raise signals.TestFailure("Failed",
4014                    extras={"fail_reason": "Phone Failed to Set Up Properly."})
4015
4016            result = two_phone_call_short_seq(
4017                self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan,
4018                ads[1], phone_idle_3g, is_phone_in_call_3g, None)
4019            self.tel_logger.set_result(result.result_value)
4020            if not result:
4021                raise signals.TestFailure("Failed",
4022                    extras={"fail_reason": str(result.result_value)})
4023        finally:
4024            remove_mobile_data_usage_limit(ads[0], subscriber_id)
4025
4026    @test_tracker_info(uuid="af943c7f-2b42-408f-b8a3-2d360a7483f7")
4027    @TelephonyBaseTest.tel_test_wrap
4028    def test_call_volte_after_mobile_data_usage_limit_reached(self):
4029        """ VoLTE to VoLTE call test after mobile data usage limit reached
4030
4031        1. Set the data limit to the current usage
4032        2. Make Sure PhoneA is in LTE mode (with VoLTE).
4033        3. Make Sure PhoneB is in LTE mode (with VoLTE).
4034        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
4035        5. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
4036
4037        Raises:
4038            TestFailure if not success.
4039        """
4040        ads = self.android_devices
4041        try:
4042            subscriber_id = ads[0].droid.telephonyGetSubscriberId()
4043            data_usage = get_mobile_data_usage(ads[0], subscriber_id)
4044            set_mobile_data_usage_limit(ads[0], data_usage, subscriber_id)
4045
4046            tasks = [(phone_setup_volte, (self.log, ads[0])),
4047                     (phone_setup_volte, (self.log, ads[1]))]
4048            if not multithread_func(self.log, tasks):
4049                self.log.error("Phone Failed to Set Up Properly.")
4050                self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
4051                raise signals.TestFailure("Failed",
4052                    extras={"fail_reason": "Phone Failed to Set Up Properly."})
4053
4054            result = two_phone_call_short_seq(
4055                self.log, ads[0], phone_idle_volte, is_phone_in_call_volte,
4056                ads[1], phone_idle_volte, is_phone_in_call_volte, None,
4057                WAIT_TIME_IN_CALL_FOR_IMS)
4058            self.tel_logger.set_result(result.result_value)
4059            if not result:
4060                raise signals.TestFailure("Failed",
4061                    extras={"fail_reason": str(result.result_value)})
4062        finally:
4063            remove_mobile_data_usage_limit(ads[0], subscriber_id)
4064
4065    @test_tracker_info(uuid="7955f1ae-84b1-4c33-9e59-af930605672a")
4066    @TelephonyBaseTest.tel_test_wrap
4067    def test_volte_in_call_wifi_toggling(self):
4068        """ General voice to voice call.
4069
4070        1. Make Sure PhoneA in VoLTE.
4071        2. Make Sure PhoneB in VoLTE.
4072        3. Call from PhoneA to PhoneB.
4073        4. Toggling Wifi connnection in call.
4074        5. Verify call is active.
4075        6. Hung up the call on PhoneA
4076
4077        Returns:
4078            True if pass; False if fail.
4079        """
4080        ads = self.android_devices
4081
4082        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
4083                                                           (self.log, ads[1]))]
4084        if not multithread_func(self.log, tasks):
4085            self.log.error("Phone Failed to Set Up Properly.")
4086            return False
4087        return test_wifi_cell_switching_in_call(
4088            self.log,
4089            ads,
4090            self.wifi_network_ssid,
4091            self.wifi_network_pass,
4092            verify_caller_func=is_phone_in_call_volte,
4093            verify_callee_func=is_phone_in_call_volte)
4094
4095    @test_tracker_info(uuid="8a853186-cdff-4078-930a-6c619ea89183")
4096    @TelephonyBaseTest.tel_test_wrap
4097    def test_wfc_in_call_wifi_toggling(self):
4098        """ General voice to voice call. TMO Only Test
4099
4100        1. Make Sure PhoneA in wfc with APM off.
4101        2. Make Sure PhoneB in Voice Capable.
4102        3. Call from PhoneA to PhoneB.
4103        4. Toggling Wifi connection in call.
4104        5. Verify call is active.
4105        6. Hung up the call on PhoneA
4106
4107        Returns:
4108            True if pass; False if fail.
4109        """
4110        ads = self.android_devices
4111
4112        if not phone_setup_volte(self.log, ads[0]):
4113            return False
4114
4115        tasks = [(phone_setup_iwlan,
4116                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
4117                   self.wifi_network_ssid, self.wifi_network_pass)),
4118                 (phone_setup_voice_general, (self.log, ads[1]))]
4119
4120        if not multithread_func(self.log, tasks):
4121            self.log.error("Phone Failed to Set Up Properly.")
4122            return False
4123        return test_wifi_cell_switching_in_call(
4124            self.log,
4125            ads,
4126            self.wifi_network_ssid,
4127            self.wifi_network_pass,
4128            verify_caller_func=is_phone_in_call_iwlan)
4129
4130    @test_tracker_info(uuid="187bf7b5-d122-4914-82c0-b0709272ee12")
4131    @TelephonyBaseTest.tel_test_wrap
4132    def test_csfb_in_call_wifi_toggling(self):
4133        """ General voice to voice call.
4134
4135        1. Make Sure PhoneA in CSFB.
4136        2. Make Sure PhoneB in CSFB.
4137        3. Call from PhoneA to PhoneB.
4138        4. Toggling Wifi connection in call.
4139        5. Verify call is active.
4140        6. Hung up the call on PhoneA
4141
4142        Returns:
4143            True if pass; False if fail.
4144        """
4145        ads = self.android_devices
4146
4147        tasks = [(phone_setup_csfb, (self.log, ads[0])), (phone_setup_csfb,
4148                                                          (self.log, ads[1]))]
4149        if not multithread_func(self.log, tasks):
4150            self.log.error("Phone Failed to Set Up Properly.")
4151            return False
4152        return test_wifi_cell_switching_in_call(
4153            self.log,
4154            ads,
4155            self.wifi_network_ssid,
4156            self.wifi_network_pass,
4157            verify_caller_func=is_phone_in_call_csfb,
4158            verify_callee_func=is_phone_in_call_csfb)
4159
4160    @test_tracker_info(uuid="df555d9f-30e6-47f9-9e9f-9814e6892857")
4161    @TelephonyBaseTest.tel_test_wrap
4162    def test_wfc_lte_call_handover(self):
4163        """ WFC to lte handover.
4164
4165        1. Make a voice call over wifi.
4166        2. Turn off Wifi.
4167        3. Call should handover from Wifi to LTE.
4168        4. Verify call is active.
4169        5. Hung up the call on PhoneA
4170
4171        Returns:
4172            True if pass; False if fail.
4173        """
4174        ads = self.android_devices
4175
4176        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
4177                                                           (self.log, ads[1]))]
4178        if not multithread_func(self.log, tasks):
4179            self.log.error("Phone Failed to Set Up Properly.")
4180            raise signals.TestFailure("Failed",
4181                extras={"fail_reason": "Phone Failed to Set Up Properly."})
4182
4183
4184        tasks = [(phone_setup_iwlan,
4185                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
4186                   self.wifi_network_ssid, self.wifi_network_pass))]
4187
4188        if not multithread_func(self.log, tasks):
4189            self.log.error("Phone Failed to Set Up Properly.")
4190            raise signals.TestFailure("Failed",
4191                extras={"fail_reason": "Phone Failed to Set Up Properly."})
4192
4193        ad_caller = ads[0]
4194        ad_callee = ads[1]
4195        caller_number = get_phone_number(self.log, ad_caller)
4196        callee_number = get_phone_number(self.log, ad_callee)
4197
4198        try:
4199            # Make MO/MT call.
4200            if not initiate_call(self.log, ad_caller, callee_number):
4201                raise signals.TestFailure("Failed to initiate call")
4202            if not wait_and_answer_call(self.log, ad_callee, caller_number):
4203                raise signals.TestFailure("Answer call falied")
4204            if not self._is_phone_in_call_iwlan():
4205                raise signals.TestFailure("Phone call not in Iwlan ")
4206            time.sleep(15)
4207            # Turn off the wifi and wait call to handover.
4208            wifi_toggle_state(self.log, self.android_devices[0], False)
4209            time.sleep(15)
4210            if not self.is_phone_in_call_volte():
4211                raise signals.TestFailure("WFC handover failed, call disconnected ")
4212
4213            else:
4214                self.log.info("Handover Successful")
4215
4216            if is_phone_in_call(self.log, ads[0]):
4217                # hangup call
4218                if not hangup_call(self.log, ads[0]):
4219                    raise signals.TestFailure("hangup_call fail.")
4220
4221            else:
4222                raise signals.TestFailure("Unexpected call drop.")
4223
4224
4225        except Exception as e:
4226                self.log.error("Exception error %s", str(e))
4227                return False
4228        return True
4229
4230    @test_tracker_info(uuid="331ff54c-ee36-4f59-9c3c-24faf41b1383")
4231    @TelephonyBaseTest.tel_test_wrap
4232    def test_lte_wfc_call_handover(self):
4233        """ LTE to WFC handover.
4234
4235        1. Make a voice call over LTE.
4236        2. Turn on Wifi.
4237        3. Call should handover from LTE to Wifi.
4238        4. Verify call is active.
4239        5. Hung up the call on PhoneA
4240
4241        Returns:
4242            True if pass; False if fail.
4243        """
4244        ads = self.android_devices
4245
4246        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
4247                                                           (self.log, ads[1]))]
4248        if not multithread_func(self.log, tasks):
4249            self.log.error("Phone Failed to Set Up Properly.")
4250            raise signals.TestFailure("Failed",
4251                extras={"fail_reason": "Phone Failed to Set Up Properly."})
4252
4253
4254        tasks = [(phone_setup_iwlan,
4255                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
4256                   self.wifi_network_ssid, self.wifi_network_pass))]
4257
4258        if not multithread_func(self.log, tasks):
4259            self.log.error("Phone Failed to Set Up Properly.")
4260            raise signals.TestFailure("Failed",
4261                extras={"fail_reason": "Phone Failed to Set Up Properly."})
4262
4263        ad_caller = ads[0]
4264        ad_callee = ads[1]
4265        caller_number = get_phone_number(self.log, ad_caller)
4266        callee_number = get_phone_number(self.log, ad_callee)
4267
4268        try:
4269            # Turn off the wifi and make a call.
4270            wifi_toggle_state(self.log, self.android_devices[0], False)
4271            if not initiate_call(self.log, ad_caller, callee_number):
4272                raise signals.TestFailure("Failed to initiate call")
4273            if not wait_and_answer_call(self.log, ad_callee, caller_number):
4274                raise signals.TestFailure("Answer call falied")
4275            if not self.is_phone_in_call_volte():
4276                raise signals.TestFailure("Phone call not via LTE")
4277            time.sleep(15)
4278            # Turn on the wifi and wait call to handover.
4279            wifi_toggle_state(self.log, self.android_devices[0], True)
4280            time.sleep(15)
4281            if not self._is_phone_in_call_iwlan():
4282                raise signals.TestFailure("LTE handover failed, call disconnected ")
4283
4284            else:
4285                self.log.info("Handover Successful")
4286
4287            if is_phone_in_call(self.log, ads[0]):
4288                # hangup call
4289                if not hangup_call(self.log, ads[0]):
4290                    raise signals.TestFailure("hangup_call fail.")
4291
4292            else:
4293                raise signals.TestFailure("Unexpected call drop.")
4294
4295
4296        except Exception as e:
4297                self.log.error("Exception error %s", str(e))
4298                return False
4299        return True
4300
4301
4302
4303""" Tests End """
4304