• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2022 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import time
18from acts import asserts
19from acts.test_decorators import test_tracker_info
20
21from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
22from acts_contrib.test_utils.tel.GFTInOutBaseTest import GFTInOutBaseTest
23from acts_contrib.test_utils.tel.gft_inout_defines import NO_SERVICE_POWER_LEVEL
24from acts_contrib.test_utils.tel.gft_inout_defines import IN_SERVICE_POWER_LEVEL
25from acts_contrib.test_utils.tel.tel_defines import INVALID_SUB_ID
26from acts_contrib.test_utils.tel.tel_data_utils import start_youtube_video
27from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot
28from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot_0
29from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot_1
30from acts_contrib.test_utils.tel.tel_phone_setup_utils import ensure_phones_idle
31from acts_contrib.test_utils.tel.tel_dsds_utils import dsds_voice_call_test
32from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot_0
33from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot_1
34
35_5G_VOLTE = "5g_volte"
36_VOLTE = "volte"
37_NO_SERVICE_TIME = 30
38_ERROR_MSG_DATA_TRANSFER_FAILURE = "_test_in_out_service_data_transfer failure"
39_ERROR_MSG_IDLE_FAILURE = "_test_in_out_service_idle failure"
40
41
42class TelLabGFTDSDSTest(GFTInOutBaseTest):
43    def __init__(self, controllers):
44        # requirs 2 android devices to run DSDS test
45        GFTInOutBaseTest.__init__(self, controllers)
46        self.tel_logger = TelephonyMetricLogger.for_test_case()
47        self.my_error_msg = ""
48
49    def teardown_test(self):
50        GFTInOutBaseTest.teardown_class(self)
51        ensure_phones_idle(self.log, self.android_devices)
52
53    @test_tracker_info(uuid="90ef8e20-64bb-4bf8-81b6-431de524f2af")
54    @TelephonyBaseTest.tel_test_wrap
55    def test_in_out_msim_5g_esim_5g_dds_sim1(self, loop=1):
56        '''
57            1.7.19 - [SA/NSA][DDS:SIM1][SIM1:5G, SIM2:5G]
58            Attach to 5G after in/out service during idle
59            SIM1 (pSIM) : Carrier 1 with 5G SIM.
60            SIM2 (eSIM) : Carrier 2 with 5G SIM.
61            DDS (Data preferred) on SIM1 and this slot has the 5G capability.
62
63            (1) Moves to no service area during data idle.
64            (2) Moves to service area.
65            (3) Makes a MOMT voice/VT call on SIM1.
66            (4) Makes a MOMT voice/VT call on SIM2.
67            (5) Starts streaming.
68            Args:
69                loop: repeat this test cases for how many times
70            Returns:
71                True if pass; False if fail
72        '''
73        for x in range(self.user_params.get("dsds_io_cycle", 1)):
74            self.log.info("%s loop: %s/%s" %
75                          (self.current_test_name, x + 1, loop))
76            asserts.assert_true(self._test_in_out_service_idle(
77                _5G_VOLTE, _5G_VOLTE, 0),
78                                "[Fail]%s" % (_ERROR_MSG_IDLE_FAILURE),
79                                extras={"failure_cause": self.my_error_msg})
80        return True
81
82    @test_tracker_info(uuid="21b3ff34-e42a-4d42-ba98-87c510e83967")
83    @TelephonyBaseTest.tel_test_wrap
84    def test_in_out_msim_5g_esim_5g_dds_sim2(self, loop=1):
85        '''
86            1.7.20 [SA/NSA][DDS:SIM2][SIM1:5G, SIM2:5G]
87            Attach to 5G after in/out service during idle.
88            SIM1 (pSIM) : Carrier 1 with 5G SIM.
89            SIM2 (eSIM) : Carrier 2 with 5G SIM.
90            DDS (Data preferred) on SIM2
91
92            (1) Moves to no service area during data idle.
93            (2) Moves to service area.
94            (3) Makes a MOMT voice/VT call on SIM2.
95            (4) Makes a MOMT voice/VT call on SIM1.
96            (5) Starts streaming.
97
98            Args:
99                loop: repeat this test cases for how many times
100            Returns:
101                True if pass; False if fail
102        '''
103        for x in range(self.user_params.get("dsds_io_cycle", 1)):
104            self.log.info("%s loop: %s/%s" %
105                          (self.current_test_name, x + 1, loop))
106            asserts.assert_true(self._test_in_out_service_idle(
107                _5G_VOLTE, _5G_VOLTE, 1),
108                                "[Fail]%s" % (_ERROR_MSG_IDLE_FAILURE),
109                                extras={"failure_cause": self.my_error_msg})
110        return True
111
112    @test_tracker_info(uuid="f1311823-e6e4-478e-a38d-2344389698b7")
113    @TelephonyBaseTest.tel_test_wrap
114    def test_in_out_msim_4g_esim_5g_dds_sim1(self, loop=1):
115        '''
116            1.7.21 - [SA/NSA][DDS:SIM1][SIM1:VoLTE, SIM2:5G]
117            Attach to 5G after in/out service during idle
118            SIM1 (pSIM) : Carrier 1 with 4G SIM or 5G SIM locks in 4G.
119            SIM2 (eSIM) : Carrier 2 with 5G SIM.
120            DDS (Data preferred) on SIM1.
121
122            (1) Move to no service area during data idle.
123            (2) Moves to service area.
124            (3) Makes a MOMT voice/VT call on SIM1.
125            (4) Makes a MOMT voice/VT call on SIM2.
126            (5) Starts streaming.
127
128            Args:
129                loop: repeat this test cases for how many times
130            Returns:
131                True if pass; False if fail
132        '''
133        for x in range(self.user_params.get("dsds_io_cycle", 1)):
134            self.log.info("%s loop: %s/%s" %
135                          (self.current_test_name, x + 1, loop))
136            asserts.assert_true(self._test_in_out_service_idle(
137                _VOLTE, _5G_VOLTE, 0),
138                                "[Fail]%s" % (_ERROR_MSG_IDLE_FAILURE),
139                                extras={"failure_cause": self.my_error_msg})
140        return True
141
142    @test_tracker_info(uuid="7dc38fd5-741f-42b0-a476-3aa51610d184")
143    @TelephonyBaseTest.tel_test_wrap
144    def test_in_out_msim_4g_esim_5g_dds_sim2(self, loop=1):
145        '''
146            1.7.22 - [SA/NSA][DDS:SIM2][SIM1:VoLTE, SIM2:5G]
147            Attach to 5G after in/out service during idle
148            SIM1 (pSIM) : Carrier 1 with 4G SIM or 5G SIM locks in 4G.
149            SIM2 (eSIM) : Carrier 2 with 5G SIM.
150            DDS (Data preferred) on SIM2.
151
152            (1) Moves to no service area during data idle.
153            (2) Moves to service area.
154            (3) Makes a MOMT voice/VT call on SIM2.
155            (4) Makes a MOMT voice/VT call on SIM1.
156            (5) Starts streaming.
157
158            Args:
159                loop: repeat this test cases for how many times
160            Returns:
161                True if pass; False if fail
162            Raises:
163                TestFailure if not success.
164        '''
165        for x in range(self.user_params.get("dsds_io_cycle", 1)):
166            self.log.info("%s loop: %s/%s" %
167                          (self.current_test_name, x + 1, loop))
168            asserts.assert_true(self._test_in_out_service_idle(
169                _VOLTE, _5G_VOLTE, 1),
170                                "[Fail]%s" % (_ERROR_MSG_IDLE_FAILURE),
171                                extras={"failure_cause": self.my_error_msg})
172        return True
173
174    @test_tracker_info(uuid="a47cdaf6-87b6-416e-a0e4-ebdd2ec5f3f1")
175    @TelephonyBaseTest.tel_test_wrap
176    def test_in_out_msim_5g_esim_4g_dds_sim1(self, loop=1):
177        '''
178            1.7.23 - [SA/NSA][DDS:SIM1][SIM1:5G, SIM2:VoLTE]
179            Attach to 5G after in/out service during idle
180            SIM1 (pSIM) : Carrier 1 with 5G SIM.
181            SIM2 (eSIM) : Carrier 2 with 4G SIM
182            DDS (Data preferred) on SIM1.
183
184            (1) Moves to no service area during data idle.
185            (2) Moves to service area.
186            (3) Makes a MOMT voice/VT call on SIM1.
187            (4) Makes a MOMT voice/VT call on SIM2.
188            (5) Starts streaming.
189
190            Args:
191                loop: repeat this test cases for how many times
192            Returns:
193                True if pass; False if fail
194        '''
195        for x in range(self.user_params.get("dsds_io_cycle", 1)):
196            self.log.info("%s loop: %s/%s" %
197                          (self.current_test_name, x + 1, loop))
198            asserts.assert_true(self._test_in_out_service_idle(
199                _5G_VOLTE, _VOLTE, 0),
200                                "[Fail]%s" % (_ERROR_MSG_IDLE_FAILURE),
201                                extras={"failure_cause": self.my_error_msg})
202        return True
203
204    @test_tracker_info(uuid="5e2e3ce2-6d37-48dd-9007-6aa3f593150b")
205    @TelephonyBaseTest.tel_test_wrap
206    def test_in_out_msim_5g_esim_4g_dds_sim2(self, loop=1):
207        '''
208            1.7.24 - [SA/NSA][DDS:SIM2][SIM1:5G, SIM2:VoLTE]
209            Attach to 5G after in/out service during idle
210            SIM1 (pSIM) : Carrier 1 with 5G SIM.
211            SIM2 (eSIM) : Carrier 2 with 4G SIM
212            DDS (Data preferred) on SIM1.
213
214            (1) Moves to no service area during data idle.
215            (2) Moves to service area.
216            (3) Makes a MOMT voice/VT call on SIM1.
217            (4) Makes a MOMT voice/VT call on SIM2.
218            (5) Starts streaming.
219
220            Args:
221                loop: repeat this test cases for how many times
222            Returns:
223                True if pass; False if fail
224        '''
225        for x in range(self.user_params.get("dsds_io_cycle", 1)):
226            self.log.info("%s loop: %s/%s" %
227                          (self.current_test_name, x + 1, loop))
228            asserts.assert_true(self._test_in_out_service_idle(
229                _5G_VOLTE, _VOLTE, 1),
230                                "[Fail]%s" % (_ERROR_MSG_IDLE_FAILURE),
231                                extras={"failure_cause": self.my_error_msg})
232        return True
233
234    @test_tracker_info(uuid="51f291f0-af5f-400c-9678-4f129695bb68")
235    @TelephonyBaseTest.tel_test_wrap
236    def test_in_out_data_transfer_msim_5g_esim_5g_dds_sim1(self, loop=1):
237        '''
238            1.7.25 - [SA/NSA][DDS:SIM1][SIM1:5G, SIM2:5G]
239            Attach to 5G after in/out service during data transferring
240            SIM1 (pSIM) : Carrier 1 with 5G SIM.
241            SIM2 (eSIM) : Carrier 2 with 5G SIM
242            DDS (Data preferred) on SIM1.
243
244            (1) Moves to no service area during data transferring..
245            (2) Moves to service area.
246            (3) Makes a MOMT voice/VT call on SIM1.
247            (4) Makes a MOMT voice/VT call on SIM2.
248            (5) Starts streaming.
249
250            Args:
251                loop: repeat this test cases for how many times
252            Returns:
253                True if pass; False if fail
254        '''
255        for x in range(self.user_params.get("dsds_io_cycle", 1)):
256            self.log.info("%s loop: %s/%s" %
257                          (self.current_test_name, x + 1, loop))
258            asserts.assert_true(self._test_in_out_service_data_transfer(
259                _5G_VOLTE, _5G_VOLTE, 0),
260                                "[Fail]%s" %
261                                (_ERROR_MSG_DATA_TRANSFER_FAILURE),
262                                extras={"failure_cause": self.my_error_msg})
263        return True
264
265    @test_tracker_info(uuid="d0b134c5-380f-4c74-8ab9-8322de1c59e9")
266    @TelephonyBaseTest.tel_test_wrap
267    def test_in_out_data_transfer_msim_5g_esim_5g_dds_sim2(self, loop=1):
268        '''
269            1.7.26 - [SA/NSA][DDS:SIM2][SIM1:5G, SIM2:5G]
270            Attach to 5G after in/out service during data transferring
271            SIM1 (pSIM) : Carrier 1 with 5G SIM.
272            SIM2 (eSIM) : Carrier 2 with 5G SIM
273            DDS (Data preferred) on SIM2.
274
275            (1) Moves to no service area during data transferring..
276            (2) Moves to service area.
277            (3) Makes a MOMT voice/VT call on SIM1.
278            (4) Makes a MOMT voice/VT call on SIM2.
279            (5) Starts streaming.
280
281            Args:
282                loop: repeat this test cases for how many times
283            Returns:
284                True if pass; False if fail
285        '''
286        for x in range(self.user_params.get("dsds_io_cycle", 1)):
287            self.log.info("%s loop: %s/%s" %
288                          (self.current_test_name, x + 1, loop))
289            asserts.assert_true(
290                self._test_in_out_service_data_transfer(_VOLTE, _5G_VOLTE, 1),
291                "[Fail]%s" % (_ERROR_MSG_DATA_TRANSFER_FAILURE),
292                extras={"failure_cause": self.my_error_msg})
293        return True
294
295    @test_tracker_info(uuid="c28a9ea5-28a8-4d21-ba25-cb38aca30170")
296    @TelephonyBaseTest.tel_test_wrap
297    def test_in_out_data_transfer_msim_4g_esim_5g_dds_sim1(self, loop=1):
298        '''
299            1.7.27 - [SA/NSA][DDS:SIM1][SIM1:VoLTE, SIM2:5G]
300            Attach to 5G after in/out service during data transferring
301            SIM1 (pSIM) : Carrier 1 with 4G SIM.
302            SIM2 (eSIM) : Carrier 2 with 5G SIM
303            DDS (Data preferred) on SIM1.
304
305            (1) Moves to no service area during data transferring..
306            (2) Moves to service area.
307            (3) Makes a MOMT voice/VT call on SIM1.
308            (4) Makes a MOMT voice/VT call on SIM2.
309            (5) Starts streaming.
310
311            Args:
312                loop: repeat this test cases for how many times
313            Returns:
314                True if pass; False if fail
315        '''
316        for x in range(self.user_params.get("dsds_io_cycle", 1)):
317            self.log.info("%s loop: %s/%s" %
318                          (self.current_test_name, x + 1, loop))
319            asserts.assert_true(
320                self._test_in_out_service_data_transfer(_VOLTE, _5G_VOLTE, 0),
321                "[Fail]%s" % (_ERROR_MSG_DATA_TRANSFER_FAILURE),
322                extras={"failure_cause": self.my_error_msg})
323        return True
324
325    @test_tracker_info(uuid="c28a9ea5-28a8-4d21-ba25-cb38aca30170")
326    @TelephonyBaseTest.tel_test_wrap
327    def test_in_out_data_transfer_msim_4g_esim_5g_dds_sim2(self, loop=1):
328        '''
329            1.7.28 - [SA/NSA][DDS:SIM2][SIM1:VoLTE, SIM2:5G]
330            Attach to 5G after in/out service during data transferring
331            SIM1 (pSIM) : Carrier 1 with 4G SIM.
332            SIM2 (eSIM) : Carrier 2 with 5G SIM
333            DDS (Data preferred) on SIM2.
334
335            (1) Moves to no service area during data transferring..
336            (2) Moves to service area.
337            (3) Makes a MOMT voice/VT call on SIM1.
338            (4) Makes a MOMT voice/VT call on SIM2.
339            (5) Start a download via speedtest lab mode.
340
341            Args:
342                loop: repeat this test cases for how many times
343            Returns:
344                True if pass; False if fail
345        '''
346        for x in range(self.user_params.get("dsds_io_cycle", 1)):
347            self.log.info("%s loop: %s/%s" %
348                          (self.current_test_name, x + 1, loop))
349            asserts.assert_true(
350                self._test_in_out_service_data_transfer(_VOLTE, _5G_VOLTE, 1),
351                "[Fail]%s" % (_ERROR_MSG_DATA_TRANSFER_FAILURE),
352                extras={"failure_cause": self.my_error_msg})
353        return True
354
355    @test_tracker_info(uuid="7d6a85c0-0194-4705-8a80-49f21cebc4ed")
356    @TelephonyBaseTest.tel_test_wrap
357    def test_in_out_data_transfer_msim_5g_esim_4g_dds_sim1(self, loop=1):
358        '''
359            1.7.29 - [SA/NSA][DDS:SIM1][SIM1:5G, SIM2:VoLTE]
360            Attach to 5G after in/out service during data transferring
361            SIM1 (pSIM) : Carrier 1 with 5G SIM.
362            SIM2 (eSIM) : Carrier 2 with 4G SIM
363            DDS (Data preferred) on SIM1.
364
365            (1) Move to no service area during data transferring..
366            (2) Move to service area.
367            (3) Make a MOMT voice/VT call on SIM1.
368            (4) Makes a MOMT voice/VT call on SIM2.
369            (5) Starts streaming.
370
371            Args:
372                loop: repeat this test cases for how many times
373            Returns:
374                True if pass; False if fail
375        '''
376        for x in range(self.user_params.get("dsds_io_cycle", 1)):
377            self.log.info("%s loop: %s/%s" %
378                          (self.current_test_name, x + 1, loop))
379            asserts.assert_true(
380                self._test_in_out_service_data_transfer(_5G_VOLTE, _VOLTE, 0),
381                "[Fail]%s" % (_ERROR_MSG_DATA_TRANSFER_FAILURE),
382                extras={"failure_cause": self.my_error_msg})
383        return True
384
385    @test_tracker_info(uuid="43cd405f-d510-4193-9bff-795db12dbb30")
386    @TelephonyBaseTest.tel_test_wrap
387    def test_in_out_data_transfer_msim_5g_esim_4g_dds_sim2(self, loop=1):
388        '''
389            1.7.30 - [SA/NSA][DDS:SIM2][SIM1:5G, SIM2:VoLTE]
390            Attach to 5G after in/out service during data transferring
391            SIM1 (pSIM) : Carrier 1 with 5G SIM.
392            SIM2 (eSIM) : Carrier 2 with 4G SIM
393            DDS (Data preferred) on SIM2.
394
395            (1) Move to no service area during data transferring..
396            (2) Move to service area.
397            (3) Make a MOMT voice/VT call on SIM1.
398            (4) Make a MOMT voice/VT call on SIM2.
399            (5) start streaming.
400
401            Args:
402                loop: repeat this test cases for how many times
403            Returns:
404                True if pass; False if fail
405        '''
406        for x in range(self.user_params.get("dsds_io_cycle", 1)):
407            self.log.info("%s loop: %s/%s" %
408                          (self.current_test_name, x + 1, loop))
409            asserts.assert_true(
410                self._test_in_out_service_data_transfer(_5G_VOLTE, _VOLTE, 1),
411                "[Fail]%s" % (_ERROR_MSG_DATA_TRANSFER_FAILURE),
412                extras={"failure_cause": self.my_error_msg})
413        return True
414
415    def _test_in_out_service_idle(self,
416                                  psim_rat=_5G_VOLTE,
417                                  esim_rat=_5G_VOLTE,
418                                  dds_slot=0,
419                                  momt_direction="mo"):
420        ad = self.android_devices[0]
421        set_dds_on_slot(ad, dds_slot)
422        self.adjust_cellular_signal(NO_SERVICE_POWER_LEVEL)
423        time.sleep(_NO_SERVICE_TIME)
424        self.adjust_cellular_signal(IN_SERVICE_POWER_LEVEL)
425        return self._test_mo_voice_call(psim_rat, esim_rat, dds_slot,
426                                        momt_direction)
427
428    def _test_in_out_service_data_transfer(self,
429                                           psim_rat=_5G_VOLTE,
430                                           esim_rat=_5G_VOLTE,
431                                           dds_slot=0,
432                                           momt_direction="mo"):
433        ad = self.android_devices[0]
434        set_dds_on_slot(ad, dds_slot)
435        # start streaming
436        if not start_youtube_video(ad):
437            ad.log.warning("Fail to bring up youtube video")
438            time.sleep(10)
439        self.adjust_cellular_signal(NO_SERVICE_POWER_LEVEL)
440        time.sleep(_NO_SERVICE_TIME)
441        self.adjust_cellular_signal(IN_SERVICE_POWER_LEVEL)
442        return self._test_mo_voice_call(psim_rat, esim_rat, dds_slot,
443                                        momt_direction)
444
445    def _test_mo_voice_call(self,
446                            psim_rat=_5G_VOLTE,
447                            esim_rat=_5G_VOLTE,
448                            dds_slot=0,
449                            momt_direction="mo"):
450        ad = self.android_devices[0]
451        # Make a MOMT voice on SIM1
452        test_result = dsds_voice_call_test(self.log,
453                                           self.tel_logger,
454                                           self.android_devices,
455                                           0,
456                                           None,
457                                           dds_slot,
458                                           mo_rat=[psim_rat, esim_rat],
459                                           call_direction=momt_direction)
460        ensure_phones_idle(self.log, self.android_devices)
461        # Make a MOMT voice on SIM2
462        test_result = dsds_voice_call_test(self.log,
463                                           self.tel_logger,
464                                           self.android_devices,
465                                           1,
466                                           None,
467                                           dds_slot,
468                                           mo_rat=[psim_rat, esim_rat],
469                                           call_direction=momt_direction)
470        # start streaming
471        if not start_youtube_video(ad):
472            ad.log.warning("Fail to bring up youtube video")
473            time.sleep(10)
474        return test_result
475