Exemplo n.º 1
0
    def test_wifi_only_http_dl(self):
        """Test for 10MB file download on WiFi Only

        Steps:
        1. Set WiFi atten to MIN and Cellular to MAX
        2. Start downloading 1GB file from net
        3. Verify is the download is successfull

        Expected Results:
        1. File should download over WiFi

        Returns:
        True if Pass. False if fail.
        """
        ad = self.android_devices[0]
        if not self._basic_connectivity_check():
            self.log.error("Basic Connectivity Check Failed")
            return False
        self._atten_setup_wifi_only()
        if (not wait_for_wifi_data_connection(self.log, ad, True)
                or not verify_http_connection(self.log, ad)):
            ad.log.error("Data not on WiFi")
            return False
        if not active_file_download_test(self.log, ad, "10MB"):
            ad.log.error("HTTP file download failed on WiFi")
            return False
        return True
Exemplo n.º 2
0
    def test_wifi_cell_irat_stress_http_dl(self):
        """Test for data switch between WiFi and Cell. DUT go in and out WiFi
        coverage for multiple times.

        Steps:
        1. Set WiFi and Cellular signal to good (attenuation value to MIN).
        2. Make sure DUT get Cell data coverage (LTE) and WiFi connected.
        3. Set WiFi RSSI to MAX (WiFi attenuator value to MIN).
        4. Verify DUT report WiFi connected and able to download file
        5. Set WiFi RSSI to MIN (WiFi attenuator value to MAX).
        6. Verify DUT report Cellular Data connected and able to download file
        7. Repeat Step 3~6 for stress number.

        Expected Results:
        4. DUT report WiFi connected and able to download file
        6. DUT report Cellular Data connected and able to download file
        7. Stress test should pass.

        Returns:
        True if Pass. False if fail.
        """
        ad = self.android_devices[0]
        if not self._basic_connectivity_check():
            self.log.error("Basic Connectivity Check Failed")
            return False

        total_iteration = self.stress_test_number
        self.log.info("Stress test. Total iteration = %d.", total_iteration)
        current_iteration = 1
        while (current_iteration <= total_iteration):
            self.log.info(">----Current iteration = %d/%d----<",
                          current_iteration, total_iteration)

            self._atten_setup_wifi_cell()
            if (not wait_for_wifi_data_connection(self.log, ad, True)):
                ad.log.error("Data not on WiFi")
                break
            if not active_file_download_test(self.log, ad):
                ad.log.error("HTTP file download failed on WiFi")
                break

            self._atten_setup_cell_only()
            if (not wait_for_cell_data_connection(self.log, ad, True)):
                ad.log.error("Data not on Cell")
                break
            if not active_file_download_test(self.log, ad):
                ad.log.error("HTTP file download failed on cell")
                break

            self.log.info(">----Iteration : %d/%d succeed.----<",
                          current_iteration, total_iteration)
            current_iteration += 1

        if current_iteration <= total_iteration:
            self.log.info(">----Iteration : %d/%d failed.----<",
                          current_iteration, total_iteration)
            return False
        else:
            return True
 def _check_wfc_enabled(self, ad):
     if not wait_for_wifi_data_connection(self.log, ad, True):
         ad.log.error("Failed to connect to WIFI")
         return False
     if not wait_for_wfc_enabled(self.log, ad):
         ad.log.error("WFC is not enabled")
         return False
     if not wait_for_network_rat(
             self.log, ad, RAT_FAMILY_WLAN,
             voice_or_data=NETWORK_SERVICE_DATA):
         ad.log.info("Data rat can not go to iwlan mode successfully")
         return False
     return True
 def test_check_environment(self):
     ad = self.android_devices[0]
     # Check WiFi environment.
     # 1. Connect to WiFi.
     # 2. Check WiFi have Internet access.
     try:
         if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid,
                                      self.wifi_network_pass):
             abort_all_tests(ad.log, "WiFi connect fail")
         if (not wait_for_wifi_data_connection(self.log, ad, True)
                 or not verify_internet_connection(self.log, ad)):
             abort_all_tests(ad.log, "Data not available on WiFi")
     finally:
         wifi_toggle_state(self.log, ad, False)
     # TODO: add more environment check here.
     return True
