1#!/usr/bin/env python3.4
2#
3#   Copyright 2021 - 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 IMS Settings scenarios
18"""
19
20from acts import signals
21from acts.test_decorators import test_tracker_info
22from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
23from acts_contrib.test_utils.tel.tel_defines import CarrierConfigs
24from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_VOLTE
25from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_WFC
26from acts_contrib.test_utils.tel.tel_defines import RAT_NR
27from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
28from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED
29from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_on_rat
30from acts_contrib.test_utils.tel.tel_subscription_utils import get_outgoing_voice_sub_id
31from acts_contrib.test_utils.tel.tel_test_utils import dumpsys_carrier_config
32from acts_contrib.test_utils.tel.tel_voice_utils import change_ims_setting
33
34
35class Nsa5gImsSettingsTest(TelephonyBaseTest):
36
37    def setup_class(self):
38        TelephonyBaseTest.setup_class(self)
39        self.dut = self.android_devices[0]
40        self.dut_client = self.android_devices[1]
41        self.skip_reset_between_cases = False
42        self.subid = get_outgoing_voice_sub_id(self.dut)
43        self.dut_capabilities = self.dut.telephony["subscription"][
44            self.subid].get("capabilities", [])
45        self.dut.log.info("DUT capabilities: %s", self.dut_capabilities)
46        if CAPABILITY_VOLTE not in self.dut_capabilities:
47            raise signals.TestAbortClass("VoLTE is not supported")
48        if CAPABILITY_WFC not in self.dut_capabilities:
49            raise signals.TestAbortClass("WFC is not supported")
50        self.carrier_configs = dumpsys_carrier_config(self.dut)[self.subid]
51        self.default_wfc_mode = self.carrier_configs.get(
52            CarrierConfigs.DEFAULT_WFC_IMS_MODE_INT, None)
53        self.dut_wfc_modes = self.dut.telephony[
54            "subscription"][self.subid].get("wfc_modes", [])
55
56
57    """ Tests Begin """
58
59    @test_tracker_info(uuid="9ed17e7b-c933-4b46-9349-a76fbcba3a24")
60    @TelephonyBaseTest.tel_test_wrap
61    def test_5g_nsa_volte_wifi_connected_toggle_wfc(self):
62        """Test for WiFi Calling settings:
63        nsa 5G + VoLTE Enabled + WiFi Connected, Toggling WFC
64
65        Steps:
66        1. Setup DUT Idle, 5G network type, VoLTE enabled.
67        2. Make sure DUT WiFi connected, WFC disabled.
68        3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available,
69            report iwlan rat.
70        4. Set DUT WFC disabled, verify DUT WFC unavailable,
71            not report iwlan rat.
72
73        Expected Results:
74        3. DUT WiFi Calling feature bit return True, network rat is iwlan.
75        4. DUT WiFi Calling feature bit return False, network rat is not iwlan.
76        """
77
78        if not phone_setup_on_rat(self.log, self.dut, rat='5g_volte'):
79            self.log.error("Phone Failed to setup Properly")
80            return False
81
82        if not change_ims_setting(log=self.log,
83                                ad=self.dut,
84                                dut_client= self.dut_client,
85                                wifi_network_ssid=self.wifi_network_ssid,
86                                wifi_network_pass=self.wifi_network_pass,
87                                subid=self.subid,
88                                dut_capabilities=self.dut_capabilities,
89                                airplane_mode=False,
90                                wifi_enabled=True,
91                                volte_enabled=True,
92                                wfc_enabled=True,
93                                nw_gen=RAT_NR,
94                                wfc_mode=self.default_wfc_mode):
95            return False
96        if not change_ims_setting(log=self.log,
97                                ad=self.dut,
98                                dut_client= self.dut_client,
99                                wifi_network_ssid=self.wifi_network_ssid,
100                                wifi_network_pass=self.wifi_network_pass,
101                                dut_capabilities=self.dut_capabilities,
102                                subid=self.subid,
103                                airplane_mode=False,
104                                wifi_enabled=True,
105                                volte_enabled=True,
106                                wfc_enabled=False,
107                                nw_gen=RAT_NR,
108                                wfc_mode=None):
109            return False
110        return change_ims_setting(log=self.log,
111                                ad=self.dut,
112                                dut_client= self.dut_client,
113                                wifi_network_ssid=self.wifi_network_ssid,
114                                wifi_network_pass=self.wifi_network_pass,
115                                dut_capabilities=self.dut_capabilities,
116                                subid=self.subid,
117                                airplane_mode=False,
118                                wifi_enabled=True,
119                                volte_enabled=True,
120                                wfc_enabled=True,
121                                nw_gen=RAT_NR,
122                                wfc_mode=None)
123
124
125    @test_tracker_info(uuid="425b16ec-869d-4a0b-a1bc-a3243503525f")
126    @TelephonyBaseTest.tel_test_wrap
127    def test_5g_nsa_wifi_connected_toggle_wfc(self):
128        """Test for WiFi Calling settings:
129        nsa 5G + VoLTE Disabled + WiFi Connected, Toggling WFC
130
131        Steps:
132        1. Setup DUT Idle, nsa 5G network type, VoLTE disabled.
133        2. Make sure DUT WiFi connected, WFC disabled.
134        3. Set DUT WFC enabled (WiFi Preferred), verify DUT WFC available,
135            report iwlan rat.
136        4. Set DUT WFC disabled, verify DUT WFC unavailable,
137            not report iwlan rat.
138
139        Expected Results:
140        3. DUT WiFi Calling feature bit return True, network rat is iwlan.
141        4. DUT WiFi Calling feature bit return False, network rat is not iwlan.
142        """
143
144        if not phone_setup_on_rat(self.log, self.dut, rat='5g_csfb'):
145            self.log.error("Phone Failed to setup Properly")
146            return False
147
148        if not change_ims_setting(log=self.log,
149                                       ad=self.dut,
150                                       dut_client= self.dut_client,
151                                       wifi_network_ssid=self.wifi_network_ssid,
152                                       wifi_network_pass=self.wifi_network_pass,
153                                       dut_capabilities=self.dut_capabilities,
154                                       subid=self.subid,
155                                       airplane_mode=False,
156                                       wifi_enabled=True,
157                                       volte_enabled=False,
158                                       wfc_enabled=True,
159                                       nw_gen=RAT_NR,
160                                       wfc_mode=self.default_wfc_mode):
161            return False
162        if not change_ims_setting(log=self.log,
163                                       ad=self.dut,
164                                       dut_client= self.dut_client,
165                                       wifi_network_ssid=self.wifi_network_ssid,
166                                       wifi_network_pass=self.wifi_network_pass,
167                                       dut_capabilities=self.dut_capabilities,
168                                       subid=self.subid,
169                                       airplane_mode=False,
170                                       wifi_enabled=True,
171                                       volte_enabled=False,
172                                       wfc_enabled=False,
173                                       nw_gen=RAT_NR,
174                                       wfc_mode=None):
175            return False
176        return change_ims_setting(log=self.log,
177                                       ad=self.dut,
178                                       dut_client= self.dut_client,
179                                       wifi_network_ssid=self.wifi_network_ssid,
180                                       wifi_network_pass=self.wifi_network_pass,
181                                       dut_capabilities=self.dut_capabilities,
182                                       subid=self.subid,
183                                       airplane_mode=False,
184                                       wifi_enabled=True,
185                                       volte_enabled=False,
186                                       wfc_enabled=True,
187                                       nw_gen=RAT_NR,
188                                       wfc_mode=None)
189
190
191    @test_tracker_info(uuid="9405d8cf-5b73-4d47-a83d-da115caed177")
192    @TelephonyBaseTest.tel_test_wrap
193    def test_5g_nsa_volte_wfc_enabled_toggle_wifi(self):
194        """Test for WiFi Calling settings:
195        nsa 5G + VoLTE Enabled + WFC enabled, Toggling WiFi
196
197        Steps:
198        1. Setup DUT Idle, nsa 5G network type, VoLTE enabled.
199        2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred).
200        3. DUT connect WiFi, verify DUT WFC available, report iwlan rat.
201        4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat.
202
203        Expected Results:
204        3. DUT WiFi Calling feature bit return True, network rat is iwlan.
205        4. DUT WiFi Calling feature bit return False, network rat is not iwlan.
206        """
207        if not phone_setup_on_rat(self.log, self.dut, rat='5g_volte'):
208            self.log.error("Phone Failed to setup Properly")
209            return False
210
211        if not change_ims_setting(log=self.log,
212                                       ad=self.dut,
213                                       dut_client= self.dut_client,
214                                       wifi_network_ssid=self.wifi_network_ssid,
215                                       wifi_network_pass=self.wifi_network_pass,
216                                       dut_capabilities=self.dut_capabilities,
217                                       subid=self.subid,
218                                       airplane_mode=False,
219                                       wifi_enabled=True,
220                                       volte_enabled=True,
221                                       wfc_enabled=True,
222                                       nw_gen=RAT_NR,
223                                       wfc_mode=self.default_wfc_mode):
224            return False
225        if not change_ims_setting(log=self.log,
226                                       ad=self.dut,
227                                       dut_client= self.dut_client,
228                                       wifi_network_ssid=self.wifi_network_ssid,
229                                       wifi_network_pass=self.wifi_network_pass,
230                                       dut_capabilities=self.dut_capabilities,
231                                       subid=self.subid,
232                                       airplane_mode=False,
233                                       wifi_enabled=True,
234                                       volte_enabled=True,
235                                       wfc_enabled=False,
236                                       nw_gen=RAT_NR,
237                                       wfc_mode=None):
238            return False
239        return change_ims_setting(log=self.log,
240                                       ad=self.dut,
241                                       dut_client= self.dut_client,
242                                       wifi_network_ssid=self.wifi_network_ssid,
243                                       wifi_network_pass=self.wifi_network_pass,
244                                       dut_capabilities=self.dut_capabilities,
245                                       subid=self.subid,
246                                       airplane_mode=False,
247                                       wifi_enabled=True,
248                                       volte_enabled=True,
249                                       wfc_enabled=True,
250                                       nw_gen=RAT_NR,
251                                       wfc_mode=None)
252
253
254    @test_tracker_info(uuid="548f07a6-74e2-4071-ba41-2acf3cd51752")
255    @TelephonyBaseTest.tel_test_wrap
256    def test_5g_nsa_wfc_enabled_toggle_wifi(self):
257        """Test for WiFi Calling settings:
258        nsa 5G + VoLTE Disabled + WFC enabled, Toggling WiFi
259
260        Steps:
261        1. Setup DUT Idle, nsa 5G network type, VoLTE disabled.
262        2. Make sure DUT WiFi disconnected, WFC enabled (WiFi Preferred).
263        3. DUT connect WiFi, verify DUT WFC available, report iwlan rat.
264        4. DUT disconnect WiFi,verify DUT WFC unavailable, not report iwlan rat.
265
266        Expected Results:
267        3. DUT WiFi Calling feature bit return True, network rat is iwlan.
268        4. DUT WiFi Calling feature bit return False, network rat is not iwlan.
269        """
270        if not phone_setup_on_rat(self.log, self.dut, rat='5g_csfb'):
271            self.log.error("Phone Failed to setup Properly")
272            return False
273
274        if not change_ims_setting(log=self.log,
275                                       ad=self.dut,
276                                       dut_client= self.dut_client,
277                                       wifi_network_ssid=self.wifi_network_ssid,
278                                       wifi_network_pass=self.wifi_network_pass,
279                                       dut_capabilities=self.dut_capabilities,
280                                       subid=self.subid,
281                                       airplane_mode=False,
282                                       wifi_enabled=True,
283                                       volte_enabled=False,
284                                       wfc_enabled=True,
285                                       nw_gen=RAT_NR,
286                                       wfc_mode=self.default_wfc_mode):
287            return False
288        if not change_ims_setting(log=self.log,
289                                       ad=self.dut,
290                                       dut_client= self.dut_client,
291                                       wifi_network_ssid=self.wifi_network_ssid,
292                                       wifi_network_pass=self.wifi_network_pass,
293                                       dut_capabilities=self.dut_capabilities,
294                                       subid=self.subid,
295                                       airplane_mode=False,
296                                       wifi_enabled=False,
297                                       volte_enabled=False,
298                                       wfc_enabled=True,
299                                       nw_gen=RAT_NR,
300                                       wfc_mode=None):
301            return False
302        return change_ims_setting(log=self.log,
303                                       ad=self.dut,
304                                       dut_client= self.dut_client,
305                                       wifi_network_ssid=self.wifi_network_ssid,
306                                       wifi_network_pass=self.wifi_network_pass,
307                                       dut_capabilities=self.dut_capabilities,
308                                       subid=self.subid,
309                                       airplane_mode=False,
310                                       wifi_enabled=True,
311                                       volte_enabled=False,
312                                       wfc_enabled=True,
313                                       nw_gen=RAT_NR,
314                                       wfc_mode=None)
315
316
317    @test_tracker_info(uuid="f53f8403-b993-4a3b-8d3f-ffc87cdc856e")
318    @TelephonyBaseTest.tel_test_wrap
319    def test_5g_nsa_wfc_enabled_wifi_connected_toggle_volte(self):
320        """Test for WiFi Calling settings:
321        nsa 5G + VoLTE Enabled + WiFi Connected + WFC enabled, toggle VoLTE setting
322
323        Steps:
324        1. Setup DUT Idle, 5G network type, VoLTE enabled.
325        2. Make sure DUT WiFi connected, WFC enabled (WiFi Preferred).
326            Verify DUT WFC available, report iwlan rat.
327        3. Disable VoLTE on DUT, verify in 2 minutes period,
328            DUT does not lost WiFi Calling, DUT still report WFC available,
329            rat iwlan.
330        4. Enable VoLTE on DUT, verify in 2 minutes period,
331            DUT does not lost WiFi Calling, DUT still report WFC available,
332            rat iwlan.
333
334        Expected Results:
335        2. DUT WiFi Calling feature bit return True, network rat is iwlan.
336        3. DUT WiFi Calling feature bit return True, network rat is iwlan.
337        4. DUT WiFi Calling feature bit return True, network rat is iwlan.
338        """
339        if not phone_setup_on_rat(self.log, self.dut, rat='5g_volte'):
340            self.log.error("Phone Failed to setup Properly")
341            return False
342
343        if not change_ims_setting(log=self.log,
344                                       ad=self.dut,
345                                       dut_client= self.dut_client,
346                                       wifi_network_ssid=self.wifi_network_ssid,
347                                       wifi_network_pass=self.wifi_network_pass,
348                                       dut_capabilities=self.dut_capabilities,
349                                       subid=self.subid,
350                                       airplane_mode=False,
351                                       wifi_enabled=True,
352                                       volte_enabled=True,
353                                       wfc_enabled=True,
354                                       nw_gen=RAT_NR,
355                                       wfc_mode=self.default_wfc_mode):
356            return False
357        if not change_ims_setting(log=self.log,
358                                       ad=self.dut,
359                                       dut_client= self.dut_client,
360                                       wifi_network_ssid=self.wifi_network_ssid,
361                                       wifi_network_pass=self.wifi_network_pass,
362                                       dut_capabilities=self.dut_capabilities,
363                                       subid=self.subid,
364                                       airplane_mode=False,
365                                       wifi_enabled=True,
366                                       volte_enabled=False,
367                                       wfc_enabled=True,
368                                       wfc_mode=None):
369            return False
370        return change_ims_setting(log=self.log,
371                                       ad=self.dut,
372                                       dut_client= self.dut_client,
373                                       wifi_network_ssid=self.wifi_network_ssid,
374                                       wifi_network_pass=self.wifi_network_pass,
375                                       dut_capabilities=self.dut_capabilities,
376                                       subid=self.subid,
377                                       airplane_mode=False,
378                                       wifi_enabled=True,
379                                       volte_enabled=True,
380                                       wfc_enabled=True,
381                                       nw_gen=RAT_NR,
382                                       wfc_mode=None)
383
384
385    @test_tracker_info(uuid="9d951951-bc04-4db1-85e3-f0980f564fd3")
386    @TelephonyBaseTest.tel_test_wrap
387    def test_5g_nsa_volte_wfc_wifi_preferred_to_cellular_preferred(self):
388        """Test for WiFi Calling settings:
389        nsa 5G + VoLTE Enabled + WiFi Connected + WiFi Preferred,
390        change WFC to Cellular Preferred
391
392        Steps:
393        1. Setup DUT Idle, nsa 5G network type, VoLTE enabled.
394        2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred.
395            Verify DUT WFC available, report iwlan rat.
396        3. Change WFC setting to Cellular Preferred.
397        4. Verify DUT report WFC not available.
398
399        Expected Results:
400        2. DUT WiFi Calling feature bit return True, network rat is iwlan.
401        4. DUT WiFI Calling feature bit return False, network rat is not iwlan.
402        """
403        if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes:
404            raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported")
405        if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes:
406            raise signals.TestSkip(
407                "WFC_MODE_CELLULAR_PREFERRED is not supported")
408
409        if not phone_setup_on_rat(self.log, self.dut, rat='5g_volte'):
410            self.log.error("Phone Failed to setup Properly")
411            return False
412
413        if not change_ims_setting(log=self.log,
414                                       ad=self.dut,
415                                       dut_client= self.dut_client,
416                                       wifi_network_ssid=self.wifi_network_ssid,
417                                       wifi_network_pass=self.wifi_network_pass,
418                                       dut_capabilities=self.dut_capabilities,
419                                       subid=self.subid,
420                                       airplane_mode=False,
421                                       wifi_enabled=True,
422                                       volte_enabled=True,
423                                       wfc_enabled=True,
424                                       nw_gen=RAT_NR,
425                                       wfc_mode=self.default_wfc_mode):
426            return False
427        return change_ims_setting(log=self.log,
428                                       ad=self.dut,
429                                       dut_client= self.dut_client,
430                                       wifi_network_ssid=self.wifi_network_ssid,
431                                       wifi_network_pass=self.wifi_network_pass,
432                                       dut_capabilities=self.dut_capabilities,
433                                       subid=self.subid,
434                                       airplane_mode=False,
435                                       wifi_enabled=True,
436                                       volte_enabled=True,
437                                       wfc_enabled=True,
438                                       nw_gen=RAT_NR,
439                                       wfc_mode= WFC_MODE_CELLULAR_PREFERRED)
440
441
442    @test_tracker_info(uuid="9d951951-bc04-4db1-85e3-f0980f564fd3")
443    @TelephonyBaseTest.tel_test_wrap
444    def test_5g_nsa_wfc_wifi_preferred_to_cellular_preferred(self):
445        """Test for WiFi Calling settings:
446        nsa 5G + WiFi Connected + WiFi Preferred, change WFC to Cellular Preferred
447
448        Steps:
449        1. Setup DUT Idle, nsa 5G network type, VoLTE disabled.
450        2. Make sure DUT WiFi connected, WFC is set to WiFi Preferred.
451            Verify DUT WFC available, report iwlan rat.
452        3. Change WFC setting to Cellular Preferred.
453        4. Verify DUT report WFC not available.
454
455        Expected Results:
456        2. DUT WiFi Calling feature bit return True, network rat is iwlan.
457        4. DUT WiFI Calling feature bit return False, network rat is not iwlan.
458        """
459        if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes:
460            raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported")
461        if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes:
462            raise signals.TestSkip(
463                "WFC_MODE_CELLULAR_PREFERRED is not supported")
464
465        if not phone_setup_on_rat(self.log, self.dut, rat='5g_csfb'):
466            self.log.error("Phone Failed to setup Properly")
467            return False
468
469        if not change_ims_setting(log=self.log,
470                                       ad=self.dut,
471                                       dut_client= self.dut_client,
472                                       wifi_network_ssid=self.wifi_network_ssid,
473                                       wifi_network_pass=self.wifi_network_pass,
474                                       dut_capabilities=self.dut_capabilities,
475                                       subid=self.subid,
476                                       airplane_mode=False,
477                                       wifi_enabled=True,
478                                       volte_enabled=False,
479                                       wfc_enabled=True,
480                                       nw_gen=RAT_NR,
481                                       wfc_mode= WFC_MODE_WIFI_PREFERRED):
482            return False
483        return change_ims_setting(log=self.log,
484                                       ad=self.dut,
485                                       dut_client= self.dut_client,
486                                       wifi_network_ssid=self.wifi_network_ssid,
487                                       wifi_network_pass=self.wifi_network_pass,
488                                       dut_capabilities=self.dut_capabilities,
489                                       subid=self.subid,
490                                       airplane_mode=False,
491                                       wifi_enabled=True,
492                                       volte_enabled=False,
493                                       wfc_enabled=True,
494                                       nw_gen=RAT_NR,
495                                       wfc_mode= WFC_MODE_CELLULAR_PREFERRED)
496
497
498    @test_tracker_info(uuid="bb3acfce-1ea9-40c2-9151-12fbc235e359")
499    @TelephonyBaseTest.tel_test_wrap
500    def test_5g_nsa_volte_wfc_cellular_preferred_to_wifi_preferred(self):
501        """Test for WiFi Calling settings:
502        nsa 5G + VoLTE Enabled + WiFi Connected + Cellular Preferred,
503        change WFC to WiFi Preferred
504
505        Steps:
506        1. Setup DUT Idle, nsa 5G network type, VoLTE enabled.
507        2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred.
508            Verify DUT WFC not available.
509        3. Change WFC setting to WiFi Preferred.
510        4. Verify DUT report WFC available.
511
512        Expected Results:
513        2. DUT WiFi Calling feature bit return False, network rat is not iwlan.
514        4. DUT WiFI Calling feature bit return True, network rat is iwlan.
515        """
516        if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes:
517            raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported")
518        if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes:
519            raise signals.TestSkip(
520                "WFC_MODE_CELLULAR_PREFERRED is not supported")
521        if not phone_setup_on_rat(self.log, self.dut, rat='5g_volte'):
522            self.log.error("Phone Failed to setup Properly")
523            return False
524
525        if not change_ims_setting(log=self.log,
526                                       ad=self.dut,
527                                       dut_client= self.dut_client,
528                                       wifi_network_ssid=self.wifi_network_ssid,
529                                       wifi_network_pass=self.wifi_network_pass,
530                                       dut_capabilities=self.dut_capabilities,
531                                       subid=self.subid,
532                                       airplane_mode=False,
533                                       wifi_enabled=True,
534                                       volte_enabled=True,
535                                       wfc_enabled=True,
536                                       nw_gen=RAT_NR,
537                                       wfc_mode= WFC_MODE_CELLULAR_PREFERRED):
538            return False
539        return change_ims_setting(log=self.log,
540                                       ad=self.dut,
541                                       dut_client= self.dut_client,
542                                       wifi_network_ssid=self.wifi_network_ssid,
543                                       wifi_network_pass=self.wifi_network_pass,
544                                       dut_capabilities=self.dut_capabilities,
545                                       subid=self.subid,
546                                       airplane_mode=False,
547                                       wifi_enabled=True,
548                                       volte_enabled=True,
549                                       wfc_enabled=True,
550                                       nw_gen=RAT_NR,
551                                       wfc_mode=WFC_MODE_WIFI_PREFERRED)
552
553
554    @test_tracker_info(uuid="d4dea8e0-5795-4769-80e2-29c0f951a84a")
555    @TelephonyBaseTest.tel_test_wrap
556    def test_5g_nsa_wfc_cellular_preferred_to_wifi_preferred(self):
557        """Test for WiFi Calling settings:
558        nsa 5G + WiFi Connected + Cellular Preferred, change WFC to WiFi Preferred
559
560        Steps:
561        1. Setup DUT Idle, nsa 5G network type, VoLTE disabled.
562        2. Make sure DUT WiFi connected, WFC is set to Cellular Preferred.
563            Verify DUT WFC not available.
564        3. Change WFC setting to WiFi Preferred.
565        4. Verify DUT report WFC available.
566
567        Expected Results:
568        2. DUT WiFi Calling feature bit return False, network rat is not iwlan.
569        4. DUT WiFI Calling feature bit return True, network rat is iwlan.
570        """
571        if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes:
572            raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported")
573        if WFC_MODE_CELLULAR_PREFERRED not in self.dut_wfc_modes:
574            raise signals.TestSkip(
575                "WFC_MODE_CELLULAR_PREFERRED is not supported")
576
577        if not phone_setup_on_rat(self.log, self.dut, rat='5g_csfb'):
578            self.log.error("Phone Failed to setup Properly")
579            return False
580
581        if not change_ims_setting(log=self.log,
582                                       ad=self.dut,
583                                       dut_client= self.dut_client,
584                                       wifi_network_ssid=self.wifi_network_ssid,
585                                       wifi_network_pass=self.wifi_network_pass,
586                                       dut_capabilities=self.dut_capabilities,
587                                       subid=self.subid,
588                                       airplane_mode=False,
589                                       wifi_enabled=True,
590                                       volte_enabled=False,
591                                       wfc_enabled=True,
592                                       nw_gen=RAT_NR,
593                                       wfc_mode=WFC_MODE_CELLULAR_PREFERRED):
594            return False
595        return change_ims_setting(log=self.log,
596                                       ad=self.dut,
597                                       dut_client= self.dut_client,
598                                       wifi_network_ssid=self.wifi_network_ssid,
599                                       wifi_network_pass=self.wifi_network_pass,
600                                       dut_capabilities=self.dut_capabilities,
601                                       subid=self.subid,
602                                       airplane_mode=False,
603                                       wifi_enabled=True,
604                                       volte_enabled=False,
605                                       wfc_enabled=True,
606                                       nw_gen=RAT_NR,
607                                       wfc_mode=WFC_MODE_WIFI_PREFERRED)
608
609
610