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

Commit 02e4ae49 authored by Ling Ma's avatar Ling Ma Committed by Android (Google) Code Review
Browse files

Merge "Make registrationState consistent with RoamType in case of override" into tm-d1-dev

parents 4de5b7fb 5153e1b7
Loading
Loading
Loading
Loading
+44 −8
Original line number Original line Diff line number Diff line
@@ -183,8 +183,17 @@ public final class NetworkRegistrationInfo implements Parcelable {
    @TransportType
    @TransportType
    private final int mTransportType;
    private final int mTransportType;


    /**
     * The initial registration state
     */
    @RegistrationState
    @RegistrationState
    private final int mRegistrationState;
    private final int mInitialRegistrationState;

    /**
     * The registration state that might have been overridden by config
     */
    @RegistrationState
    private int mRegistrationState;


    /**
    /**
     * Save the {@link ServiceState.RoamingType roaming type}. it can be overridden roaming type
     * Save the {@link ServiceState.RoamingType roaming type}. it can be overridden roaming type
@@ -255,6 +264,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
        mDomain = domain;
        mDomain = domain;
        mTransportType = transportType;
        mTransportType = transportType;
        mRegistrationState = registrationState;
        mRegistrationState = registrationState;
        mInitialRegistrationState = registrationState;
        mRoamingType = (registrationState == REGISTRATION_STATE_ROAMING)
        mRoamingType = (registrationState == REGISTRATION_STATE_ROAMING)
                ? ServiceState.ROAMING_TYPE_UNKNOWN : ServiceState.ROAMING_TYPE_NOT_ROAMING;
                ? ServiceState.ROAMING_TYPE_UNKNOWN : ServiceState.ROAMING_TYPE_NOT_ROAMING;
        setAccessNetworkTechnology(accessNetworkTechnology);
        setAccessNetworkTechnology(accessNetworkTechnology);
@@ -310,6 +320,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
        mDomain = source.readInt();
        mDomain = source.readInt();
        mTransportType = source.readInt();
        mTransportType = source.readInt();
        mRegistrationState = source.readInt();
        mRegistrationState = source.readInt();
        mInitialRegistrationState = source.readInt();
        mRoamingType = source.readInt();
        mRoamingType = source.readInt();
        mAccessNetworkTechnology = source.readInt();
        mAccessNetworkTechnology = source.readInt();
        mRejectCause = source.readInt();
        mRejectCause = source.readInt();
@@ -336,6 +347,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
        mDomain = nri.mDomain;
        mDomain = nri.mDomain;
        mTransportType = nri.mTransportType;
        mTransportType = nri.mTransportType;
        mRegistrationState = nri.mRegistrationState;
        mRegistrationState = nri.mRegistrationState;
        mInitialRegistrationState = nri.mInitialRegistrationState;
        mRoamingType = nri.mRoamingType;
        mRoamingType = nri.mRoamingType;
        mAccessNetworkTechnology = nri.mAccessNetworkTechnology;
        mAccessNetworkTechnology = nri.mAccessNetworkTechnology;
        mIsUsingCarrierAggregation = nri.mIsUsingCarrierAggregation;
        mIsUsingCarrierAggregation = nri.mIsUsingCarrierAggregation;
@@ -397,6 +409,15 @@ public final class NetworkRegistrationInfo implements Parcelable {
        return mRegistrationState;
        return mRegistrationState;
    }
    }


    /**
     * @return The initial registration state.
     *
     * @hide
     */
    public @RegistrationState int getInitialRegistrationState() {
        return mInitialRegistrationState;
    }

    /**
    /**
     * @return {@code true} if registered on roaming or home network, {@code false} otherwise.
     * @return {@code true} if registered on roaming or home network, {@code false} otherwise.
     */
     */
@@ -451,6 +472,17 @@ public final class NetworkRegistrationInfo implements Parcelable {
     */
     */
    public void setRoamingType(@ServiceState.RoamingType int roamingType) {
    public void setRoamingType(@ServiceState.RoamingType int roamingType) {
        mRoamingType = roamingType;
        mRoamingType = roamingType;

        // make sure mRegistrationState to be consistent in case of any roaming type override
        if (isRoaming()) {
            if (mRegistrationState == REGISTRATION_STATE_HOME) {
                mRegistrationState = REGISTRATION_STATE_ROAMING;
            }
        } else {
            if (mRegistrationState == REGISTRATION_STATE_ROAMING) {
                mRegistrationState = REGISTRATION_STATE_HOME;
            }
        }
    }
    }


    /**
    /**
@@ -634,6 +666,8 @@ public final class NetworkRegistrationInfo implements Parcelable {
                .append(" transportType=").append(
                .append(" transportType=").append(
                        AccessNetworkConstants.transportTypeToString(mTransportType))
                        AccessNetworkConstants.transportTypeToString(mTransportType))
                .append(" registrationState=").append(registrationStateToString(mRegistrationState))
                .append(" registrationState=").append(registrationStateToString(mRegistrationState))
                .append(" mInitialRegistrationState=")
                .append(registrationStateToString(mInitialRegistrationState))
                .append(" roamingType=").append(ServiceState.roamingTypeToString(mRoamingType))
                .append(" roamingType=").append(ServiceState.roamingTypeToString(mRoamingType))
                .append(" accessNetworkTechnology=")
                .append(" accessNetworkTechnology=")
                .append(TelephonyManager.getNetworkTypeName(mAccessNetworkTechnology))
                .append(TelephonyManager.getNetworkTypeName(mAccessNetworkTechnology))
@@ -654,10 +688,10 @@ public final class NetworkRegistrationInfo implements Parcelable {


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(mDomain, mTransportType, mRegistrationState, mRoamingType,
        return Objects.hash(mDomain, mTransportType, mRegistrationState, mInitialRegistrationState,
                mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices,
                mRoamingType, mAccessNetworkTechnology, mRejectCause, mEmergencyOnly,
                mCellIdentity, mVoiceSpecificInfo, mDataSpecificInfo, mNrState, mRplmn,
                mAvailableServices, mCellIdentity, mVoiceSpecificInfo, mDataSpecificInfo, mNrState,
                mIsUsingCarrierAggregation);
                mRplmn, mIsUsingCarrierAggregation);
    }
    }


    @Override
    @Override
@@ -672,6 +706,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
        return mDomain == other.mDomain
        return mDomain == other.mDomain
                && mTransportType == other.mTransportType
                && mTransportType == other.mTransportType
                && mRegistrationState == other.mRegistrationState
                && mRegistrationState == other.mRegistrationState
                && mInitialRegistrationState == other.mInitialRegistrationState
                && mRoamingType == other.mRoamingType
                && mRoamingType == other.mRoamingType
                && mAccessNetworkTechnology == other.mAccessNetworkTechnology
                && mAccessNetworkTechnology == other.mAccessNetworkTechnology
                && mRejectCause == other.mRejectCause
                && mRejectCause == other.mRejectCause
@@ -694,6 +729,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
        dest.writeInt(mDomain);
        dest.writeInt(mDomain);
        dest.writeInt(mTransportType);
        dest.writeInt(mTransportType);
        dest.writeInt(mRegistrationState);
        dest.writeInt(mRegistrationState);
        dest.writeInt(mInitialRegistrationState);
        dest.writeInt(mRoamingType);
        dest.writeInt(mRoamingType);
        dest.writeInt(mAccessNetworkTechnology);
        dest.writeInt(mAccessNetworkTechnology);
        dest.writeInt(mRejectCause);
        dest.writeInt(mRejectCause);
@@ -790,7 +826,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
        private int mTransportType;
        private int mTransportType;


        @RegistrationState
        @RegistrationState
        private int mRegistrationState;
        private int mInitialRegistrationState;


        @NetworkType
        @NetworkType
        private int mAccessNetworkTechnology;
        private int mAccessNetworkTechnology;
@@ -851,7 +887,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
         * @return The same instance of the builder.
         * @return The same instance of the builder.
         */
         */
        public @NonNull Builder setRegistrationState(@RegistrationState int registrationState) {
        public @NonNull Builder setRegistrationState(@RegistrationState int registrationState) {
            mRegistrationState = registrationState;
            mInitialRegistrationState = registrationState;
            return this;
            return this;
        }
        }


@@ -970,7 +1006,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
         */
         */
        @SystemApi
        @SystemApi
        public @NonNull NetworkRegistrationInfo build() {
        public @NonNull NetworkRegistrationInfo build() {
            return new NetworkRegistrationInfo(mDomain, mTransportType, mRegistrationState,
            return new NetworkRegistrationInfo(mDomain, mTransportType, mInitialRegistrationState,
                    mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices,
                    mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices,
                    mCellIdentity, mRplmn, mVoiceSpecificRegistrationInfo,
                    mCellIdentity, mRplmn, mVoiceSpecificRegistrationInfo,
                    mDataSpecificRegistrationInfo);
                    mDataSpecificRegistrationInfo);