def phone_setup_video_for_subscription(log,
                                       ad,
                                       sub_id,
                                       wfc_mode=WFC_MODE_DISABLED):
    """Setup phone sub_id to make video call

    Args:
        log: log object.
        ad: android device object
        sub_id: ad's sub id.
        wfc_mode: WFC mode to set to.
            Valid mode includes: WFC_MODE_WIFI_ONLY, WFC_MODE_CELLULAR_PREFERRED,
            WFC_MODE_WIFI_PREFERRED, WFC_MODE_DISABLED.

    Returns:
        True if ad (sub_id) is setup correctly and idle for video call.
    """

    toggle_airplane_mode(log, ad, False)
    if not set_wfc_mode(log, ad, wfc_mode):
        log.error("{} WFC mode failed to be set to {}.".format(
            ad.serial, wfc_mode))
        return False
    toggle_volte(log, ad, True)

    if not ensure_network_generation(
            log, ad, GEN_4G, voice_or_data=NETWORK_SERVICE_DATA):
        log.error("{} voice not in LTE mode.".format(ad.serial))
        return False

    return phone_idle_video_for_subscription(log, ad, sub_id)
Example #2
0
def phone_setup_iwlan_cellular_preferred(log,
                                         ad,
                                         wifi_ssid=None,
                                         wifi_pwd=None):
    """Phone setup function for iwlan Non-APM CELLULAR_PREFERRED test.
    Set WFC mode according to CELLULAR_PREFERRED.
    Set airplane mode according to False.
    Make sure phone connect to WiFi. (If wifi_ssid is not None.)
    Make sure phone don't report iwlan data network type.
    Make sure phone don't report wfc enabled flag to be true.

    Args:
        log: Log object.
        ad: Android device object.
        wifi_ssid: WiFi network SSID. This is optional.
            If wifi_ssid is None, then phone_setup_iwlan will not attempt to connect to wifi.
        wifi_pwd: WiFi network password. This is optional.

    Returns:
        True if success. False if fail.
    """
    toggle_airplane_mode(log, ad, False, strict_checking=False)
    try:
        toggle_volte(log, ad, True)
        if not wait_for_network_generation(
                log, ad, GEN_4G, voice_or_data=NETWORK_SERVICE_DATA):
            if not ensure_network_generation(
                    log, ad, GEN_4G, voice_or_data=NETWORK_SERVICE_DATA):
                ad.log.error("Fail to ensure data in 4G")
                return False
    except Exception as e:
        ad.log.error(e)
        ad.droid.telephonyToggleDataConnection(True)
    if wifi_ssid is not None:
        if not ensure_wifi_connected(log, ad, wifi_ssid, wifi_pwd):
            ad.log.error("Connect to WiFi failed.")
            return False
    if not set_wfc_mode(log, ad, WFC_MODE_CELLULAR_PREFERRED):
        ad.log.error("Set WFC mode failed.")
        return False
    if not wait_for_not_network_rat(
            log, ad, RAT_FAMILY_WLAN, voice_or_data=NETWORK_SERVICE_DATA):
        ad.log.error("Data rat in iwlan mode.")
        return False
    elif not wait_for_wfc_disabled(log, ad, MAX_WAIT_TIME_WFC_ENABLED):
        ad.log.error("Should report wifi calling disabled within %s.",
                     MAX_WAIT_TIME_WFC_ENABLED)
        return False
    return True
Example #3
0
    def _basic_connectivity_check(self):
        """
        Set Attenuator Value for WiFi and Cell to 0
        Make sure DUT get Cell Data coverage (LTE)
        Make sure DUT WiFi is connected
        """
        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

        if not ensure_wifi_connected(self.log, self.android_devices[0],
                                     self.live_network_ssid,
                                     self.live_network_pwd):
            ad.log.error("%s connect WiFI failed")
            return False
        return True
    def _basic_connectivity_check(self):
        """
        Set Attenuator Value for WiFi and Cell to 0
        Make sure DUT get Cell Data coverage (LTE)
        Make sure DUT WiFi is connected
        """
        ad = self.android_devices[0]
        toggle_airplane_mode(self.log, ad, False)
        if not ensure_network_generation(self.log, ad, GEN_4G,
                                         MAX_WAIT_TIME_NW_SELECTION,
                                         NETWORK_SERVICE_DATA):
            return False

        if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid,
                                     self.wifi_network_pass):
            ad.log.error("connect WiFi failed")
            return False
        return True