Exemplo n.º 5
0
 def _check_wfc_enabled(self):
     if not wait_for_wifi_data_connection(self.log, self.dut, True):
         self.dut.log.error("Failed to connect to WIFI")
         return False
     if not wait_for_wfc_enabled(self.log, self.dut):
         self.dut.log.error("WFC is not enabled")
         return False
     if not wait_for_network_rat(self.log,
                                 self.dut,
                                 RAT_FAMILY_WLAN,
                                 voice_or_data=NETWORK_SERVICE_DATA):
         ad.log.info("Data rat can not go to iwlan mode successfully")
         return False
     if not call_setup_teardown(self.log, self.dut, self.ad_reference,
                                self.dut, is_phone_in_call_iwlan):
         self.log.error("WFC Call Failed.")
         return False
     return True
    def test_lte_oos_lte_camping(self):
        """Test for Out Of Service Scenarios

        Steps:
        1. Set WiFi and Cell available
        2. Setup Attenuator as No Service Scenario
        3. Verify there is no LTE or WiFi Signal
        4. Wait for 2 mins
        5. Setup Attenuator as Cellular only service
        6. Verify Data Connection

        Expected Results:
        1. Device should camp back on LTE after OOS
        2. Data should be in working state

        Returns:
        True if Pass. False if fail.
        """
        ad = self.android_devices[0]
        if not self._basic_connectivity_check():
            self.log.error("Basic Connectivity Check Failed")
            return False
        self._atten_setup_no_service()
        ad.log.info("Waiting for 1 min")
        time.sleep(60)
        if (wait_for_cell_data_connection(self.log, ad, True) or
                wait_for_wifi_data_connection(self.log, ad, True)):
            ad.log.error("Data is available, Expecting no Cellular/WiFi Signal")
            get_telephony_signal_strength(ad)
            get_wifi_signal_strength(ad)
            return False
        ad.log.info("Waiting for 2 mins")
        time.sleep(120)
        self._atten_setup_lte_only()
        ad.on_mobile_data = True
        if (not wait_for_cell_data_connection(self.log, ad, True)
                or not verify_internet_connection(self.log, ad)):
            ad.log.error("Data not on LTE")
            get_telephony_signal_strength(ad)
            get_wifi_signal_strength(ad)
            return False
        return True
Exemplo n.º 7
0
    def test_check_environment(self):
        ad = self.android_devices[0]
        # Check WiFi environment.
        # 1. Connect to WiFi.
        # 2. Check WiFi have Internet access.
        toggle_airplane_mode(self.log, ad, False, strict_checking=False)

        try:
            if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid,
                                         self.wifi_network_pass):
                self._preflight_fail("{}: WiFi connect fail.".format(
                    ad.serial))
            if (not wait_for_wifi_data_connection(self.log, ad, True)
                    or not verify_http_connection(self.log, ad)):
                self._preflight_fail("{}: Data not available on WiFi.".format(
                    ad.serial))
        finally:
            WifiUtils.wifi_toggle_state(self.log, ad, False)
        # TODO: add more environment check here.
        return True
