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

Commit 0c9a514c authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge "Return copies for get methods"

parents 644792c7 b79342f2
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -95,6 +95,21 @@ public final class DataSpecificRegistrationInfo implements Parcelable {
        this.mIsUsingCarrierAggregation = isUsingCarrierAggregation;
        this.mIsUsingCarrierAggregation = isUsingCarrierAggregation;
    }
    }


    /**
     * Constructor from another data specific registration info
     *
     * @param dsri another data specific registration info
     * @hide
     */
    DataSpecificRegistrationInfo(DataSpecificRegistrationInfo dsri) {
        maxDataCalls = dsri.maxDataCalls;
        isDcNrRestricted = dsri.isDcNrRestricted;
        isNrAvailable = dsri.isNrAvailable;
        isEnDcAvailable = dsri.isEnDcAvailable;
        mLteVopsSupportInfo = dsri.mLteVopsSupportInfo;
        mIsUsingCarrierAggregation = dsri.mIsUsingCarrierAggregation;
    }

    private DataSpecificRegistrationInfo(Parcel source) {
    private DataSpecificRegistrationInfo(Parcel source) {
        maxDataCalls = source.readInt();
        maxDataCalls = source.readInt();
        isDcNrRestricted = source.readBoolean();
        isDcNrRestricted = source.readBoolean();
+33 −0
Original line number Original line Diff line number Diff line
@@ -279,6 +279,39 @@ public final class NetworkRegistrationInfo implements Parcelable {
        mNrState = source.readInt();
        mNrState = source.readInt();
    }
    }


    /**
     * Constructor from another network registration info
     *
     * @param nri Another network registration info
     * @hide
     */
    public NetworkRegistrationInfo(NetworkRegistrationInfo nri) {
        mDomain = nri.mDomain;
        mTransportType = nri.mTransportType;
        mRegistrationState = nri.mRegistrationState;
        mRoamingType = nri.mRoamingType;
        mAccessNetworkTechnology = nri.mAccessNetworkTechnology;
        mRejectCause = nri.mRejectCause;
        mEmergencyOnly = nri.mEmergencyOnly;
        mAvailableServices = new ArrayList<>(nri.mAvailableServices);
        if (nri.mCellIdentity != null) {
            Parcel p = Parcel.obtain();
            nri.mCellIdentity.writeToParcel(p, 0);
            p.setDataPosition(0);
            // TODO: Instead of doing this, we should create a formal way for cloning cell identity.
            // Cell identity is not an immutable object so we have to deep copy it.
            mCellIdentity = CellIdentity.CREATOR.createFromParcel(p);
        }

        if (nri.mVoiceSpecificInfo != null) {
            mVoiceSpecificInfo = new VoiceSpecificRegistrationInfo(nri.mVoiceSpecificInfo);
        }
        if (nri.mDataSpecificInfo != null) {
            mDataSpecificInfo = new DataSpecificRegistrationInfo(nri.mDataSpecificInfo);
        }
        mNrState = nri.mNrState;
    }

    /**
    /**
     * @return The transport type.
     * @return The transport type.
     */
     */
+37 −33
Original line number Original line Diff line number Diff line
@@ -418,7 +418,7 @@ public class ServiceState implements Parcelable {
                Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length);
                Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length);
        mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost;
        mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost;
        mNetworkRegistrationInfos = s.mNetworkRegistrationInfos == null ? null :
        mNetworkRegistrationInfos = s.mNetworkRegistrationInfos == null ? null :
                new ArrayList<>(s.mNetworkRegistrationInfos);
                s.getNetworkRegistrationInfoList();
        mNrFrequencyRange = s.mNrFrequencyRange;
        mNrFrequencyRange = s.mNrFrequencyRange;
    }
    }


