예제 #1
0
def get_current_voice_rat_for_subscription(log, ad, sub_id):
    """Return current Voice RAT for subscription id.

    Args:
        ad: Android device object.
        sub_id: subscription id.
    """
    return get_network_rat_for_subscription(log, ad, sub_id,
                                            NETWORK_SERVICE_VOICE)
예제 #2
0
def is_phone_in_call_1x_for_subscription(log, ad, sub_id):
    """Return if phone is in 1x call for subscription id.

    Args:
        ad: Android device object.
        sub_id: subscription id.
    """
    if not ad.droid.telecomIsInCall():
        ad.log.error("Not in call.")
        return False
    nw_type = get_network_rat_for_subscription(log, ad, sub_id,
                                               NETWORK_SERVICE_VOICE)
    if nw_type != RAT_1XRTT:
        ad.log.error("Voice rat on: %s. Expected: 1xrtt", nw_type)
        return False
    return True
예제 #3
0
def is_phone_in_call_csfb_for_subscription(log, ad, sub_id):
    """Return if phone is in CSFB call for subscription id.

    Args:
        ad: Android device object.
        sub_id: subscription id.
    """
    if not ad.droid.telecomIsInCall():
        log.error("{} not in call.".format(ad.serial))
        return False
    nw_type = get_network_rat_for_subscription(log, ad, sub_id,
                                               NETWORK_SERVICE_VOICE)
    if nw_type == RAT_LTE:
        log.error("{} voice rat on: {}. Expected: not LTE".format(
            ad.serial, nw_type))
        return False
    return True
예제 #4
0
def is_phone_in_call_wcdma_for_subscription(log, ad, sub_id):
    """Return if phone is in WCDMA call for subscription id.

    Args:
        ad: Android device object.
        sub_id: subscription id.
    """
    # Currently checking 'umts'.
    # Changes may needed in the future.
    if not ad.droid.telecomIsInCall():
        ad.log.error("Not in call.")
        return False
    nw_type = get_network_rat_for_subscription(log, ad, sub_id,
                                               NETWORK_SERVICE_VOICE)
    if nw_type != RAT_UMTS:
        ad.log.error("%s voice rat on: %s. Expected: umts", nw_type)
        return False
    return True
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)