Exemplo n.º 8
0
    def _wifi_cell_irat_task(self, ad, irat_wait_time=60):
        """
        Atten only WiFi to MIN and MAX
        WiFi --> Cellular
        """
        self._atten_setup_wifi_cell()
        if (not wait_for_wifi_data_connection(self.log, ad, True,
                                              irat_wait_time)
                or not verify_http_connection(self.log, ad)):
            ad.log.error("Data not on WiFi")
            return False

        ad.log.info("Triggering WiFi to Cellular IRAT")
        self._atten_setup_cell_only()
        if (not wait_for_cell_data_connection(self.log, ad, True,
                                              irat_wait_time)
                or not verify_http_connection(self.log, ad)):
            ad.log.error("Data not on Cell")
            return False
        return True
    def test_wfc_setup_timing(self):
        """ Measures the time delay in enabling WiFi calling

        Steps:
        1. Make sure DUT idle.
        2. Turn on Airplane Mode, Set WiFi Calling to WiFi_Preferred.
        3. Turn on WiFi, connect to WiFi AP and measure time delay.
        4. Wait for WiFi connected, verify Internet and measure time delay.
        5. Wait for rat to be reported as iwlan and measure time delay.
        6. Wait for ims registered and measure time delay.
        7. Wait for WiFi Calling feature bit to be True and measure time delay.

        Expected results:
        Time Delay in each step should be within pre-defined limit.

        Returns:
            Currently always return True.
        """
        # TODO: b/26338119 Set pass/fail criteria
        time_values = {
            'start': 0,
            'wifi_enabled': 0,
            'wifi_connected': 0,
            'wifi_data': 0,
            'iwlan_rat': 0,
            'ims_registered': 0,
            'wfc_enabled': 0,
            'mo_call_success': 0
        }

        wifi_reset(self.log, self.dut)
        toggle_airplane_mode_by_adb(self.log, self.dut, True)

        set_wfc_mode(self.log, self.dut, WFC_MODE_WIFI_PREFERRED)

        time_values['start'] = time.time()

        self.dut.log.info("Start Time %ss", time_values['start'])

        wifi_toggle_state(self.log, self.dut, True)
        time_values['wifi_enabled'] = time.time()
        self.dut.log.info("WiFi Enabled After %ss",
                          time_values['wifi_enabled'] - time_values['start'])

        network = {WIFI_SSID_KEY: self.wifi_network_ssid}
        if self.wifi_network_pass:
            network[WIFI_PWD_KEY] = self.wifi_network_pass
        try:
            self.dut.droid.wifiConnectByConfig(network)
        except Exception:
            self.dut.log.info("Connecting to wifi by RPC wifiConnect instead")
            self.dut.droid.wifiConnect(network)
        self.dut.droid.wakeUpNow()

        if not wait_for_wifi_data_connection(self.log, self.dut, True,
                                             MAX_WAIT_TIME_WIFI_CONNECTION):
            self.dut.log.error("Failed WiFi connection, aborting!")
            return False
        time_values['wifi_connected'] = time.time()

        self.dut.log.info(
            "WiFi Connected After %ss",
            time_values['wifi_connected'] - time_values['wifi_enabled'])

        if not verify_internet_connection(self.log, self.dut, retries=3):
            self.dut.log.error("Failed to get user-plane traffic, aborting!")
            return False

        time_values['wifi_data'] = time.time()
        self.dut.log.info(
            "WifiData After %ss",
            time_values['wifi_data'] - time_values['wifi_connected'])

        if not wait_for_network_rat(
                self.log,
                self.dut,
                RAT_FAMILY_WLAN,
                voice_or_data=NETWORK_SERVICE_DATA):
            self.dut.log.error("Failed to set-up iwlan, aborting!")
            if is_droid_in_rat_family(self.log, self.dut, RAT_FAMILY_WLAN,
                                      NETWORK_SERVICE_DATA):
                self.dut.log.error(
                    "Never received the event, but droid in iwlan")
            else:
                return False
        time_values['iwlan_rat'] = time.time()
        self.dut.log.info("iWLAN Reported After %ss",
                          time_values['iwlan_rat'] - time_values['wifi_data'])

        if not wait_for_ims_registered(self.log, self.dut,
                                       MAX_WAIT_TIME_IMS_REGISTRATION):
            self.dut.log.error("Never received IMS registered, aborting")
            return False
        time_values['ims_registered'] = time.time()
        self.dut.log.info(
            "Ims Registered After %ss",
            time_values['ims_registered'] - time_values['iwlan_rat'])

        if not wait_for_wfc_enabled(self.log, self.dut,
                                    MAX_WAIT_TIME_WFC_ENABLED):
            self.dut.log.error("Never received WFC feature, aborting")
            return False

        time_values['wfc_enabled'] = time.time()
        self.dut.log.info(
            "Wifi Calling Feature Enabled After %ss",
            time_values['wfc_enabled'] - time_values['ims_registered'])

        set_wfc_mode(self.log, self.dut, WFC_MODE_DISABLED)

        wait_for_not_network_rat(
            self.log,
            self.dut,
            RAT_FAMILY_WLAN,
            voice_or_data=NETWORK_SERVICE_DATA)

        self.dut.log.info("\n\n------------------summary-----------------")
        self.dut.log.info("WiFi Enabled After %.2f seconds",
                          time_values['wifi_enabled'] - time_values['start'])
        self.dut.log.info(
            "WiFi Connected After %.2f seconds",
            time_values['wifi_connected'] - time_values['wifi_enabled'])
        self.dut.log.info(
            "WifiData After %.2f s",
            time_values['wifi_data'] - time_values['wifi_connected'])
        self.dut.log.info("iWLAN Reported After %.2f seconds",
                          time_values['iwlan_rat'] - time_values['wifi_data'])
        self.dut.log.info(
            "Ims Registered After %.2f seconds",
            time_values['ims_registered'] - time_values['iwlan_rat'])
        self.dut.log.info(
            "Wifi Calling Feature Enabled After %.2f seconds",
            time_values['wfc_enabled'] - time_values['ims_registered'])
        self.dut.log.info("\n\n")
        return True
