1#!/usr/bin/env python3.4
2#
3#   Copyright 2016 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16"""
17    Test Script for epdg RF shield box related tests.
18"""
19
20import time
21from queue import Empty
22from acts.test_decorators import test_tracker_info
23from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
24from acts.test_utils.tel.tel_atten_utils import set_rssi
25from acts.test_utils.tel.tel_defines import CELL_STRONG_RSSI_VALUE
26from acts.test_utils.tel.tel_defines import CELL_WEAK_RSSI_VALUE
27from acts.test_utils.tel.tel_defines import DIRECTION_MOBILE_ORIGINATED
28from acts.test_utils.tel.tel_defines import DIRECTION_MOBILE_TERMINATED
29from acts.test_utils.tel.tel_defines import GEN_3G
30from acts.test_utils.tel.tel_defines import GEN_4G
31from acts.test_utils.tel.tel_defines import INVALID_WIFI_RSSI
32from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_CALL_DROP
33from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_NW_SELECTION
34from acts.test_utils.tel.tel_defines import MAX_RSSI_RESERVED_VALUE
35from acts.test_utils.tel.tel_defines import MIN_RSSI_RESERVED_VALUE
36from acts.test_utils.tel.tel_defines import NETWORK_SERVICE_DATA
37from acts.test_utils.tel.tel_defines import NETWORK_SERVICE_VOICE
38from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND
39from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND
40from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING
41from acts.test_utils.tel.tel_defines import RAT_LTE
42from acts.test_utils.tel.tel_defines import RAT_IWLAN
43from acts.test_utils.tel.tel_defines import RAT_WCDMA
44from acts.test_utils.tel.tel_defines import WAIT_TIME_BETWEEN_REG_AND_CALL
45from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL
46from acts.test_utils.tel.tel_defines import WAIT_TIME_WIFI_RSSI_CALIBRATION_SCREEN_ON
47from acts.test_utils.tel.tel_defines import WAIT_TIME_WIFI_RSSI_CALIBRATION_WIFI_CONNECTED
48from acts.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED
49from acts.test_utils.tel.tel_defines import WFC_MODE_DISABLED
50from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_ONLY
51from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
52from acts.test_utils.tel.tel_defines import WIFI_WEAK_RSSI_VALUE
53from acts.test_utils.tel.tel_defines import EventNetworkCallback
54from acts.test_utils.tel.tel_defines import NetworkCallbackAvailable
55from acts.test_utils.tel.tel_defines import NetworkCallbackLost
56from acts.test_utils.tel.tel_defines import SignalStrengthContainer
57from acts.test_utils.tel.tel_test_utils import wifi_toggle_state
58from acts.test_utils.tel.tel_test_utils import ensure_network_generation
59from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state
60from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected
61from acts.test_utils.tel.tel_test_utils import get_network_rat
62from acts.test_utils.tel.tel_test_utils import get_phone_number
63from acts.test_utils.tel.tel_test_utils import hangup_call
64from acts.test_utils.tel.tel_test_utils import initiate_call
65from acts.test_utils.tel.tel_test_utils import is_network_call_back_event_match
66from acts.test_utils.tel.tel_test_utils import is_phone_in_call
67from acts.test_utils.tel.tel_test_utils import is_phone_not_in_call
68from acts.test_utils.tel.tel_test_utils import set_wfc_mode
69from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode
70from acts.test_utils.tel.tel_test_utils import toggle_volte
71from acts.test_utils.tel.tel_test_utils import wait_and_answer_call
72from acts.test_utils.tel.tel_test_utils import wait_for_cell_data_connection
73from acts.test_utils.tel.tel_test_utils import wait_for_droid_not_in_call
74from acts.test_utils.tel.tel_test_utils import wait_for_wfc_disabled
75from acts.test_utils.tel.tel_test_utils import wait_for_wfc_enabled
76from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection
77from acts.test_utils.tel.tel_test_utils import verify_http_connection
78from acts.test_utils.tel.tel_test_utils import get_telephony_signal_strength
79from acts.test_utils.tel.tel_test_utils import get_wifi_signal_strength
80from acts.test_utils.tel.tel_test_utils import wait_for_state
81from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g
82from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
83from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
84from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_not_iwlan
85from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
86from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_general
87from acts.test_utils.tel.tel_voice_utils import phone_idle_3g
88from acts.test_utils.tel.tel_voice_utils import phone_idle_csfb
89from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan
90from acts.test_utils.tel.tel_voice_utils import phone_idle_not_iwlan
91from acts.test_utils.tel.tel_voice_utils import phone_idle_volte
92
93# Attenuator name
94ATTEN_NAME_FOR_WIFI_2G = 'wifi0'
95ATTEN_NAME_FOR_WIFI_5G = 'wifi1'
96ATTEN_NAME_FOR_CELL_3G = 'cell0'
97ATTEN_NAME_FOR_CELL_4G = 'cell1'
98
99# WiFi RSSI settings for ROVE_IN test
100WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN = -60
101WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN = -70
102
103# WiFi RSSI settings for ROVE_OUT test
104WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE = -60
105WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT = -70
106WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT = -90
107
108# WiFi RSSI settings for HAND_IN test
109WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN = -80
110WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN = -50
111
112# WiFi RSSI settings for HAND_OUT test
113WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_NOT_HAND_OUT = -60
114WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT = -85
115
116
117class TelWifiVoiceTest(TelephonyBaseTest):
118    def setup_class(self):
119        super().setup_class()
120        self.stress_test_number = self.get_stress_test_number()
121
122        self.attens = {}
123        for atten in self.attenuators:
124            self.attens[atten.path] = atten
125            atten.set_atten(atten.get_max_atten())  # Default all attens to max
126
127        self.log.info("WFC phone: <{}> <{}>".format(
128            self.android_devices[0].serial,
129            get_phone_number(self.log, self.android_devices[0])))
130        self.android_devices[
131            0].droid.telephonyStartTrackingSignalStrengthChange()
132
133        for ad in self.android_devices:
134            if not wait_for_state(ad.droid.imsIsVolteProvisionedOnDevice,
135                                  True):
136                ad.log.info("VoLTE not Provisioned, Turning it ON")
137                ad.droid.imsSetVolteProvisioning(True)
138            else:
139                ad.log.info("VoLTE Provisioning is Enabled")
140
141        # Do WiFi RSSI calibration.
142        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
143                 MAX_RSSI_RESERVED_VALUE)
144        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
145                 MAX_RSSI_RESERVED_VALUE)
146        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
147                 MAX_RSSI_RESERVED_VALUE)
148        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
149                 MAX_RSSI_RESERVED_VALUE)
150
151        if not ensure_network_generation(
152                self.log,
153                self.android_devices[0],
154                GEN_4G,
155                voice_or_data=NETWORK_SERVICE_DATA,
156                toggle_apm_after_setting=True):
157            self.log.error("Setup_class: phone failed to select to LTE.")
158            return False
159        if not ensure_wifi_connected(self.log, self.android_devices[0],
160                                     self.wifi_network_ssid,
161                                     self.wifi_network_pass):
162            self.log.error("{} connect WiFI failed".format(
163                self.android_devices[0].serial))
164            return False
165        if (not wait_for_wifi_data_connection(self.log,
166                                              self.android_devices[0], True) or
167                not verify_http_connection(self.log, self.android_devices[0])):
168            self.log.error("No Data on Wifi")
169            return False
170
171        # Delay WAIT_TIME_WIFI_RSSI_CALIBRATION_WIFI_CONNECTED after WiFi
172        # Connected to make sure WiFi RSSI reported value is correct.
173        time.sleep(WAIT_TIME_WIFI_RSSI_CALIBRATION_WIFI_CONNECTED)
174        # Turn On Screen and delay WAIT_TIME_WIFI_RSSI_CALIBRATION_SCREEN_ON
175        # then get WiFi RSSI to avoid WiFi RSSI report -127(invalid value).
176        self.android_devices[0].droid.wakeUpNow()
177        time.sleep(WAIT_TIME_WIFI_RSSI_CALIBRATION_SCREEN_ON)
178
179        setattr(self, "wifi_rssi_with_no_atten",
180                self.android_devices[0].droid.wifiGetConnectionInfo()['rssi'])
181        if self.wifi_rssi_with_no_atten == INVALID_WIFI_RSSI:
182            self.log.error(
183                "Initial WiFi RSSI calibration value is wrong: -127.")
184            return False
185        self.log.info("WiFi RSSI calibration info: atten=0, RSSI={}".format(
186            self.wifi_rssi_with_no_atten))
187        ensure_phones_default_state(self.log, [self.android_devices[0]])
188
189        # Do Cellular RSSI calibration.
190        setattr(self, "cell_rssi_with_no_atten",
191                self.android_devices[0].droid.telephonyGetSignalStrength()[
192                    SignalStrengthContainer.SIGNAL_STRENGTH_LTE_DBM])
193        self.log.info(
194            "Cellular RSSI calibration info: atten=0, RSSI={}".format(
195                self.cell_rssi_with_no_atten))
196        return True
197
198    def teardown_class(self):
199
200        super().teardown_class()
201
202        self.android_devices[
203            0].droid.telephonyStopTrackingSignalStrengthChange()
204        return True
205
206    def teardown_test(self):
207
208        super().teardown_test()
209        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
210                 MAX_RSSI_RESERVED_VALUE)
211        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
212                 MAX_RSSI_RESERVED_VALUE)
213        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
214                 MAX_RSSI_RESERVED_VALUE)
215        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
216                 MAX_RSSI_RESERVED_VALUE)
217        return True
218
219    def _wfc_call_sequence(self, ads, mo_mt, initial_wifi_cellular_setup_func,
220                           wfc_phone_setup_func, verify_wfc_initial_idle_func,
221                           verify_wfc_in_call_state_func,
222                           incall_wifi_cellular_setting_check_func,
223                           expected_result):
224        """_wfc_call_sequence
225
226        Args:
227            ads: list of android devices. This list should have 2 ad.
228            mo_mt: indicating this call sequence is MO or MT.
229                Valid input: DIRECTION_MOBILE_ORIGINATED and
230                DIRECTION_MOBILE_TERMINATED.
231            initial_wifi_cellular_setup_func: Initial WiFI router and Attenuator
232                setup function before phone setup.
233            wfc_phone_setup_func: WFC phone setup function.
234            verify_wfc_initial_idle_func: Initial WFC phone idle check function.
235            verify_wfc_in_call_state_func: WFC phone in call state check function.
236            incall_wifi_cellular_setting_check_func: During call, WiFI router and Attenuator
237                change setting  and phone status check function.
238                (for test hand-in and hand-out)
239
240            expected_result: expected test result.
241                If expect call sequence finish, this value should be set to 'True'.
242                If expect call sequence not finish (eg. setup fail, call initial fail),
243                    this value should be set to "exception string"
244                    Current supported string include:
245                        "initial_wifi_cellular_setup_func fail."
246                        "wfc_phone_setup_func fail."
247                        "phone_setup_voice_general fail."
248                        "verify_wfc_initial_idle_func fail."
249                        "initiate_call fail."
250                        "wait_and_answer_call fail."
251                        "verify_wfc_in_call_state_func fail."
252                        "PhoneB not in call."
253                        "verify_wfc_in_call_state_func fail after 30 seconds."
254                        "PhoneB not in call after 30 seconds."
255                        "incall_wifi_cellular_setting_func fail."
256                        "incall_setting_check_func fail."
257                        "hangup_call fail."
258
259        Returns:
260            if expected_result is True,
261                Return True if call sequence finish without exception. Otherwise False.
262            if expected_result is string,
263                Return True if expected exception happened. Otherwise False.
264
265        """
266
267        class _WfcCallSequenceException(Exception):
268            pass
269
270        if (len(ads) != 2) or (mo_mt not in [
271                DIRECTION_MOBILE_ORIGINATED, DIRECTION_MOBILE_TERMINATED
272        ]):
273            self.log.error("Invalid parameters.")
274            return False
275
276        if mo_mt == DIRECTION_MOBILE_ORIGINATED:
277            ad_caller = ads[0]
278            ad_callee = ads[1]
279        else:
280            ad_caller = ads[1]
281            ad_callee = ads[0]
282        caller_number = get_phone_number(self.log, ad_caller)
283        callee_number = get_phone_number(self.log, ad_callee)
284
285        self.log.info("-->Begin wfc_call_sequence: {} to {}<--".format(
286            caller_number, callee_number))
287
288        try:
289            # initial setup wifi router and RF
290            if initial_wifi_cellular_setup_func and not initial_wifi_cellular_setup_func(
291            ):
292                raise _WfcCallSequenceException(
293                    "initial_wifi_cellular_setup_func fail.")
294
295            if wfc_phone_setup_func and not wfc_phone_setup_func():
296                raise _WfcCallSequenceException("wfc_phone_setup_func fail.")
297            if not phone_setup_voice_general(self.log, ads[1]):
298                raise _WfcCallSequenceException(
299                    "phone_setup_voice_general fail.")
300            time.sleep(WAIT_TIME_BETWEEN_REG_AND_CALL)
301
302            # Ensure idle status correct
303            if verify_wfc_initial_idle_func and not verify_wfc_initial_idle_func(
304            ):
305                raise _WfcCallSequenceException(
306                    "verify_wfc_initial_idle_func fail.")
307
308            # Make MO/MT call.
309            if not initiate_call(self.log, ad_caller, callee_number):
310                raise _WfcCallSequenceException("initiate_call fail.")
311            if not wait_and_answer_call(self.log, ad_callee, caller_number):
312                raise _WfcCallSequenceException("wait_and_answer_call fail.")
313            time.sleep(1)
314
315            # Check state, wait 30 seconds, check again.
316            if verify_wfc_in_call_state_func and not verify_wfc_in_call_state_func(
317            ):
318                raise _WfcCallSequenceException(
319                    "verify_wfc_in_call_state_func fail.")
320            if is_phone_not_in_call(self.log, ads[1]):
321                raise _WfcCallSequenceException("PhoneB not in call.")
322            time.sleep(WAIT_TIME_IN_CALL)
323            if verify_wfc_in_call_state_func and not verify_wfc_in_call_state_func(
324            ):
325                raise _WfcCallSequenceException(
326                    "verify_wfc_in_call_state_func fail after 30 seconds.")
327            if is_phone_not_in_call(self.log, ads[1]):
328                raise _WfcCallSequenceException(
329                    "PhoneB not in call after 30 seconds.")
330
331            # in call change setting and check
332            if incall_wifi_cellular_setting_check_func and not incall_wifi_cellular_setting_check_func(
333            ):
334                raise _WfcCallSequenceException(
335                    "incall_wifi_cellular_setting_check_func fail.")
336
337            if is_phone_in_call(self.log, ads[0]):
338                # hangup call
339                if not hangup_call(self.log, ads[0]):
340                    raise _WfcCallSequenceException("hangup_call fail.")
341            else:
342                # Call drop is unexpected if
343                # incall_wifi_cellular_setting_check_func is None
344                if incall_wifi_cellular_setting_check_func is None:
345                    raise _WfcCallSequenceException("Unexpected call drop.")
346
347        except _WfcCallSequenceException as e:
348            if str(e) == expected_result:
349                self.log.info(
350                    "Expected exception happened: <{}>, return True.".format(
351                        e))
352                get_telephony_signal_strength(self.android_devices[0])
353                get_wifi_signal_strength(self.android_devices[0])
354                return True
355            else:
356                self.log.info(
357                    "Unexpected exception happened: <{}>, return False.".
358                    format(e))
359                get_telephony_signal_strength(self.android_devices[0])
360                get_wifi_signal_strength(self.android_devices[0])
361                return False
362        finally:
363            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
364                     MAX_RSSI_RESERVED_VALUE)
365            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
366                     MAX_RSSI_RESERVED_VALUE)
367            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
368                     MAX_RSSI_RESERVED_VALUE)
369            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
370                     MAX_RSSI_RESERVED_VALUE)
371            ensure_phones_default_state(self.log, [ads[0], ads[1]])
372
373        self.log.info("wfc_call_sequence finished, return {}".format(
374            expected_result is True))
375        return (expected_result is True)
376
377    def _phone_idle_iwlan(self):
378        return phone_idle_iwlan(self.log, self.android_devices[0])
379
380    def _phone_idle_not_iwlan(self):
381        return phone_idle_not_iwlan(self.log, self.android_devices[0])
382
383    def _phone_idle_volte(self):
384        return phone_idle_volte(self.log, self.android_devices[0])
385
386    def _phone_idle_csfb(self):
387        return phone_idle_csfb(self.log, self.android_devices[0])
388
389    def _phone_idle_3g(self):
390        return phone_idle_3g(self.log, self.android_devices[0])
391
392    def _phone_wait_for_not_wfc(self):
393        result = wait_for_wfc_disabled(self.log, self.android_devices[0],
394                                       MAX_WAIT_TIME_NW_SELECTION)
395        self.log.info(
396            "_phone_wait_for_not_wfc: WFC_disabled is {}".format(result))
397        if not result:
398            return False
399        # TODO: b/26338343 Need to check Data RAT. Data RAT should not be iwlan.
400        return True
401
402    def _phone_wait_for_wfc(self):
403        result = wait_for_wfc_enabled(self.log, self.android_devices[0],
404                                      MAX_WAIT_TIME_NW_SELECTION)
405        self.log.info("_phone_wait_for_wfc: WFC_enabled is {}".format(result))
406        if not result:
407            return False
408        nw_type = get_network_rat(self.log, self.android_devices[0],
409                                  NETWORK_SERVICE_DATA)
410        if nw_type != RAT_IWLAN:
411            self.log.error(
412                "_phone_wait_for_wfc Data Rat is {}, expecting {}".format(
413                    nw_type, RAT_IWLAN))
414            return False
415        return True
416
417    def _phone_wait_for_call_drop(self):
418        if not wait_for_droid_not_in_call(self.log, self.android_devices[0],
419                                          MAX_WAIT_TIME_CALL_DROP):
420            self.log.info("_phone_wait_for_call_drop: Call not drop.")
421            return False
422        return True
423
424    def _is_phone_in_call_iwlan(self):
425        return is_phone_in_call_iwlan(self.log, self.android_devices[0])
426
427    def _is_phone_in_call_not_iwlan(self):
428        return is_phone_in_call_not_iwlan(self.log, self.android_devices[0])
429
430    def _is_phone_not_in_call(self):
431        if is_phone_in_call(self.log, self.android_devices[0]):
432            self.log.info("{} in call.".format(self.android_devices[0].serial))
433            return False
434        self.log.info("{} not in call.".format(self.android_devices[0].serial))
435        return True
436
437    def _is_phone_in_call_volte(self):
438        return is_phone_in_call_volte(self.log, self.android_devices[0])
439
440    def _is_phone_in_call_3g(self):
441        return is_phone_in_call_3g(self.log, self.android_devices[0])
442
443    def _is_phone_in_call_csfb(self):
444        return is_phone_in_call_csfb(self.log, self.android_devices[0])
445
446    def _wfc_phone_setup(self, is_airplane_mode, wfc_mode, volte_mode=True):
447        toggle_airplane_mode(self.log, self.android_devices[0], False)
448        toggle_volte(self.log, self.android_devices[0], volte_mode)
449        if not ensure_network_generation(
450                self.log,
451                self.android_devices[0],
452                GEN_4G,
453                voice_or_data=NETWORK_SERVICE_DATA):
454            return False
455
456        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
457            self.log.error("{} set WFC mode failed.".format(
458                self.android_devices[0].serial))
459            return False
460
461        toggle_airplane_mode(self.log, self.android_devices[0],
462                             is_airplane_mode)
463
464        if not ensure_wifi_connected(self.log, self.android_devices[0],
465                                     self.wifi_network_ssid,
466                                     self.wifi_network_pass):
467            self.log.error("{} connect WiFI failed".format(
468                self.android_devices[0].serial))
469            return False
470        return True
471
472    def _wfc_phone_setup_cellular_absent(self, wfc_mode):
473        is_exception_happened = False
474        time.sleep(90)
475        try:
476            if not toggle_airplane_mode(self.log, self.android_devices[0],
477                                        False):
478                raise Exception("Toggle APM failed.")
479            if not ensure_network_generation(
480                    self.log,
481                    self.android_devices[0],
482                    GEN_4G,
483                    voice_or_data=NETWORK_SERVICE_DATA):
484                raise Exception("Ensure LTE failed.")
485        except Exception:
486            is_exception_happened = True
487
488        if not is_exception_happened:
489            self.log.error(
490                "_wfc_phone_setup_cellular_absent error:"
491                "Phone on LTE, expected Phone have no cellular signal")
492            return False
493        if not toggle_volte(self.log, self.android_devices[0], True):
494            self.log.error(
495                "_wfc_phone_setup_cellular_absent: toggle VoLTE fail.")
496            raise False
497
498        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
499            self.log.error("{} set WFC mode failed.".format(
500                self.android_devices[0].serial))
501            return False
502
503        if not ensure_wifi_connected(self.log, self.android_devices[0],
504                                     self.wifi_network_ssid,
505                                     self.wifi_network_pass):
506            self.log.error("{} connect WiFI failed".format(
507                self.android_devices[0].serial))
508            return False
509        return True
510
511    def _wfc_phone_setup_apm_wifi_only(self):
512        return self._wfc_phone_setup(True, WFC_MODE_WIFI_ONLY)
513
514    def _wfc_phone_setup_apm_wifi_preferred(self):
515        return self._wfc_phone_setup(True, WFC_MODE_WIFI_PREFERRED)
516
517    def _wfc_phone_setup_apm_cellular_preferred(self):
518        return self._wfc_phone_setup(True, WFC_MODE_CELLULAR_PREFERRED)
519
520    def _wfc_phone_setup_apm_wfc_disabled(self):
521        return self._wfc_phone_setup(True, WFC_MODE_DISABLED)
522
523    def _wfc_phone_setup_wifi_only(self):
524        return self._wfc_phone_setup(False, WFC_MODE_WIFI_ONLY)
525
526    def _wfc_phone_setup_wifi_preferred(self):
527        return self._wfc_phone_setup(False, WFC_MODE_WIFI_PREFERRED)
528
529    def _wfc_phone_setup_cellular_preferred(self):
530        return self._wfc_phone_setup(False, WFC_MODE_CELLULAR_PREFERRED)
531
532    def _wfc_phone_setup_wfc_disabled(self):
533        return self._wfc_phone_setup(False, WFC_MODE_DISABLED)
534
535    def _wfc_phone_setup_cellular_absent_wifi_only(self):
536        return self._wfc_phone_setup_cellular_absent(WFC_MODE_WIFI_ONLY)
537
538    def _wfc_phone_setup_cellular_absent_wifi_preferred(self):
539        return self._wfc_phone_setup_cellular_absent(WFC_MODE_WIFI_PREFERRED)
540
541    def _wfc_phone_setup_cellular_absent_cellular_preferred(self):
542        return self._wfc_phone_setup_cellular_absent(
543            WFC_MODE_CELLULAR_PREFERRED)
544
545    def _wfc_phone_setup_cellular_absent_wfc_disabled(self):
546        return self._wfc_phone_setup_cellular_absent(WFC_MODE_DISABLED)
547
548    def _wfc_phone_setup_wifi_preferred_e4g_disabled(self):
549        return self._wfc_phone_setup(False, WFC_MODE_WIFI_PREFERRED, False)
550
551    def _wfc_phone_setup_wifi_absent(self,
552                                     is_airplane_mode,
553                                     wfc_mode,
554                                     volte_mode=True):
555        toggle_airplane_mode(self.log, self.android_devices[0], False)
556        toggle_volte(self.log, self.android_devices[0], volte_mode)
557        if not ensure_network_generation(
558                self.log,
559                self.android_devices[0],
560                GEN_4G,
561                voice_or_data=NETWORK_SERVICE_DATA):
562            return False
563
564        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
565            self.log.error("{} set WFC mode failed.".format(
566                self.android_devices[0].serial))
567            return False
568
569        toggle_airplane_mode(self.log, self.android_devices[0],
570                             is_airplane_mode)
571
572        if ensure_wifi_connected(self.log, self.android_devices[0],
573                                 self.wifi_network_ssid,
574                                 self.wifi_network_pass, 1):
575            self.log.error(
576                "{} connect WiFI succeed, expected not succeed".format(
577                    self.android_devices[0].serial))
578            return False
579        return True
580
581    def _wfc_phone_setup_cellular_absent_wifi_absent(self, wfc_mode):
582        is_exception_happened = False
583        time.sleep(60)
584        try:
585            if not toggle_airplane_mode(self.log, self.android_devices[0],
586                                        False):
587                raise Exception("Toggle APM failed.")
588            if not ensure_network_generation(
589                    self.log,
590                    self.android_devices[0],
591                    GEN_4G,
592                    voice_or_data=NETWORK_SERVICE_DATA):
593                raise Exception("Ensure LTE failed.")
594        except Exception:
595            is_exception_happened = True
596
597        if not is_exception_happened:
598            self.log.error(
599                "_wfc_phone_setup_cellular_absent_wifi_absent error:"
600                "Phone on LTE, expected Phone have no cellular signal")
601            return False
602        if not toggle_volte(self.log, self.android_devices[0], True):
603            self.log.error(
604                "_wfc_phone_setup_cellular_absent: toggle VoLTE fail.")
605            raise False
606
607        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
608            self.log.error("{} set WFC mode failed.".format(
609                self.android_devices[0].serial))
610            return False
611
612        if ensure_wifi_connected(self.log, self.android_devices[0],
613                                 self.wifi_network_ssid,
614                                 self.wifi_network_pass, 1):
615            self.log.error(
616                "{} connect WiFI succeed, expected not succeed".format(
617                    self.android_devices[0].serial))
618            return False
619        return True
620
621    def _wfc_phone_setup_apm_wifi_absent_wifi_only(self):
622        return self._wfc_phone_setup_wifi_absent(True, WFC_MODE_WIFI_ONLY)
623
624    def _wfc_phone_setup_apm_wifi_absent_wifi_preferred(self):
625        return self._wfc_phone_setup_wifi_absent(True, WFC_MODE_WIFI_PREFERRED)
626
627    def _wfc_phone_setup_apm_wifi_absent_cellular_preferred(self):
628        return self._wfc_phone_setup_wifi_absent(True,
629                                                 WFC_MODE_CELLULAR_PREFERRED)
630
631    def _wfc_phone_setup_wifi_absent_wifi_only(self):
632        return self._wfc_phone_setup_wifi_absent(False, WFC_MODE_WIFI_ONLY)
633
634    def _wfc_phone_setup_wifi_absent_wifi_preferred(self):
635        return self._wfc_phone_setup_wifi_absent(False,
636                                                 WFC_MODE_WIFI_PREFERRED)
637
638    def _wfc_phone_setup_wifi_absent_cellular_preferred(self):
639        return self._wfc_phone_setup_wifi_absent(False,
640                                                 WFC_MODE_CELLULAR_PREFERRED)
641
642    def _wfc_phone_setup_cellular_absent_wifi_absent_wifi_only(self):
643        return self._wfc_phone_setup_cellular_absent_wifi_absent(
644            WFC_MODE_WIFI_ONLY)
645
646    def _wfc_phone_setup_cellular_absent_wifi_absent_wifi_preferred(self):
647        return self._wfc_phone_setup_cellular_absent_wifi_absent(
648            WFC_MODE_WIFI_PREFERRED)
649
650    def _wfc_phone_setup_cellular_absent_wifi_absent_cellular_preferred(self):
651        return self._wfc_phone_setup_cellular_absent_wifi_absent(
652            WFC_MODE_CELLULAR_PREFERRED)
653
654    def _wfc_phone_setup_wifi_absent_wifi_preferred_e4g_disabled(self):
655        return self._wfc_phone_setup_wifi_absent(
656            False, WFC_MODE_WIFI_PREFERRED, False)
657
658    def _wfc_phone_setup_wifi_disabled(self, is_airplane_mode, wfc_mode):
659        toggle_airplane_mode(self.log, self.android_devices[0], False)
660        toggle_volte(self.log, self.android_devices[0], True)
661        if not ensure_network_generation(
662                self.log,
663                self.android_devices[0],
664                GEN_4G,
665                voice_or_data=NETWORK_SERVICE_DATA):
666            return False
667
668        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
669            self.log.error("{} set WFC mode failed.".format(
670                self.android_devices[0].serial))
671            return False
672
673        toggle_airplane_mode(self.log, self.android_devices[0],
674                             is_airplane_mode)
675
676        wifi_toggle_state(self.log, self.android_devices[0], False)
677        return True
678
679    def _wfc_phone_setup_cellular_absent_wifi_disabled(self, wfc_mode):
680        is_exception_happened = False
681        time.sleep(60)
682        try:
683            if not toggle_airplane_mode(self.log, self.android_devices[0],
684                                        False):
685                raise Exception("Toggle APM failed.")
686            if not ensure_network_generation(
687                    self.log,
688                    self.android_devices[0],
689                    GEN_4G,
690                    voice_or_data=NETWORK_SERVICE_DATA):
691                raise Exception("Ensure LTE failed.")
692        except Exception:
693            is_exception_happened = True
694
695        if not is_exception_happened:
696            self.log.error(
697                "_wfc_phone_setup_cellular_absent_wifi_disabled error:"
698                "Phone on LTE, expected Phone have no cellular signal")
699            return False
700        if not toggle_volte(self.log, self.android_devices[0], True):
701            self.log.error(
702                "_wfc_phone_setup_cellular_absent: toggle VoLTE fail.")
703            raise False
704
705        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
706            self.log.error("{} set WFC mode failed.".format(
707                self.android_devices[0].serial))
708            return False
709
710        wifi_toggle_state(self.log, self.android_devices[0], False)
711        return True
712
713    def _wfc_phone_setup_apm_wifi_disabled_wifi_only(self):
714        return self._wfc_phone_setup_wifi_disabled(True, WFC_MODE_WIFI_ONLY)
715
716    def _wfc_phone_setup_apm_wifi_disabled_wifi_preferred(self):
717        return self._wfc_phone_setup_wifi_disabled(True,
718                                                   WFC_MODE_WIFI_PREFERRED)
719
720    def _wfc_phone_setup_apm_wifi_disabled_cellular_preferred(self):
721        return self._wfc_phone_setup_wifi_disabled(True,
722                                                   WFC_MODE_CELLULAR_PREFERRED)
723
724    def _wfc_phone_setup_wifi_disabled_wifi_only(self):
725        return self._wfc_phone_setup_wifi_disabled(False, WFC_MODE_WIFI_ONLY)
726
727    def _wfc_phone_setup_wifi_disabled_wifi_preferred(self):
728        return self._wfc_phone_setup_wifi_disabled(False,
729                                                   WFC_MODE_WIFI_PREFERRED)
730
731    def _wfc_phone_setup_wifi_disabled_cellular_preferred(self):
732        return self._wfc_phone_setup_wifi_disabled(False,
733                                                   WFC_MODE_CELLULAR_PREFERRED)
734
735    def _wfc_phone_setup_cellular_absent_wifi_disabled_wifi_only(self):
736        return self._wfc_phone_setup_cellular_absent_wifi_disabled(
737            WFC_MODE_WIFI_ONLY)
738
739    def _wfc_phone_setup_cellular_absent_wifi_disabled_wifi_preferred(self):
740        return self._wfc_phone_setup_cellular_absent_wifi_disabled(
741            WFC_MODE_WIFI_PREFERRED)
742
743    def _wfc_phone_setup_cellular_absent_wifi_disabled_cellular_preferred(
744            self):
745        return self._wfc_phone_setup_cellular_absent_wifi_disabled(
746            WFC_MODE_CELLULAR_PREFERRED)
747
748    def _wfc_set_wifi_strong_cell_strong(self):
749        self.log.info("--->Setting WiFi strong cell strong<---")
750        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
751                 MAX_RSSI_RESERVED_VALUE)
752        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
753                 MAX_RSSI_RESERVED_VALUE)
754        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
755                 MAX_RSSI_RESERVED_VALUE)
756        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
757                 MAX_RSSI_RESERVED_VALUE)
758        return True
759
760    def _wfc_set_wifi_strong_cell_weak(self):
761        self.log.info("--->Setting WiFi strong cell weak<---")
762        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
763                 MAX_RSSI_RESERVED_VALUE)
764        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
765                 MAX_RSSI_RESERVED_VALUE)
766        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G],
767                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE)
768        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G],
769                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE)
770        return True
771
772    def _wfc_set_wifi_strong_cell_absent(self):
773        self.log.info("--->Setting WiFi strong cell absent<---")
774        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
775                 MAX_RSSI_RESERVED_VALUE)
776        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
777                 MAX_RSSI_RESERVED_VALUE)
778        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
779                 MIN_RSSI_RESERVED_VALUE)
780        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
781                 MIN_RSSI_RESERVED_VALUE)
782        return True
783
784    def _wfc_set_wifi_weak_cell_strong(self):
785        self.log.info("--->Setting WiFi weak cell strong<---")
786        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
787                 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE)
788        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
789                 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE)
790        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
791                 MAX_RSSI_RESERVED_VALUE)
792        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
793                 MAX_RSSI_RESERVED_VALUE)
794        return True
795
796    def _wfc_set_wifi_weak_cell_weak(self):
797        self.log.info("--->Setting WiFi weak cell weak<---")
798        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
799                 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE)
800        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
801                 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE)
802        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G],
803                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE)
804        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G],
805                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE)
806        return True
807
808    def _wfc_set_wifi_weak_cell_absent(self):
809        self.log.info("--->Setting WiFi weak cell absent<---")
810        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
811                 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE)
812        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
813                 self.wifi_rssi_with_no_atten, WIFI_WEAK_RSSI_VALUE)
814        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
815                 MIN_RSSI_RESERVED_VALUE)
816        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
817                 MIN_RSSI_RESERVED_VALUE)
818        return True
819
820    def _wfc_set_wifi_absent_cell_strong(self):
821        self.log.info("--->Setting WiFi absent cell strong<---")
822        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
823                 MIN_RSSI_RESERVED_VALUE)
824        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
825                 MIN_RSSI_RESERVED_VALUE)
826        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
827                 MAX_RSSI_RESERVED_VALUE)
828        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
829                 MAX_RSSI_RESERVED_VALUE)
830        return True
831
832    def _wfc_set_wifi_absent_cell_weak(self):
833        self.log.info("--->Setting WiFi absent cell weak<---")
834        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
835                 MIN_RSSI_RESERVED_VALUE)
836        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
837                 MIN_RSSI_RESERVED_VALUE)
838        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G],
839                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE)
840        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G],
841                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE)
842        return True
843
844    def _wfc_set_wifi_absent_cell_absent(self):
845        self.log.info("--->Setting WiFi absent cell absent<---")
846        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
847                 MIN_RSSI_RESERVED_VALUE)
848        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
849                 MIN_RSSI_RESERVED_VALUE)
850        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
851                 MIN_RSSI_RESERVED_VALUE)
852        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
853                 MIN_RSSI_RESERVED_VALUE)
854        return True
855
856    """ Tests Begin """
857
858    @test_tracker_info(uuid="a9a369bc-b8cc-467b-a847-82d004db851d")
859    @TelephonyBaseTest.tel_test_wrap
860    def test_call_epdg_wfc_wifi_only_wifi_strong_apm(self):
861        """ Test WFC MO MT, WiFI only mode, WIFI Strong, Phone in APM
862
863        Set WiFi/Cellular network environment.
864        Make Sure PhoneA is set correct WFC parameters.
865        Make SUre PhoneB is able to make MO/MT call.
866        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
867        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
868
869        Returns:
870            True if pass; False if fail.
871        """
872
873        ads = [self.android_devices[0], self.android_devices[1]]
874        mo_result = self._wfc_call_sequence(
875            ads, DIRECTION_MOBILE_ORIGINATED,
876            self._wfc_set_wifi_strong_cell_strong,
877            self._wfc_phone_setup_apm_wifi_only, self._phone_idle_iwlan,
878            self._is_phone_in_call_iwlan, None, True)
879
880        mt_result = self._wfc_call_sequence(
881            ads, DIRECTION_MOBILE_TERMINATED,
882            self._wfc_set_wifi_strong_cell_strong,
883            self._wfc_phone_setup_apm_wifi_only, self._phone_idle_iwlan,
884            self._is_phone_in_call_iwlan, None, True)
885
886        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
887        return ((mo_result is True) and (mt_result is True))
888
889    @test_tracker_info(uuid="c88999d7-7fe7-4163-9430-4aee88852e7b")
890    @TelephonyBaseTest.tel_test_wrap
891    def test_call_epdg_wfc_wifi_preferred_wifi_strong_apm(self):
892        """ Test WFC MO MT, WiFI preferred mode, WIFI Strong, Phone in APM
893
894        Set WiFi/Cellular network environment.
895        Make Sure PhoneA is set correct WFC parameters.
896        Make SUre PhoneB is able to make MO/MT call.
897        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
898        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
899
900        Returns:
901            True if pass; False if fail.
902        """
903
904        ads = [self.android_devices[0], self.android_devices[1]]
905        mo_result = self._wfc_call_sequence(
906            ads, DIRECTION_MOBILE_ORIGINATED,
907            self._wfc_set_wifi_strong_cell_strong,
908            self._wfc_phone_setup_apm_wifi_preferred, self._phone_idle_iwlan,
909            self._is_phone_in_call_iwlan, None, True)
910
911        mt_result = self._wfc_call_sequence(
912            ads, DIRECTION_MOBILE_TERMINATED,
913            self._wfc_set_wifi_strong_cell_strong,
914            self._wfc_phone_setup_apm_wifi_preferred, self._phone_idle_iwlan,
915            self._is_phone_in_call_iwlan, None, True)
916
917        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
918        return ((mo_result is True) and (mt_result is True))
919
920    @test_tracker_info(uuid="a4464c2c-753e-4702-b4fc-73d7bb6265da")
921    @TelephonyBaseTest.tel_test_wrap
922    def test_call_epdg_wfc_cellular_preferred_wifi_strong_apm(self):
923        """ Test WFC MO MT, cellular preferred mode, WIFI Strong, Phone in APM
924
925        Set WiFi/Cellular network environment.
926        Make Sure PhoneA is set correct WFC parameters.
927        Make SUre PhoneB is able to make MO/MT call.
928        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
929        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
930
931        Returns:
932            True if pass; False if fail.
933        """
934
935        ads = [self.android_devices[0], self.android_devices[1]]
936        mo_result = self._wfc_call_sequence(
937            ads, DIRECTION_MOBILE_ORIGINATED,
938            self._wfc_set_wifi_strong_cell_strong,
939            self._wfc_phone_setup_apm_cellular_preferred,
940            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
941
942        mt_result = self._wfc_call_sequence(
943            ads, DIRECTION_MOBILE_TERMINATED,
944            self._wfc_set_wifi_strong_cell_strong,
945            self._wfc_phone_setup_apm_cellular_preferred,
946            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
947
948        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
949        return ((mo_result is True) and (mt_result is True))
950
951    @test_tracker_info(uuid="797ad987-db48-456e-b092-d27be110b7ff")
952    @TelephonyBaseTest.tel_test_wrap
953    def test_call_epdg_wfc_wifi_only_wifi_weak_apm(self):
954        """ Test WFC MO MT, WiFI only mode, WIFI weak, Phone in APM
955
956        Set WiFi/Cellular network environment.
957        Make Sure PhoneA is set correct WFC parameters.
958        Make SUre PhoneB is able to make MO/MT call.
959        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
960        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
961
962        Returns:
963            True if pass; False if fail.
964        """
965
966        ads = [self.android_devices[0], self.android_devices[1]]
967        mo_result = self._wfc_call_sequence(
968            ads, DIRECTION_MOBILE_ORIGINATED,
969            self._wfc_set_wifi_weak_cell_strong,
970            self._wfc_phone_setup_apm_wifi_only, self._phone_idle_iwlan,
971            self._is_phone_in_call_iwlan, None, True)
972
973        mt_result = self._wfc_call_sequence(
974            ads, DIRECTION_MOBILE_TERMINATED,
975            self._wfc_set_wifi_weak_cell_strong,
976            self._wfc_phone_setup_apm_wifi_only, self._phone_idle_iwlan,
977            self._is_phone_in_call_iwlan, None, True)
978
979        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
980        return ((mo_result is True) and (mt_result is True))
981
982    @test_tracker_info(uuid="00000f11-1749-47e9-a9b3-d67a43f97470")
983    @TelephonyBaseTest.tel_test_wrap
984    def test_call_epdg_wfc_wifi_preferred_wifi_weak_apm(self):
985        """ Test WFC MO MT, WiFI preferred mode, WIFI weak, Phone in APM
986
987        Set WiFi/Cellular network environment.
988        Make Sure PhoneA is set correct WFC parameters.
989        Make SUre PhoneB is able to make MO/MT call.
990        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
991        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
992
993        Returns:
994            True if pass; False if fail.
995        """
996
997        ads = [self.android_devices[0], self.android_devices[1]]
998        mo_result = self._wfc_call_sequence(
999            ads, DIRECTION_MOBILE_ORIGINATED,
1000            self._wfc_set_wifi_weak_cell_strong,
1001            self._wfc_phone_setup_apm_wifi_preferred, self._phone_idle_iwlan,
1002            self._is_phone_in_call_iwlan, None, True)
1003
1004        mt_result = self._wfc_call_sequence(
1005            ads, DIRECTION_MOBILE_TERMINATED,
1006            self._wfc_set_wifi_weak_cell_strong,
1007            self._wfc_phone_setup_apm_wifi_preferred, self._phone_idle_iwlan,
1008            self._is_phone_in_call_iwlan, None, True)
1009
1010        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1011        return ((mo_result is True) and (mt_result is True))
1012
1013    @test_tracker_info(uuid="db3e96f4-bbb6-48f8-9eb6-71f489987f8f")
1014    @TelephonyBaseTest.tel_test_wrap
1015    def test_call_epdg_wfc_cellular_preferred_wifi_weak_apm(self):
1016        """ Test WFC MO MT, cellular preferred mode, WIFI weak, Phone in APM
1017
1018        Set WiFi/Cellular network environment.
1019        Make Sure PhoneA is set correct WFC parameters.
1020        Make SUre PhoneB is able to make MO/MT call.
1021        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1022        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
1023
1024        Returns:
1025            True if pass; False if fail.
1026        """
1027
1028        ads = [self.android_devices[0], self.android_devices[1]]
1029        mo_result = self._wfc_call_sequence(
1030            ads, DIRECTION_MOBILE_ORIGINATED,
1031            self._wfc_set_wifi_weak_cell_strong,
1032            self._wfc_phone_setup_apm_cellular_preferred,
1033            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
1034
1035        mt_result = self._wfc_call_sequence(
1036            ads, DIRECTION_MOBILE_TERMINATED,
1037            self._wfc_set_wifi_weak_cell_strong,
1038            self._wfc_phone_setup_apm_cellular_preferred,
1039            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
1040
1041        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1042        return ((mo_result is True) and (mt_result is True))
1043
1044    @test_tracker_info(uuid="121574c3-4c58-4fd5-abbb-c626c5f777c8")
1045    @TelephonyBaseTest.tel_test_wrap
1046    def test_call_epdg_wfc_wifi_only_wifi_absent_apm(self):
1047        """ Test WFC MO MT, WiFI only mode, WIFI absent, Phone in APM
1048
1049        Set WiFi/Cellular network environment.
1050        Make Sure PhoneA is set correct WFC parameters.
1051        Make SUre PhoneB is able to make MO/MT call.
1052        Call from PhoneA to PhoneB, call should fail.
1053        Call from PhoneB to PHoneA, call should fail.
1054
1055        Returns:
1056            True if pass; False if fail.
1057        """
1058        ads = [self.android_devices[0], self.android_devices[1]]
1059        mo_result = self._wfc_call_sequence(
1060            ads, DIRECTION_MOBILE_ORIGINATED,
1061            self._wfc_set_wifi_absent_cell_strong,
1062            self._wfc_phone_setup_apm_wifi_absent_wifi_only,
1063            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1064            "initiate_call fail.")
1065
1066        mt_result = self._wfc_call_sequence(
1067            ads, DIRECTION_MOBILE_TERMINATED,
1068            self._wfc_set_wifi_absent_cell_strong,
1069            self._wfc_phone_setup_apm_wifi_absent_wifi_only,
1070            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1071            "wait_and_answer_call fail.")
1072
1073        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1074        return ((mo_result is True) and (mt_result is True))
1075
1076    @test_tracker_info(uuid="bccff410-ada3-407a-8b50-c84b0064bd8a")
1077    @TelephonyBaseTest.tel_test_wrap
1078    def test_call_epdg_wfc_wifi_preferred_wifi_absent_apm(self):
1079        """ Test WFC MO MT, WiFI preferred mode, WIFI absent, Phone in APM
1080
1081        Set WiFi/Cellular network environment.
1082        Make Sure PhoneA is set correct WFC parameters.
1083        Make SUre PhoneB is able to make MO/MT call.
1084        Call from PhoneA to PhoneB, call should fail.
1085        Call from PhoneB to PHoneA, call should fail.
1086
1087        Returns:
1088            True if pass; False if fail.
1089        """
1090        ads = [self.android_devices[0], self.android_devices[1]]
1091        mo_result = self._wfc_call_sequence(
1092            ads, DIRECTION_MOBILE_ORIGINATED,
1093            self._wfc_set_wifi_absent_cell_strong,
1094            self._wfc_phone_setup_apm_wifi_absent_wifi_preferred,
1095            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1096            "initiate_call fail.")
1097
1098        mt_result = self._wfc_call_sequence(
1099            ads, DIRECTION_MOBILE_TERMINATED,
1100            self._wfc_set_wifi_absent_cell_strong,
1101            self._wfc_phone_setup_apm_wifi_absent_wifi_preferred,
1102            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1103            "wait_and_answer_call fail.")
1104
1105        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1106        return ((mo_result is True) and (mt_result is True))
1107
1108    @test_tracker_info(uuid="a9722c73-5b6e-46d0-962c-e612df84b7b7")
1109    @TelephonyBaseTest.tel_test_wrap
1110    def test_call_epdg_wfc_cellular_preferred_wifi_absent_apm(self):
1111        """ Test WFC MO MT, cellular preferred mode, WIFI absent, Phone in APM
1112
1113        Set WiFi/Cellular network environment.
1114        Make Sure PhoneA is set correct WFC parameters.
1115        Make SUre PhoneB is able to make MO/MT call.
1116        Call from PhoneA to PhoneB, call should fail.
1117        Call from PhoneB to PHoneA, call should fail.
1118
1119        Returns:
1120            True if pass; False if fail.
1121        """
1122        ads = [self.android_devices[0], self.android_devices[1]]
1123        mo_result = self._wfc_call_sequence(
1124            ads, DIRECTION_MOBILE_ORIGINATED,
1125            self._wfc_set_wifi_absent_cell_strong,
1126            self._wfc_phone_setup_apm_wifi_absent_cellular_preferred,
1127            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1128            "initiate_call fail.")
1129
1130        mt_result = self._wfc_call_sequence(
1131            ads, DIRECTION_MOBILE_TERMINATED,
1132            self._wfc_set_wifi_absent_cell_strong,
1133            self._wfc_phone_setup_apm_wifi_absent_cellular_preferred,
1134            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1135            "wait_and_answer_call fail.")
1136
1137        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1138        return ((mo_result is True) and (mt_result is True))
1139
1140    @test_tracker_info(uuid="6ed1be09-b825-43a4-8317-822070023329")
1141    @TelephonyBaseTest.tel_test_wrap
1142    def test_call_epdg_wfc_wifi_only_wifi_disabled_apm(self):
1143        """ Test WFC MO MT, WiFI only mode, WIFI disabled, Phone in APM
1144
1145        Set WiFi/Cellular network environment.
1146        Make Sure PhoneA is set correct WFC parameters.
1147        Make SUre PhoneB is able to make MO/MT call.
1148        Call from PhoneA to PhoneB, call should fail.
1149        Call from PhoneB to PHoneA, call should fail.
1150
1151        Returns:
1152            True if pass; False if fail.
1153        """
1154        ads = [self.android_devices[0], self.android_devices[1]]
1155        mo_result = self._wfc_call_sequence(
1156            ads, DIRECTION_MOBILE_ORIGINATED,
1157            self._wfc_set_wifi_strong_cell_strong,
1158            self._wfc_phone_setup_apm_wifi_disabled_wifi_only,
1159            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1160            "initiate_call fail.")
1161
1162        mt_result = self._wfc_call_sequence(
1163            ads, DIRECTION_MOBILE_TERMINATED,
1164            self._wfc_set_wifi_strong_cell_strong,
1165            self._wfc_phone_setup_apm_wifi_disabled_wifi_only,
1166            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1167            "wait_and_answer_call fail.")
1168
1169        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1170        return ((mo_result is True) and (mt_result is True))
1171
1172    @test_tracker_info(uuid="c4059ea2-732c-4a22-943c-f19ad65d5fe9")
1173    @TelephonyBaseTest.tel_test_wrap
1174    def test_call_epdg_wfc_wifi_preferred_wifi_disabled_apm(self):
1175        """ Test WFC MO MT, WiFI preferred mode, WIFI disabled, Phone in APM
1176
1177        Set WiFi/Cellular network environment.
1178        Make Sure PhoneA is set correct WFC parameters.
1179        Make SUre PhoneB is able to make MO/MT call.
1180        Call from PhoneA to PhoneB, call should fail.
1181        Call from PhoneB to PHoneA, call should fail.
1182
1183        Returns:
1184            True if pass; False if fail.
1185        """
1186        ads = [self.android_devices[0], self.android_devices[1]]
1187        mo_result = self._wfc_call_sequence(
1188            ads, DIRECTION_MOBILE_ORIGINATED,
1189            self._wfc_set_wifi_strong_cell_strong,
1190            self._wfc_phone_setup_apm_wifi_disabled_wifi_preferred,
1191            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1192            "initiate_call fail.")
1193
1194        mt_result = self._wfc_call_sequence(
1195            ads, DIRECTION_MOBILE_TERMINATED,
1196            self._wfc_set_wifi_strong_cell_strong,
1197            self._wfc_phone_setup_apm_wifi_disabled_wifi_preferred,
1198            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1199            "wait_and_answer_call fail.")
1200
1201        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1202        return ((mo_result is True) and (mt_result is True))
1203
1204    @test_tracker_info(uuid="a4c000a1-b3cd-4fe2-8d82-d857fb3b2d62")
1205    @TelephonyBaseTest.tel_test_wrap
1206    def test_call_epdg_wfc_cellular_preferred_wifi_disabled_apm(self):
1207        """ Test WFC MO MT, cellular preferred mode, WIFI disabled, Phone in APM
1208
1209        Set WiFi/Cellular network environment.
1210        Make Sure PhoneA is set correct WFC parameters.
1211        Make SUre PhoneB is able to make MO/MT call.
1212        Call from PhoneA to PhoneB, call should fail.
1213        Call from PhoneB to PHoneA, call should fail.
1214
1215        Returns:
1216            True if pass; False if fail.
1217        """
1218        ads = [self.android_devices[0], self.android_devices[1]]
1219        mo_result = self._wfc_call_sequence(
1220            ads, DIRECTION_MOBILE_ORIGINATED,
1221            self._wfc_set_wifi_strong_cell_strong,
1222            self._wfc_phone_setup_apm_wifi_disabled_cellular_preferred,
1223            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1224            "initiate_call fail.")
1225
1226        mt_result = self._wfc_call_sequence(
1227            ads, DIRECTION_MOBILE_TERMINATED,
1228            self._wfc_set_wifi_strong_cell_strong,
1229            self._wfc_phone_setup_apm_wifi_disabled_cellular_preferred,
1230            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1231            "wait_and_answer_call fail.")
1232
1233        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1234        return ((mo_result is True) and (mt_result is True))
1235
1236    @test_tracker_info(uuid="d37909d3-40b4-4989-a444-fca60bd355cf")
1237    @TelephonyBaseTest.tel_test_wrap
1238    def test_call_epdg_wfc_wifi_only_wifi_strong_cellular_strong(self):
1239        """ Test WFC MO MT, WiFI only mode, WIFI strong, Cellular strong
1240
1241        Set WiFi/Cellular network environment.
1242        Make Sure PhoneA is set correct WFC parameters.
1243        Make SUre PhoneB is able to make MO/MT call.
1244        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1245        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
1246
1247        Returns:
1248            True if pass; False if fail.
1249        """
1250        ads = [self.android_devices[0], self.android_devices[1]]
1251        mo_result = self._wfc_call_sequence(
1252            ads, DIRECTION_MOBILE_ORIGINATED,
1253            self._wfc_set_wifi_strong_cell_strong,
1254            self._wfc_phone_setup_wifi_only, self._phone_idle_iwlan,
1255            self._is_phone_in_call_iwlan, None, True)
1256
1257        mt_result = self._wfc_call_sequence(
1258            ads, DIRECTION_MOBILE_TERMINATED,
1259            self._wfc_set_wifi_strong_cell_strong,
1260            self._wfc_phone_setup_wifi_only, self._phone_idle_iwlan,
1261            self._is_phone_in_call_iwlan, None, True)
1262
1263        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1264        return ((mo_result is True) and (mt_result is True))
1265
1266    @test_tracker_info(uuid="bba0d159-ec45-43ea-9c1f-94f6e3a0cff8")
1267    @TelephonyBaseTest.tel_test_wrap
1268    def test_call_epdg_wfc_wifi_preferred_wifi_strong_cellular_strong(self):
1269        """ Test WFC MO MT, WiFI preferred mode, WIFI strong, Cellular strong
1270
1271        Set WiFi/Cellular network environment.
1272        Make Sure PhoneA is set correct WFC parameters.
1273        Make SUre PhoneB is able to make MO/MT call.
1274        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1275        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
1276
1277        Returns:
1278            True if pass; False if fail.
1279        """
1280        ads = [self.android_devices[0], self.android_devices[1]]
1281        mo_result = self._wfc_call_sequence(
1282            ads, DIRECTION_MOBILE_ORIGINATED,
1283            self._wfc_set_wifi_strong_cell_strong,
1284            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
1285            self._is_phone_in_call_iwlan, None, True)
1286
1287        mt_result = self._wfc_call_sequence(
1288            ads, DIRECTION_MOBILE_TERMINATED,
1289            self._wfc_set_wifi_strong_cell_strong,
1290            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
1291            self._is_phone_in_call_iwlan, None, True)
1292
1293        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1294        return ((mo_result is True) and (mt_result is True))
1295
1296    @test_tracker_info(uuid="39d6808c-37f3-4ae1-babb-2218a4827da9")
1297    @TelephonyBaseTest.tel_test_wrap
1298    def test_call_epdg_wfc_cellular_preferred_wifi_strong_cellular_strong(
1299            self):
1300        """ Test WFC MO MT, cellular preferred mode, WIFI strong, Cellular strong
1301
1302        Set WiFi/Cellular network environment.
1303        Make Sure PhoneA is set correct WFC parameters.
1304        Make SUre PhoneB is able to make MO/MT call.
1305        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1306        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
1307
1308        Returns:
1309            True if pass; False if fail.
1310        """
1311        ads = [self.android_devices[0], self.android_devices[1]]
1312        mo_result = self._wfc_call_sequence(
1313            ads, DIRECTION_MOBILE_ORIGINATED,
1314            self._wfc_set_wifi_strong_cell_strong,
1315            self._wfc_phone_setup_cellular_preferred,
1316            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1317            True)
1318
1319        mt_result = self._wfc_call_sequence(
1320            ads, DIRECTION_MOBILE_TERMINATED,
1321            self._wfc_set_wifi_strong_cell_strong,
1322            self._wfc_phone_setup_cellular_preferred,
1323            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1324            True)
1325
1326        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1327        return ((mo_result is True) and (mt_result is True))
1328
1329    @test_tracker_info(uuid="ccc4973b-254f-4f12-a101-324c17e114d1")
1330    @TelephonyBaseTest.tel_test_wrap
1331    def test_call_epdg_wfc_wifi_only_wifi_weak_cellular_strong(self):
1332        """ Test WFC MO MT, WiFI only mode, WIFI weak, Cellular strong
1333
1334        Set WiFi/Cellular network environment.
1335        Make Sure PhoneA is set correct WFC parameters.
1336        Make SUre PhoneB is able to make MO/MT call.
1337        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1338        Call from PhoneB to PHoneA, call should succeed, call should on WiFi.
1339
1340        Returns:
1341            True if pass; False if fail.
1342        """
1343        ads = [self.android_devices[0], self.android_devices[1]]
1344        mo_result = self._wfc_call_sequence(
1345            ads, DIRECTION_MOBILE_ORIGINATED,
1346            self._wfc_set_wifi_weak_cell_strong,
1347            self._wfc_phone_setup_wifi_only, self._phone_idle_iwlan,
1348            self._is_phone_in_call_iwlan, None, True)
1349
1350        mt_result = self._wfc_call_sequence(
1351            ads, DIRECTION_MOBILE_TERMINATED,
1352            self._wfc_set_wifi_weak_cell_strong,
1353            self._wfc_phone_setup_wifi_only, self._phone_idle_iwlan,
1354            self._is_phone_in_call_iwlan, None, True)
1355
1356        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1357        return ((mo_result is True) and (mt_result is True))
1358
1359    @test_tracker_info(uuid="cdbfca5e-06a3-4fd4-87a7-cc8028335c94")
1360    @TelephonyBaseTest.tel_test_wrap
1361    def test_call_epdg_wfc_wifi_preferred_wifi_weak_cellular_strong(self):
1362        """ Test WFC MO MT, WiFI preferred mode, WIFI weak, Cellular strong
1363
1364        Set WiFi/Cellular network environment.
1365        Make Sure PhoneA is set correct WFC parameters.
1366        Make SUre PhoneB is able to make MO/MT call.
1367        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1368        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
1369
1370        Returns:
1371            True if pass; False if fail.
1372        """
1373        ads = [self.android_devices[0], self.android_devices[1]]
1374        mo_result = self._wfc_call_sequence(
1375            ads, DIRECTION_MOBILE_ORIGINATED,
1376            self._wfc_set_wifi_weak_cell_strong,
1377            self._wfc_phone_setup_wifi_preferred, self._phone_idle_not_iwlan,
1378            self._is_phone_in_call_not_iwlan, None, True)
1379
1380        mt_result = self._wfc_call_sequence(
1381            ads, DIRECTION_MOBILE_TERMINATED,
1382            self._wfc_set_wifi_weak_cell_strong,
1383            self._wfc_phone_setup_wifi_preferred, self._phone_idle_not_iwlan,
1384            self._is_phone_in_call_not_iwlan, None, True)
1385
1386        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1387        return ((mo_result is True) and (mt_result is True))
1388
1389    @test_tracker_info(uuid="dbcbc77a-8551-4a40-88c3-3493d7c4d506")
1390    @TelephonyBaseTest.tel_test_wrap
1391    def test_call_epdg_wfc_cellular_preferred_wifi_weak_cellular_strong(self):
1392        """ Test WFC MO MT, cellular preferred mode, WIFI strong, Cellular strong
1393
1394        Set WiFi/Cellular network environment.
1395        Make Sure PhoneA is set correct WFC parameters.
1396        Make SUre PhoneB is able to make MO/MT call.
1397        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1398        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
1399
1400        Returns:
1401            True if pass; False if fail.
1402        """
1403        ads = [self.android_devices[0], self.android_devices[1]]
1404        mo_result = self._wfc_call_sequence(
1405            ads, DIRECTION_MOBILE_ORIGINATED,
1406            self._wfc_set_wifi_weak_cell_strong,
1407            self._wfc_phone_setup_cellular_preferred,
1408            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1409            True)
1410
1411        mt_result = self._wfc_call_sequence(
1412            ads, DIRECTION_MOBILE_TERMINATED,
1413            self._wfc_set_wifi_weak_cell_strong,
1414            self._wfc_phone_setup_cellular_preferred,
1415            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1416            True)
1417
1418        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1419        return ((mo_result is True) and (mt_result is True))
1420
1421    @test_tracker_info(uuid="2a52dbf7-b63b-42d9-8406-09d168878041")
1422    @TelephonyBaseTest.tel_test_wrap
1423    def test_call_epdg_wfc_wifi_only_wifi_absent_cellular_strong(self):
1424        """ Test WFC MO MT, WiFI only mode, WIFI absent, Cellular strong
1425
1426        Set WiFi/Cellular network environment.
1427        Make Sure PhoneA is set correct WFC parameters.
1428        Make SUre PhoneB is able to make MO/MT call.
1429        Call from PhoneA to PhoneB, call should fail.
1430        Call from PhoneB to PHoneA, call should fail.
1431
1432        Returns:
1433            True if pass; False if fail.
1434        """
1435        ads = [self.android_devices[0], self.android_devices[1]]
1436        mo_result = self._wfc_call_sequence(
1437            ads, DIRECTION_MOBILE_ORIGINATED,
1438            self._wfc_set_wifi_absent_cell_strong,
1439            self._wfc_phone_setup_wifi_absent_wifi_only,
1440            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1441            "initiate_call fail.")
1442
1443        mt_result = self._wfc_call_sequence(
1444            ads, DIRECTION_MOBILE_TERMINATED,
1445            self._wfc_set_wifi_absent_cell_strong,
1446            self._wfc_phone_setup_wifi_absent_wifi_only,
1447            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1448            "wait_and_answer_call fail.")
1449
1450        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1451        return ((mo_result is True) and (mt_result is True))
1452
1453    @test_tracker_info(uuid="31ae1aee-977c-45ec-abfc-24121fcd2fe9")
1454    @TelephonyBaseTest.tel_test_wrap
1455    def test_call_epdg_wfc_wifi_preferred_wifi_absent_cellular_strong(self):
1456        """ Test WFC MO MT, WiFI preferred mode, WIFI absent, Cellular strong
1457
1458        Set WiFi/Cellular network environment.
1459        Make Sure PhoneA is set correct WFC parameters.
1460        Make SUre PhoneB is able to make MO/MT call.
1461        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1462        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
1463
1464        Returns:
1465            True if pass; False if fail.
1466        """
1467        ads = [self.android_devices[0], self.android_devices[1]]
1468        mo_result = self._wfc_call_sequence(
1469            ads, DIRECTION_MOBILE_ORIGINATED,
1470            self._wfc_set_wifi_absent_cell_strong,
1471            self._wfc_phone_setup_wifi_absent_wifi_preferred,
1472            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1473            True)
1474
1475        mt_result = self._wfc_call_sequence(
1476            ads, DIRECTION_MOBILE_TERMINATED,
1477            self._wfc_set_wifi_absent_cell_strong,
1478            self._wfc_phone_setup_wifi_absent_wifi_preferred,
1479            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1480            True)
1481
1482        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1483        return ((mo_result is True) and (mt_result is True))
1484
1485    @test_tracker_info(uuid="314bf912-0fef-4047-bdeb-5cae2e89bbe6")
1486    @TelephonyBaseTest.tel_test_wrap
1487    def test_call_epdg_wfc_cellular_preferred_wifi_absent_cellular_strong(
1488            self):
1489        """ Test WFC MO MT, cellular preferred mode, WIFI absent, Cellular strong
1490
1491        Set WiFi/Cellular network environment.
1492        Make Sure PhoneA is set correct WFC parameters.
1493        Make SUre PhoneB is able to make MO/MT call.
1494        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1495        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
1496
1497        Returns:
1498            True if pass; False if fail.
1499        """
1500        ads = [self.android_devices[0], self.android_devices[1]]
1501        mo_result = self._wfc_call_sequence(
1502            ads, DIRECTION_MOBILE_ORIGINATED,
1503            self._wfc_set_wifi_absent_cell_strong,
1504            self._wfc_phone_setup_wifi_absent_cellular_preferred,
1505            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1506            True)
1507
1508        mt_result = self._wfc_call_sequence(
1509            ads, DIRECTION_MOBILE_TERMINATED,
1510            self._wfc_set_wifi_absent_cell_strong,
1511            self._wfc_phone_setup_wifi_absent_cellular_preferred,
1512            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1513            True)
1514
1515        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1516        return ((mo_result is True) and (mt_result is True))
1517
1518    @test_tracker_info(uuid="27516aa7-0f28-4cf6-9562-4f0ad7378f64")
1519    @TelephonyBaseTest.tel_test_wrap
1520    def test_call_epdg_wfc_wifi_only_wifi_disabled_cellular_strong(self):
1521        """ Test WFC MO MT, WiFI only mode, WIFI disabled, Cellular strong
1522
1523        Set WiFi/Cellular network environment.
1524        Make Sure PhoneA is set correct WFC parameters.
1525        Make SUre PhoneB is able to make MO/MT call.
1526        Call from PhoneA to PhoneB, call should fail.
1527        Call from PhoneB to PHoneA, call should fail.
1528
1529        Returns:
1530            True if pass; False if fail.
1531        """
1532        ads = [self.android_devices[0], self.android_devices[1]]
1533        mo_result = self._wfc_call_sequence(
1534            ads, DIRECTION_MOBILE_ORIGINATED,
1535            self._wfc_set_wifi_strong_cell_strong,
1536            self._wfc_phone_setup_wifi_disabled_wifi_only,
1537            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1538            "initiate_call fail.")
1539
1540        mt_result = self._wfc_call_sequence(
1541            ads, DIRECTION_MOBILE_TERMINATED,
1542            self._wfc_set_wifi_strong_cell_strong,
1543            self._wfc_phone_setup_wifi_disabled_wifi_only,
1544            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1545            "wait_and_answer_call fail.")
1546
1547        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1548        return ((mo_result is True) and (mt_result is True))
1549
1550    @test_tracker_info(uuid="e031a0f4-6896-454a-af70-8472a9805432")
1551    @TelephonyBaseTest.tel_test_wrap
1552    def test_call_epdg_wfc_wifi_preferred_wifi_disabled_cellular_strong(self):
1553        """ Test WFC MO MT, WiFI preferred mode, WIFI disabled, Cellular strong
1554
1555        Set WiFi/Cellular network environment.
1556        Make Sure PhoneA is set correct WFC parameters.
1557        Make SUre PhoneB is able to make MO/MT call.
1558        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1559        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
1560
1561        Returns:
1562            True if pass; False if fail.
1563        """
1564        ads = [self.android_devices[0], self.android_devices[1]]
1565        mo_result = self._wfc_call_sequence(
1566            ads, DIRECTION_MOBILE_ORIGINATED,
1567            self._wfc_set_wifi_strong_cell_strong,
1568            self._wfc_phone_setup_wifi_disabled_wifi_preferred,
1569            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1570            True)
1571
1572        mt_result = self._wfc_call_sequence(
1573            ads, DIRECTION_MOBILE_TERMINATED,
1574            self._wfc_set_wifi_strong_cell_strong,
1575            self._wfc_phone_setup_wifi_disabled_wifi_preferred,
1576            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1577            True)
1578
1579        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1580        return ((mo_result is True) and (mt_result is True))
1581
1582    @test_tracker_info(uuid="1aff2cb3-fcbe-425e-be46-2cd693b1d239")
1583    @TelephonyBaseTest.tel_test_wrap
1584    def test_call_epdg_wfc_cellular_preferred_wifi_disabled_cellular_strong(
1585            self):
1586        """ Test WFC MO MT, cellular preferred mode, WIFI disabled, Cellular strong
1587
1588        Set WiFi/Cellular network environment.
1589        Make Sure PhoneA is set correct WFC parameters.
1590        Make SUre PhoneB is able to make MO/MT call.
1591        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1592        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
1593
1594        Returns:
1595            True if pass; False if fail.
1596        """
1597        ads = [self.android_devices[0], self.android_devices[1]]
1598        mo_result = self._wfc_call_sequence(
1599            ads, DIRECTION_MOBILE_ORIGINATED,
1600            self._wfc_set_wifi_strong_cell_strong,
1601            self._wfc_phone_setup_wifi_disabled_cellular_preferred,
1602            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1603            True)
1604
1605        mt_result = self._wfc_call_sequence(
1606            ads, DIRECTION_MOBILE_TERMINATED,
1607            self._wfc_set_wifi_strong_cell_strong,
1608            self._wfc_phone_setup_wifi_disabled_cellular_preferred,
1609            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1610            True)
1611
1612        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1613        return ((mo_result is True) and (mt_result is True))
1614
1615    @test_tracker_info(uuid="fb24722e-3c11-4443-a65e-3bc64cff55ef")
1616    @TelephonyBaseTest.tel_test_wrap
1617    def test_call_epdg_wfc_wifi_only_wifi_strong_cellular_weak(self):
1618        """ Test WFC MO MT, WiFI only mode, WIFI strong, Cellular weak
1619
1620        Set WiFi/Cellular network environment.
1621        Make Sure PhoneA is set correct WFC parameters.
1622        Make SUre PhoneB is able to make MO/MT call.
1623        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1624        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
1625
1626        Returns:
1627            True if pass; False if fail.
1628        """
1629        ads = [self.android_devices[0], self.android_devices[1]]
1630        mo_result = self._wfc_call_sequence(
1631            ads, DIRECTION_MOBILE_ORIGINATED,
1632            self._wfc_set_wifi_strong_cell_weak,
1633            self._wfc_phone_setup_wifi_only, self._phone_idle_iwlan,
1634            self._is_phone_in_call_iwlan, None, True)
1635
1636        mt_result = self._wfc_call_sequence(
1637            ads, DIRECTION_MOBILE_TERMINATED,
1638            self._wfc_set_wifi_strong_cell_weak,
1639            self._wfc_phone_setup_wifi_only, self._phone_idle_iwlan,
1640            self._is_phone_in_call_iwlan, None, True)
1641
1642        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1643        return ((mo_result is True) and (mt_result is True))
1644
1645    @test_tracker_info(uuid="5b649c6d-1fa2-4044-b487-79cb897a803f")
1646    @TelephonyBaseTest.tel_test_wrap
1647    def test_call_epdg_wfc_wifi_preferred_wifi_strong_cellular_weak(self):
1648        """ Test WFC MO MT, WiFI preferred mode, WIFI strong, Cellular weak
1649
1650        Set WiFi/Cellular network environment.
1651        Make Sure PhoneA is set correct WFC parameters.
1652        Make SUre PhoneB is able to make MO/MT call.
1653        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1654        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
1655
1656        Returns:
1657            True if pass; False if fail.
1658        """
1659        ads = [self.android_devices[0], self.android_devices[1]]
1660        mo_result = self._wfc_call_sequence(
1661            ads, DIRECTION_MOBILE_ORIGINATED,
1662            self._wfc_set_wifi_strong_cell_weak,
1663            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
1664            self._is_phone_in_call_iwlan, None, True)
1665
1666        mt_result = self._wfc_call_sequence(
1667            ads, DIRECTION_MOBILE_TERMINATED,
1668            self._wfc_set_wifi_strong_cell_weak,
1669            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
1670            self._is_phone_in_call_iwlan, None, True)
1671
1672        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1673        return ((mo_result is True) and (mt_result is True))
1674
1675    @test_tracker_info(uuid="225cc438-620f-45c4-9682-ae5f13c81b03")
1676    @TelephonyBaseTest.tel_test_wrap
1677    def test_call_epdg_wfc_cellular_preferred_wifi_strong_cellular_weak(self):
1678        """ Test WFC MO MT, cellular preferred mode, WIFI strong, Cellular weak
1679
1680        Set WiFi/Cellular network environment.
1681        Make Sure PhoneA is set correct WFC parameters.
1682        Make SUre PhoneB is able to make MO/MT call.
1683        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1684        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
1685
1686        Returns:
1687            True if pass; False if fail.
1688        """
1689        ads = [self.android_devices[0], self.android_devices[1]]
1690        mo_result = self._wfc_call_sequence(
1691            ads, DIRECTION_MOBILE_ORIGINATED,
1692            self._wfc_set_wifi_strong_cell_weak,
1693            self._wfc_phone_setup_cellular_preferred, self._phone_idle_iwlan,
1694            self._is_phone_in_call_iwlan, None, True)
1695
1696        mt_result = self._wfc_call_sequence(
1697            ads, DIRECTION_MOBILE_TERMINATED,
1698            self._wfc_set_wifi_strong_cell_weak,
1699            self._wfc_phone_setup_cellular_preferred, self._phone_idle_iwlan,
1700            self._is_phone_in_call_iwlan, None, True)
1701
1702        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1703        return ((mo_result is True) and (mt_result is True))
1704
1705    @test_tracker_info(uuid="837de903-06f2-4a60-a623-b3478a5d6639")
1706    @TelephonyBaseTest.tel_test_wrap
1707    def test_call_epdg_wfc_wifi_only_wifi_weak_cellular_weak(self):
1708        """ Test WFC MO MT, WiFI only mode, WIFI weak, Cellular weak
1709
1710        Set WiFi/Cellular network environment.
1711        Make Sure PhoneA is set correct WFC parameters.
1712        Make SUre PhoneB is able to make MO/MT call.
1713        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1714        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
1715
1716        Returns:
1717            True if pass; False if fail.
1718        """
1719        ads = [self.android_devices[0], self.android_devices[1]]
1720        mo_result = self._wfc_call_sequence(
1721            ads, DIRECTION_MOBILE_ORIGINATED,
1722            self._wfc_set_wifi_weak_cell_weak, self._wfc_phone_setup_wifi_only,
1723            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
1724
1725        mt_result = self._wfc_call_sequence(
1726            ads, DIRECTION_MOBILE_TERMINATED,
1727            self._wfc_set_wifi_weak_cell_weak, self._wfc_phone_setup_wifi_only,
1728            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
1729
1730        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1731        return ((mo_result is True) and (mt_result is True))
1732
1733    @test_tracker_info(uuid="57f70488-19ec-4ca9-9837-e6acec2494ae")
1734    @TelephonyBaseTest.tel_test_wrap
1735    def test_call_epdg_wfc_wifi_preferred_wifi_weak_cellular_weak(self):
1736        """ Test WFC MO MT, WiFI preferred mode, WIFI weak, Cellular weak
1737
1738        Set WiFi/Cellular network environment.
1739        Make Sure PhoneA is set correct WFC parameters.
1740        Make SUre PhoneB is able to make MO/MT call.
1741        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1742        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
1743
1744        Returns:
1745            True if pass; False if fail.
1746        """
1747        ads = [self.android_devices[0], self.android_devices[1]]
1748        mo_result = self._wfc_call_sequence(
1749            ads, DIRECTION_MOBILE_ORIGINATED,
1750            self._wfc_set_wifi_weak_cell_weak,
1751            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
1752            self._is_phone_in_call_iwlan, None, True)
1753
1754        mt_result = self._wfc_call_sequence(
1755            ads, DIRECTION_MOBILE_TERMINATED,
1756            self._wfc_set_wifi_weak_cell_weak,
1757            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
1758            self._is_phone_in_call_iwlan, None, True)
1759
1760        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1761        return ((mo_result is True) and (mt_result is True))
1762
1763    @test_tracker_info(uuid="845a62ba-3457-42ed-8a74-0f7fdde44011")
1764    @TelephonyBaseTest.tel_test_wrap
1765    def test_call_epdg_wfc_cellular_preferred_wifi_weak_cellular_weak(self):
1766        """ Test WFC MO MT, cellular preferred mode, WIFI weak, Cellular weak
1767
1768        Set WiFi/Cellular network environment.
1769        Make Sure PhoneA is set correct WFC parameters.
1770        Make SUre PhoneB is able to make MO/MT call.
1771        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1772        Call from PhoneB to PhoneA, call should succeed, call should on Cellular.
1773
1774        Returns:
1775            True if pass; False if fail.
1776        """
1777        ads = [self.android_devices[0], self.android_devices[1]]
1778        mo_result = self._wfc_call_sequence(
1779            ads, DIRECTION_MOBILE_ORIGINATED,
1780            self._wfc_set_wifi_weak_cell_weak,
1781            self._wfc_phone_setup_cellular_preferred,
1782            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1783            True)
1784
1785        mt_result = self._wfc_call_sequence(
1786            ads, DIRECTION_MOBILE_TERMINATED,
1787            self._wfc_set_wifi_weak_cell_weak,
1788            self._wfc_phone_setup_cellular_preferred,
1789            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1790            True)
1791
1792        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1793        return ((mo_result is True) and (mt_result is True))
1794
1795    @test_tracker_info(uuid="298f92e5-c509-42d7-bd85-d29337e391df")
1796    @TelephonyBaseTest.tel_test_wrap
1797    def test_call_epdg_wfc_wifi_only_wifi_absent_cellular_weak(self):
1798        """ Test WFC MO MT, WiFI only mode, WIFI absent, Cellular weak
1799
1800        Set WiFi/Cellular network environment.
1801        Make Sure PhoneA is set correct WFC parameters.
1802        Make SUre PhoneB is able to make MO/MT call.
1803        Call from PhoneA to PhoneB, call should fail.
1804        Call from PhoneB to PhoneA, call should fail.
1805
1806        Returns:
1807            True if pass; False if fail.
1808        """
1809        ads = [self.android_devices[0], self.android_devices[1]]
1810        mo_result = self._wfc_call_sequence(
1811            ads, DIRECTION_MOBILE_ORIGINATED,
1812            self._wfc_set_wifi_absent_cell_weak,
1813            self._wfc_phone_setup_wifi_absent_wifi_only,
1814            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1815            "initiate_call fail.")
1816
1817        mt_result = self._wfc_call_sequence(
1818            ads, DIRECTION_MOBILE_TERMINATED,
1819            self._wfc_set_wifi_absent_cell_weak,
1820            self._wfc_phone_setup_wifi_absent_wifi_only,
1821            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1822            "wait_and_answer_call fail.")
1823
1824        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1825        return ((mo_result is True) and (mt_result is True))
1826
1827    @test_tracker_info(uuid="845278c5-1442-4a3a-93cd-c661190a5574")
1828    @TelephonyBaseTest.tel_test_wrap
1829    def test_call_epdg_wfc_wifi_preferred_wifi_absent_cellular_weak(self):
1830        """ Test WFC MO MT, WiFI preferred mode, WIFI absent, Cellular weak
1831
1832        Set WiFi/Cellular network environment.
1833        Make Sure PhoneA is set correct WFC parameters.
1834        Make SUre PhoneB is able to make MO/MT call.
1835        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1836        Call from PhoneB to PhoneA, call should succeed, call should on Cellular.
1837
1838        Returns:
1839            True if pass; False if fail.
1840        """
1841        ads = [self.android_devices[0], self.android_devices[1]]
1842        mo_result = self._wfc_call_sequence(
1843            ads, DIRECTION_MOBILE_ORIGINATED,
1844            self._wfc_set_wifi_absent_cell_weak,
1845            self._wfc_phone_setup_wifi_absent_wifi_preferred,
1846            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1847            True)
1848
1849        mt_result = self._wfc_call_sequence(
1850            ads, DIRECTION_MOBILE_TERMINATED,
1851            self._wfc_set_wifi_absent_cell_weak,
1852            self._wfc_phone_setup_wifi_absent_wifi_preferred,
1853            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1854            True)
1855
1856        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1857        return ((mo_result is True) and (mt_result is True))
1858
1859    @test_tracker_info(uuid="63319009-aaef-424a-bfb1-da56d3f9a2b2")
1860    @TelephonyBaseTest.tel_test_wrap
1861    def test_call_epdg_wfc_cellular_preferred_wifi_absent_cellular_weak(self):
1862        """ Test WFC MO MT, cellular preferred mode, WIFI absent, Cellular weak
1863
1864        Set WiFi/Cellular network environment.
1865        Make Sure PhoneA is set correct WFC parameters.
1866        Make SUre PhoneB is able to make MO/MT call.
1867        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1868        Call from PhoneB to PhoneA, call should succeed, call should on Cellular.
1869
1870        Returns:
1871            True if pass; False if fail.
1872        """
1873        ads = [self.android_devices[0], self.android_devices[1]]
1874        mo_result = self._wfc_call_sequence(
1875            ads, DIRECTION_MOBILE_ORIGINATED,
1876            self._wfc_set_wifi_absent_cell_weak,
1877            self._wfc_phone_setup_wifi_absent_cellular_preferred,
1878            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1879            True)
1880
1881        mt_result = self._wfc_call_sequence(
1882            ads, DIRECTION_MOBILE_TERMINATED,
1883            self._wfc_set_wifi_absent_cell_weak,
1884            self._wfc_phone_setup_wifi_absent_cellular_preferred,
1885            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1886            True)
1887
1888        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1889        return ((mo_result is True) and (mt_result is True))
1890
1891    @test_tracker_info(uuid="ff3f474c-5d7a-4440-b2d4-a99ccb5d2dd7")
1892    @TelephonyBaseTest.tel_test_wrap
1893    def test_call_epdg_wfc_wifi_only_wifi_disabled_cellular_weak(self):
1894        """ Test WFC MO MT, WiFI only mode, WIFI disabled, Cellular weak
1895
1896        Set WiFi/Cellular network environment.
1897        Make Sure PhoneA is set correct WFC parameters.
1898        Make SUre PhoneB is able to make MO/MT call.
1899        Call from PhoneA to PhoneB, call should fail.
1900        Call from PhoneB to PhoneA, call should fail.
1901
1902        Returns:
1903            True if pass; False if fail.
1904        """
1905        ads = [self.android_devices[0], self.android_devices[1]]
1906        mo_result = self._wfc_call_sequence(
1907            ads, DIRECTION_MOBILE_ORIGINATED,
1908            self._wfc_set_wifi_strong_cell_weak,
1909            self._wfc_phone_setup_wifi_disabled_wifi_only,
1910            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1911            "initiate_call fail.")
1912
1913        mt_result = self._wfc_call_sequence(
1914            ads, DIRECTION_MOBILE_TERMINATED,
1915            self._wfc_set_wifi_strong_cell_weak,
1916            self._wfc_phone_setup_wifi_disabled_wifi_only,
1917            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
1918            "wait_and_answer_call fail.")
1919
1920        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1921        return ((mo_result is True) and (mt_result is True))
1922
1923    @test_tracker_info(uuid="7ad6d6e3-1113-4304-96fa-961983380207")
1924    @TelephonyBaseTest.tel_test_wrap
1925    def test_call_epdg_wfc_wifi_preferred_wifi_disabled_cellular_weak(self):
1926        """ Test WFC MO MT, WiFI preferred mode, WIFI disabled, Cellular weak
1927
1928        Set WiFi/Cellular network environment.
1929        Make Sure PhoneA is set correct WFC parameters.
1930        Make SUre PhoneB is able to make MO/MT call.
1931        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1932        Call from PhoneB to PhoneA, call should succeed, call should on Cellular.
1933
1934        Returns:
1935            True if pass; False if fail.
1936        """
1937        ads = [self.android_devices[0], self.android_devices[1]]
1938        mo_result = self._wfc_call_sequence(
1939            ads, DIRECTION_MOBILE_ORIGINATED,
1940            self._wfc_set_wifi_strong_cell_weak,
1941            self._wfc_phone_setup_wifi_disabled_wifi_preferred,
1942            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1943            True)
1944
1945        mt_result = self._wfc_call_sequence(
1946            ads, DIRECTION_MOBILE_TERMINATED,
1947            self._wfc_set_wifi_strong_cell_weak,
1948            self._wfc_phone_setup_wifi_disabled_wifi_preferred,
1949            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1950            True)
1951
1952        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1953        return ((mo_result is True) and (mt_result is True))
1954
1955    @test_tracker_info(uuid="3062d062-17f1-4265-8dec-ed75d5d275ee")
1956    @TelephonyBaseTest.tel_test_wrap
1957    def test_call_epdg_wfc_cellular_preferred_wifi_disabled_cellular_weak(
1958            self):
1959        """ Test WFC MO MT, cellular preferred mode, WIFI disabled, Cellular weak
1960
1961        Set WiFi/Cellular network environment.
1962        Make Sure PhoneA is set correct WFC parameters.
1963        Make SUre PhoneB is able to make MO/MT call.
1964        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
1965        Call from PhoneB to PhoneA, call should succeed, call should on Cellular.
1966
1967        Returns:
1968            True if pass; False if fail.
1969        """
1970        ads = [self.android_devices[0], self.android_devices[1]]
1971        mo_result = self._wfc_call_sequence(
1972            ads, DIRECTION_MOBILE_ORIGINATED,
1973            self._wfc_set_wifi_strong_cell_weak,
1974            self._wfc_phone_setup_wifi_disabled_cellular_preferred,
1975            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1976            True)
1977
1978        mt_result = self._wfc_call_sequence(
1979            ads, DIRECTION_MOBILE_TERMINATED,
1980            self._wfc_set_wifi_strong_cell_weak,
1981            self._wfc_phone_setup_wifi_disabled_cellular_preferred,
1982            self._phone_idle_not_iwlan, self._is_phone_in_call_not_iwlan, None,
1983            True)
1984
1985        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
1986        return ((mo_result is True) and (mt_result is True))
1987
1988    @test_tracker_info(uuid="0f40d344-25b4-459e-a21e-79c84bb5db41")
1989    @TelephonyBaseTest.tel_test_wrap
1990    def test_call_epdg_wfc_wifi_only_wifi_strong_cellular_absent(self):
1991        """ Test WFC MO MT, WiFI only mode, WIFI strong, Cellular absent
1992
1993        Set WiFi/Cellular network environment.
1994        Make Sure PhoneA is set correct WFC parameters.
1995        Make SUre PhoneB is able to make MO/MT call.
1996        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
1997        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
1998
1999        Returns:
2000            True if pass; False if fail.
2001        """
2002        ads = [self.android_devices[0], self.android_devices[1]]
2003        mo_result = self._wfc_call_sequence(
2004            ads, DIRECTION_MOBILE_ORIGINATED,
2005            self._wfc_set_wifi_strong_cell_absent,
2006            self._wfc_phone_setup_cellular_absent_wifi_only,
2007            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2008
2009        mt_result = self._wfc_call_sequence(
2010            ads, DIRECTION_MOBILE_TERMINATED,
2011            self._wfc_set_wifi_strong_cell_absent,
2012            self._wfc_phone_setup_cellular_absent_wifi_only,
2013            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2014
2015        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2016        return ((mo_result is True) and (mt_result is True))
2017
2018    @test_tracker_info(uuid="62c0e1c7-9fd7-4d98-87c8-a2d8df69cbd6")
2019    @TelephonyBaseTest.tel_test_wrap
2020    def test_call_epdg_wfc_wifi_preferred_wifi_strong_cellular_absent(self):
2021        """ Test WFC MO MT, WiFI preferred mode, WIFI strong, Cellular absent
2022
2023        Set WiFi/Cellular network environment.
2024        Make Sure PhoneA is set correct WFC parameters.
2025        Make SUre PhoneB is able to make MO/MT call.
2026        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
2027        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
2028
2029        Returns:
2030            True if pass; False if fail.
2031        """
2032        ads = [self.android_devices[0], self.android_devices[1]]
2033        mo_result = self._wfc_call_sequence(
2034            ads, DIRECTION_MOBILE_ORIGINATED,
2035            self._wfc_set_wifi_strong_cell_absent,
2036            self._wfc_phone_setup_cellular_absent_wifi_preferred,
2037            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2038
2039        mt_result = self._wfc_call_sequence(
2040            ads, DIRECTION_MOBILE_TERMINATED,
2041            self._wfc_set_wifi_strong_cell_absent,
2042            self._wfc_phone_setup_cellular_absent_wifi_preferred,
2043            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2044
2045        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2046        return ((mo_result is True) and (mt_result is True))
2047
2048    @test_tracker_info(uuid="2b13f862-71e4-4b33-be0b-e83a61e3f443")
2049    @TelephonyBaseTest.tel_test_wrap
2050    def test_call_epdg_wfc_cellular_preferred_wifi_strong_cellular_absent(
2051            self):
2052        """ Test WFC MO MT, cellular preferred mode, WIFI strong, Cellular absent
2053
2054        Set WiFi/Cellular network environment.
2055        Make Sure PhoneA is set correct WFC parameters.
2056        Make SUre PhoneB is able to make MO/MT call.
2057        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
2058        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
2059
2060        Returns:
2061            True if pass; False if fail.
2062        """
2063        ads = [self.android_devices[0], self.android_devices[1]]
2064        mo_result = self._wfc_call_sequence(
2065            ads, DIRECTION_MOBILE_ORIGINATED,
2066            self._wfc_set_wifi_strong_cell_absent,
2067            self._wfc_phone_setup_cellular_absent_cellular_preferred,
2068            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2069
2070        mt_result = self._wfc_call_sequence(
2071            ads, DIRECTION_MOBILE_TERMINATED,
2072            self._wfc_set_wifi_strong_cell_absent,
2073            self._wfc_phone_setup_cellular_absent_cellular_preferred,
2074            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2075
2076        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2077        return ((mo_result is True) and (mt_result is True))
2078
2079    @test_tracker_info(uuid="49aa09d1-afd5-4b8a-9155-b351b1cecd83")
2080    @TelephonyBaseTest.tel_test_wrap
2081    def test_call_epdg_wfc_wifi_only_wifi_weak_cellular_absent(self):
2082        """ Test WFC MO MT, WiFI only mode, WIFI weak, Cellular absent
2083
2084        Set WiFi/Cellular network environment.
2085        Make Sure PhoneA is set correct WFC parameters.
2086        Make SUre PhoneB is able to make MO/MT call.
2087        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
2088        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
2089
2090        Returns:
2091            True if pass; False if fail.
2092        """
2093        ads = [self.android_devices[0], self.android_devices[1]]
2094        mo_result = self._wfc_call_sequence(
2095            ads, DIRECTION_MOBILE_ORIGINATED,
2096            self._wfc_set_wifi_weak_cell_absent,
2097            self._wfc_phone_setup_cellular_absent_wifi_only,
2098            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2099
2100        mt_result = self._wfc_call_sequence(
2101            ads, DIRECTION_MOBILE_TERMINATED,
2102            self._wfc_set_wifi_weak_cell_absent,
2103            self._wfc_phone_setup_cellular_absent_wifi_only,
2104            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2105
2106        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2107        return ((mo_result is True) and (mt_result is True))
2108
2109    @test_tracker_info(uuid="29e20d21-33bd-444f-ba51-487332e8bcbb")
2110    @TelephonyBaseTest.tel_test_wrap
2111    def test_call_epdg_wfc_wifi_preferred_wifi_weak_cellular_absent(self):
2112        """ Test WFC MO MT, WiFI preferred mode, WIFI weak, Cellular absent
2113
2114        Set WiFi/Cellular network environment.
2115        Make Sure PhoneA is set correct WFC parameters.
2116        Make SUre PhoneB is able to make MO/MT call.
2117        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
2118        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
2119
2120        Returns:
2121            True if pass; False if fail.
2122        """
2123        ads = [self.android_devices[0], self.android_devices[1]]
2124        mo_result = self._wfc_call_sequence(
2125            ads, DIRECTION_MOBILE_ORIGINATED,
2126            self._wfc_set_wifi_weak_cell_absent,
2127            self._wfc_phone_setup_cellular_absent_wifi_preferred,
2128            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2129
2130        mt_result = self._wfc_call_sequence(
2131            ads, DIRECTION_MOBILE_TERMINATED,
2132            self._wfc_set_wifi_weak_cell_absent,
2133            self._wfc_phone_setup_cellular_absent_wifi_preferred,
2134            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2135
2136        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2137        return ((mo_result is True) and (mt_result is True))
2138
2139    @test_tracker_info(uuid="f1aae6c2-0b40-4ee5-a8a9-f0036130dcf1")
2140    @TelephonyBaseTest.tel_test_wrap
2141    def test_call_epdg_wfc_cellular_preferred_wifi_weak_cellular_absent(self):
2142        """ Test WFC MO MT, cellular preferred mode, WIFI weak, Cellular absent
2143
2144        Set WiFi/Cellular network environment.
2145        Make Sure PhoneA is set correct WFC parameters.
2146        Make SUre PhoneB is able to make MO/MT call.
2147        Call from PhoneA to PhoneB, call should succeed, call should on WiFi.
2148        Call from PhoneB to PhoneA, call should succeed, call should on WiFi.
2149
2150        Returns:
2151            True if pass; False if fail.
2152        """
2153        ads = [self.android_devices[0], self.android_devices[1]]
2154        mo_result = self._wfc_call_sequence(
2155            ads, DIRECTION_MOBILE_ORIGINATED,
2156            self._wfc_set_wifi_weak_cell_absent,
2157            self._wfc_phone_setup_cellular_absent_cellular_preferred,
2158            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2159
2160        mt_result = self._wfc_call_sequence(
2161            ads, DIRECTION_MOBILE_TERMINATED,
2162            self._wfc_set_wifi_weak_cell_absent,
2163            self._wfc_phone_setup_cellular_absent_cellular_preferred,
2164            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
2165
2166        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2167        return ((mo_result is True) and (mt_result is True))
2168
2169    @test_tracker_info(uuid="7be33498-8f1c-4462-909b-09cd9abab053")
2170    @TelephonyBaseTest.tel_test_wrap
2171    def test_call_epdg_wfc_wifi_only_wifi_absent_cellular_absent(self):
2172        """ Test WFC MO MT, WiFI only mode, WIFI absent, Cellular absent
2173
2174        Set WiFi/Cellular network environment.
2175        Make Sure PhoneA is set correct WFC parameters.
2176        Make SUre PhoneB is able to make MO/MT call.
2177        Call from PhoneA to PhoneB, call should fail.
2178        Call from PhoneB to PhoneA, call should fail.
2179
2180        Returns:
2181            True if pass; False if fail.
2182        """
2183        ads = [self.android_devices[0], self.android_devices[1]]
2184        mo_result = self._wfc_call_sequence(
2185            ads, DIRECTION_MOBILE_ORIGINATED,
2186            self._wfc_set_wifi_absent_cell_absent,
2187            self._wfc_phone_setup_cellular_absent_wifi_absent_wifi_only,
2188            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2189            "initiate_call fail.")
2190
2191        mt_result = self._wfc_call_sequence(
2192            ads, DIRECTION_MOBILE_TERMINATED,
2193            self._wfc_set_wifi_absent_cell_absent,
2194            self._wfc_phone_setup_cellular_absent_wifi_absent_wifi_only,
2195            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2196            "wait_and_answer_call fail.")
2197
2198        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2199        return ((mo_result is True) and (mt_result is True))
2200
2201    @test_tracker_info(uuid="406c86cc-f3bb-4356-9ce7-6ae336e164f3")
2202    @TelephonyBaseTest.tel_test_wrap
2203    def test_call_epdg_wfc_wifi_preferred_wifi_absent_cellular_absent(self):
2204        """ Test WFC MO MT, WiFI preferred mode, WIFI absent, Cellular absent
2205
2206        Set WiFi/Cellular network environment.
2207        Make Sure PhoneA is set correct WFC parameters.
2208        Make SUre PhoneB is able to make MO/MT call.
2209        Call from PhoneA to PhoneB, call should fail.
2210        Call from PhoneB to PhoneA, call should fail.
2211
2212        Returns:
2213            True if pass; False if fail.
2214        """
2215        ads = [self.android_devices[0], self.android_devices[1]]
2216        mo_result = self._wfc_call_sequence(
2217            ads, DIRECTION_MOBILE_ORIGINATED,
2218            self._wfc_set_wifi_absent_cell_absent,
2219            self._wfc_phone_setup_cellular_absent_wifi_absent_wifi_preferred,
2220            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2221            "initiate_call fail.")
2222
2223        mt_result = self._wfc_call_sequence(
2224            ads, DIRECTION_MOBILE_TERMINATED,
2225            self._wfc_set_wifi_absent_cell_absent,
2226            self._wfc_phone_setup_cellular_absent_wifi_absent_wifi_preferred,
2227            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2228            "wait_and_answer_call fail.")
2229
2230        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2231        return ((mo_result is True) and (mt_result is True))
2232
2233    @test_tracker_info(uuid="e172082b-5e88-4229-9da9-e16a74da8fbb")
2234    @TelephonyBaseTest.tel_test_wrap
2235    def test_call_epdg_wfc_cellular_preferred_wifi_absent_cellular_absent(
2236            self):
2237        """ Test WFC MO MT, cellular preferred mode, WIFI absent, Cellular absent
2238
2239        Set WiFi/Cellular network environment.
2240        Make Sure PhoneA is set correct WFC parameters.
2241        Make SUre PhoneB is able to make MO/MT call.
2242        Call from PhoneA to PhoneB, call should fail.
2243        Call from PhoneB to PhoneA, call should fail.
2244
2245        Returns:
2246            True if pass; False if fail.
2247        """
2248        ads = [self.android_devices[0], self.android_devices[1]]
2249        mo_result = self._wfc_call_sequence(
2250            ads, DIRECTION_MOBILE_ORIGINATED,
2251            self._wfc_set_wifi_absent_cell_absent, self.
2252            _wfc_phone_setup_cellular_absent_wifi_absent_cellular_preferred,
2253            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2254            "initiate_call fail.")
2255
2256        mt_result = self._wfc_call_sequence(
2257            ads, DIRECTION_MOBILE_TERMINATED,
2258            self._wfc_set_wifi_absent_cell_absent, self.
2259            _wfc_phone_setup_cellular_absent_wifi_absent_cellular_preferred,
2260            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2261            "wait_and_answer_call fail.")
2262
2263        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2264        return ((mo_result is True) and (mt_result is True))
2265
2266    @test_tracker_info(uuid="f4a93a88-4a20-4e4a-9168-a7b1f1ad5462")
2267    @TelephonyBaseTest.tel_test_wrap
2268    def test_call_epdg_wfc_wifi_only_wifi_disabled_cellular_absent(self):
2269        """ Test WFC MO MT, WiFI only mode, WIFI strong, Cellular absent
2270
2271        Set WiFi/Cellular network environment.
2272        Make Sure PhoneA is set correct WFC parameters.
2273        Make SUre PhoneB is able to make MO/MT call.
2274        Call from PhoneA to PhoneB, call should fail.
2275        Call from PhoneB to PhoneA, call should fail.
2276
2277        Returns:
2278            True if pass; False if fail.
2279        """
2280        ads = [self.android_devices[0], self.android_devices[1]]
2281        mo_result = self._wfc_call_sequence(
2282            ads, DIRECTION_MOBILE_ORIGINATED,
2283            self._wfc_set_wifi_strong_cell_absent,
2284            self._wfc_phone_setup_cellular_absent_wifi_disabled_wifi_only,
2285            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2286            "initiate_call fail.")
2287
2288        mt_result = self._wfc_call_sequence(
2289            ads, DIRECTION_MOBILE_TERMINATED,
2290            self._wfc_set_wifi_strong_cell_absent,
2291            self._wfc_phone_setup_cellular_absent_wifi_disabled_wifi_only,
2292            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2293            "wait_and_answer_call fail.")
2294
2295        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2296        return ((mo_result is True) and (mt_result is True))
2297
2298    @test_tracker_info(uuid="c8f62254-2dba-4c54-a9d1-5741b6c05f10")
2299    @TelephonyBaseTest.tel_test_wrap
2300    def test_call_epdg_wfc_wifi_preferred_wifi_disabled_cellular_absent(self):
2301        """ Test WFC MO MT, WiFI preferred mode, WIFI strong, Cellular absent
2302
2303        Set WiFi/Cellular network environment.
2304        Make Sure PhoneA is set correct WFC parameters.
2305        Make SUre PhoneB is able to make MO/MT call.
2306        Call from PhoneA to PhoneB, call should fail.
2307        Call from PhoneB to PhoneA, call should fail.
2308
2309        Returns:
2310            True if pass; False if fail.
2311        """
2312        ads = [self.android_devices[0], self.android_devices[1]]
2313        mo_result = self._wfc_call_sequence(
2314            ads, DIRECTION_MOBILE_ORIGINATED,
2315            self._wfc_set_wifi_strong_cell_absent,
2316            self._wfc_phone_setup_cellular_absent_wifi_disabled_wifi_preferred,
2317            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2318            "initiate_call fail.")
2319
2320        mt_result = self._wfc_call_sequence(
2321            ads, DIRECTION_MOBILE_TERMINATED,
2322            self._wfc_set_wifi_strong_cell_absent,
2323            self._wfc_phone_setup_cellular_absent_wifi_disabled_wifi_preferred,
2324            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2325            "wait_and_answer_call fail.")
2326
2327        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2328        return ((mo_result is True) and (mt_result is True))
2329
2330    @test_tracker_info(uuid="1c593836-fbdd-415c-a997-5835303069ad")
2331    @TelephonyBaseTest.tel_test_wrap
2332    def test_call_epdg_wfc_cellular_preferred_wifi_disabled_cellular_absent(
2333            self):
2334        """ Test WFC MO MT, cellular preferred mode, WIFI strong, Cellular absent
2335
2336        Set WiFi/Cellular network environment.
2337        Make Sure PhoneA is set correct WFC parameters.
2338        Make SUre PhoneB is able to make MO/MT call.
2339        Call from PhoneA to PhoneB, call should fail.
2340        Call from PhoneB to PhoneA, call should fail.
2341
2342        Returns:
2343            True if pass; False if fail.
2344        """
2345        ads = [self.android_devices[0], self.android_devices[1]]
2346        mo_result = self._wfc_call_sequence(
2347            ads, DIRECTION_MOBILE_ORIGINATED,
2348            self._wfc_set_wifi_strong_cell_absent, self.
2349            _wfc_phone_setup_cellular_absent_wifi_disabled_cellular_preferred,
2350            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2351            "initiate_call fail.")
2352
2353        mt_result = self._wfc_call_sequence(
2354            ads, DIRECTION_MOBILE_TERMINATED,
2355            self._wfc_set_wifi_strong_cell_absent, self.
2356            _wfc_phone_setup_cellular_absent_wifi_disabled_cellular_preferred,
2357            self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2358            "wait_and_answer_call fail.")
2359
2360        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2361        return ((mo_result is True) and (mt_result is True))
2362
2363    @test_tracker_info(uuid="41ec5080-810a-47f0-93c6-281fc19c4d12")
2364    @TelephonyBaseTest.tel_test_wrap
2365    def test_call_epdg_wfc_disabled_wifi_strong_cellular_strong(self):
2366        """ Test WFC MO MT, WFC disabled, WIFI strong, Cellular strong
2367
2368        Set WiFi/Cellular network environment.
2369        Make Sure PhoneA is set correct WFC parameters.
2370        Make SUre PhoneB is able to make MO/MT call.
2371        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
2372        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
2373
2374        Returns:
2375            True if pass; False if fail.
2376        """
2377        ads = [self.android_devices[0], self.android_devices[1]]
2378        mo_result = self._wfc_call_sequence(
2379            ads, DIRECTION_MOBILE_ORIGINATED,
2380            self._wfc_set_wifi_strong_cell_strong,
2381            self._wfc_phone_setup_wfc_disabled, None,
2382            self._is_phone_in_call_not_iwlan, None, True)
2383
2384        mt_result = self._wfc_call_sequence(
2385            ads, DIRECTION_MOBILE_TERMINATED,
2386            self._wfc_set_wifi_strong_cell_strong,
2387            self._wfc_phone_setup_wfc_disabled, None,
2388            self._is_phone_in_call_not_iwlan, None, True)
2389
2390        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2391        return ((mo_result is True) and (mt_result is True))
2392
2393    @test_tracker_info(uuid="8c9dd7a3-c840-474d-b929-07e557428648")
2394    @TelephonyBaseTest.tel_test_wrap
2395    def test_call_epdg_wfc_disabled_wifi_strong_cellular_weak(self):
2396        """ Test WFC MO MT, WFC disabled, WIFI strong, Cellular weak
2397
2398        Set WiFi/Cellular network environment.
2399        Make Sure PhoneA is set correct WFC parameters.
2400        Make SUre PhoneB is able to make MO/MT call.
2401        Call from PhoneA to PhoneB, call should succeed, call should on Cellular.
2402        Call from PhoneB to PHoneA, call should succeed, call should on Cellular.
2403
2404        Returns:
2405            True if pass; False if fail.
2406        """
2407        ads = [self.android_devices[0], self.android_devices[1]]
2408        mo_result = self._wfc_call_sequence(
2409            ads, DIRECTION_MOBILE_ORIGINATED,
2410            self._wfc_set_wifi_strong_cell_weak,
2411            self._wfc_phone_setup_wfc_disabled, None,
2412            self._is_phone_in_call_not_iwlan, None, True)
2413
2414        mt_result = self._wfc_call_sequence(
2415            ads, DIRECTION_MOBILE_TERMINATED,
2416            self._wfc_set_wifi_strong_cell_weak,
2417            self._wfc_phone_setup_wfc_disabled, None,
2418            self._is_phone_in_call_not_iwlan, None, True)
2419
2420        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2421        return ((mo_result is True) and (mt_result is True))
2422
2423    @test_tracker_info(uuid="ddb3372d-23d2-492c-881a-e509e7ac4c8d")
2424    @TelephonyBaseTest.tel_test_wrap
2425    def test_call_epdg_wfc_disabled_wifi_strong_cellular_absent(self):
2426        """ Test WFC MO MT, WFC disabled, WIFI strong, Cellular absent
2427
2428        Set WiFi/Cellular network environment.
2429        Make Sure PhoneA is set correct WFC parameters.
2430        Make SUre PhoneB is able to make MO/MT call.
2431        Call from PhoneA to PhoneB, call should fail.
2432        Call from PhoneB to PhoneA, call should fail.
2433
2434        Returns:
2435            True if pass; False if fail.
2436        """
2437        ads = [self.android_devices[0], self.android_devices[1]]
2438        mo_result = self._wfc_call_sequence(
2439            ads, DIRECTION_MOBILE_ORIGINATED,
2440            self._wfc_set_wifi_strong_cell_absent,
2441            self._wfc_phone_setup_cellular_absent_wfc_disabled, None,
2442            self._is_phone_not_in_call, None, "initiate_call fail.")
2443
2444        mt_result = self._wfc_call_sequence(
2445            ads, DIRECTION_MOBILE_TERMINATED,
2446            self._wfc_set_wifi_strong_cell_absent,
2447            self._wfc_phone_setup_cellular_absent_wfc_disabled, None,
2448            self._is_phone_not_in_call, None, "wait_and_answer_call fail.")
2449
2450        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2451        return ((mo_result is True) and (mt_result is True))
2452
2453    @test_tracker_info(uuid="91232d7e-ccb5-4581-8093-1ab42eca3815")
2454    @TelephonyBaseTest.tel_test_wrap
2455    def test_call_epdg_wfc_disabled_wifi_strong_apm(self):
2456        """ Test WFC MO MT, WFC disabled, WIFI strong, Phone in APM
2457
2458        Set WiFi/Cellular network environment.
2459        Make Sure PhoneA is set correct WFC parameters.
2460        Make SUre PhoneB is able to make MO/MT call.
2461        Call from PhoneA to PhoneB, call should fail.
2462        Call from PhoneB to PhoneA, call should fail.
2463
2464        Returns:
2465            True if pass; False if fail.
2466        """
2467        ads = [self.android_devices[0], self.android_devices[1]]
2468        mo_result = self._wfc_call_sequence(
2469            ads, DIRECTION_MOBILE_ORIGINATED,
2470            self._wfc_set_wifi_strong_cell_strong,
2471            self._wfc_phone_setup_apm_wfc_disabled, None,
2472            self._is_phone_not_in_call, None, "initiate_call fail.")
2473
2474        mt_result = self._wfc_call_sequence(
2475            ads, DIRECTION_MOBILE_TERMINATED,
2476            self._wfc_set_wifi_strong_cell_strong,
2477            self._wfc_phone_setup_apm_wfc_disabled, None,
2478            self._is_phone_not_in_call, None, "wait_and_answer_call fail.")
2479
2480        self.log.info("MO: {}, MT: {}".format(mo_result, mt_result))
2481        return ((mo_result is True) and (mt_result is True))
2482
2483    def _rove_in_test(self, cellular_gen, wfc_mode):
2484        """Test utility for Rove-in Tests.
2485
2486        Cellular strong, WiFi RSSI < -100 dBm.
2487        Setup Cellular network and wfc_mode, WiFi enabled but not associated.
2488        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN in 10s,
2489            PhoneA does not rove-in.
2490        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10s,
2491            PhoneA rove-in.
2492        Make WFC call.
2493        """
2494        self._wfc_set_wifi_absent_cell_strong()
2495        # ensure cellular rat, wfc mode, wifi not associated
2496        toggle_airplane_mode(self.log, self.android_devices[0], False)
2497        toggle_volte(self.log, self.android_devices[0], True)
2498        if not ensure_network_generation(
2499                self.log,
2500                self.android_devices[0],
2501                cellular_gen,
2502                voice_or_data=NETWORK_SERVICE_DATA):
2503            self.log.error("_rove_in_test: {} failed to be in rat: {}".format(
2504                self.android_devices[0].serial, cellular_rat))
2505            return False
2506        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
2507            self.log.error("{} set WFC mode failed.".format(
2508                self.android_devices[0].serial))
2509            return False
2510
2511        if ensure_wifi_connected(self.log, self.android_devices[0],
2512                                 self.wifi_network_ssid,
2513                                 self.wifi_network_pass, 1):
2514            self.log.error(
2515                "{} connect WiFI succeed, expected not succeed".format(
2516                    self.android_devices[0].serial))
2517            return False
2518
2519        # set up wifi to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN in 10 seconds
2520        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2521                 self.wifi_rssi_with_no_atten,
2522                 WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN, 5, 1)
2523        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2524                 self.wifi_rssi_with_no_atten,
2525                 WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN, 5, 1)
2526        if (not wait_for_wifi_data_connection(self.log,
2527                                              self.android_devices[0], True) or
2528                not verify_http_connection(self.log, self.android_devices[0])):
2529            self.log.error("No Data on Wifi")
2530            return False
2531
2532        if self._phone_idle_iwlan():
2533            self.log.error("Phone should not report iwlan in WiFi {}Bm".format(
2534                WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN))
2535            return False
2536
2537        # set up wifi to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10 seconds
2538        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2539                 self.wifi_rssi_with_no_atten,
2540                 WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN, 1, 1)
2541        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2542                 self.wifi_rssi_with_no_atten,
2543                 WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN, 1, 1)
2544        if not self._phone_idle_iwlan():
2545            self.log.error("Phone should report iwlan in WiFi {}dBm".format(
2546                WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN))
2547            return False
2548
2549        # make a wfc call.
2550        return self._wfc_call_sequence(
2551            [self.android_devices[0], self.android_devices[1]],
2552            DIRECTION_MOBILE_ORIGINATED, None, None, self._phone_idle_iwlan,
2553            self._is_phone_in_call_iwlan, None, True)
2554
2555    def _rove_out_test(self, cellular_gen, wfc_mode):
2556        """Test utility for Rove-out Tests.
2557
2558        Cellular strong, WiFi RSSI WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE.
2559        Setup Cellular network and wfc_mode, WiFi associated.
2560        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT in 10s,
2561            PhoneA does not rove-out.
2562        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10s,
2563            PhoneA rove-out.
2564        Make a call.
2565        """
2566        # set up cell strong
2567        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G],
2568                 self.cell_rssi_with_no_atten, MAX_RSSI_RESERVED_VALUE)
2569        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G],
2570                 self.cell_rssi_with_no_atten, MAX_RSSI_RESERVED_VALUE)
2571        # set up wifi WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE
2572        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2573                 self.wifi_rssi_with_no_atten,
2574                 WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE)
2575        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2576                 self.wifi_rssi_with_no_atten,
2577                 WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE)
2578        # ensure cellular rat, wfc mode, wifi associated
2579        toggle_airplane_mode(self.log, self.android_devices[0], False)
2580        toggle_volte(self.log, self.android_devices[0], True)
2581
2582        if not ensure_network_generation(
2583                self.log,
2584                self.android_devices[0],
2585                GEN_4G,
2586                voice_or_data=NETWORK_SERVICE_DATA):
2587            self.log.error("_rove_out_test: {} failed to be in rat: {}".format(
2588                self.android_devices[0].serial, cellular_rat))
2589            get_telephony_signal_strength(self.android_devices[0])
2590            get_wifi_signal_strength(self.android_devices[0])
2591            return False
2592
2593        if not set_wfc_mode(self.log, self.android_devices[0], wfc_mode):
2594            self.log.error("{} set WFC mode failed.".format(
2595                self.android_devices[0].serial))
2596            return False
2597
2598        if not ensure_wifi_connected(self.log, self.android_devices[0],
2599                                     self.wifi_network_ssid,
2600                                     self.wifi_network_pass):
2601            self.log.error("{} connect WiFI failed, expected succeed".format(
2602                self.android_devices[0].serial))
2603            return False
2604
2605        if (not wait_for_wifi_data_connection(self.log,
2606                                              self.android_devices[0], True) or
2607                not verify_http_connection(self.log, self.android_devices[0])):
2608            self.log.error("No Data on Wifi")
2609            get_telephony_signal_strength(self.android_devices[0])
2610            get_wifi_signal_strength(self.android_devices[0])
2611            return False
2612
2613        if not self._phone_idle_iwlan():
2614            self.log.error("Phone failed to report iwlan in {}dBm.".format(
2615                WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE))
2616            get_telephony_signal_strength(self.android_devices[0])
2617            get_wifi_signal_strength(self.android_devices[0])
2618            return False
2619
2620        # set up wifi to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT in 10 seconds
2621        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2622                 self.wifi_rssi_with_no_atten,
2623                 WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT, 1, 1)
2624        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2625                 self.wifi_rssi_with_no_atten,
2626                 WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT, 1, 1)
2627        if (not wait_for_wifi_data_connection(self.log,
2628                                              self.android_devices[0], True) or
2629                not verify_http_connection(self.log, self.android_devices[0])):
2630            self.log.error("No Data on Wifi")
2631            get_telephony_signal_strength(self.android_devices[0])
2632            get_wifi_signal_strength(self.android_devices[0])
2633            return False
2634
2635        if self._phone_wait_for_not_wfc() or not self._phone_idle_iwlan():
2636            self.log.error("Phone should not rove-out in {}dBm.".format(
2637                WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT))
2638            get_telephony_signal_strength(self.android_devices[0])
2639            get_wifi_signal_strength(self.android_devices[0])
2640            return False
2641
2642        # set up wifi to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10 seconds
2643        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2644                 self.wifi_rssi_with_no_atten,
2645                 WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT, 2, 1)
2646        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2647                 self.wifi_rssi_with_no_atten,
2648                 WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT, 2, 1)
2649        if (not wait_for_wifi_data_connection(self.log,
2650                                              self.android_devices[0], True) or
2651                not verify_http_connection(self.log, self.android_devices[0])):
2652            self.log.error("No Data on Wifi")
2653            get_telephony_signal_strength(self.android_devices[0])
2654            get_wifi_signal_strength(self.android_devices[0])
2655            return False
2656
2657        if not self._phone_wait_for_not_wfc() or self._phone_idle_iwlan():
2658            self.log.error("Phone should rove-out in {}dBm.".format(
2659                WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT))
2660            get_telephony_signal_strength(self.android_devices[0])
2661            get_wifi_signal_strength(self.android_devices[0])
2662            return False
2663
2664        # make a call.
2665        if wfc_mode == WFC_MODE_WIFI_ONLY:
2666            return self._wfc_call_sequence(
2667                [self.android_devices[0], self.android_devices[1]],
2668                DIRECTION_MOBILE_ORIGINATED, None, None,
2669                self._phone_idle_not_iwlan, self._is_phone_not_in_call, None,
2670                "initiate_call fail.")
2671        elif wfc_mode == WFC_MODE_WIFI_PREFERRED:
2672            if cellular_gen == GEN_4G:
2673                return self._wfc_call_sequence(
2674                    [self.android_devices[0], self.android_devices[1]],
2675                    DIRECTION_MOBILE_ORIGINATED, None, None,
2676                    self._phone_idle_volte, self._is_phone_in_call_volte, None,
2677                    True)
2678            else:
2679                return self._wfc_call_sequence(
2680                    [self.android_devices[0], self.android_devices[1]],
2681                    DIRECTION_MOBILE_ORIGINATED, None, None,
2682                    self._phone_idle_3g, self._is_phone_in_call_3g, None, True)
2683        else:
2684            return False
2685
2686    @test_tracker_info(uuid="7f9779c1-75c6-413e-9e3b-7e4d9896379a")
2687    @TelephonyBaseTest.tel_test_wrap
2688    def test_rove_out_in_stress(self):
2689        """WiFi Calling Rove out/in stress test.
2690
2691        Steps:
2692        1. PhoneA on LTE, VoLTE enabled.
2693        2. PhoneA WFC mode WiFi preferred, WiFi associated.
2694        3. Cellular strong, WiFi RSSI WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE.
2695        4. Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10s,
2696            PhoneA rove-out.
2697        5. Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10s,
2698            PhoneA rove-in.
2699        6. Repeat Step 4~5.
2700
2701        Expected Results:
2702        4. Phone should rove out.
2703        5. Phone should rove in.
2704        6. Stress test pass rate should be higher than pre-defined limit.
2705        """
2706        self._wfc_set_wifi_strong_cell_strong()
2707        if not self._wfc_phone_setup_wifi_preferred():
2708            self.log.error("Setup WFC failed.")
2709            return False
2710        if (not wait_for_wifi_data_connection(self.log,
2711                                              self.android_devices[0], True) or
2712                not verify_http_connection(self.log, self.android_devices[0])):
2713            self.log.error("No Data on Wifi")
2714            return False
2715        if not self._phone_idle_iwlan():
2716            self.log.error("Phone failed to report iwlan in {}dBm.".format(
2717                WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE))
2718            return False
2719        total_iteration = self.stress_test_number
2720        self.log.info(
2721            "Rove_out/Rove_in stress test. Total iteration = {}.".format(
2722                total_iteration))
2723        current_iteration = 1
2724        while (current_iteration <= total_iteration):
2725            self.log.info(">----Current iteration = {}/{}----<".format(
2726                current_iteration, total_iteration))
2727
2728            # set up wifi to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10 seconds
2729            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2730                     self.wifi_rssi_with_no_atten,
2731                     WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT, 2, 1)
2732            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2733                     self.wifi_rssi_with_no_atten,
2734                     WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT, 2, 1)
2735            if (not wait_for_wifi_data_connection(
2736                    self.log, self.android_devices[0], True)
2737                    or not verify_http_connection(self.log,
2738                                                  self.android_devices[0])):
2739                self.log.error("No Data on Wifi")
2740                break
2741            if not self._phone_wait_for_not_wfc():
2742                self.log.error("Phone should rove-out in {}dBm.".format(
2743                    WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT))
2744                break
2745            self.log.info("Rove-out succeed.")
2746            # set up wifi to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10 seconds
2747            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2748                     self.wifi_rssi_with_no_atten,
2749                     WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN, 2, 1)
2750            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2751                     self.wifi_rssi_with_no_atten,
2752                     WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN, 2, 1)
2753            if (not wait_for_wifi_data_connection(
2754                    self.log, self.android_devices[0], True)
2755                    or not verify_http_connection(self.log,
2756                                                  self.android_devices[0])):
2757                self.log.error("No Data on Wifi")
2758                break
2759            if not self._phone_wait_for_wfc():
2760                self.log.error("Phone should rove-in in {}dBm.".format(
2761                    WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN))
2762                break
2763            self.log.info("Rove-in succeed.")
2764
2765            self.log.info(">----Iteration : {}/{} succeed.----<".format(
2766                current_iteration, total_iteration))
2767            current_iteration += 1
2768        if current_iteration <= total_iteration:
2769            self.log.info(">----Iteration : {}/{} failed.----<".format(
2770                current_iteration, total_iteration))
2771            return False
2772        else:
2773            return True
2774
2775    @test_tracker_info(uuid="3ba22f37-a9fd-4890-9805-941d80f5600d")
2776    @TelephonyBaseTest.tel_test_wrap
2777    def test_rove_in_out_stress(self):
2778        """WiFi Calling Rove in/out stress test.
2779
2780        Steps:
2781        1. PhoneA on LTE, VoLTE enabled.
2782        2. PhoneA WFC mode WiFi preferred, WiFi associated.
2783        3. Cellular strong, WiFi RSSI weak.
2784        4. Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10s,
2785            PhoneA rove-in.
2786        5. Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10s,
2787            PhoneA rove-out.
2788        6. Repeat Step 4~5.
2789
2790        Expected Results:
2791        4. Phone should rove in.
2792        5. Phone should rove out.
2793        6. Stress test pass rate should be higher than pre-defined limit.
2794        """
2795        self._wfc_set_wifi_weak_cell_strong()
2796        # ensure cellular rat, wfc mode, wifi not associated
2797        if not self._wfc_phone_setup_wifi_preferred():
2798            self.log.error("Failed to setup for rove_in_out_stress")
2799            return False
2800        total_iteration = self.stress_test_number
2801        self.log.info(
2802            "Rove_in/Rove_out stress test. Total iteration = {}.".format(
2803                total_iteration))
2804        current_iteration = 1
2805        while (current_iteration <= total_iteration):
2806            self.log.info(">----Current iteration = {}/{}----<".format(
2807                current_iteration, total_iteration))
2808
2809            # set up wifi to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10 seconds
2810            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2811                     self.wifi_rssi_with_no_atten,
2812                     WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN, 2, 1)
2813            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2814                     self.wifi_rssi_with_no_atten,
2815                     WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN, 2, 1)
2816            if (not wait_for_wifi_data_connection(
2817                    self.log, self.android_devices[0], True)
2818                    or not verify_http_connection(self.log,
2819                                                  self.android_devices[0])):
2820                self.log.error("No Data on Wifi")
2821                break
2822            if not self._phone_wait_for_wfc():
2823                self.log.error("Phone should rove-in in {}dBm.".format(
2824                    WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN))
2825                break
2826            self.log.info("Rove-in succeed.")
2827
2828            # set up wifi to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10 seconds
2829            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
2830                     self.wifi_rssi_with_no_atten,
2831                     WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT, 2, 1)
2832            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
2833                     self.wifi_rssi_with_no_atten,
2834                     WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT, 2, 1)
2835            if (not wait_for_wifi_data_connection(
2836                    self.log, self.android_devices[0], True)
2837                    or not verify_http_connection(self.log,
2838                                                  self.android_devices[0])):
2839                self.log.error("No Data on Wifi")
2840                break
2841            if not self._phone_wait_for_not_wfc():
2842                self.log.error("Phone should rove-out in {}dBm.".format(
2843                    WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT))
2844                break
2845            self.log.info("Rove-out succeed.")
2846
2847            self.log.info(">----Iteration : {}/{} succeed.----<".format(
2848                current_iteration, total_iteration))
2849            current_iteration += 1
2850        if current_iteration <= total_iteration:
2851            self.log.info(">----Iteration : {}/{} failed.----<".format(
2852                current_iteration, total_iteration))
2853            return False
2854        else:
2855            return True
2856
2857    @test_tracker_info(uuid="791bce68-d875-41cd-addd-355ff61773b9")
2858    @TelephonyBaseTest.tel_test_wrap
2859    def test_rove_in_lte_wifi_preferred(self):
2860        """ Test WFC rove-in features.
2861
2862        PhoneA on LTE, VoLTE enabled.
2863        PhoneA WFC mode WiFi preferred, WiFi enabled but not associated.
2864        Cellular strong, WiFi RSSI < -100 dBm.
2865        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN in 10s,
2866            PhoneA does not rove-in.
2867        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10s,
2868            PhoneA rove-in.
2869        Make WFC call.
2870
2871        Returns:
2872            True if pass; False if fail.
2873        """
2874        return self._rove_in_test(GEN_4G, WFC_MODE_WIFI_PREFERRED)
2875
2876    @test_tracker_info(uuid="f4b70fbb-cc44-4e7c-805e-c5f28c78e2dd")
2877    @TelephonyBaseTest.tel_test_wrap
2878    def test_rove_in_lte_wifi_only(self):
2879        """ Test WFC rove-in features.
2880
2881        PhoneA on LTE, VoLTE enabled.
2882        PhoneA WFC mode WiFi only, WiFi enabled but not associated.
2883        Cellular strong, WiFi RSSI < -100 dBm.
2884        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN in 10s,
2885            PhoneA does not rove-in.
2886        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10s,
2887            PhoneA rove-in.
2888        Make WFC call.
2889
2890        Returns:
2891            True if pass; False if fail.
2892        """
2893        return self._rove_in_test(GEN_4G, WFC_MODE_WIFI_ONLY)
2894
2895    @test_tracker_info(uuid="b9f3648e-7168-4c82-aec5-f4a7cc77ad99")
2896    @TelephonyBaseTest.tel_test_wrap
2897    def test_rove_in_wcdma_wifi_preferred(self):
2898        """ Test WFC rove-in features.
2899
2900        PhoneA on WCDMA, VoLTE enabled.
2901        PhoneA WFC mode WiFi preferred, WiFi enabled but not associated.
2902        Cellular strong, WiFi RSSI < -100 dBm.
2903        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN in 10s,
2904            PhoneA does not rove-in.
2905        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10s,
2906            PhoneA rove-in.
2907        Make WFC call.
2908
2909        Returns:
2910            True if pass; False if fail.
2911        """
2912        return self._rove_in_test(GEN_3G, WFC_MODE_WIFI_PREFERRED)
2913
2914    @test_tracker_info(uuid="8ce03ae7-0b21-49e4-828f-cf8dcd54ba35")
2915    @TelephonyBaseTest.tel_test_wrap
2916    def test_rove_in_wcdma_wifi_only(self):
2917        """ Test WFC rove-in features.
2918
2919        PhoneA on WCDMA, VoLTE enabled.
2920        PhoneA WFC mode WiFi only, WiFi enabled but not associated.
2921        Cellular strong, WiFi RSSI < -100 dBm.
2922        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_NOT_ROVE_IN in 10s,
2923            PhoneA does not rove-in.
2924        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_IN_TEST_PHONE_ROVE_IN in 10s,
2925            PhoneA rove-in.
2926        Make WFC call.
2927
2928        Returns:
2929            True if pass; False if fail.
2930        """
2931        return self._rove_in_test(GEN_3G, WFC_MODE_WIFI_ONLY)
2932
2933    @test_tracker_info(uuid="7784923f-10f1-4dca-bdc1-8de55b7b9d40")
2934    @TelephonyBaseTest.tel_test_wrap
2935    def test_rove_out_lte_wifi_preferred(self):
2936        """ Test WFC rove-out features.
2937
2938        PhoneA on LTE, VoLTE enabled.
2939        PhoneA WFC mode WiFi preferred, WiFi associated.
2940        Cellular strong, WiFi RSSI WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE.
2941        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT in 10s,
2942            PhoneA does not rove-out.
2943        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10s,
2944            PhoneA rove-out.
2945        Make a call, call should succeed by cellular VoLTE.
2946
2947        Returns:
2948            True if pass; False if fail.
2949        """
2950        return self._rove_out_test(GEN_4G, WFC_MODE_WIFI_PREFERRED)
2951
2952    @test_tracker_info(uuid="6bb42ab2-02bd-4637-b3b6-3ce4cffffda8")
2953    @TelephonyBaseTest.tel_test_wrap
2954    def test_rove_out_lte_wifi_only(self):
2955        """ Test WFC rove-out features.
2956
2957        PhoneA on LTE, VoLTE enabled.
2958        PhoneA WFC mode WiFi only, WiFi associated.
2959        Cellular strong, WiFi RSSI WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE.
2960        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT in 10s,
2961            PhoneA does not rove-out.
2962        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10s,
2963            PhoneA rove-out.
2964        Make a call, call should fail.
2965
2966        Returns:
2967            True if pass; False if fail.
2968        """
2969        return self._rove_out_test(GEN_4G, WFC_MODE_WIFI_ONLY)
2970
2971    @test_tracker_info(uuid="3261b432-01de-4dd9-a309-ff53059df521")
2972    @TelephonyBaseTest.tel_test_wrap
2973    def test_rove_out_wcdma_wifi_preferred(self):
2974        """ Test WFC rove-out features.
2975
2976        PhoneA on WCDMA, VoLTE enabled.
2977        PhoneA WFC mode WiFi preferred, WiFi associated.
2978        Cellular strong, WiFi RSSI WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE.
2979        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT in 10s,
2980            PhoneA does not rove-out.
2981        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10s,
2982            PhoneA rove-out.
2983        Make a call, call should succeed by cellular 3g.
2984
2985        Returns:
2986            True if pass; False if fail.
2987        """
2988        return self._rove_out_test(GEN_3G, WFC_MODE_WIFI_PREFERRED)
2989
2990    @test_tracker_info(uuid="89fac8bf-b8e1-443a-8be7-f21f306c0d6c")
2991    @TelephonyBaseTest.tel_test_wrap
2992    def test_rove_out_wcdma_wifi_only(self):
2993        """ Test WFC rove-out features.
2994
2995        PhoneA on WCDMA, VoLTE enabled.
2996        PhoneA WFC mode WiFi only, WiFi associated.
2997        Cellular strong, WiFi RSSI WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_INITIAL_STATE.
2998        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_NOT_ROVE_OUT in 10s,
2999            PhoneA does not rove-out.
3000        Set WiFI RSSI to WIFI_RSSI_FOR_ROVE_OUT_TEST_PHONE_ROVE_OUT in 10s,
3001            PhoneA rove-out.
3002        Make a call, call should fail.
3003
3004        Returns:
3005            True if pass; False if fail.
3006        """
3007        return self._rove_out_test(GEN_3G, WFC_MODE_WIFI_ONLY)
3008
3009    def _increase_wifi_rssi_check_phone_hand_in(self):
3010        """Private Test utility for hand_in test.
3011
3012        Increase WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN in 10s.
3013        PhoneA should connect to WiFi and have data on WiFi.
3014        PhoneA should not hand-in to iwlan.
3015        Increase WiFi RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s.
3016        PhoneA should hand-in to iwlan.
3017        PhoneA call should remain active.
3018        """
3019        # Increase WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN in 10s
3020        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3021                 self.wifi_rssi_with_no_atten,
3022                 WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN, 5, 1)
3023        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3024                 self.wifi_rssi_with_no_atten,
3025                 WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN, 5, 1)
3026        # Make sure WiFI connected and data OK.
3027        if (not wait_for_wifi_data_connection(self.log,
3028                                              self.android_devices[0], True) or
3029                not verify_http_connection(self.log, self.android_devices[0])):
3030            self.log.error("No Data on Wifi")
3031            return False
3032        # Make sure phone not hand in to iwlan.
3033        if self._phone_wait_for_wfc():
3034            self.log.error("Phone hand-in to wfc.")
3035            return False
3036        # Increase WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s
3037        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3038                 self.wifi_rssi_with_no_atten,
3039                 WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN, 2, 1)
3040        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3041                 self.wifi_rssi_with_no_atten,
3042                 WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN, 2, 1)
3043        # Make sure phone hand in to iwlan.
3044        if not self._phone_wait_for_wfc():
3045            self.log.error("Phone failed to hand-in to wfc.")
3046            return False
3047        if self._is_phone_not_in_call():
3048            self.log.error("Phone call dropped.")
3049            return False
3050        return True
3051
3052    @test_tracker_info(uuid="e8ba5d0f-afc5-42c2-b7f0-9f5d06774556")
3053    @TelephonyBaseTest.tel_test_wrap
3054    def test_hand_in_wifi_preferred(self):
3055        """WiFi Hand-In Threshold - WiFi Preferred
3056
3057        PhoneA on LTE, VoLTE enabled, WFC WiFi preferred. WiFI not associated.
3058        Cellular Strong, WiFi <-100 dBm
3059        Call from PhoneA to PhoneB, PhoneA should be on VoLTE.
3060        Increase WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN in 10s.
3061        PhoneA should connect to WiFi and have data on WiFi.
3062        PhoneA should not hand-in to iwlan.
3063        Increase WiFi RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s.
3064        PhoneA should hand-in to iwlan.
3065        PhoneA call should remain active.
3066        """
3067        return self._wfc_call_sequence(
3068            [self.android_devices[0], self.android_devices[1]],
3069            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_absent_cell_strong,
3070            self._wfc_phone_setup_wifi_absent_wifi_preferred,
3071            self._phone_idle_volte, self._is_phone_in_call_volte,
3072            self._increase_wifi_rssi_check_phone_hand_in, True)
3073
3074    def _increase_wifi_rssi_hand_in_and_decrease_wifi_rssi_hand_out(self):
3075        if not self._increase_wifi_rssi_check_phone_hand_in():
3076            return False
3077        if not self._decrease_wifi_rssi_check_phone_hand_out():
3078            return False
3079        return True
3080
3081    @test_tracker_info(uuid="2a20d499-80e1-4d4f-beca-05763863fbdb")
3082    @TelephonyBaseTest.tel_test_wrap
3083    def test_hand_in_out_wifi_preferred(self):
3084        """WiFi Hand-In-Out Threshold - WiFi Preferred
3085
3086        PhoneA on LTE, VoLTE enabled, WFC WiFi preferred. WiFI not associated.
3087        Cellular Strong, WiFi <-100 dBm
3088        Call from PhoneA to PhoneB, PhoneA should be on VoLTE.
3089
3090        Increase WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN in 10s.
3091        PhoneA should connect to WiFi and have data on WiFi.
3092        PhoneA should not hand-in to iwlan.
3093        Increase WiFi RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s.
3094        PhoneA should hand-in to iwlan.
3095        PhoneA call should remain active.
3096
3097        Decrease WiFi RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_NOT_HAND_OUT, in 10s.
3098        PhoneA should still be in call.
3099        PhoneA should not hand-out, PhoneA should have data on WiFi.
3100        Decrease WiFi RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT, in 10s.
3101        PhoneA should still be in call. PhoneA should hand-out to LTE.
3102        """
3103        return self._wfc_call_sequence(
3104            [self.android_devices[0], self.android_devices[1]],
3105            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_absent_cell_strong,
3106            self._wfc_phone_setup_wifi_absent_wifi_preferred,
3107            self._phone_idle_volte, self._is_phone_in_call_volte,
3108            self._increase_wifi_rssi_hand_in_and_decrease_wifi_rssi_hand_out,
3109            True)
3110
3111    def _decrease_lte_rssi_check_phone_not_hand_in(self):
3112        """Private Test utility for hand_in test.
3113
3114        Decrease Cellular RSSI to CELL_WEAK_RSSI_VALUE in 30s.
3115        PhoneA should not hand-in to WFC.
3116        PhoneA should either drop or hands over to 3g/2g.
3117        """
3118        # Decrease LTE RSSI to CELL_WEAK_RSSI_VALUE in 30 seconds
3119        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G],
3120                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE, 1, 1)
3121        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G],
3122                 self.cell_rssi_with_no_atten, CELL_WEAK_RSSI_VALUE, 1, 1)
3123        # Make sure phone not hand in to iwlan.
3124        if self._phone_wait_for_wfc():
3125            self.log.error("Phone hand-in to wfc.")
3126            return False
3127
3128        if is_phone_not_in_call(self.log, self.android_devices[0]):
3129            self.log.info("Call drop.")
3130            return True
3131        if self._is_phone_in_call_csfb():
3132            self.log.info("Call hands over to 2g/3g.")
3133            return True
3134        return False
3135
3136    @test_tracker_info(uuid="a83734c1-db91-4ea2-9d79-02d7f803905a")
3137    @TelephonyBaseTest.tel_test_wrap
3138    def test_hand_in_cellular_preferred(self):
3139        """WiFi Hand-In Not Attempted - Cellular Preferred
3140
3141        PhoneA on LTE, VoLTE enabled, WFC cellular preferred. WiFI associated.
3142        Cellular and WiFi signal strong.
3143        Call from PhoneA to PhoneB, PhoneA should be on VoLTE.
3144        Decrease Cellular RSSI to CELL_WEAK_RSSI_VALUE in 30s.
3145        PhoneA should not hand-in to WFC.
3146        PhoneA should either drop or hands over to 3g/2g.
3147        """
3148        return self._wfc_call_sequence(
3149            [self.android_devices[0], self.android_devices[1]],
3150            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3151            self._wfc_phone_setup_cellular_preferred, self._phone_idle_volte,
3152            self._is_phone_in_call_volte,
3153            self._decrease_lte_rssi_check_phone_not_hand_in, True)
3154
3155    def _decrease_wifi_rssi_check_phone_hand_out(self):
3156        """Private Test utility for hand_out test.
3157
3158        Decrease WiFi RSSI to MIN_RSSI_RESERVED_VALUE
3159        PhoneA should still be in call. PhoneA should hand-out to LTE.
3160        """
3161        time.sleep(30)
3162        # Decrease WiFi RSSI to MIN_RSSI_RESERVED_VALUE
3163        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
3164                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3165        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
3166                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3167        # Make sure phone hand-out, not drop call
3168        if not self._phone_wait_for_not_wfc():
3169            self.log.error("Phone should hand out to LTE.")
3170            get_telephony_signal_strength(self.android_devices[0])
3171            get_wifi_signal_strength(self.android_devices[0])
3172            return False
3173        self.log.info("iWLAN to LTE switch happened at below Signal Strengths")
3174        get_telephony_signal_strength(self.android_devices[0])
3175        get_wifi_signal_strength(self.android_devices[0])
3176        if not self._is_phone_in_call_volte():
3177            self.log.error("Phone should be in volte call.")
3178            return False
3179
3180        return True
3181
3182    @test_tracker_info(uuid="2242aa49-474c-496b-be1b-ccd900523a54")
3183    @TelephonyBaseTest.tel_test_wrap
3184    def test_iwlan_lte_handoff_wifi_preferred(self):
3185        """VoWiFi to VoLTE In Call Handover Test
3186
3187        PhoneA on LTE, VoLTE enabled, WFC WiFi preferred, WiFi associated.
3188        Cellular strong, WiFi signal strong.
3189        Call from PhoneA to PhoneB, PhoneA should be on iwlan.
3190        Attenuate WiFi
3191        PhoneA should still be in call. PhoneA should handover to LTE.
3192        """
3193        return self._wfc_call_sequence(
3194            [self.android_devices[0], self.android_devices[1]],
3195            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3196            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
3197            self._is_phone_in_call_iwlan,
3198            self._decrease_wifi_rssi_check_phone_hand_out, True)
3199
3200    def _increase_lte_decrease_wifi_rssi_check_phone_hand_out(self):
3201        """Private Test utility for hand_out test.
3202
3203        Attenuate WiFi and Bringup LTE
3204        PhoneA should still be in call. PhoneA should hand-out to LTE.
3205        """
3206        # Increase LTE RSRP to MAX_RSSI_RESERVED_VALUE
3207        time.sleep(30)
3208        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
3209                 MAX_RSSI_RESERVED_VALUE)
3210        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
3211                 MAX_RSSI_RESERVED_VALUE)
3212        time.sleep(30)
3213        # Decrease WiFi RSSI to MIN_RSSI_RESERVED_VALUE
3214        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
3215                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3216        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
3217                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3218        # Make sure phone hand-out, not drop call
3219        if not self._phone_wait_for_not_wfc():
3220            self.log.error("Phone should hand out to LTE.")
3221            get_telephony_signal_strength(self.android_devices[0])
3222            get_wifi_signal_strength(self.android_devices[0])
3223            return False
3224        self.log.info("iWLAN to LTE switch happened at below Signal Strengths")
3225        get_telephony_signal_strength(self.android_devices[0])
3226        get_wifi_signal_strength(self.android_devices[0])
3227        if not self._is_phone_in_call_volte():
3228            self.log.error("Phone should be in volte call.")
3229            return False
3230
3231        return True
3232
3233    @test_tracker_info(uuid="dcd1e8f6-e002-48c3-b1eb-a46df5d66a6a")
3234    @TelephonyBaseTest.tel_test_wrap
3235    def test_iwlan_lte_handoff_cellular_preferred(self):
3236        """VoWiFi to VoLTE In Call Handover Test
3237
3238        PhoneA on LTE, VoLTE enabled, WFC Cellular preferred, WiFi associated.
3239        Cellular absent, WiFi signal strong.
3240        Call from PhoneA to PhoneB, PhoneA should be on iwlan.
3241        Attenuate WiFi and Bring up LTE
3242        PhoneA should still be in call. PhoneA should handover to LTE.
3243        """
3244        return self._wfc_call_sequence(
3245            [self.android_devices[0], self.android_devices[1]],
3246            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_absent,
3247            self._wfc_phone_setup_cellular_preferred, self._phone_idle_iwlan,
3248            self._is_phone_in_call_iwlan,
3249            self._increase_lte_decrease_wifi_rssi_check_phone_hand_out, True)
3250
3251    def _decrease_wifi_rssi_hand_out_and_increase_wifi_rssi_hand_in(self):
3252        if not self._decrease_wifi_rssi_check_phone_hand_out():
3253            return False
3254        if not self._increase_wifi_rssi_check_phone_hand_in():
3255            return False
3256        return True
3257
3258    @test_tracker_info(uuid="59fc0104-5f4c-4aa5-b58b-e50d94fb90fe")
3259    @TelephonyBaseTest.tel_test_wrap
3260    def test_hand_out_in_wifi_preferred(self):
3261        """WiFi Hand-Out Threshold - WiFi Preferred
3262
3263        PhoneA on LTE, VoLTE enabled, WFC WiFi preferred, WiFi associated.
3264        Cellular and WiFi signal strong.
3265        Call from PhoneA to PhoneB, PhoneA should be on iwlan.
3266
3267        Decrease WiFi RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_NOT_HAND_OUT in 10s.
3268        PhoneA should still be in call.
3269        PhoneA should not hand-out, PhoneA should have data on WiFi.
3270        Decrease WiFi RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT in 10s.
3271        PhoneA should still be in call. PhoneA should hand-out to LTE.
3272        PhoneA should have data on WiFi.
3273
3274        Increase WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_NOT_HAND_IN in 10s.
3275        PhoneA should connect to WiFi and have data on WiFi.
3276        PhoneA should not hand-in to iwlan.
3277        Increase WiFi RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s.
3278        PhoneA should hand-in to iwlan.
3279        PhoneA call should remain active.
3280        """
3281        return self._wfc_call_sequence(
3282            [self.android_devices[0], self.android_devices[1]],
3283            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3284            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
3285            self._is_phone_in_call_iwlan,
3286            self._decrease_wifi_rssi_hand_out_and_increase_wifi_rssi_hand_in,
3287            True)
3288
3289    def _hand_out_hand_in_stress(self):
3290        total_iteration = self.stress_test_number
3291        self.log.info(
3292            "Hand_out/Hand_in stress test. Total iteration = {}.".format(
3293                total_iteration))
3294        current_iteration = 1
3295        if self._phone_wait_for_call_drop():
3296            self.log.error("Call Drop.")
3297            return False
3298        while (current_iteration <= total_iteration):
3299            self.log.info(">----Current iteration = {}/{}----<".format(
3300                current_iteration, total_iteration))
3301
3302            # Decrease WiFi RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT
3303            # in 10 seconds
3304            self.log.info("Decrease WiFi RSSI to hand out.")
3305            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3306                     self.wifi_rssi_with_no_atten,
3307                     WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT, 2, 1)
3308            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3309                     self.wifi_rssi_with_no_atten,
3310                     WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT, 2, 1)
3311            # Make sure WiFi still connected and have data.
3312            if (not wait_for_wifi_data_connection(
3313                    self.log, self.android_devices[0], True)
3314                    or not verify_http_connection(self.log,
3315                                                  self.android_devices[0])):
3316                self.log.error("No Data on Wifi")
3317                break
3318            # Make sure phone hand-out, not drop call
3319            if not self._phone_wait_for_not_wfc():
3320                self.log.error("Phone failed to hand-out in RSSI {}.".format(
3321                    WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT))
3322                break
3323            if self._phone_wait_for_call_drop():
3324                self.log.error("Call Drop.")
3325                break
3326            # Increase WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s
3327            self.log.info("Increase WiFi RSSI to hand in.")
3328            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3329                     self.wifi_rssi_with_no_atten,
3330                     WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN, 2, 1)
3331            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3332                     self.wifi_rssi_with_no_atten,
3333                     WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN, 2, 1)
3334            # Make sure WiFi still connected and have data.
3335            if (not wait_for_wifi_data_connection(
3336                    self.log, self.android_devices[0], True)
3337                    or not verify_http_connection(self.log,
3338                                                  self.android_devices[0])):
3339                self.log.error("No Data on Wifi")
3340                break
3341            # Make sure phone hand in to iwlan.
3342            if not self._phone_wait_for_wfc():
3343                self.log.error("Phone failed to hand-in to wfc.")
3344                break
3345            if self._phone_wait_for_call_drop():
3346                self.log.error("Call Drop.")
3347                break
3348
3349            self.log.info(">----Iteration : {}/{} succeed.----<".format(
3350                current_iteration, total_iteration))
3351            current_iteration += 1
3352        if current_iteration <= total_iteration:
3353            self.log.info(">----Iteration : {}/{} failed.----<".format(
3354                current_iteration, total_iteration))
3355            return False
3356        else:
3357            return True
3358
3359    @test_tracker_info(uuid="330ef8d7-3bbb-4492-84d0-43fdfe3fe78b")
3360    @TelephonyBaseTest.tel_test_wrap
3361    def test_hand_out_in_stress(self):
3362        """WiFi Calling Hand out/in stress test.
3363
3364        Steps:
3365        1. PhoneA on LTE, VoLTE enabled.
3366        2. PhoneA WFC mode WiFi preferred, WiFi associated.
3367        3. Cellular strong, WiFi RSSI strong. Call from PhoneA to PhoneB,
3368            call should be on WFC.
3369        4. Set WiFI RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT in 10s,
3370            PhoneA hand-out.
3371        5. Set WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s,
3372            PhoneA hand-in.
3373        6. Repeat Step 4~5. Call should not drop.
3374
3375        Expected Results:
3376        4. Phone should hand out.
3377        5. Phone should hand in.
3378        6. Stress test pass rate should be higher than pre-defined limit.
3379        """
3380        return self._wfc_call_sequence(
3381            [self.android_devices[0], self.android_devices[1]],
3382            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3383            self._wfc_phone_setup_wifi_preferred, self._phone_idle_iwlan,
3384            self._is_phone_in_call_iwlan, self._hand_out_hand_in_stress, True)
3385
3386    def _hand_in_hand_out_stress(self):
3387        total_iteration = self.stress_test_number
3388        self.log.info(
3389            "Hand_in/Hand_out stress test. Total iteration = {}.".format(
3390                total_iteration))
3391        current_iteration = 1
3392        if self._phone_wait_for_call_drop():
3393            self.log.error("Call Drop.")
3394            return False
3395        while (current_iteration <= total_iteration):
3396            self.log.info(">----Current iteration = {}/{}----<".format(
3397                current_iteration, total_iteration))
3398
3399            # Increase WiFi RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN
3400            # in 10 seconds
3401            self.log.info("Increase WiFi RSSI to hand in.")
3402            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3403                     self.wifi_rssi_with_no_atten,
3404                     WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN, 2, 1)
3405            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3406                     self.wifi_rssi_with_no_atten,
3407                     WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN, 2, 1)
3408            # Make sure WiFi still connected and have data.
3409            if (not wait_for_wifi_data_connection(
3410                    self.log, self.android_devices[0], True)
3411                    or not verify_http_connection(self.log,
3412                                                  self.android_devices[0])):
3413                self.log.error("No Data on Wifi")
3414                break
3415            # Make sure phone hand in to iwlan.
3416            if not self._phone_wait_for_wfc():
3417                self.log.error("Phone failed to hand-in to wfc.")
3418                break
3419            if self._phone_wait_for_call_drop():
3420                self.log.error("Call Drop.")
3421                break
3422
3423            # Decrease WiFI RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT in 10s
3424            self.log.info("Decrease WiFi RSSI to hand out.")
3425            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3426                     self.wifi_rssi_with_no_atten,
3427                     WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT, 2, 1)
3428            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3429                     self.wifi_rssi_with_no_atten,
3430                     WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT, 2, 1)
3431            # Make sure WiFi still connected and have data.
3432            if (not wait_for_wifi_data_connection(
3433                    self.log, self.android_devices[0], True)
3434                    or not verify_http_connection(self.log,
3435                                                  self.android_devices[0])):
3436                self.log.error("No Data on Wifi")
3437                break
3438            # Make sure phone hand-out, not drop call
3439            if not self._phone_wait_for_not_wfc():
3440                self.log.error("Phone failed to hand-out in RSSI {}.".format(
3441                    WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT))
3442                break
3443            if self._phone_wait_for_call_drop():
3444                self.log.error("Call Drop.")
3445                break
3446
3447            self.log.info(">----Iteration : {}/{} succeed.----<".format(
3448                current_iteration, total_iteration))
3449            current_iteration += 1
3450        if current_iteration <= total_iteration:
3451            self.log.info(">----Iteration : {}/{} failed.----<".format(
3452                current_iteration, total_iteration))
3453            return False
3454        else:
3455            return True
3456
3457    @test_tracker_info(uuid="97ae2018-935c-4dfc-bf5a-747777201ae4")
3458    @TelephonyBaseTest.tel_test_wrap
3459    def test_hand_in_out_stress(self):
3460        """WiFi Calling Hand in/out stress test.
3461
3462        Steps:
3463        1. PhoneA on LTE, VoLTE enabled.
3464        2. PhoneA WFC mode WiFi preferred, WiFi associated.
3465        3. Cellular strong, WiFi RSSI weak. Call from PhoneA to PhoneB,
3466            call should be on VoLTE.
3467        4. Set WiFI RSSI to WIFI_RSSI_FOR_HAND_IN_TEST_PHONE_HAND_IN in 10s,
3468            PhoneA hand-in.
3469        5. Set WiFI RSSI to WIFI_RSSI_FOR_HAND_OUT_TEST_PHONE_HAND_OUT in 10s,
3470            PhoneA hand-out.
3471        6. Repeat Step 4~5. Call should not drop.
3472
3473        Expected Results:
3474        4. Phone should hand in.
3475        5. Phone should hand out.
3476        6. Stress test pass rate should be higher than pre-defined limit.
3477        """
3478        return self._wfc_call_sequence(
3479            [self.android_devices[0], self.android_devices[1]],
3480            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_weak_cell_strong,
3481            self._wfc_phone_setup_wifi_preferred, self._phone_idle_volte,
3482            self._is_phone_in_call_volte, self._hand_in_hand_out_stress, True)
3483
3484    def _decrease_cellular_rssi_check_phone_hand_out(self):
3485        """Private Test utility for hand_out test.
3486
3487        Decrease Cellular RSSI to MIN_RSSI_RESERVED_VALUE 5db per sec
3488        PhoneA should still be in call. PhoneA should hand-out to iWLAN.
3489        """
3490        time.sleep(60)
3491        # Decrease Cellular RSSI to MIN_RSSI_RESERVED_VALUE
3492        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
3493                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3494        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
3495                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3496        # Make sure phone hand-out to iWLAN, not drop call
3497        if not self._phone_wait_for_wfc():
3498            self.log.error("Phone should hand out to iWLAN.")
3499            get_telephony_signal_strength(self.android_devices[0])
3500            get_wifi_signal_strength(self.android_devices[0])
3501            return False
3502        self.log.info("LTE to iWLAN switch happened at below Signal Strengths")
3503        get_telephony_signal_strength(self.android_devices[0])
3504        get_wifi_signal_strength(self.android_devices[0])
3505        time.sleep(30)
3506        if not self._is_phone_in_call_iwlan():
3507            self.log.error("Phone should be in iWLAN call.")
3508            return False
3509        time.sleep(30)
3510        return True
3511
3512    @test_tracker_info(uuid="a83734c1-db91-4ea2-9d79-02d7f803905a")
3513    @TelephonyBaseTest.tel_test_wrap
3514    def test_lte_iwlan_handoff_cellular_preferred(self):
3515        """VoLTE to VoWiFi In Call Handover Test
3516
3517        PhoneA on LTE, VoLTE enabled, WFC WiFi preferred, WiFi associated.
3518        Cellular strong, WiFi signal strong.
3519        Call from PhoneA to PhoneB, PhoneA should be on LTE.
3520        Attenuate LTE
3521        PhoneA should still be in call. PhoneA should handover to iWLAN.
3522        """
3523        return self._wfc_call_sequence(
3524            [self.android_devices[0], self.android_devices[1]],
3525            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3526            self._wfc_phone_setup_cellular_preferred, self._phone_idle_volte,
3527            self._is_phone_in_call_volte,
3528            self._decrease_cellular_rssi_check_phone_hand_out, True)
3529
3530    def _increase_wifi_decrease_cellular_check_phone_hand_out(self):
3531        """Private Test utility for hand_out test.
3532
3533        Increase WiFi RSSI to MAX_RSSI_RESERVED_VALUE
3534        Decrease Cellular RSSI to MIN_RSSI_RESERVED_VALUE 5db per sec
3535        PhoneA should still be in call. PhoneA should hand-out to iWLAN.
3536        """
3537        time.sleep(30)
3538        # Increase WiFi RSSI to MAX_RSSI_RESERVED_VALUE
3539        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G], 0,
3540                 MAX_RSSI_RESERVED_VALUE)
3541        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G], 0,
3542                 MAX_RSSI_RESERVED_VALUE)
3543        time.sleep(30)
3544        if not ensure_wifi_connected(self.log, self.android_devices[0],
3545                                     self.wifi_network_ssid,
3546                                     self.wifi_network_pass):
3547            self.log.error("{} connect WiFI failed".format(
3548                self.android_devices[0].serial))
3549            return False
3550        # Decrease Cellular RSSI to MIN_RSSI_RESERVED_VALUE
3551        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_3G], 0,
3552                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3553        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL_4G], 0,
3554                 MIN_RSSI_RESERVED_VALUE, 5, 1)
3555        # Make sure phone hand-out to iWLAN, not drop call
3556        if not self._phone_wait_for_wfc():
3557            self.log.error("Phone should hand out to iWLAN.")
3558            get_telephony_signal_strength(self.android_devices[0])
3559            get_wifi_signal_strength(self.android_devices[0])
3560            return False
3561        self.log.info("LTE to iWLAN switch happened at below Signal Strengths")
3562        get_telephony_signal_strength(self.android_devices[0])
3563        get_wifi_signal_strength(self.android_devices[0])
3564        time.sleep(30)
3565        if not self._is_phone_in_call_iwlan():
3566            self.log.error("Phone should be in iWLAN call.")
3567            return False
3568        time.sleep(30)
3569        return True
3570
3571    @test_tracker_info(uuid="6a71f8f5-d348-49b6-8ca6-2464e6387d26")
3572    @TelephonyBaseTest.tel_test_wrap
3573    def test_lte_iwlan_handoff_wifi_preferred(self):
3574        """VoLTE to VoWiFi In Call Handover Test
3575
3576        PhoneA on LTE, VoLTE enabled, WFC WiFi preferred, WiFi not associated.
3577        Cellular strong, WiFi signal absent.
3578        Call from PhoneA to PhoneB, PhoneA should be on LTE.
3579        Attenuate LTE and Bringup WiFi
3580        PhoneA should still be in call. PhoneA should handover to iWLAN.
3581        """
3582        return self._wfc_call_sequence(
3583            [self.android_devices[0], self.android_devices[1]],
3584            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_absent_cell_strong,
3585            self._wfc_phone_setup_wifi_absent_wifi_preferred,
3586            self._phone_idle_volte, self._is_phone_in_call_volte,
3587            self._increase_wifi_decrease_cellular_check_phone_hand_out, True)
3588
3589    def _decrease_wifi_rssi_check_phone_not_hand_out(self):
3590        """Private Test utility for hand_out test.
3591
3592        Decrease WiFi RSSI to <-100dBm, in 30s.
3593        PhoneA should drop call. PhoneA should not report LTE as voice RAT.
3594        PhoneA data should be on LTE.
3595        """
3596        # Decrease WiFi RSSI to <-100dBm in 30 seconds
3597        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3598                 self.wifi_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE)
3599        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3600                 self.wifi_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE)
3601        # Make sure PhoneA data is on LTE.
3602        if (not wait_for_cell_data_connection(self.log,
3603                                              self.android_devices[0], True) or
3604                not verify_http_connection(self.log, self.android_devices[0])):
3605            self.log.error("Data not on Cell.")
3606            return False
3607        # Make sure phone drop.
3608        self.log.info("Wait for call drop.")
3609        if not self._phone_wait_for_call_drop():
3610            self.log.error("Phone should drop call.")
3611            return False
3612        # Make sure Voice RAT is not LTE.
3613        # FIXME: I think there's something wrong with this check
3614        if RAT_LTE == get_network_rat(self.log, self.android_devices[0],
3615                                      NETWORK_SERVICE_VOICE):
3616            self.log.error("Phone should not report lte as voice rat.")
3617            return False
3618        return True
3619
3620    @test_tracker_info(uuid="40aa17a5-d9e0-4cff-9ca8-c187d7ae3ad1")
3621    @TelephonyBaseTest.tel_test_wrap
3622    def test_hand_out_wifi_only(self):
3623        """WiFi Hand-Out Not Attempted - WiFi Only
3624
3625        PhoneA on LTE, VoLTE enabled, WFC WiFi only, WiFi associated.
3626        Cellular and WiFi signal strong.
3627        Call from PhoneA to PhoneB, PhoneA should be on iwlan.
3628        Decrease WiFi RSSI to <-100dBm, in 30s.
3629        PhoneA should drop call. PhoneA should not report LTE as voice RAT.
3630        PhoneA data should be on LTE.
3631        """
3632        return self._wfc_call_sequence(
3633            [self.android_devices[0], self.android_devices[1]],
3634            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3635            self._wfc_phone_setup_wifi_only, self._phone_idle_iwlan,
3636            self._is_phone_in_call_iwlan,
3637            self._decrease_wifi_rssi_check_phone_not_hand_out, True)
3638
3639    @test_tracker_info(uuid="75a0ae08-3e17-4011-8201-2634026a1fb5")
3640    @TelephonyBaseTest.tel_test_wrap
3641    def test_call_epdg_wfc_wifi_preferred_e4g_disabled(self):
3642        """WiFi Calling with E4G disabled.
3643
3644        PhoneA on LTE, VoLTE disabled, WFC WiFi preferred, WiFi associated.
3645        Cellular and WiFi signal strong.
3646        Call from PhoneA to PhoneB, PhoneA should be on iwlan.
3647        """
3648        return self._wfc_call_sequence(
3649            [self.android_devices[0], self.android_devices[1]],
3650            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3651            self._wfc_phone_setup_wifi_preferred_e4g_disabled,
3652            self._phone_idle_iwlan, self._is_phone_in_call_iwlan, None, True)
3653
3654    @test_tracker_info(uuid="b6b4b423-e7bd-480d-b460-6260556ce73b")
3655    @TelephonyBaseTest.tel_test_wrap
3656    def test_call_epdg_wfc_wifi_preferred_e4g_disabled_wifi_not_connected(
3657            self):
3658        """WiFi Calling with E4G disabled.
3659
3660        PhoneA on LTE, VoLTE disabled, WFC WiFi preferred, WiFi not associated.
3661        Cellular signal strong, WiFi absent.
3662        Call from PhoneA to PhoneB, PhoneA should be on CSFB.
3663        """
3664        return self._wfc_call_sequence(
3665            [self.android_devices[0], self.android_devices[1]],
3666            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_absent_cell_strong,
3667            self._wfc_phone_setup_wifi_absent_wifi_preferred_e4g_disabled,
3668            self._phone_idle_not_iwlan, self._is_phone_in_call_csfb, None,
3669            True)
3670
3671    def _decrease_wifi_rssi_check_phone_drop(self):
3672        """Private Test utility for e4g_disabled_wfc test.
3673
3674        Decrease WiFi RSSI to make sure WiFI not connected. Call should Drop.
3675        """
3676        # Decrease WiFi RSSI to <-100dBm in 30 seconds
3677        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3678                 self.wifi_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE)
3679        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3680                 self.wifi_rssi_with_no_atten, MIN_RSSI_RESERVED_VALUE)
3681        # Make sure PhoneA data is on cellular.
3682        if (not wait_for_cell_data_connection(self.log,
3683                                              self.android_devices[0], True) or
3684                not verify_http_connection(self.log, self.android_devices[0])):
3685            self.log.error("Data not on Cell.")
3686            return False
3687        # Make sure phone drop.
3688        self.log.info("Wait for call drop.")
3689        if not self._phone_wait_for_call_drop():
3690            self.log.error("Phone should drop call.")
3691            return False
3692        return True
3693
3694    @test_tracker_info(uuid="0de1cf4f-9ae3-4da6-8f0c-666b3968009b")
3695    @TelephonyBaseTest.tel_test_wrap
3696    def test_call_epdg_wfc_wifi_preferred_e4g_disabled_leave_wifi_coverage(
3697            self):
3698        """WiFi Calling with E4G disabled.
3699
3700        PhoneA on LTE, VoLTE disabled, WFC WiFi preferred, WiFi associated.
3701        Cellular and WiFi signal strong.
3702        Call from PhoneA to PhoneB, PhoneA should be on iwlan.
3703        Decrease WiFi RSSI to make sure WiFI not connected. Call should Drop.
3704        """
3705        return self._wfc_call_sequence(
3706            [self.android_devices[0], self.android_devices[1]],
3707            DIRECTION_MOBILE_ORIGINATED, self._wfc_set_wifi_strong_cell_strong,
3708            self._wfc_phone_setup_wifi_preferred_e4g_disabled,
3709            self._phone_idle_iwlan, self._is_phone_in_call_iwlan,
3710            self._decrease_wifi_rssi_check_phone_drop, True)
3711
3712    @TelephonyBaseTest.tel_test_wrap
3713    def test_rssi_monitoring(self):
3714        """Test WiFi RSSI Monitoring API and Callback function.
3715
3716        Steps:
3717        1. Set WiFi RSSI to INITIAL_RSSI (-60dBm), connect WiFi on DUT.
3718        2. Start WiFi RSSI Monitoring for HIGHER_RSSI_THRESHOLD (-50dBm) and
3719            LOWER_RSSI_THRESHOLD (-70dBm)
3720        3. Increase WiFi RSSI to HIGHER_RSSI_THRESHOLD+5dBm
3721        4. Decrease WiFi RSSI to HIGHER_RSSI_THRESHOLD-5dBm
3722        5. Decrease WiFi RSSI to LOWER_RSSI_THRESHOLD-5dBm
3723        6. Increase WiFi RSSI to LOWER_RSSI_THRESHOLD+5dBm
3724
3725        Expected Results:
3726        1. WiFi Connected successfully.
3727        2. DUT report LOWER_RSSI_THRESHOLD available.
3728        3. DUT report HIGHER_RSSI_THRESHOLD available.
3729        4. DUT report HIGHER_RSSI_THRESHOLD lost.
3730        5. DUT report LOWER_RSSI_THRESHOLD lost.
3731        6. DUT report LOWER_RSSI_THRESHOLD available.
3732        """
3733        INITIAL_RSSI = -60
3734        HIGHER_RSSI_THRESHOLD = -50
3735        LOWER_RSSI_THRESHOLD = -70
3736        RSSI_THRESHOLD_MARGIN = 5
3737
3738        WIFI_RSSI_CHANGE_STEP_SIZE = 2
3739        WIFI_RSSI_CHANGE_DELAY_PER_STEP = 1
3740
3741        ad = self.android_devices[0]
3742
3743        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3744                 self.wifi_rssi_with_no_atten, INITIAL_RSSI)
3745        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3746                 self.wifi_rssi_with_no_atten, INITIAL_RSSI)
3747        if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid,
3748                                     self.wifi_network_pass):
3749            self.log.error("{} connect WiFI failed".format(ad.serial))
3750            return False
3751        try:
3752            rssi_monitoring_id_higher = ad.droid.connectivitySetRssiThresholdMonitor(
3753                HIGHER_RSSI_THRESHOLD)
3754            rssi_monitoring_id_lower = ad.droid.connectivitySetRssiThresholdMonitor(
3755                LOWER_RSSI_THRESHOLD)
3756
3757            self.log.info(
3758                "Initial RSSI: {},"
3759                "rssi_monitoring_id_lower should be available.".format(
3760                    INITIAL_RSSI))
3761            try:
3762                event = ad.ed.wait_for_event(
3763                    EventNetworkCallback,
3764                    is_network_call_back_event_match,
3765                    network_callback_id=rssi_monitoring_id_lower,
3766                    network_callback_event=NetworkCallbackAvailable)
3767                self.log.info("Received Event: {}".format(event))
3768            except Empty:
3769                self.log.error("No {} event for id {}".format(
3770                    NetworkCallbackAvailable, rssi_monitoring_id_lower))
3771                return False
3772
3773            self.log.info("Set RSSI to HIGHER_RSSI_THRESHOLD+5,"
3774                          "rssi_monitoring_id_higher should be available.")
3775            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3776                     self.wifi_rssi_with_no_atten,
3777                     HIGHER_RSSI_THRESHOLD + RSSI_THRESHOLD_MARGIN,
3778                     WIFI_RSSI_CHANGE_STEP_SIZE,
3779                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3780            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3781                     self.wifi_rssi_with_no_atten,
3782                     HIGHER_RSSI_THRESHOLD + RSSI_THRESHOLD_MARGIN,
3783                     WIFI_RSSI_CHANGE_STEP_SIZE,
3784                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3785            try:
3786                event = ad.ed.wait_for_event(
3787                    EventNetworkCallback,
3788                    is_network_call_back_event_match,
3789                    network_callback_id=rssi_monitoring_id_higher,
3790                    network_callback_event=NetworkCallbackAvailable)
3791                self.log.info("Received Event: {}".format(event))
3792            except Empty:
3793                self.log.error("No {} event for id {}".format(
3794                    NetworkCallbackAvailable, rssi_monitoring_id_higher))
3795                return False
3796
3797            self.log.info("Set RSSI to HIGHER_RSSI_THRESHOLD-5,"
3798                          "rssi_monitoring_id_higher should be lost.")
3799            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3800                     self.wifi_rssi_with_no_atten,
3801                     HIGHER_RSSI_THRESHOLD - RSSI_THRESHOLD_MARGIN,
3802                     WIFI_RSSI_CHANGE_STEP_SIZE,
3803                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3804            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3805                     self.wifi_rssi_with_no_atten,
3806                     HIGHER_RSSI_THRESHOLD - RSSI_THRESHOLD_MARGIN,
3807                     WIFI_RSSI_CHANGE_STEP_SIZE,
3808                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3809            try:
3810                event = ad.ed.wait_for_event(
3811                    EventNetworkCallback,
3812                    is_network_call_back_event_match,
3813                    network_callback_id=rssi_monitoring_id_higher,
3814                    network_callback_event=NetworkCallbackLost)
3815                self.log.info("Received Event: {}".format(event))
3816            except Empty:
3817                self.log.error("No {} event for id {}".format(
3818                    NetworkCallbackLost, rssi_monitoring_id_higher))
3819                return False
3820
3821            self.log.info("Set RSSI to LOWER_RSSI_THRESHOLD-5,"
3822                          "rssi_monitoring_id_lower should be lost.")
3823            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3824                     self.wifi_rssi_with_no_atten,
3825                     LOWER_RSSI_THRESHOLD - RSSI_THRESHOLD_MARGIN,
3826                     WIFI_RSSI_CHANGE_STEP_SIZE,
3827                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3828            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3829                     self.wifi_rssi_with_no_atten,
3830                     LOWER_RSSI_THRESHOLD - RSSI_THRESHOLD_MARGIN,
3831                     WIFI_RSSI_CHANGE_STEP_SIZE,
3832                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3833            try:
3834                event = ad.ed.wait_for_event(
3835                    EventNetworkCallback,
3836                    is_network_call_back_event_match,
3837                    network_callback_id=rssi_monitoring_id_lower,
3838                    network_callback_event=NetworkCallbackLost)
3839                self.log.info("Received Event: {}".format(event))
3840            except Empty:
3841                self.log.error("No {} event for id {}".format(
3842                    NetworkCallbackLost, rssi_monitoring_id_lower))
3843                return False
3844
3845            self.log.info("Set RSSI to LOWER_RSSI_THRESHOLD+5,"
3846                          "rssi_monitoring_id_lower should be available.")
3847            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_2G],
3848                     self.wifi_rssi_with_no_atten,
3849                     LOWER_RSSI_THRESHOLD + RSSI_THRESHOLD_MARGIN,
3850                     WIFI_RSSI_CHANGE_STEP_SIZE,
3851                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3852            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI_5G],
3853                     self.wifi_rssi_with_no_atten,
3854                     LOWER_RSSI_THRESHOLD + RSSI_THRESHOLD_MARGIN,
3855                     WIFI_RSSI_CHANGE_STEP_SIZE,
3856                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
3857            try:
3858                event = ad.ed.wait_for_event(
3859                    EventNetworkCallback,
3860                    is_network_call_back_event_match,
3861                    network_callback_id=rssi_monitoring_id_lower,
3862                    network_callback_event=NetworkCallbackAvailable)
3863                self.log.info("Received Event: {}".format(event))
3864            except Empty:
3865                self.log.error("No {} event for id {}".format(
3866                    NetworkCallbackAvailable, rssi_monitoring_id_lower))
3867                return False
3868        finally:
3869            ad.droid.connectivityStopRssiThresholdMonitor(
3870                rssi_monitoring_id_higher)
3871            ad.droid.connectivityStopRssiThresholdMonitor(
3872                rssi_monitoring_id_lower)
3873        return True
3874
3875
3876""" Tests End """
3877