Example #5
0
    def test_sms_mo_4g(self):
        """Test SMS basic function between two phone. Phones in LTE network.

        Airplane mode is off.
        Send SMS from PhoneA to PhoneB.
        Verify received message on PhoneB is correct.

        Returns:
            True if success.
            False if failed.
        """

        ads = self.android_devices
        # TODO: this is a temporary fix for this test case.
        # A better fix will be introduced once pag/539845 is merged.
        if not phone_setup_voice_general(self.log, ads[1]):
            self.log.error("Failed to setup PhoneB.")
            return False
        if not ensure_network_generation(self.log, ads[0], GEN_4G):
            self.log.error("DUT Failed to Set Up Properly.")
            return False

        return self._sms_test_mo(ads)
    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
Example #7
0
    def _setup_data(self, set_simulation_func, rat):
        try:
            [self.bts1] = set_simulation_func(self.anritsu, self.user_params,
                                              self.ad.sim_card)
            set_usim_parameters(self.anritsu, self.ad.sim_card)
            if self.lte_bandwidth == 20:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_20MHz
            elif self.lte_bandwidth == 15:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_15MHz
            elif self.lte_bandwidth == 10:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_10MHz
            else:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_5MHz

            self.anritsu.start_simulation()

            if rat == RAT_LTE:
                preferred_network_setting = NETWORK_MODE_LTE_GSM_WCDMA
                rat_family = RAT_FAMILY_LTE
            elif rat == RAT_WCDMA:
                preferred_network_setting = NETWORK_MODE_GSM_UMTS
                rat_family = RAT_FAMILY_UMTS
            elif rat == RAT_GSM:
                preferred_network_setting = NETWORK_MODE_GSM_ONLY
                rat_family = RAT_FAMILY_GSM
            elif rat == RAT_1XRTT:
                preferred_network_setting = NETWORK_MODE_CDMA
                rat_family = RAT_FAMILY_CDMA2000
            else:
                self.log.error("No valid RAT provided for SMS test.")
                return False

            if not ensure_network_rat(self.log,
                                      self.ad,
                                      preferred_network_setting,
                                      rat_family,
                                      toggle_apm_after_setting=True):
                self.log.error(
                    "Failed to set rat family {}, preferred network:{}".format(
                        rat_family, preferred_network_setting))
                return False

            self.anritsu.wait_for_registration_state()
            time.sleep(self.SETTLING_TIME)
            if not ensure_network_generation(self.log, self.ad, GEN_4G,
                                             NETWORK_SERVICE_DATA):
                self.log.error("Device not in 4G Connected Mode.")
                return False

            # Fetch IP address of the host machine
            cmd = "|".join(("ifconfig", "grep eth0 -A1", "grep inet",
                            "cut -d ':' -f2", "cut -d ' ' -f 1"))
            destination_ip = exe_cmd(cmd)
            destination_ip = (destination_ip.decode("utf-8")).split("\n")[0]
            self.log.info("Dest IP is %s", destination_ip)

            if not adb_shell_ping(self.ad, DEFAULT_PING_DURATION,
                                  destination_ip):
                self.log.error("Pings failed to Destination.")
                return False
            self.bts1.output_level = self.start_power_level

            # Power, iperf, file output, power change
            for iteration in range(1, self.MAX_ITERATIONS + 1):
                self.log.info("------- Current Iteration: %d / %d -------",
                              iteration, self.MAX_ITERATIONS)
                current_power = self.bts1.output_level
                self.log.info("Current Power Level is %s", current_power)

                self.ip_server.start()
                tput_dict = {"Uplink": 0, "Downlink": 0}
                if iperf_test_by_adb(self.log,
                                     self.ad,
                                     destination_ip,
                                     self.port_num,
                                     True,
                                     10,
                                     rate_dict=tput_dict):
                    uplink = tput_dict["Uplink"]
                    downlink = tput_dict["Downlink"]
                else:
                    self.log.error("iperf failed to Destination.")
                    self.log.info("Iteration %d Failed", iteration)
                    if float(current_power) < -55.0:
                        return True
                    else:
                        return False
                self.ip_server.stop()

                self.log.info("Iteration %d Passed", iteration)
                self.logpath = os.path.join(logging.log_path, "power_tput.txt")
                line = "Power " + current_power + " DL TPUT " + str(downlink)
                with open(self.logpath, "a") as tput_file:
                    tput_file.write(line)
                    tput_file.write("\n")
                current_power = float(current_power)
                new_power = current_power - self.step_size
                self.log.info("Setting Power Level to %f", new_power)
                self.bts1.output_level = new_power

        except AnritsuError as e:
            self.log.error("Error in connection with Anritsu Simulator: " +
                           str(e))
            return False
        except Exception as e:
            self.log.error("Exception during Data procedure: " + str(e))
            return False
        return True