Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6730f345 authored by Chen Xu's avatar Chen Xu Committed by Gerrit Code Review
Browse files

Merge "NWRegState.getAccessNetworkTechnology in sync with SS.getNetworkType"

parents e09f7b5e f513b528
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class NetworkRegistrationState implements Parcelable {
    @ServiceState.RoamingType
    private int mRoamingType;

    private final int mAccessNetworkTechnology;
    private int mAccessNetworkTechnology;

    private final int mRejectCause;

@@ -256,12 +256,20 @@ public class NetworkRegistrationState implements Parcelable {
    public int[] getAvailableServices() { return mAvailableServices; }

    /**
     * @return The access network technology. Must be one of TelephonyManager.NETWORK_TYPE_XXXX.
     * @return The access network technology {@link TelephonyManager.NetworkType}.
     */
    public int getAccessNetworkTechnology() {
    public @TelephonyManager.NetworkType int getAccessNetworkTechnology() {
        return mAccessNetworkTechnology;
    }

    /**
     * override the access network technology {@link TelephonyManager.NetworkType} e.g, rat ratchet.
     * @hide
     */
    public void setAccessNetworkTechnology(@TelephonyManager.NetworkType int tech) {
        mAccessNetworkTechnology = tech;
    }

    /**
     * @return Network reject cause
     */
+56 −9
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -250,8 +251,17 @@ public class ServiceState implements Parcelable {
    private boolean mIsManualNetworkSelection;

    private boolean mIsEmergencyOnly;

    /**
     * TODO: remove mRilVoiceRadioTechnology after completely migrate to
     * {@link TelephonyManager.NetworkType}
     */
    @RilRadioTechnology
    private int mRilVoiceRadioTechnology;
    /**
     * TODO: remove mRilDataRadioTechnology after completely migrate to
     * {@link TelephonyManager.NetworkType}
     */
    @RilRadioTechnology
    private int mRilDataRadioTechnology;

    @UnsupportedAppUsage
@@ -1218,17 +1228,30 @@ public class ServiceState implements Parcelable {

    /** @hide */
    @TestApi
    public void setRilVoiceRadioTechnology(int rt) {
    public void setRilVoiceRadioTechnology(@RilRadioTechnology int rt) {
        if (rt == RIL_RADIO_TECHNOLOGY_LTE_CA) {
            rt = RIL_RADIO_TECHNOLOGY_LTE;
        }

        this.mRilVoiceRadioTechnology = rt;

        // sync to network registration state
        NetworkRegistrationState regState = getNetworkRegistrationState(
                NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN);
        if (regState == null) {
            regState = new NetworkRegistrationState(
                    NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN,
                    ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN,
                    0, false, null, null);
            addNetworkRegistrationState(regState);
        }
        regState.setAccessNetworkTechnology(
                rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology));
    }

    /** @hide */
    @TestApi
    public void setRilDataRadioTechnology(int rt) {
    public void setRilDataRadioTechnology(@RilRadioTechnology int rt) {
        if (rt == RIL_RADIO_TECHNOLOGY_LTE_CA) {
            rt = RIL_RADIO_TECHNOLOGY_LTE;
            this.mIsUsingCarrierAggregation = true;
@@ -1238,6 +1261,20 @@ public class ServiceState implements Parcelable {
        this.mRilDataRadioTechnology = rt;
        if (VDBG) Rlog.d(LOG_TAG, "[ServiceState] setRilDataRadioTechnology=" +
                mRilDataRadioTechnology);

        // sync to network registration state
        NetworkRegistrationState regState = getNetworkRegistrationState(
                NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);

        if (regState == null) {
            regState = new NetworkRegistrationState(
                    NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN,
                    ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN,
                    0, false, null, null);
            addNetworkRegistrationState(regState);
        }
        regState.setAccessNetworkTechnology(
                rilRadioTechnologyToNetworkType(mRilDataRadioTechnology));
    }

    /** @hide */
@@ -1418,15 +1455,25 @@ public class ServiceState implements Parcelable {


    /** @hide */
    @UnsupportedAppUsage
    public int getDataNetworkType() {
        return rilRadioTechnologyToNetworkType(mRilDataRadioTechnology);
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    public @TelephonyManager.NetworkType int getDataNetworkType() {
        final NetworkRegistrationState regState = getNetworkRegistrationState(
                NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
        if (regState != null) {
            return regState.getAccessNetworkTechnology();
        }
        return TelephonyManager.NETWORK_TYPE_UNKNOWN;
    }

    /** @hide */
    @UnsupportedAppUsage
    public int getVoiceNetworkType() {
        return rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology);
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    public @TelephonyManager.NetworkType int getVoiceNetworkType() {
        final NetworkRegistrationState regState = getNetworkRegistrationState(
                NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN);
        if (regState != null) {
            return regState.getAccessNetworkTechnology();
        }
        return TelephonyManager.NETWORK_TYPE_UNKNOWN;
    }

    /** @hide */