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