def wifi_tethering_setup_teardown(log,
                                  provider,
                                  client_list,
                                  ap_band=WifiUtils.WIFI_CONFIG_APBAND_2G,
                                  check_interval=30,
                                  check_iteration=4,
                                  do_cleanup=True,
                                  ssid=None,
                                  password=None):
    """Test WiFi Tethering.

    Turn off WiFi on clients.
    Turn off data and reset WiFi on clients.
    Verify no Internet access on clients.
    Turn on WiFi tethering on provider.
    Clients connect to provider's WiFI.
    Verify Internet on provider and clients.
    Tear down WiFi tethering setup and clean up.

    Args:
        log: log object.
        provider: android object provide WiFi tethering.
        client_list: a list of clients using tethered WiFi.
        ap_band: setup WiFi tethering on 2G or 5G.
            This is optional, default value is WifiUtils.WIFI_CONFIG_APBAND_2G
        check_interval: delay time between each around of Internet connection check.
            This is optional, default value is 30 (seconds).
        check_iteration: check Internet connection for how many times in total.
            This is optional, default value is 4 (4 times).
        do_cleanup: after WiFi tethering test, do clean up to tear down tethering
            setup or not. This is optional, default value is True.
        ssid: use this string as WiFi SSID to setup tethered WiFi network.
            This is optional. Default value is None.
            If it's None, a random string will be generated.
        password: use this string as WiFi password to setup tethered WiFi network.
            This is optional. Default value is None.
            If it's None, a random string will be generated.

    Returns:
        True if no error happened. False otherwise.
    """
    log.info("--->Start wifi_tethering_setup_teardown<---")
    log.info("Provider: {}".format(provider.serial))
    if not provider.droid.connectivityIsTetheringSupported():
        log.error("Provider does not support tethering. Stop tethering test.")
        return False

    if ssid is None:
        ssid = rand_ascii_str(10)
    if password is None:
        password = rand_ascii_str(8)

    # No password
    if password == "":
        password = None

    try:
        for client in client_list:
            log.info("Client: {}".format(client.serial))
            WifiUtils.wifi_toggle_state(log, client, False)
            client.droid.telephonyToggleDataConnection(False)
        log.info("WiFI Tethering: Verify client have no Internet access.")
        for client in client_list:
            if verify_http_connection(log, client):
                log.error("Turn off Data on client fail. {}".format(
                    client.serial))
                return False

        log.info(
            "WiFI Tethering: Turn on WiFi tethering on {}. SSID: {}, password: {}".format(
                provider.serial, ssid, password))

        if not WifiUtils.start_wifi_tethering(log, provider, ssid, password,
                                              ap_band):
            log.error("Provider start WiFi tethering failed.")
            return False
        time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)

        log.info("Provider {} check Internet connection.".format(
            provider.serial))
        if not verify_http_connection(log, provider):
            return False
        for client in client_list:
            log.info(
                "WiFI Tethering: {} connect to WiFi and verify AP band correct.".format(
                    client.serial))
            if not ensure_wifi_connected(log, client, ssid, password):
                log.error("Client connect to WiFi failed.")
                return False

            wifi_info = client.droid.wifiGetConnectionInfo()
            if ap_band == WifiUtils.WIFI_CONFIG_APBAND_5G:
                if wifi_info["is_24ghz"]:
                    log.error("Expected 5g network. WiFi Info: {}".format(
                        wifi_info))
                    return False
            else:
                if wifi_info["is_5ghz"]:
                    log.error("Expected 2g network. WiFi Info: {}".format(
                        wifi_info))
                    return False

            log.info("Client{} check Internet connection.".format(
                client.serial))
            if (not wait_for_wifi_data_connection(log, client, True) or
                    not verify_http_connection(log, client)):
                log.error("No WiFi Data on client: {}.".format(client.serial))
                return False

        if not tethering_check_internet_connection(
                log, provider, client_list, check_interval, check_iteration):
            return False

    finally:
        if (do_cleanup and
            (not wifi_tethering_cleanup(log, provider, client_list))):
            return False
    return True
