def _bluetooth_tethering_then_disconnect(self, pan_ad, panu_ad):
        """Test bluetooth PAN tethering connection then disconnect service.

    Test basic PAN tethering connection between two devices then disconnect
    service.

    Steps:
    1. Enable data connection on PAN device
    2. Disable data connection on PANU device
    (steps 3-7: orchestrate_and_verify_pan_connection())
    3. Enable Airplane mode on PANU device. Enable Bluetooth only.
    4. Enable Bluetooth tethering on PAN Service device.
    5. Pair the PAN Service device to the PANU device.
    6. Verify that Bluetooth tethering is enabled on PAN Service device.
    7. Verify HTTP connection on PANU device.
    8. Disable Bluetooth tethering on PAN Service device.
    9. Verify no HTTP connection on PANU device.

    Args:
      pan_ad: Android device providing tethering via Bluetooth
      panu_ad: Android device receiving tethering via Bluetooth

    Expected Result:
    PANU device has internet access only with Bluetooth tethering

    Returns:
      Pass if True
      Fail if False
    """

        if not wait_for_cell_data_connection(self.log, pan_ad, True):
            self.log.error("Failed to enable data connection.")
            return False

        panu_ad.droid.telephonyToggleDataConnection(False)
        if not wait_for_cell_data_connection(self.log, panu_ad, False):
            self.log.error("Failed to disable data connection.")
            return False

        if not orchestrate_and_verify_pan_connection(pan_ad, panu_ad):
            self.log.error("Could not establish a PAN connection.")
            return False
        internet = wutils.validate_connection(panu_ad, DEFAULT_PING_URL)
        if not internet:
            self.log.error("Internet is not connected with Bluetooth")
            return False

        # disable bluetooth tethering and verify internet is not working
        internet = None
        pan_ad.droid.bluetoothPanSetBluetoothTethering(False)
        try:
            internet = wutils.validate_connection(panu_ad, DEFAULT_PING_URL)
        except Exception as e:
            self.log.error(e)
        if internet:
            self.log.error("Internet is working without Bluetooth tethering")
            return False

        return True