@@ -1113,16 +1113,16 @@ public class ServiceState implements Parcelable {
    /** @hide */
    /** @hide */
    @TestApi
    @TestApi
    public void setVoiceRoamingType(@RoamingType int type) {
    public void setVoiceRoamingType(@RoamingType int type) {
        NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
        NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (regState == null) {
        if (regInfo == null) {
            regState = new NetworkRegistrationInfo.Builder()
            regInfo = new NetworkRegistrationInfo.Builder()
                    .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                    .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .build();
                    .build();
            addNetworkRegistrationInfo(regState);
        }
        }
        regState.setRoamingType(type);
        regInfo.setRoamingType(type);
        addNetworkRegistrationInfo(regInfo);
    }
    }


    /** @hide */
    /** @hide */
@@ -1134,16 +1134,16 @@ public class ServiceState implements Parcelable {
    /** @hide */
    /** @hide */
    @TestApi
    @TestApi
    public void setDataRoamingType(@RoamingType int type) {
    public void setDataRoamingType(@RoamingType int type) {
        NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
        NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (regState == null) {
        if (regInfo == null) {
            regState = new NetworkRegistrationInfo.Builder()
            regInfo = new NetworkRegistrationInfo.Builder()
                    .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                    .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .build();
                    .build();
            addNetworkRegistrationInfo(regState);
        }
        }
        regState.setRoamingType(type);
        regInfo.setRoamingType(type);
        addNetworkRegistrationInfo(regInfo);
    }
    }


    /**
    /**
@@ -1305,16 +1305,16 @@ public class ServiceState implements Parcelable {
        Rlog.e(LOG_TAG, "ServiceState.setRilVoiceRadioTechnology() called. It's encouraged to "
        Rlog.e(LOG_TAG, "ServiceState.setRilVoiceRadioTechnology() called. It's encouraged to "
                + "use addNetworkRegistrationInfo() instead *******");
                + "use addNetworkRegistrationInfo() instead *******");
        // Sync to network registration state
        // Sync to network registration state
        NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
        NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (regState == null) {
        if (regInfo == null) {
            regState = new NetworkRegistrationInfo.Builder()
            regInfo = new NetworkRegistrationInfo.Builder()
                    .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                    .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .build();
                    .build();
            addNetworkRegistrationInfo(regState);
        }
        }
        regState.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
        regInfo.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
        addNetworkRegistrationInfo(regInfo);
    }
    }




@@ -1326,17 +1326,17 @@ public class ServiceState implements Parcelable {
        // Sync to network registration state. Always write down the WWAN transport. For AP-assisted
        // Sync to network registration state. Always write down the WWAN transport. For AP-assisted
        // mode device, use addNetworkRegistrationInfo() to set the correct transport if RAT
        // mode device, use addNetworkRegistrationInfo() to set the correct transport if RAT
        // is IWLAN.
        // is IWLAN.
        NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
        NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);


        if (regState == null) {
        if (regInfo == null) {
            regState = new NetworkRegistrationInfo.Builder()
            regInfo = new NetworkRegistrationInfo.Builder()
                    .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                    .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .build();
                    .build();
            addNetworkRegistrationInfo(regState);
        }
        }
        regState.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
        regInfo.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
        addNetworkRegistrationInfo(regInfo);
    }
    }


    /** @hide */
    /** @hide */
@@ -1378,10 +1378,10 @@ public class ServiceState implements Parcelable {
     * @hide
     * @hide
     */
     */
    public @NRState int getNrState() {
    public @NRState int getNrState() {
        final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
        final NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
        if (regState == null) return NetworkRegistrationInfo.NR_STATE_NONE;
        if (regInfo == null) return NetworkRegistrationInfo.NR_STATE_NONE;
        return regState.getNrState();
        return regInfo.getNrState();
    }
    }


    /**
    /**
@@ -1775,7 +1775,11 @@ public class ServiceState implements Parcelable {
    @SystemApi
    @SystemApi
    public List<NetworkRegistrationInfo> getNetworkRegistrationInfoList() {
    public List<NetworkRegistrationInfo> getNetworkRegistrationInfoList() {
        synchronized (mNetworkRegistrationInfos) {
        synchronized (mNetworkRegistrationInfos) {
            return new ArrayList<>(mNetworkRegistrationInfos);
            List<NetworkRegistrationInfo> newList = new ArrayList<>();
            for (NetworkRegistrationInfo nri : mNetworkRegistrationInfos) {
                newList.add(new NetworkRegistrationInfo(nri));
            }
            return newList;
        }
        }
    }
    }


@@ -1795,7 +1799,7 @@ public class ServiceState implements Parcelable {
        synchronized (mNetworkRegistrationInfos) {
        synchronized (mNetworkRegistrationInfos) {
            for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
            for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
                if (networkRegistrationInfo.getTransportType() == transportType) {
                if (networkRegistrationInfo.getTransportType() == transportType) {
                    list.add(networkRegistrationInfo);
                    list.add(new NetworkRegistrationInfo(networkRegistrationInfo));
                }
                }
            }
            }
        }
        }
@@ -1819,7 +1823,7 @@ public class ServiceState implements Parcelable {
        synchronized (mNetworkRegistrationInfos) {
        synchronized (mNetworkRegistrationInfos) {
            for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
            for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
                if (networkRegistrationInfo.getDomain() == domain) {
                if (networkRegistrationInfo.getDomain() == domain) {
                    list.add(networkRegistrationInfo);
                    list.add(new NetworkRegistrationInfo(networkRegistrationInfo));
                }
                }
            }
            }
        }
        }
@@ -1844,7 +1848,7 @@ public class ServiceState implements Parcelable {
            for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
            for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
                if (networkRegistrationInfo.getTransportType() == transportType
                if (networkRegistrationInfo.getTransportType() == transportType
                        && networkRegistrationInfo.getDomain() == domain) {
                        && networkRegistrationInfo.getDomain() == domain) {
                    return networkRegistrationInfo;
                    return new NetworkRegistrationInfo(networkRegistrationInfo);
                }
                }
            }
            }
        }
        }
@@ -1856,20 +1860,20 @@ public class ServiceState implements Parcelable {
     * @hide
     * @hide
     */
     */
    @TestApi
    @TestApi
    public void addNetworkRegistrationInfo(NetworkRegistrationInfo regState) {
    public void addNetworkRegistrationInfo(NetworkRegistrationInfo nri) {
        if (regState == null) return;
        if (nri == null) return;


        synchronized (mNetworkRegistrationInfos) {
        synchronized (mNetworkRegistrationInfos) {
            for (int i = 0; i < mNetworkRegistrationInfos.size(); i++) {
            for (int i = 0; i < mNetworkRegistrationInfos.size(); i++) {
                NetworkRegistrationInfo curRegState = mNetworkRegistrationInfos.get(i);
                NetworkRegistrationInfo curRegState = mNetworkRegistrationInfos.get(i);
                if (curRegState.getTransportType() == regState.getTransportType()
                if (curRegState.getTransportType() == nri.getTransportType()
                        && curRegState.getDomain() == regState.getDomain()) {
                        && curRegState.getDomain() == nri.getDomain()) {
                    mNetworkRegistrationInfos.remove(i);
                    mNetworkRegistrationInfos.remove(i);
                    break;
                    break;
                }
                }
            }
            }


            mNetworkRegistrationInfos.add(regState);
            mNetworkRegistrationInfos.add(new NetworkRegistrationInfo(nri));
        }
        }
    }
    }


+13 −0
Original line number Original line Diff line number Diff line
@@ -65,6 +65,19 @@ public class VoiceSpecificRegistrationInfo implements Parcelable{
        this.defaultRoamingIndicator = defaultRoamingIndicator;
        this.defaultRoamingIndicator = defaultRoamingIndicator;
    }
    }


    /**
     * Constructor from another voice specific registration info
     *
     * @param vsri another voice specific registration info
     * @hide
     */
    VoiceSpecificRegistrationInfo(VoiceSpecificRegistrationInfo vsri) {
        cssSupported = vsri.cssSupported;
        roamingIndicator = vsri.roamingIndicator;
        systemIsInPrl = vsri.systemIsInPrl;
        defaultRoamingIndicator = vsri.defaultRoamingIndicator;
    }

    private VoiceSpecificRegistrationInfo(Parcel source) {
    private VoiceSpecificRegistrationInfo(Parcel source) {
        this.cssSupported = source.readBoolean();
        this.cssSupported = source.readBoolean();
        this.roamingIndicator = source.readInt();
        this.roamingIndicator = source.readInt();