def wifi_cell_switching(log, ad, wifi_network_ssid, wifi_network_pass, nw_gen):
    """Test data connection network switching when phone on <nw_gen>.

    Ensure phone is on <nw_gen>
    Ensure WiFi can connect to live network,
    Airplane mode is off, data connection is on, WiFi is on.
    Turn off WiFi, verify data is on cell and browse to google.com is OK.
    Turn on WiFi, verify data is on WiFi and browse to google.com is OK.
    Turn off WiFi, verify data is on cell and browse to google.com is OK.

    Args:
        log: log object.
        ad: android object.
        wifi_network_ssid: ssid for live wifi network.
        wifi_network_pass: password for live wifi network.
        nw_gen: network generation the phone should be camped on.

    Returns:
        True if pass.
    """
    try:

        if not ensure_network_generation_for_subscription(
                log, ad, get_default_data_sub_id(ad), nw_gen,
                MAX_WAIT_TIME_NW_SELECTION, NETWORK_SERVICE_DATA):
            log.error("Device failed to register in {}".format(nw_gen))
            return False

        # Ensure WiFi can connect to live network
        log.info("Make sure phone can connect to live network by WIFI")
        if not ensure_wifi_connected(log, ad, wifi_network_ssid,
                                     wifi_network_pass):
            log.error("WiFi connect fail.")
            return False
        log.info("Phone connected to WIFI.")

        log.info("Step1 Airplane Off, WiFi On, Data On.")
        toggle_airplane_mode(log, ad, False)
        WifiUtils.wifi_toggle_state(log, ad, True)
        ad.droid.telephonyToggleDataConnection(True)
        if (not wait_for_wifi_data_connection(log, ad, True) or
                not verify_http_connection(log, ad)):
            log.error("Data is not on WiFi")
            return False

        log.info("Step2 WiFi is Off, Data is on Cell.")
        WifiUtils.wifi_toggle_state(log, ad, False)
        if (not wait_for_cell_data_connection(log, ad, True) or
                not verify_http_connection(log, ad)):
            log.error("Data did not return to cell")
            return False

        log.info("Step3 WiFi is On, Data is on WiFi.")
        WifiUtils.wifi_toggle_state(log, ad, True)
        if (not wait_for_wifi_data_connection(log, ad, True) or
                not verify_http_connection(log, ad)):
            log.error("Data did not return to WiFi")
            return False

        log.info("Step4 WiFi is Off, Data is on Cell.")
        WifiUtils.wifi_toggle_state(log, ad, False)
        if (not wait_for_cell_data_connection(log, ad, True) or
                not verify_http_connection(log, ad)):
            log.error("Data did not return to cell")
            return False
        return True

    finally:
        WifiUtils.wifi_toggle_state(log, ad, False)
    def test_wifi_cell_switching_stress(self):
        """Test for data switch between WiFi and Cell. DUT go in and out WiFi
        coverage for multiple times.

        Steps:
        1. Set WiFi and Cellular signal to good (attenuation value to MIN).
        2. Make sure DUT get Cell data coverage (LTE) and WiFi connected.
        3. Set WiFi RSSI to MAX (WiFi attenuator value to MIN).
        4. Verify DUT report WiFi connected and Internet access OK.
        5. Set WiFi RSSI to MIN (WiFi attenuator value to MAX).
        6. Verify DUT report Cellular Data connected and Internet access OK.
        7. Repeat Step 3~6 for stress number.

        Expected Results:
        4. DUT report WiFi connected and Internet access OK.
        6. DUT report Cellular Data connected and Internet access OK.
        7. Stress test should pass.

        Returns:
        True if Pass. False if fail.
        """
        WIFI_RSSI_CHANGE_STEP_SIZE = 2
        WIFI_RSSI_CHANGE_DELAY_PER_STEP = 1
        # Set Attenuator Value for WiFi and Cell to 0.
        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI], 0,
                 MAX_RSSI_RESERVED_VALUE)
        set_rssi(self.log, self.attens[ATTEN_NAME_FOR_CELL], 0,
                 MAX_RSSI_RESERVED_VALUE)

        # Make sure DUT get Cell Data coverage (LTE).
        toggle_airplane_mode(self.log, self.android_devices[0], False)
        if not ensure_network_generation(self.log, self.android_devices[0],
                                         GEN_4G, NETWORK_SERVICE_DATA):
            return False

        # Make sure DUT WiFi is connected.
        if not ensure_wifi_connected(self.log, self.android_devices[0],
                                     self.live_network_ssid,
                                     self.live_network_pwd):
            self.log.error("{} connect WiFI failed".format(
                self.android_devices[0].serial))
            return False

        total_iteration = self.stress_test_number
        self.log.info("Stress test. Total iteration = {}.".format(
            total_iteration))
        current_iteration = 1
        while (current_iteration <= total_iteration):
            self.log.info(">----Current iteration = {}/{}----<".format(
                current_iteration, total_iteration))

            # Set WiFi RSSI to MAX.
            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI], 0,
                     MAX_RSSI_RESERVED_VALUE, WIFI_RSSI_CHANGE_STEP_SIZE,
                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
            # Wait for DUT report WiFi connected and Internet access OK.
            if (not wait_for_wifi_data_connection(
                    self.log, self.android_devices[0], True) or
                    not verify_http_connection(self.log,
                                               self.android_devices[0])):
                self.log.error("Data not on WiFi")
                break

            # Set WiFi RSSI to MIN (DUT lose WiFi coverage).
            set_rssi(self.log, self.attens[ATTEN_NAME_FOR_WIFI], 0,
                     MIN_RSSI_RESERVED_VALUE, WIFI_RSSI_CHANGE_STEP_SIZE,
                     WIFI_RSSI_CHANGE_DELAY_PER_STEP)
            # Wait for DUT report Cellular Data connected and Internet access OK.
            if (not wait_for_cell_data_connection(
                    self.log, self.android_devices[0], True) or
                    not verify_http_connection(self.log,
                                               self.android_devices[0])):
                self.log.error("Data not on Cell")
                break

            self.log.info(">----Iteration : {}/{} succeed.----<".format(
                current_iteration, total_iteration))
            current_iteration += 1
        if current_iteration <= total_iteration:
            self.log.info(">----Iteration : {}/{} failed.----<".format(
                current_iteration, total_iteration))
            return False
        else:
            return True