def airplane_mode_test(log, ad):
    """ Test airplane mode basic on Phone and Live SIM.

    Ensure phone attach, data on, WiFi off and verify Internet.
    Turn on airplane mode to make sure detach.
    Turn off airplane mode to make sure attach.
    Verify Internet connection.

    Args:
        log: log object.
        ad: android object.

    Returns:
        True if pass; False if fail.
    """
    if not ensure_phones_idle(log, [ad]):
        log.error("Failed to return phones to idle.")
        return False

    try:
        ad.droid.telephonyToggleDataConnection(True)
        WifiUtils.wifi_toggle_state(log, ad, False)

        log.info("Step1: ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            log.error("Failed initial attach")
            return False
        if not verify_http_connection(log, ad):
            log.error("Data not available on cell.")
            return False

        log.info("Step2: enable airplane mode and ensure detach")
        if not toggle_airplane_mode(log, ad, True):
            log.error("Failed to enable Airplane Mode")
            return False
        if not wait_for_cell_data_connection(log, ad, False):
            log.error("Failed to disable cell data connection")
            return False
        if verify_http_connection(log, ad):
            log.error("Data available in airplane mode.")
            return False

        log.info("Step3: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            log.error("Failed to disable Airplane Mode")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            log.error("Failed to enable cell data connection")
            return False

        time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)

        log.info("Step4 verify internet")
        return verify_http_connection(log, ad)
    finally:
        toggle_airplane_mode(log, ad, False)
Пример #3
0
    def test_lte_only_http_dl(self):
        """Test for 1GB 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_lte_only()
        if (not wait_for_cell_data_connection(self.log, ad, True)
                or not verify_http_connection(self.log, ad)):
            ad.log.error("Data not on LTE")
            return False
        if not active_file_download_test(self.log, ad, "1GB"):
            ad.log.error("HTTP file download failed on LTE")
            return False
        return True
Пример #4
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 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
Пример #6
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 _check_data_roaming_status(self):
     if not self.dut.droid.telephonyIsDataEnabled():
         self.log.info("Enabling Cellular Data")
         telephonyToggleDataConnection(True)
     else:
         self.log.info("Cell Data is Enabled")
     self.log.info("Waiting for cellular data to be connected")
     if not wait_for_cell_data_connection(self.log, self.dut, state=True):
         self.log.error("Failed to enable cell data")
         return False
     self.log.info("Cellular data connected, checking NetworkInfos")
     roaming_state = self.dut.droid.telephonyCheckNetworkRoaming()
     for network_info in self.dut.droid.connectivityNetworkGetAllInfo():
         sl4a_network_info = Sl4aNetworkInfo.from_dict(network_info)
         if sl4a_network_info.isRoaming:
             self.log.warning("We don't expect to be roaming")
         if sl4a_network_info.isRoaming != roaming_state:
             self.log.error(
                 "Mismatched Roaming Status Information Telephony: {}, NetworkInfo {}"
                 .format(roaming_state, sl4a_network_info.isRoaming))
             self.log.error(network_info)
             return False
     return True
Пример #8
0
    def test_smoke_volte_call_data_sms(self):
        try:
            ads = self.android_devices
            sms_idle_result = False
            sms_incall_result = False
            data_idle_result = False
            data_incall_result = False
            call_result = False

            self.log.info(
                "--------start test_smoke_volte_call_data_sms--------")
            ensure_phones_default_state(self.log, ads)
            tasks = [(phone_setup_volte, (self.log, ads[0])),
                     (phone_setup_volte, (self.log, ads[1]))]
            if not multithread_func(self.log, tasks):
                self.log.error("Phone Failed to Set Up VoLTE.")
                return False

            # This is to reduce call fail in VoLTE mode.
            # TODO: b/26338170 remove sleep, use proper API to check DUT status.
            time.sleep(10)

            self.log.info("1. SMS in LTE idle.")
            sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1],
                                                      [rand_ascii_str(50)])

            self.log.info("2. Data in LTE idle.")
            if (wait_for_cell_data_connection(self.log, ads[0], True)
                    and verify_http_connection(self.log, ads[0])):
                data_idle_result = True

            self.log.info("3. Setup VoLTE Call.")
            if not call_setup_teardown(
                    self.log,
                    ads[0],
                    ads[1],
                    ad_hangup=None,
                    verify_caller_func=is_phone_in_call_volte,
                    verify_callee_func=is_phone_in_call_volte,
                    wait_time_in_call=WAIT_TIME_IN_CALL_FOR_IMS):
                self.log.error("Setup VoLTE Call Failed.")
                return False

            self.log.info("4. Verify SMS in call.")
            sms_incall_result = sms_send_receive_verify(
                self.log, ads[0], ads[1], [rand_ascii_str(51)])

            self.log.info("5. Verify Data in call.")
            if (wait_for_cell_data_connection(self.log, ads[0], True)
                    and verify_http_connection(self.log, ads[0])):
                data_incall_result = True

            self.log.info("6. Verify Call not drop and hangup.")
            if (is_phone_in_call_volte(self.log, ads[0])
                    and is_phone_in_call_volte(self.log, ads[1])
                    and hangup_call(self.log, ads[0])):
                call_result = True

            return (sms_idle_result and data_idle_result and call_result
                    and sms_incall_result and data_incall_result)
        finally:
            self.log.info(
                "Summary for test run. Testbed:<{}>. <VoLTE> SMS idle: {}, "
                "Data idle: {}, SMS in call: {}, Data in call: {}, "
                "Voice Call: {}".format(
                    getattr(self, Config.ikey_testbed_name.value),
                    sms_idle_result, data_idle_result, sms_incall_result,
                    data_incall_result, call_result))
Пример #9
0
    def test_smoke_3g_call_data_sms(self):
        try:
            ads = self.android_devices
            sms_idle_result = False
            sms_incall_result = False
            data_idle_result = False
            data_incall_result = False
            call_result = False

            self.log.info("--------start test_smoke_3g_call_data_sms--------")
            ensure_phones_default_state(self.log, ads)
            tasks = [(phone_setup_voice_3g, (self.log, ads[0])),
                     (phone_setup_voice_3g, (self.log, ads[1]))]
            if not multithread_func(self.log, tasks):
                self.log.error("Phone Failed to Set Up 3G.")
                return False
            self.log.info("1. SMS in 3G idle.")
            sms_idle_result = sms_send_receive_verify(self.log, ads[0], ads[1],
                                                      [rand_ascii_str(50)])

            self.log.info("2. Data in 3G idle.")
            if (wait_for_cell_data_connection(self.log, ads[0], True)
                    and verify_http_connection(self.log, ads[0])):
                data_idle_result = True

            self.log.info("3. Setup 3G Call.")
            if not call_setup_teardown(self.log,
                                       ads[0],
                                       ads[1],
                                       ad_hangup=None,
                                       verify_caller_func=is_phone_in_call_3g,
                                       verify_callee_func=is_phone_in_call_3g):
                self.log.error("Setup 3G Call Failed.")
                return False

            self.log.info("4. Verify SMS in call.")
            sms_incall_result = sms_send_receive_verify(
                self.log, ads[0], ads[1], [rand_ascii_str(51)])

            self.log.info("5. Verify Data in call.")
            if is_rat_svd_capable(
                    get_network_rat(self.log, ads[0], NETWORK_SERVICE_VOICE)):
                if (wait_for_cell_data_connection(self.log, ads[0], True)
                        and verify_http_connection(self.log, ads[0])):
                    data_incall_result = True
            else:
                self.log.info("Data in call not supported on current RAT."
                              "Skip Data verification.")
                data_incall_result = SKIP

            self.log.info("6. Verify Call not drop and hangup.")
            if (is_phone_in_call_3g(self.log, ads[0])
                    and is_phone_in_call_3g(self.log, ads[1])
                    and hangup_call(self.log, ads[0])):
                call_result = True

            return (sms_idle_result and data_idle_result and call_result
                    and sms_incall_result and ((data_incall_result is True) or
                                               (data_incall_result == SKIP)))
        finally:
            self.log.info(
                "Summary for test run. Testbed:<{}>. <3G> SMS idle: {}, "
                "Data idle: {}, SMS in call: {}, Data in call: {}, "
                "Voice Call: {}".format(
                    getattr(self, Config.ikey_testbed_name.value),
                    sms_idle_result, data_idle_result, sms_incall_result,
                    data_incall_result, call_result))
Пример #10
0
    def check_emergency_call_back_mode(self,
                                       by_emergency_dialer=True,
                                       non_emergency_call_allowed=True,
                                       attemps=3):
        state = "true" if non_emergency_call_allowed else "false"
        self.set_allow_non_emergency_call(state)
        result = True
        for _ in range(attemps):
            if not self.change_emergency_number_list():
                self.dut.log.error("Unable to add number to ril.ecclist")
                return False
            last_call_number = dumpsys_last_call_number(self.dut)
            self.dut.log.info("Hung up fake emergency call in ringing")
            if by_emergency_dialer:
                initiate_emergency_dialer_call_by_adb(
                    self.log, self.dut, self.fake_emergency_number, timeout=0)
            else:
                callee = "+%s" % self.fake_emergency_number
                self.dut.droid.telecomCallNumber(callee)
            time.sleep(3)
            hangup_call_by_adb(self.dut)
            ecclist = self.dut.adb.getprop("ril.ecclist")
            self.dut.log.info("ril.ecclist = %s", ecclist)
            if self.fake_emergency_number in ecclist:
                break
        call_info = dumpsys_new_call_info(self.dut, last_call_number)
        if not call_info:
            return False
        call_tech = call_info.get("callTechnologies", "")
        if "CDMA" in call_tech:
            expected_ecbm = True
            expected_data = False
            expected_call = non_emergency_call_allowed
        elif "GSM" in call_tech:
            expected_ecbm = True
            expected_data = True
            expected_call = True
        else:
            expected_ecbm = False
            expected_data = True
            expected_call = True
        last_call_number = dumpsys_last_call_number(self.dut)
        begin_time = get_current_epoch_time()
        self.dut.ensure_screen_on()
        self.dut.exit_setup_wizard()
        reset_device_password(self.dut, None)
        call_check = call_setup_teardown(self.log,
                                         self.dut,
                                         self.android_devices[1],
                                         ad_hangup=self.dut)
        if call_check != expected_call:
            self.dut.log.error("Regular phone call is %s, expecting %s",
                               call_check, expected_call)
            result = False
        call_info = dumpsys_new_call_info(self.dut, last_call_number)
        if not call_info:
            self.dut.log.error("New call is not in dumpsys telecom")
            return False
        if expected_ecbm:
            if "ecbm" in call_info["callProperties"]:
                self.dut.log.info("New call is in ecbm.")
            else:
                self.dut.log.error(
                    "New call is not in emergency call back mode.")
                result = False
        else:
            if "ecbm" in call_info["callProperties"]:
                self.dut.log.error("New call is in emergency call back mode")
                result = False
        if not expected_data:
            if self.dut.droid.telephonyGetDataConnectionState():
                self.dut.log.info(
                    "Data connection is off as expected in ECB mode")
                self.dut.log.info("Wait for getting out of ecbm")
                if not wait_for_cell_data_connection(self.log, self.dut, True,
                                                     400):
                    self.dut.log.error(
                        "Data connection didn't come back after 5 minutes")
                    result = False
                #if not self.dut.droid.telephonyGetDataConnectionState():
                #    self.dut.log.error(
                #        "Data connection is not coming back")
                #    result = False
                elif not verify_internet_connection(self.log, self.dut):
                    self.dut.log.error(
                        "Internet connection check failed after getting out of ECB"
                    )
                    result = False

            else:
                self.dut.log.error("Data connection is not off in ECB mode")
                if not verify_internet_connection(self.log, self.dut, False):
                    self.dut.log.error("Internet connection is not off")
                    result = False
        else:
            if self.dut.droid.telephonyGetDataConnectionState():
                self.dut.log.info("Data connection is on as expected")
                if not verify_internet_connection(self.log, self.dut):
                    self.dut.log.error("Internet connection check failed")
                    result = False
            else:
                self.dut.log.error("Data connection is off, expecting on")
                result = False
        if expected_call:
            return result
        elapsed_time = (get_current_epoch_time() - begin_time) / 1000
        if elapsed_time < BLOCK_DURATION:
            time.sleep(BLOCK_DURATION - elapsed_time + 10)
        if not call_setup_teardown(
                self.log, self.dut, self.android_devices[1],
                ad_hangup=self.dut):
            self.dut.log.error("Regular phone call failed after out of ecbm")
            result = False
        return result
def data_connectivity_single_bearer(log, ad, nw_gen):
    """Test data connection: single-bearer (no voice).

    Turn off airplane mode, enable Cellular Data.
    Ensure phone data generation is expected.
    Verify Internet.
    Disable Cellular Data, verify Internet is inaccessible.
    Enable Cellular Data, verify Internet.

    Args:
        log: log object.
        ad: android object.
        nw_gen: network generation the phone should on.

    Returns:
        True if success.
        False if failed.
    """
    ensure_phones_idle(log, [ad])

    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 reselect in {}s.".format(
            MAX_WAIT_TIME_NW_SELECTION))
        return False

    try:
        log.info("Step1 Airplane Off, Data On.")
        toggle_airplane_mode(log, ad, False)
        ad.droid.telephonyToggleDataConnection(True)
        if not wait_for_cell_data_connection(log, ad, True):
            log.error("Failed to enable data connection.")
            return False

        log.info("Step2 Verify internet")
        if not verify_http_connection(log, ad):
            log.error("Data not available on cell.")
            return False

        log.info("Step3 Turn off data and verify not connected.")
        ad.droid.telephonyToggleDataConnection(False)
        if not wait_for_cell_data_connection(log, ad, False):
            log.error("Step3 Failed to disable data connection.")
            return False

        if verify_http_connection(log, ad):
            log.error("Step3 Data still available when disabled.")
            return False

        log.info("Step4 Re-enable data.")
        ad.droid.telephonyToggleDataConnection(True)
        if not wait_for_cell_data_connection(log, ad, True):
            log.error("Step4 failed to re-enable data.")
            return False
        if not verify_http_connection(log, ad):
            log.error("Data not available on cell.")
            return False

        if not is_droid_in_network_generation_for_subscription(
                log, ad, get_default_data_sub_id(ad), nw_gen,
                NETWORK_SERVICE_DATA):
            log.error("Failed: droid is no longer on correct network")
            log.info("Expected:{}, Current:{}".format(
                nw_gen, rat_generation_from_rat(
                    get_network_rat_for_subscription(
                        log, ad, get_default_data_sub_id(
                            ad), NETWORK_SERVICE_DATA))))
            return False
        return True
    finally:
        ad.droid.telephonyToggleDataConnection(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
def airplane_mode_test(log, ad, retries=3):
    """ Test airplane mode basic on Phone and Live SIM.

    Ensure phone attach, data on, WiFi off and verify Internet.
    Turn on airplane mode to make sure detach.
    Turn off airplane mode to make sure attach.
    Verify Internet connection.

    Args:
        log: log object.
        ad: android object.

    Returns:
        True if pass; False if fail.
    """
    if not ensure_phones_idle(log, [ad]):
        log.error("Failed to return phones to idle.")
        return False

    try:
        ad.droid.telephonyToggleDataConnection(True)
        wifi_toggle_state(log, ad, False)

        ad.log.info("Step1: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed initial attach")
            return False

        if not wait_for_state(get_service_state_by_adb, "IN_SERVICE",
                              MAX_WAIT_TIME_FOR_STATE_CHANGE,
                              WAIT_TIME_BETWEEN_STATE_CHECK, log, ad):
            ad.log.error("Current service state is not 'IN_SERVICE'.")
            return False

        time.sleep(30)
        if not ad.droid.connectivityNetworkIsConnected():
            ad.log.error("Network is NOT connected!")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable data connection.")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.error("Data not available on cell.")
            return False

        log.info("Step2: enable airplane mode and ensure detach")
        if not toggle_airplane_mode(log, ad, True):
            ad.log.error("Failed to enable Airplane Mode")
            return False
        if not wait_for_cell_data_connection(log, ad, False):
            ad.log.error("Failed to disable cell data connection")
            return False

        if not verify_internet_connection(log, ad, expected_state=False):
            ad.log.error("Data available in airplane mode.")
            return False

        log.info("Step3: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed to disable Airplane Mode")
            return False

        if not wait_for_state(get_service_state_by_adb, "IN_SERVICE",
                              MAX_WAIT_TIME_FOR_STATE_CHANGE,
                              WAIT_TIME_BETWEEN_STATE_CHECK, log, ad):
            ad.log.error("Current service state is not 'IN_SERVICE'.")
            return False

        time.sleep(30)
        if not ad.droid.connectivityNetworkIsConnected():
            ad.log.warning("Network is NOT connected!")

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable cell data connection")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.warning("Data not available on cell")
            return False
        return True
    finally:
        toggle_airplane_mode(log, ad, False)
Пример #15
0
def airplane_mode_test(log, ad, retries=3):
    """ Test airplane mode basic on Phone and Live SIM.

    Ensure phone attach, data on, WiFi off and verify Internet.
    Turn on airplane mode to make sure detach.
    Turn off airplane mode to make sure attach.
    Verify Internet connection.

    Args:
        log: log object.
        ad: android object.

    Returns:
        True if pass; False if fail.
    """
    if not ensure_phones_idle(log, [ad]):
        log.error("Failed to return phones to idle.")
        return False

    try:
        ad.droid.telephonyToggleDataConnection(True)
        wifi_toggle_state(log, ad, False)

        ad.log.info("Step1: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed initial attach")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable data connection.")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.error("Data not available on cell.")
            return False

        log.info("Step2: enable airplane mode and ensure detach")
        if not toggle_airplane_mode(log, ad, True):
            ad.log.error("Failed to enable Airplane Mode")
            return False
        if not wait_for_cell_data_connection(log, ad, False):
            ad.log.error("Failed to disable cell data connection")
            return False

        if not verify_internet_connection(log, ad, expected_state=False):
            ad.log.error("Data available in airplane mode.")
            return False

        log.info("Step3: disable airplane mode and ensure attach")
        if not toggle_airplane_mode(log, ad, False):
            ad.log.error("Failed to disable Airplane Mode")
            return False

        if not wait_for_cell_data_connection(log, ad, True):
            ad.log.error("Failed to enable cell data connection")
            return False

        if not verify_internet_connection(log, ad, retries=3):
            ad.log.warning("Data not available on cell")
            return False
        return True
    finally:
        toggle_airplane_mode(log, ad, False)
Пример #16
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