1#!/usr/bin/env python3.4
2#
3#   Copyright 2022 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16"""
17    Test Script for 5G Voice scenarios
18"""
19
20from acts import signals
21from acts.libs.utils.multithread import multithread_func
22from acts.libs.utils.multithread import run_multithread_func
23from acts.test_decorators import test_tracker_info
24from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
25from acts_contrib.test_utils.tel.loggers.telephony_metric_logger import TelephonyMetricLogger
26from acts_contrib.test_utils.tel.loggers.protos.telephony_metric_pb2 import TelephonyVoiceTestResult
27from acts_contrib.test_utils.tel.tel_defines import DIRECTION_MOBILE_ORIGINATED
28from acts_contrib.test_utils.tel.tel_defines import DIRECTION_MOBILE_TERMINATED
29from acts_contrib.test_utils.tel.tel_defines import GEN_5G
30from acts_contrib.test_utils.tel.tel_defines import TOTAL_LONG_CALL_DURATION
31from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_FOR_IMS
32from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
33from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_ONLY
34from acts_contrib.test_utils.tel.tel_5g_utils import is_current_network_5g
35from acts_contrib.test_utils.tel.tel_5g_test_utils import provision_both_devices_for_volte
36from acts_contrib.test_utils.tel.tel_5g_test_utils import provision_device_for_5g
37from acts_contrib.test_utils.tel.tel_5g_test_utils import verify_5g_attach_for_both_devices
38from acts_contrib.test_utils.tel.tel_data_utils import active_file_download_task
39from acts_contrib.test_utils.tel.tel_data_utils import call_epdg_to_epdg_wfc
40from acts_contrib.test_utils.tel.tel_data_utils import get_mobile_data_usage
41from acts_contrib.test_utils.tel.tel_data_utils import remove_mobile_data_usage_limit
42from acts_contrib.test_utils.tel.tel_data_utils import set_mobile_data_usage_limit
43from acts_contrib.test_utils.tel.tel_data_utils import test_call_setup_in_active_data_transfer
44from acts_contrib.test_utils.tel.tel_data_utils import test_call_setup_in_active_youtube_video
45from acts_contrib.test_utils.tel.tel_data_utils import wifi_cell_switching
46from acts_contrib.test_utils.tel.tel_data_utils import test_wifi_cell_switching_in_call
47from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_2g
48from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_csfb
49from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_iwlan
50from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_volte
51from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_csfb
52from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_iwlan
53from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_2g
54from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_3g
55from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_general
56from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_volte
57from acts_contrib.test_utils.tel.tel_phone_setup_utils import ensure_phones_idle
58from acts_contrib.test_utils.tel.tel_test_utils import install_dialer_apk
59from acts_contrib.test_utils.tel.tel_test_utils import toggle_airplane_mode
60from acts_contrib.test_utils.tel.tel_voice_utils import _test_call_long_duration
61from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_2g
62from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_3g
63from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
64from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
65from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
66from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_call_hold_unhold_test
67from acts_contrib.test_utils.tel.tel_voice_utils import call_setup_teardown
68from acts_contrib.test_utils.tel.tel_voice_utils import call_voicemail_erase_all_pending_voicemail
69from acts_contrib.test_utils.tel.tel_voice_utils import hangup_call
70from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_active
71from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_leave_voice_mail
72from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_long_seq
73from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_short_seq
74from acts_contrib.test_utils.tel.tel_ops_utils import initiate_call_verify_operation
75
76
77CallResult = TelephonyVoiceTestResult.CallResult.Value
78
79
80class Nsa5gVoiceTest(TelephonyBaseTest):
81    def setup_class(self):
82        super().setup_class()
83        self.number_of_devices = 2
84        self.message_lengths = (50, 160, 180)
85        self.tel_logger = TelephonyMetricLogger.for_test_case()
86        self.stress_test_number = self.get_stress_test_number()
87        self.long_call_duration = self.user_params.get(
88            "long_call_duration",
89            TOTAL_LONG_CALL_DURATION)
90
91        self.dialer_util = self.user_params.get("dialer_apk", None)
92        if isinstance(self.dialer_util, list):
93            self.dialer_util = self.dialer_util[0]
94
95        if self.dialer_util:
96            ads = self.android_devices
97            for ad in ads:
98                install_dialer_apk(ad, self.dialer_util)
99
100    def setup_test(self):
101        TelephonyBaseTest.setup_test(self)
102
103    def teardown_test(self):
104        ensure_phones_idle(self.log, self.android_devices)
105
106    """ Tests Begin """
107
108    @test_tracker_info(uuid="1bef3da1-4608-4b0e-8b78-f3f7be0115d5")
109    @TelephonyBaseTest.tel_test_wrap
110    def test_5g_nsa_call_volte_to_volte(self):
111        """ 5g nsa volte to volte call test
112
113        1. Make sure PhoneA is in nsa5g mode (with volte).
114        2. Make sure PhoneB is in nsa5g mode (with volte).
115        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
116        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
117        5. Verify both PhoneA and PhoneB gets attached back to nsa5g
118
119        Raises:
120            TestFailure if not success.
121        """
122        ads = self.android_devices
123        if not provision_both_devices_for_volte(self.log, ads, GEN_5G,
124                                                nr_type='nsa'):
125            return False
126
127        # VoLTE calls
128        result = two_phone_call_short_seq(
129            self.log, ads[0], None, is_phone_in_call_volte, ads[1],
130            None, is_phone_in_call_volte, None,
131            WAIT_TIME_IN_CALL_FOR_IMS)
132        if not result:
133            self.log.error("Failure is volte call during 5g nsa")
134            return False
135
136        if not verify_5g_attach_for_both_devices(self.log, ads, nr_type='nsa'):
137            return False
138
139        self.log.info("PASS - volte test over 5g nsa validated")
140        return True
141
142    @test_tracker_info(uuid="3df252a4-308a-49c3-8e37-08e9c4e8efef")
143    @TelephonyBaseTest.tel_test_wrap
144    def test_5g_nsa_call_volte_to_3g(self):
145        """ 5g nsa volte to 3g call test
146
147        1. Make sure PhoneA is in nsa5g mode (with volte).
148        2. Make sure PhoneB is in 3g mode.
149        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
150        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
151        5. Verify both PhoneA and PhoneB gets attached back to nsa5g
152
153        Raises:
154            TestFailure if not success.
155        """
156        ads = self.android_devices
157
158        # LTE attach
159        tasks = [(phone_setup_volte, (self.log, ads[0], GEN_5G, 'nsa')),
160                 (phone_setup_voice_3g, (self.log, ads[1]))]
161        if not multithread_func(self.log, tasks):
162            self.log.error("Phone failed to set up in volte/3g")
163            return False
164
165        # VoLTE to 3G
166        result = two_phone_call_short_seq(
167            self.log, ads[0], None, is_phone_in_call_volte, ads[1],
168            None, is_phone_in_call_3g, None,
169            WAIT_TIME_IN_CALL_FOR_IMS)
170        if not result:
171            self.log.error("Failure is volte to 3g call during 5g nsa")
172            return False
173
174        # Attach nsa5g
175        if not is_current_network_5g(ads[0], nr_type = 'nsa'):
176            ads[0].log.error("Phone not attached on 5g nsa after call end.")
177            return False
178
179        self.log.info("PASS - VoLTE to 3g over 5g nsa validated")
180        return True
181
182
183    @test_tracker_info(uuid="3a8147d6-c136-42cb-92ca-2023b8eed85e")
184    @TelephonyBaseTest.tel_test_wrap
185    def test_5g_nsa_call_volte_mo_hold_unhold(self):
186        """ 5g nsa volte mo hold unhold test
187
188        1. Make sure PhoneA is in nsa 5g (with volte)
189        2. Make sure PhoneB is in nsa 5g (with volte)
190        3. Call from PhoneA to PhoneB, accept on PhoneB
191        4. Make sure PhoneA/B are in call
192        5. Hold and unhold on PhoneA
193        6. Verify both PhoneA and PhoneB gets attached back to nsa5g
194
195        Raises:
196            TestFailure if not success.
197        """
198        ads = self.android_devices
199        if not provision_both_devices_for_volte(self.log, ads, GEN_5G,
200                                                nr_type='nsa'):
201            return False
202
203        if not phone_setup_call_hold_unhold_test(self.log,
204                                                 ads,
205                                                 DIRECTION_MOBILE_ORIGINATED,
206                                                 caller_func=is_phone_in_call_volte):
207            return False
208
209        if not verify_5g_attach_for_both_devices(self.log, ads, nr_type='nsa'):
210            return False
211        return True
212
213    @test_tracker_info(uuid="1825f9d9-dcf1-4407-922d-3f218d5b8932")
214    @TelephonyBaseTest.tel_test_wrap
215    def test_5g_nsa_call_volte_mt_hold_unhold(self):
216        """ 5g nsa volte mt hold unhold test
217
218        1. Make sure PhoneA is in nsa 5g (with volte)
219        2. Make sure PhoneB is in nsa 5g (with volte)
220        3. Call from PhoneB to PhoneA, accept on PhoneA
221        4. Make sure PhoneA/B are in call
222        5. Hold and unhold on PhoneA
223        6. Verify both PhoneA and PhoneB gets attached back to nsa5g
224
225        Raises:
226            TestFailure if not success.
227        """
228        ads = self.android_devices
229        if not provision_both_devices_for_volte(self.log, ads, GEN_5G,
230                                                nr_type='nsa'):
231            return False
232
233        if not phone_setup_call_hold_unhold_test(self.log,
234                                                 ads,
235                                                 DIRECTION_MOBILE_TERMINATED,
236                                                 callee_func=is_phone_in_call_volte):
237            return False
238
239        if not verify_5g_attach_for_both_devices(self.log, ads, nr_type='nsa'):
240            return False
241        return True
242
243
244    @test_tracker_info(uuid="c082a9b0-fb66-4d3a-9fdd-1ce5710624be")
245    @TelephonyBaseTest.tel_test_wrap
246    def test_5g_nsa_call_mo_volte_in_active_data_transfer(self):
247        """Test call can be established during active data connection in 5G NSA.
248
249        Turn off airplane mode, disable WiFi, enable Cellular Data.
250        Make sure phone in 5G NSA.
251        Starting downloading file from Internet.
252        Initiate a MO voice call. Verify call can be established.
253        Hangup Voice Call, verify file is downloaded successfully.
254        Note: file download will be suspended when call is initiated if voice
255              is using voice channel and voice channel and data channel are
256              on different RATs.
257
258        Returns:
259            True if success.
260            False if failed.
261        """
262        return test_call_setup_in_active_data_transfer(
263            self.log,
264            self.android_devices,
265            rat='5g_volte',
266            nr_type='nsa',
267            call_direction=DIRECTION_MOBILE_ORIGINATED)
268
269
270    @test_tracker_info(uuid="aaa98e51-0bde-472a-abc3-5dc180f56a08")
271    @TelephonyBaseTest.tel_test_wrap
272    def test_5g_nsa_call_mt_volte_in_active_data_transfer(self):
273        """Test call can be established during active data connection in 5G NSA.
274
275        Turn off airplane mode, disable WiFi, enable Cellular Data.
276        Make sure phone in 5G NSA.
277        Starting downloading file from Internet.
278        Initiate a MT voice call. Verify call can be established.
279        Hangup Voice Call, verify file is downloaded successfully.
280        Note: file download will be suspended when call is initiated if voice
281              is using voice channel and voice channel and data channel are
282              on different RATs.
283
284        Returns:
285            True if success.
286            False if failed.
287        """
288        return test_call_setup_in_active_data_transfer(
289            self.log,
290            self.android_devices,
291            rat='5g_volte',
292            nr_type='nsa',
293            call_direction=DIRECTION_MOBILE_TERMINATED)
294
295
296    @test_tracker_info(uuid="96b7d8c9-d32a-4abf-8326-6b060d116ac2")
297    @TelephonyBaseTest.tel_test_wrap
298    def test_5g_nsa_call_epdg_to_epdg_wfc_wifi_preferred(self):
299        """ WiFi Preferred, WiFi calling to WiFi Calling test on 5G NSA
300
301        1. Setup PhoneA WFC mode: WIFI_PREFERRED, APM off.
302        2. Setup PhoneB WFC mode: WIFI_PREFERRED, APM off .
303        3. Set PhoneA/PhoneB on 5G NSA
304        4. Make sure PhoneA/PhoneB on 5G NSA before testing
305        5. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
306        6. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
307        7. Make sure PhoneA/PhoneB on 5G NSA after testing
308
309        Returns:
310            True if pass; False if fail.
311        """
312        return call_epdg_to_epdg_wfc(self.log,
313                                     self.android_devices,
314                                     False,
315                                     WFC_MODE_WIFI_PREFERRED,
316                                     self.wifi_network_ssid,
317                                     self.wifi_network_pass,
318                                     GEN_5G)
319
320
321    @test_tracker_info(uuid="29fa7f44-8d6a-4948-8178-33c9a9aab334")
322    @TelephonyBaseTest.tel_test_wrap
323    def test_5g_nsa_call_mo_volte_in_active_youtube(self):
324        """Test call can be established during active youtube video on 5G NSA.
325
326        1. Enable VoLTE on PhoneA.
327        2. Set up PhoneA on 5G NSA.
328        3. Make sure phoneA is on 5G NSA.
329        4. Starting an youtube video.
330        5. Initiate a MO voice call. Verify call can be established.
331        6. Make sure phoneA is on 5G NSA.
332
333        Returns:
334            True if success.
335            False if failed.
336        """
337        return test_call_setup_in_active_youtube_video(
338            self.log,
339            self.android_devices,
340            rat='5g_volte',
341            nr_type='nsa',
342            call_direction=DIRECTION_MOBILE_ORIGINATED)
343
344    @test_tracker_info(uuid="4e138477-3536-48bd-ab8a-7fb7c228b3e6")
345    @TelephonyBaseTest.tel_test_wrap
346    def test_5g_nsa_call_mt_volte_in_active_youtube(self):
347        """Test call can be established during active youtube video on 5G NSA.
348
349        1. Enable VoLTE on PhoneA.
350        2. Set up PhoneA on 5G NSA.
351        3. Make sure phoneA is on 5G NSA.
352        4. Starting an youtube video.
353        5. Initiate a MT voice call. Verify call can be established.
354        6. Make sure phoneA is on 5G NSA.
355
356        Returns:
357            True if success.
358            False if failed.
359        """
360        return test_call_setup_in_active_youtube_video(
361            self.log,
362            self.android_devices,
363            rat='5g_volte',
364            nr_type='nsa',
365            call_direction=DIRECTION_MOBILE_TERMINATED)
366
367
368    @test_tracker_info(uuid="0d477f6f-3464-4b32-a5e5-0fd134f2753d")
369    @TelephonyBaseTest.tel_test_wrap
370    def test_5g_nsa_call_mo_vowifi_in_active_data_transfer(self):
371        """Test MO voice wifi call can be established during active data connection on 5G NSA.
372
373        1. Turn off airplane mode, turn on wfc and wifi on phoneA.
374        2. Set PhoneA on 5G NSA
375        3. Make sure PhoneA on 5G NSA before testing
376        4. Starting downloading file from Internet.
377        5. Initiate a MO voice call. Verify call can be established.
378        6. Hangup Voice Call, verify file is downloaded successfully.
379        7. Make sure PhoneA on 5G NSA after testing
380
381        Returns:
382            True if success.
383            False if failed.
384        """
385        return test_call_setup_in_active_data_transfer(
386            self.log,
387            self.android_devices,
388            rat='5g_wfc',
389            is_airplane_mode=False,
390            wfc_mode=WFC_MODE_WIFI_PREFERRED,
391            wifi_ssid=self.wifi_network_ssid,
392            wifi_pwd=self.wifi_network_pass,
393            nr_type='nsa',
394            call_direction=DIRECTION_MOBILE_ORIGINATED)
395
396
397    @test_tracker_info(uuid="4d1d7dd9-b373-4361-8301-8517ef77b57b")
398    @TelephonyBaseTest.tel_test_wrap
399    def test_5g_nsa_call_mt_vowifi_in_active_data_transfer(self):
400        """Test MT voice wifi call can be established during active data connection on 5G NSA.
401
402        1. Turn off airplane mode, turn on wfc and wifi on phoneA.
403        2. Set PhoneA on 5G NSA
404        3. Make sure PhoneA on 5G NSA before testing
405        4. Starting downloading file from Internet.
406        5. Initiate a MT voice call. Verify call can be established.
407        6. Hangup Voice Call, verify file is downloaded successfully.
408        7. Make sure PhoneA on 5G NSA after testing
409
410        Returns:
411            True if success.
412            False if failed.
413        """
414        return test_call_setup_in_active_data_transfer(
415            self.log,
416            self.android_devices,
417            rat='5g_wfc',
418            is_airplane_mode=False,
419            wfc_mode=WFC_MODE_WIFI_PREFERRED,
420            wifi_ssid=self.wifi_network_ssid,
421            wifi_pwd=self.wifi_network_pass,
422            nr_type='nsa',
423            call_direction=DIRECTION_MOBILE_TERMINATED)
424
425
426    @test_tracker_info(uuid="e360bc3a-96b3-4fdf-9bf3-fe3aa08b1af5")
427    @TelephonyBaseTest.tel_test_wrap
428    def test_5g_nsa_call_epdg_mo_hold_unhold_wfc_wifi_preferred(self):
429        """ WiFi Preferred, WiFi calling MO call hold/unhold test on 5G NSA
430
431        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
432        2. Set preferred network of phoneA on 5G NSA
433        3. Verify phoneA is on 5G NSA.
434        4. Call from PhoneA to PhoneB, accept on PhoneB.
435        5. Hold and unhold on PhoneA.
436        6. Verify phoneA is on 5G NSA.
437
438        Returns:
439            True if pass; False if fail.
440        """
441        ads = self.android_devices
442        if not phone_setup_iwlan(self.log, ads[0], False,
443                                 WFC_MODE_WIFI_PREFERRED,
444                                 self.wifi_network_ssid,
445                                 self.wifi_network_pass):
446            ads[0].log.error(
447                "Failed to setup iwlan with APM off and WIFI and WFC on")
448            return False
449
450        if not provision_device_for_5g(self.log, ads[0], nr_type='nsa'):
451            return False
452
453        if not phone_setup_call_hold_unhold_test(self.log,
454                                                 ads,
455                                                 DIRECTION_MOBILE_ORIGINATED,
456                                                 caller_func=is_phone_in_call_iwlan):
457            return False
458
459        if not is_current_network_5g(ads[0], nr_type = 'nsa'):
460            ads[0].log.error("Phone not attached on 5G NSA after call.")
461            return False
462        return True
463
464
465    @test_tracker_info(uuid="d2335c83-87ec-4a0e-97a8-b53f769b0d21")
466    @TelephonyBaseTest.tel_test_wrap
467    def test_5g_nsa_call_epdg_mt_hold_unhold_wfc_wifi_preferred(self):
468        """ WiFi Preferred, WiFi calling MT call hold/unhold test on 5G NSA
469
470        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
471        2. Set preferred network of phoneA on 5G NSA
472        3. Verify if phoneA is on 5G NSA.
473        4. Call from PhoneB to PhoneA, accept on PhoneA.
474        5. Hold and unhold on PhoneA.
475        6. Verify if phoneA is on 5G NSA.
476
477        Returns:
478            True if pass; False if fail.
479        """
480        ads = self.android_devices
481        if not phone_setup_iwlan(self.log, ads[0], False,
482                                 WFC_MODE_WIFI_PREFERRED,
483                                 self.wifi_network_ssid,
484                                 self.wifi_network_pass):
485            ads[0].log.error(
486                "Failed to setup iwlan with APM off and WIFI and WFC on")
487            return False
488
489        if not provision_device_for_5g(self.log, ads[0], nr_type='nsa'):
490            return False
491
492        if not phone_setup_call_hold_unhold_test(self.log,
493                                                 ads,
494                                                 DIRECTION_MOBILE_TERMINATED,
495                                                 callee_func=is_phone_in_call_iwlan):
496            return False
497
498        if not is_current_network_5g(ads[0], nr_type = 'nsa'):
499            ads[0].log.error("Phone not attached on 5G NSA after call.")
500            return False
501        return True
502
503
504    @test_tracker_info(uuid="03dc3296-5f2f-4141-b2e5-bb0d8ea6ffec")
505    @TelephonyBaseTest.tel_test_wrap
506    def test_5g_nsa_call_volte_to_csfb_3g(self):
507        """ VoLTE nsa 5G to CSFB 3G call test
508
509        1. Make Sure PhoneA is in nsa 5G mode (with VoLTE).
510        2. Make Sure PhoneB is in CSFB mode (without VoLTE).
511        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
512        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
513
514        Raises:
515            TestFailure if not success.
516        """
517        ads = self.android_devices
518
519        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_csfb,
520                                                           (self.log, ads[1]))]
521        if not multithread_func(self.log, tasks):
522            self.log.error("Phone failed to set up in VoLTE/CSFB")
523            return False
524
525        if not provision_device_for_5g(self.log, ads[0], nr_type='nsa'):
526            return False
527
528        result = two_phone_call_short_seq(
529            self.log, ads[0], None, is_phone_in_call_volte, ads[1],
530            phone_idle_csfb, is_phone_in_call_csfb, None)
531        self.tel_logger.set_result(result.result_value)
532        if not result:
533            raise signals.TestFailure("Failed",
534                extras={"fail_reason": str(result.result_value)})
535
536
537    @test_tracker_info(uuid="1955604b-5b81-4b06-b846-ba55b46ea997")
538    @TelephonyBaseTest.tel_test_wrap
539    def test_5g_nsa_call_volte_to_2g(self):
540        """ nsa 5G to 2G call test (with VoLTE)
541
542        1. Make Sure PhoneA is in nsa 5G mode (with VoLTE).
543        2. Make Sure PhoneB is in 2G mode.
544        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
545        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
546
547        Raises:
548            TestFailure if not success.
549        """
550        ads = self.android_devices
551
552        tasks = [(phone_setup_volte, (self.log, ads[0])),
553                 (phone_setup_voice_2g, (self.log, ads[1]))]
554        if not multithread_func(self.log, tasks):
555            self.log.error("Phone failed to set up in VoLTE/2G")
556            return False
557
558        if not provision_device_for_5g(self.log, ads[0], nr_type='nsa'):
559            return False
560
561        result = two_phone_call_short_seq(
562            self.log, ads[0], None, is_phone_in_call_volte, ads[1],
563            phone_idle_2g, is_phone_in_call_2g, None)
564        self.tel_logger.set_result(result.result_value)
565        if not result:
566            raise signals.TestFailure("Failed",
567                extras={"fail_reason": str(result.result_value)})
568
569
570    @test_tracker_info(uuid="547d0b7e-8130-4166-bd57-af8257d5d0c4")
571    @TelephonyBaseTest.tel_test_wrap
572    def test_5g_nsa_call_epdg_to_volte_wfc_wifi_preferred(self):
573        """ WiFi Preferred, WiFi calling to nsa5g VoLTE test
574
575        1. Setup PhoneA WFC mode: WIFI_PREFERRED.
576        2. Make Sure PhoneB is in nsa5G mode (with VoLTE enabled).
577        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
578        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
579
580        Raises:
581            TestFailure if not success.
582        """
583        ads = self.android_devices
584        tasks = [(phone_setup_iwlan,
585                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
586                   self.wifi_network_ssid, self.wifi_network_pass)),
587                 (phone_setup_volte, (self.log, ads[1]))]
588
589        if not multithread_func(self.log, tasks):
590            self.log.error("Phone failed to set up in VoLTE")
591            return False
592
593        if not provision_device_for_5g(self.log, ads[1], nr_type='nsa'):
594            return False
595
596        result = two_phone_call_short_seq(
597            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
598            None, is_phone_in_call_volte, None,
599            WAIT_TIME_IN_CALL_FOR_IMS)
600        self.tel_logger.set_result(result.result_value)
601        if not result:
602            raise signals.TestFailure("Failed",
603                extras={"fail_reason": str(result.result_value)})
604
605
606    @test_tracker_info(uuid="119b54f8-fe4f-4158-baa3-c869a7ce12b9")
607    @TelephonyBaseTest.tel_test_wrap
608    def test_5g_nsa_call_epdg_to_volte_apm_wfc_wifi_only(self):
609        """ Airplane + WiFi Only, WiFi calling to nsa5g VoLTE test
610
611        1. Setup PhoneA in airplane mode, WFC mode: WIFI_ONLY.
612        2. Make Sure PhoneB is in nsa 5G mode (with VoLTE enabled).
613        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
614        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
615
616        Raises:
617            TestFailure if not success.
618        """
619        ads = self.android_devices
620        tasks = [(phone_setup_iwlan,
621                  (self.log, ads[0], True, WFC_MODE_WIFI_ONLY,
622                   self.wifi_network_ssid, self.wifi_network_pass)),
623                 (phone_setup_volte, (self.log, ads[1]))]
624
625        if not multithread_func(self.log, tasks):
626            self.log.error("Phone failed to set up in VoLTE")
627            return False
628
629        if not provision_device_for_5g(self.log, ads[1], nr_type='nsa'):
630            return False
631
632        result = two_phone_call_short_seq(
633            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
634            None, is_phone_in_call_volte, None,
635            WAIT_TIME_IN_CALL_FOR_IMS)
636        self.tel_logger.set_result(result.result_value)
637
638        toggle_airplane_mode(self.log, ads[0], False)
639
640        if not result:
641            raise signals.TestFailure("Failed",
642                extras={"fail_reason": str(result.result_value)})
643
644
645    @test_tracker_info(uuid="cb2eac2b-fc48-409d-bff2-a06849d6cd1a")
646    @TelephonyBaseTest.tel_test_wrap
647    def test_5g_nsa_call_epdg_to_volte_apm_wfc_wifi_preferred(self):
648        """ Airplane + WiFi Preferred, WiFi calling to nsa5g VoLTE test
649
650        1. Setup PhoneA in airplane mode, WFC mode: WIFI_PREFERRED.
651        2. Make Sure PhoneB is in nsa 5G mode (with VoLTE enabled).
652        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
653        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
654
655        Raises:
656            TestFailure if not success.
657        """
658        ads = self.android_devices
659        tasks = [(phone_setup_iwlan,
660                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
661                   self.wifi_network_ssid, self.wifi_network_pass)),
662                 (phone_setup_volte, (self.log, ads[1]))]
663
664        if not multithread_func(self.log, tasks):
665            self.log.error("Phone failed to set up in VoLTE")
666            return False
667
668        if not provision_device_for_5g(self.log, ads[1], nr_type='nsa'):
669            return False
670
671        result = two_phone_call_short_seq(
672            self.log, ads[0], phone_idle_iwlan, is_phone_in_call_iwlan, ads[1],
673            None, is_phone_in_call_volte, None,
674            WAIT_TIME_IN_CALL_FOR_IMS)
675        self.tel_logger.set_result(result.result_value)
676
677        toggle_airplane_mode(self.log, ads[0], False)
678
679        if not result:
680            raise signals.TestFailure("Failed",
681                extras={"fail_reason": str(result.result_value)})
682
683
684    @test_tracker_info(uuid="c06d6c81-ce26-474d-b41e-fcfe1ec6e761")
685    @TelephonyBaseTest.tel_test_wrap
686    def test_5g_nsa_call_volte_to_volte_long(self):
687        """ VoLTE to nsa 5G VoLTE call test
688
689        1. Make Sure PhoneA is in LTE mode (with VoLTE).
690        2. Make Sure PhoneB is in nsa 5G mode (with VoLTE).
691        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
692        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
693        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
694        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
695
696        Raises:
697            TestFailure if not success.
698        """
699        ads = self.android_devices
700
701        tasks = [(phone_setup_volte, (self.log, ads[0])),
702                (phone_setup_volte, (self.log, ads[1], GEN_5G, 'nsa'))]
703        if not multithread_func(self.log, tasks):
704            self.log.error("phone failed to set up in volte")
705            return False
706
707        result = two_phone_call_long_seq(
708            self.log, ads[0], phone_idle_volte, is_phone_in_call_volte, ads[1],
709            None, is_phone_in_call_volte, None,
710            WAIT_TIME_IN_CALL_FOR_IMS)
711        self.tel_logger.set_result(result.result_value)
712        if not result:
713            raise signals.TestFailure("Failed",
714                extras={"fail_reason": str(result.result_value)})
715
716
717    @test_tracker_info(uuid="3c45ab10-9e8c-4804-9f32-c775baa3d5e7")
718    @TelephonyBaseTest.tel_test_wrap
719    def test_5g_nsa_call_volte_to_volte_loop(self):
720        """ Stress test: VoLTE to nsa 5g VoLTE call test
721
722        1. Make Sure PhoneA is in LTE mode (with VoLTE).
723        2. Make Sure PhoneB is in nsa 5G mode (with VoLTE).
724        3. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
725        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
726        5. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneB.
727        6. Call from PhoneB to PhoneA, accept on PhoneA, hang up on PhoneA.
728        7. Repeat step 3~6.
729
730        Returns:
731            True if pass; False if fail.
732        """
733
734        MINIMUM_SUCCESS_RATE = .95
735        ads = self.android_devices
736
737        tasks = [(phone_setup_volte, (self.log, ads[0])),
738                (phone_setup_volte, (self.log, ads[1], GEN_5G, 'nsa'))]
739        if not multithread_func(self.log, tasks):
740            self.log.error("phone failed to set up in volte")
741            return False
742
743        success_count = 0
744        fail_count = 0
745
746        for i in range(1, self.stress_test_number + 1):
747
748            if two_phone_call_long_seq(
749                    self.log, ads[0], phone_idle_volte, is_phone_in_call_volte,
750                    ads[1], None, is_phone_in_call_volte, None,
751                    WAIT_TIME_IN_CALL_FOR_IMS):
752                success_count += 1
753                result_str = "Succeeded"
754
755            else:
756                fail_count += 1
757                result_str = "Failed"
758
759            self.log.info("Iteration %s %s. Current: %s / %s passed.", i,
760                          result_str, success_count, self.stress_test_number)
761
762        self.log.info("Final Count - Success: %s, Failure: %s - %s%",
763                      success_count, fail_count,
764                      str(100 * success_count / (success_count + fail_count)))
765        if success_count / (
766                success_count + fail_count) >= MINIMUM_SUCCESS_RATE:
767            return True
768        else:
769            return False
770
771
772    @test_tracker_info(uuid="875292c8-14f8-43aa-8770-3d0099da9c53")
773    @TelephonyBaseTest.tel_test_wrap
774    def test_5g_nsa_call_voicemail_indicator_volte(self):
775        """Test Voice Mail notification in nsa 5G (VoLTE enabled).
776        This script currently only works for TMO now.
777
778        1. Make sure DUT (ads[0]) in nsa 5g VoLTE mode. Both PhoneB and DUT idle.
779        2. Make call from PhoneB to DUT, reject on DUT.
780        3. On PhoneB, leave a voice mail to DUT.
781        4. Verify DUT receive voice mail notification.
782
783        Returns:
784            True if pass; False if fail.
785        """
786        ads = self.android_devices
787
788        tasks = [(phone_setup_voice_general, (self.log, ads[1])),
789                 (phone_setup_volte, (self.log, ads[0]))]
790        if not multithread_func(self.log, tasks):
791            self.log.error("Phone Failed to Set Up Properly.")
792            return False
793
794        if not provision_device_for_5g(self.log, ads[0], nr_type='nsa'):
795            return False
796
797        if not call_voicemail_erase_all_pending_voicemail(self.log, ads[0]):
798            self.log.error("Failed to clear voice mail.")
799            return False
800
801        return two_phone_call_leave_voice_mail(self.log, ads[1], None, None,
802                                               ads[0], phone_idle_volte)
803
804
805    @test_tracker_info(uuid="b866dcfa-f133-424d-bb5d-f381a1f63602")
806    @TelephonyBaseTest.tel_test_wrap
807    def test_5g_nsa_call_long_duration_volte(self):
808        """ Test call drop rate for nsa 5g VoLTE long duration call.
809
810        Steps:
811        1. Setup nsa 5g VoLTE for DUT.
812        2. Make nsa 5g VoLTE call from DUT to PhoneB.
813        3. For <total_duration> time, check if DUT drop call or not.
814
815        Expected Results:
816        DUT should not drop call.
817
818        Returns:
819        False if DUT call dropped during test.
820        Otherwise True.
821        """
822        ads = self.android_devices
823
824        tasks = [(phone_setup_volte, (self.log, ads[0])),
825                 (phone_setup_voice_general, (self.log, ads[1]))]
826        if not multithread_func(self.log, tasks):
827            self.log.error("Phone Failed to Set Up Properly.")
828            return False
829
830        if not provision_device_for_5g(self.log, ads[0], nr_type='nsa'):
831            return False
832
833        return _test_call_long_duration(self.log, ads,
834            is_phone_in_call_volte, self.long_call_duration)
835
836
837    @test_tracker_info(uuid="527e6676-25c7-4adc-94e7-bb6d3b8f6c24")
838    @TelephonyBaseTest.tel_test_wrap
839    def test_5g_nsa_call_volte_after_mobile_data_usage_limit_reached(self):
840        """ VoLTE to VoLTE call test after mobile data usage limit reached
841
842        1. Set the data limit to the current usage
843        2. Make Sure PhoneA is in nsa 5G mode (with VoLTE).
844        3. Make Sure PhoneB is in nsa 5G mode (with VoLTE).
845        4. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneA.
846        5. Call from PhoneA to PhoneB, accept on PhoneB, hang up on PhoneB.
847
848        Raises:
849            TestFailure if not success.
850        """
851        ads = self.android_devices
852        try:
853            subscriber_id = ads[0].droid.telephonyGetSubscriberId()
854            data_usage = get_mobile_data_usage(ads[0], subscriber_id)
855            set_mobile_data_usage_limit(ads[0], data_usage, subscriber_id)
856
857            if not provision_device_for_5g(self.log, ads, nr_type='nsa'):
858                self.log.error("Phone Failed to Set Up Properly.")
859                self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
860                raise signals.TestFailure("Failed",
861                    extras={"fail_reason": "Phone Failed to Set Up Properly."})
862
863            result = two_phone_call_short_seq(
864                self.log, ads[0], None, is_phone_in_call_volte,
865                ads[1], None, is_phone_in_call_volte, None,
866                WAIT_TIME_IN_CALL_FOR_IMS)
867            self.tel_logger.set_result(result.result_value)
868
869            if not result:
870                raise signals.TestFailure("Failed",
871                    extras={"fail_reason": str(result.result_value)})
872        finally:
873            remove_mobile_data_usage_limit(ads[0], subscriber_id)
874
875
876    @test_tracker_info(uuid="2c28a974-dc31-4f01-b555-d3e0a8374f37")
877    @TelephonyBaseTest.tel_test_wrap
878    def test_5g_nsa_call_volte_in_call_wifi_toggling(self):
879        """ General voice to voice call.
880
881        1. Make Sure PhoneA in nsa5G.
882        2. Make Sure PhoneB in nsa5G.
883        3. Call from PhoneA to PhoneB.
884        4. Toggling Wifi connnection in call.
885        5. Verify call is active.
886        6. Hung up the call on PhoneA
887
888        Returns:
889            True if pass; False if fail.
890        """
891        ads = self.android_devices
892        result = True
893
894        if not provision_device_for_5g(self.log, ads, nr_type='nsa'):
895                self.log.error("Phone Failed to Set Up Properly.")
896                self.tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
897                raise signals.TestFailure("Failed",
898                    extras={"fail_reason": "Phone Failed to Set Up Properly."})
899
900        if not call_setup_teardown(self.log, ads[0], ads[1], None, None, None,
901                                   5):
902            self.log.error("Call setup failed")
903            return False
904        else:
905            self.log.info("Call setup succeed")
906
907        if not wifi_cell_switching(self.log, ads[0], None, self.wifi_network_ssid,
908                                   self.wifi_network_pass):
909            ads[0].log.error("Failed to do WIFI and Cell switch in call")
910            result = False
911
912        if not is_phone_in_call_active(ads[0]):
913            return False
914        else:
915            if not ads[0].droid.telecomCallGetAudioState():
916                ads[0].log.error("Audio is not on call")
917                result = False
918            else:
919                ads[0].log.info("Audio is on call")
920            hangup_call(self.log, ads[0])
921            return result
922
923    @test_tracker_info(uuid="95802175-06d5-4774-8ce8-fdf7922eca20")
924    @TelephonyBaseTest.tel_test_wrap
925    def test_5g_nsa_call_mo_vowifi_in_active_youtube(self):
926        """Test call can be established during active youtube video on 5G NSA.
927
928        Turn off airplane mode, turn on wfc and wifi.
929        Starting youtube video.
930        Initiate a MO voice call. Verify call can be established.
931
932        Returns:
933            True if success.
934            False if failed.
935        """
936        return test_call_setup_in_active_youtube_video(
937            self.log,
938            self.android_devices,
939            rat='5g_wfc',
940            is_airplane_mode=False,
941            wfc_mode=WFC_MODE_WIFI_PREFERRED,
942            wifi_ssid=self.wifi_network_ssid,
943            wifi_pwd=self.wifi_network_pass,
944            nr_type='nsa',
945            call_direction=DIRECTION_MOBILE_ORIGINATED)
946
947    @test_tracker_info(uuid="f827a8b5-039c-4cc1-b030-78a09119acfc")
948    @TelephonyBaseTest.tel_test_wrap
949    def test_5g_nsa_call_mt_vowifi_in_active_youtube(self):
950        """Test call can be established during active youtube_video on 5G NSA.
951
952        Turn off airplane mode, turn on wfc and wifi.
953        Starting an youtube video.
954        Initiate a MT voice call. Verify call can be established.
955
956        Returns:
957            True if success.
958            False if failed.
959        """
960        return test_call_setup_in_active_youtube_video(
961            self.log,
962            self.android_devices,
963            rat='5g_wfc',
964            is_airplane_mode=False,
965            wfc_mode=WFC_MODE_WIFI_PREFERRED,
966            wifi_ssid=self.wifi_network_ssid,
967            wifi_pwd=self.wifi_network_pass,
968            nr_type='nsa',
969            call_direction=DIRECTION_MOBILE_TERMINATED)
970
971    @test_tracker_info(uuid="af3254d0-a84a-47c8-8ebc-11517b7b4944")
972    @TelephonyBaseTest.tel_test_wrap
973    def test_5g_nsa_call_mo_vowifi_apm_in_active_data_transfer(self):
974        """Test call can be established during active data connection on 5G NSA.
975
976        Turn on wifi-calling, airplane mode and wifi.
977        Starting downloading file from Internet.
978        Initiate a MO voice call. Verify call can be established.
979        Hangup Voice Call, verify file is downloaded successfully.
980
981        Returns:
982            True if success.
983            False if failed.
984        """
985        return test_call_setup_in_active_data_transfer(
986            self.log,
987            self.android_devices,
988            rat='5g_wfc',
989            is_airplane_mode=True,
990            wfc_mode=WFC_MODE_WIFI_PREFERRED,
991            wifi_ssid=self.wifi_network_ssid,
992            wifi_pwd=self.wifi_network_pass,
993            nr_type='nsa',
994            call_direction=DIRECTION_MOBILE_ORIGINATED)
995
996    @test_tracker_info(uuid="5c58af94-8c24-481b-a555-bdbf36db5f6e")
997    @TelephonyBaseTest.tel_test_wrap
998    def test_5g_nsa_call_mt_vowifi_apm_in_active_data_transfer(self):
999        """Test call can be established during active data connection on 5G NSA.
1000
1001        Turn on wifi-calling, airplane mode and wifi.
1002        Starting downloading file from Internet.
1003        Initiate a MT voice call. Verify call can be established.
1004        Hangup Voice Call, verify file is downloaded successfully.
1005
1006        Returns:
1007            True if success.
1008            False if failed.
1009        """
1010        return test_call_setup_in_active_data_transfer(
1011            self.log,
1012            self.android_devices,
1013            rat='5g_wfc',
1014            is_airplane_mode=True,
1015            wfc_mode=WFC_MODE_WIFI_PREFERRED,
1016            wifi_ssid=self.wifi_network_ssid,
1017            wifi_pwd=self.wifi_network_pass,
1018            nr_type='nsa',
1019            call_direction=DIRECTION_MOBILE_TERMINATED)
1020
1021    @test_tracker_info(uuid="bcd874ae-58e1-4954-88af-bb3dd54d4abf")
1022    @TelephonyBaseTest.tel_test_wrap
1023    def test_5g_nsa_call_mo_vowifi_apm_in_active_youtube(self):
1024        """Test call can be established during active youtube video on 5G NSA.
1025
1026        Turn on wifi-calling, airplane mode and wifi.
1027        Starting an youtube video.
1028        Initiate a MO voice call. Verify call can be established.
1029
1030        Returns:
1031            True if success.
1032            False if failed.
1033        """
1034        return test_call_setup_in_active_youtube_video(
1035            self.log,
1036            self.android_devices,
1037            rat='5g_wfc',
1038            is_airplane_mode=True,
1039            wfc_mode=WFC_MODE_WIFI_PREFERRED,
1040            wifi_ssid=self.wifi_network_ssid,
1041            wifi_pwd=self.wifi_network_pass,
1042            nr_type='nsa',
1043            call_direction=DIRECTION_MOBILE_ORIGINATED)
1044
1045    @test_tracker_info(uuid="ad96f1cf-0d17-4a39-86cf-cacb5f4cc81c")
1046    @TelephonyBaseTest.tel_test_wrap
1047    def test_5g_nsa_call_mt_vowifi_apm_in_active_youtube(self):
1048        """Test call can be established during active youtube video on 5G NSA.
1049
1050        Turn on wifi-calling, airplane mode and wifi.
1051        Starting youtube video.
1052        Initiate a MT voice call. Verify call can be established.
1053
1054        Returns:
1055            True if success.
1056            False if failed.
1057        """
1058        return test_call_setup_in_active_youtube_video(
1059            self.log,
1060            self.android_devices,
1061            rat='5g_wfc',
1062            is_airplane_mode=True,
1063            wfc_mode=WFC_MODE_WIFI_PREFERRED,
1064            wifi_ssid=self.wifi_network_ssid,
1065            wifi_pwd=self.wifi_network_pass,
1066            nr_type='nsa',
1067            call_direction=DIRECTION_MOBILE_TERMINATED)
1068
1069    @test_tracker_info(uuid="9d1121c1-aae4-428b-9167-09d4efdb7e37")
1070    @TelephonyBaseTest.tel_test_wrap
1071    def test_5g_nsa_call_wfc_in_call_wifi_toggling(self):
1072        """ General voice to voice call on 5G NSA. TMO Only Test
1073
1074        1. Make Sure PhoneA in wfc with APM off.
1075        2. Make Sure PhoneB in Voice Capable.
1076        3. Call from PhoneA to PhoneB.
1077        4. Toggling Wifi connection in call.
1078        5. Verify call is active.
1079        6. Hung up the call on PhoneA
1080
1081        Returns:
1082            True if pass; False if fail.
1083        """
1084
1085        ads = self.android_devices
1086
1087        if not phone_setup_volte(
1088                self.log, ads[0], nw_gen=GEN_5G, nr_type='nsa'):
1089            return False
1090        tasks = [(phone_setup_iwlan,
1091                  (self.log, ads[0], False, WFC_MODE_WIFI_PREFERRED,
1092                   self.wifi_network_ssid, self.wifi_network_pass)),
1093                 (phone_setup_voice_general, (self.log, ads[1]))]
1094
1095        if not multithread_func(self.log, tasks):
1096            self.log.error("Phone Failed to Set Up Properly.")
1097            return False
1098        return test_wifi_cell_switching_in_call(self.log,
1099                                                ads,
1100                                                self.wifi_network_ssid,
1101                                                self.wifi_network_pass)
1102
1103    @test_tracker_info(uuid="e42cb2bc-db0b-4053-a052-7d95e55bc815")
1104    @TelephonyBaseTest.tel_test_wrap
1105    def test_5g_nsa_volte_call_during_data_idle_and_transfer_mo(self):
1106        """Test 5G NSA for VoLTE call during data idle and data transfer.
1107
1108        Steps:
1109	    (1) Provision both devices on 5G NSA.
1110	    (2) Initiate MO VoLTE call during data idle.
1111	    (3) End call.
1112	    (4) Initiate a MO VoLTE call and start a download.
1113	    (5) Start another download and initiate MO VoLTE call during data transferring.
1114	    (6) End call.
1115	    (7) Initiate a MO VoLTE call and start a download.
1116
1117        Returns:
1118            True if pass; False if fail.
1119        """
1120        cell_1 = self.android_devices[0]
1121        cell_2 = self.android_devices[1]
1122
1123        if not provision_device_for_5g(self.log, [cell_1, cell_2], nr_type='nsa'):
1124            cell_1.log.error("Failed to setup on 5G NSA")
1125            return False
1126
1127        # Initiate call during data idle and end call
1128        if not initiate_call_verify_operation(self.log, cell_1, cell_2):
1129            cell_1.log.error("Phone was unable to initate a call")
1130            return False
1131
1132        # Initiate call and start a download
1133        if not initiate_call_verify_operation(self.log, cell_1, cell_2, True):
1134            cell_1.log.error("Phone was unable to initate a call and verify download")
1135            return False
1136
1137        download_task = active_file_download_task(self.log, cell_1, "10MB")
1138        call_task = (initiate_call_verify_operation, (self.log, cell_1, cell_2))
1139
1140        results = run_multithread_func(self.log, [download_task, call_task])
1141
1142        if ((results[0]) & (results[1])):
1143            self.log.info("PASS - Validate VoLTE call during data transferring")
1144        elif ((results[0] == False) & (results[1] == True)):
1145            self.log.error("FAIL - Data Transfer failed")
1146        elif ((results[0] == True) & (results[1] == False)):
1147            self.log.error("FAIL - Call Initiation failed")
1148        else:
1149            self.log.error("FAILED - Validate VoLTE call during data transferring")
1150
1151        if not initiate_call_verify_operation(self.log, cell_1, cell_2, True):
1152            cell_1.log.error("Phone was unable to initate a call and verify download")
1153            return False
1154
1155
1156    @test_tracker_info(uuid="c69ec37d-133f-42c5-babd-91f763dd5b21")
1157    @TelephonyBaseTest.tel_test_wrap
1158    def test_5g_nsa_volte_call_during_data_idle_and_transfer_mt(self):
1159        """Test 5G NSA for VoLTE call during data idle and data transfer.
1160
1161        Steps:
1162	    (1) Provision both devices on 5G NSA.
1163	    (2) Initiate MT VoLTE call during data idle.
1164	    (3) End call.
1165	    (4) Initiate a MO VoLTE call and start a download.
1166	    (5) Start another download and initiate MT VoLTE call during data transferring.
1167	    (6) End call.
1168	    (7) Initiate a MO VoLTE call and start a download.
1169
1170        Returns:
1171            True if pass; False if fail.
1172        """
1173        cell_1 = self.android_devices[0]
1174        cell_2 = self.android_devices[1]
1175
1176        if not provision_device_for_5g(self.log, [cell_1, cell_2], nr_type='nsa'):
1177            cell_1.log.error("Failed to setup on 5G NSA")
1178            return False
1179
1180        # Initiate call during data idle and end call
1181        if not initiate_call_verify_operation(self.log, cell_2, cell_1):
1182            cell_2.log.error("Phone was unable to initate a call")
1183            return False
1184
1185        # Initiate call and start a download
1186        if not initiate_call_verify_operation(self.log, cell_1, cell_2, True):
1187            cell_1.log.error("Phone was unable to initate a call and verify download")
1188            return False
1189
1190        download_task = active_file_download_task(self.log, cell_2, "10MB")
1191        call_task = (initiate_call_verify_operation, (self.log, cell_2, cell_1))
1192
1193        results = run_multithread_func(self.log, [download_task, call_task])
1194
1195        if ((results[0]) & (results[1])):
1196            self.log.info("PASS - Validate MT VoLTE call during data transferring")
1197        elif ((results[0] == False) & (results[1] == True)):
1198            self.log.error("FAIL - Data Transfer failed")
1199        elif ((results[0] == True) & (results[1] == False)):
1200            self.log.error("FAIL - Call Initiation failed")
1201        else:
1202            self.log.error("FAILED - Validate MT VoLTE call during data transferring")
1203
1204        if not initiate_call_verify_operation(self.log, cell_1, cell_2, True):
1205            cell_1.log.error("Phone was unable to initate a call and verify download")
1206            return False
1207
1208    """ Tests End """
1209