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