Exemplo n.º 13
0
    def test_modem_power_poor_coverage(self):
        """Connectivity Monitor reports Poor Coverage to User

        Steps:
        1. Set WiFi, Cellular atten to MAX
        2. Wait for X amount of time
        3. Verify if the user gets a notification on UI

        Expected Results:
        1. User gets notification "Cellular battery issue: Poor coverage"

        Returns:
        True if Pass. False if fail.
        """
        ad = self.android_devices[0]
        # Ensure apk is installed
        monitor_apk = None
        for apk in ("com.google.telephonymonitor",
                    "com.google.android.connectivitymonitor"):
            if ad.is_apk_installed(apk):
                ad.log.info("apk %s is installed", apk)
                monitor_apk = apk
                break
        if not monitor_apk:
            ad.log.info(
                "ConnectivityMonitor|TelephonyMonitor is not installed")
            return False

        # Ensure apk is running
        ad.adb.shell("am start -n com.android.settings/.DevelopmentSettings",
                     ignore_status=True)
        for cmd in ("setprop persist.radio.enable_tel_mon user_enabled",
                    "setprop persist.radio.con_mon_hbeat 15000"):
            ad.log.info(cmd)
            ad.adb.shell(cmd)
        ad.log.info("reboot to bring up %s", monitor_apk)
        reboot_device(ad)
        for i in range(30):
            if ad.is_apk_running(monitor_apk):
                ad.log.info("%s is running after reboot", monitor_apk)
                break
            elif i == 19:
                ad.log.error("%s is not running after reboot", monitor_apk)
                return False
            else:
                ad.log.info(
                    "%s is not running after reboot. Wait and check again",
                    monitor_apk)
                time.sleep(30)

        # Setup all Notify Poor Coverage params
        for cmd in (
                "am broadcast -a "
                "com.google.gservices.intent.action.GSERVICES_OVERRIDE "
                "-e \"ce.cm.bi.c.notify_poor_coverage\" \"true\"",
                "am broadcast -a "
                "com.google.gservices.intent.action.GSERVICES_OVERRIDE "
                "-e \"ce.cm.bi.c.max_time_lowest_signal_strength_level_ms\" \"1\"",
                "am broadcast -a "
                "com.google.gservices.intent.action.GSERVICES_OVERRIDE "
                "-e \"ce.cm.bi.c.max_temperature_c\" \"1\"",
                "dumpsys battery set usb 0"):
            time.sleep(1)
            ad.log.info(cmd)
            ad.adb.shell(cmd)

        # Make Chamber ready for test
        self._atten_setup_no_service()
        ad.log.info("Waiting 1 min for attens to settle")
        time.sleep(60)
        if (wait_for_cell_data_connection(self.log, ad, True)
                or wait_for_wifi_data_connection(self.log, ad, True)):
            ad.log.error(
                "Data is available, Expecting no Cellular/WiFi Signal")
            get_telephony_signal_strength(ad)
            get_wifi_signal_strength(ad)
            return False
        ad.log.info("Wait time for 2 CM Heart Beats")
        time.sleep(60)
        ad.log.info("dumpsys battery set usb 1")
        ad.adb.shell("dumpsys battery set usb 1")
        if ad.search_logcat(
                "Bugreport notification title Cellular battery drain"):
            ad.log.info("User got Poor coverage notification")
        else:
            ad.log.error("User didn't get Poor coverage notification")
            result = False
        return True
    def test_wfc_setup_timing(self):
        """ Measures the time delay in enabling WiFi calling

        Steps:
        1. Make sure DUT idle.
        2. Turn on Airplane Mode, Set WiFi Calling to WiFi_Preferred.
        3. Turn on WiFi, connect to WiFi AP and measure time delay.
        4. Wait for WiFi connected, verify Internet and measure time delay.
        5. Wait for rat to be reported as iwlan and measure time delay.
        6. Wait for ims registered and measure time delay.
        7. Wait for WiFi Calling feature bit to be True and measure time delay.

        Expected results:
        Time Delay in each step should be within pre-defined limit.

        Returns:
            Currently always return True.
        """
        # TODO: b/26338119 Set pass/fail criteria
        ad = self.android_devices[0]

        time_values = {
            'start': 0,
            'wifi_enabled': 0,
            'wifi_connected': 0,
            'wifi_data': 0,
            'iwlan_rat': 0,
            'ims_registered': 0,
            'wfc_enabled': 0,
            'mo_call_success': 0
        }

        WifiUtils.wifi_reset(self.log, ad)
        toggle_airplane_mode(self.log, ad, True)

        set_wfc_mode(self.log, ad, WFC_MODE_WIFI_PREFERRED)

        time_values['start'] = time.time()

        self.log.info("Start Time {}s".format(time_values['start']))

        WifiUtils.wifi_toggle_state(self.log, ad, True)
        time_values['wifi_enabled'] = time.time()
        self.log.info(
            "WiFi Enabled After {}s".format(time_values['wifi_enabled'] -
                                            time_values['start']))

        WifiUtils.wifi_connect(self.log, ad, self.wifi_network_ssid,
                               self.wifi_network_pass)

        ad.droid.wakeUpNow()

        if not wait_for_wifi_data_connection(self.log, ad, True,
                                             MAX_WAIT_TIME_WIFI_CONNECTION):
            self.log.error("Failed WiFi connection, aborting!")
            return False
        time_values['wifi_connected'] = time.time()

        self.log.info(
            "WiFi Connected After {}s".format(time_values['wifi_connected'] -
                                              time_values['wifi_enabled']))

        if not verify_http_connection(self.log, ad, 'http://www.google.com',
                                      100, .1):
            self.log.error("Failed to get user-plane traffic, aborting!")
            return False

        time_values['wifi_data'] = time.time()
        self.log.info(
            "WifiData After {}s".format(time_values['wifi_data'] -
                                        time_values['wifi_connected']))

        if not wait_for_network_rat(
                self.log, ad, RAT_FAMILY_WLAN,
                voice_or_data=NETWORK_SERVICE_DATA):
            self.log.error("Failed to set-up iwlan, aborting!")
            if is_droid_in_rat_family(self.log, ad, RAT_FAMILY_WLAN,
                                      NETWORK_SERVICE_DATA):
                self.log.error("Never received the event, but droid in iwlan")
            else:
                return False
        time_values['iwlan_rat'] = time.time()
        self.log.info(
            "iWLAN Reported After {}s".format(time_values['iwlan_rat'] -
                                              time_values['wifi_data']))

        if not wait_for_ims_registered(self.log, ad,
                                       MAX_WAIT_TIME_IMS_REGISTRATION):
            self.log.error("Never received IMS registered, aborting")
            return False
        time_values['ims_registered'] = time.time()
        self.log.info(
            "Ims Registered After {}s".format(time_values['ims_registered'] -
                                              time_values['iwlan_rat']))

        if not wait_for_wfc_enabled(self.log, ad, MAX_WAIT_TIME_WFC_ENABLED):
            self.log.error("Never received WFC feature, aborting")
            return False

        time_values['wfc_enabled'] = time.time()
        self.log.info("Wifi Calling Feature Enabled After {}s".format(
            time_values['wfc_enabled'] - time_values['ims_registered']))

        set_wfc_mode(self.log, ad, WFC_MODE_DISABLED)

        wait_for_not_network_rat(self.log,
                                 ad,
                                 RAT_FAMILY_WLAN,
                                 voice_or_data=NETWORK_SERVICE_DATA)

        self.log.info("\n\n------------------summary-----------------")
        self.log.info(
            "WiFi Enabled After {0:.2f} s".format(time_values['wifi_enabled'] -
                                                  time_values['start']))
        self.log.info("WiFi Connected After {0:.2f} s".format(
            time_values['wifi_connected'] - time_values['wifi_enabled']))
        self.log.info(
            "WifiData After {0:.2f} s".format(time_values['wifi_data'] -
                                              time_values['wifi_connected']))
        self.log.info(
            "iWLAN Reported After {0:.2f} s".format(time_values['iwlan_rat'] -
                                                    time_values['wifi_data']))
        self.log.info("Ims Registered After {0:.2f} s".format(
            time_values['ims_registered'] - time_values['iwlan_rat']))
        self.log.info("Wifi Calling Feature Enabled After {0:.2f} s".format(
            time_values['wfc_enabled'] - time_values['ims_registered']))
        self.log.info("\n\n")
        return True