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