}
/**
+ * 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.
*/
public @TransportType int getTransportType() { return mTransportType; }
Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length);
mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost;
mNetworkRegistrationInfos = s.mNetworkRegistrationInfos == null ? null :
- new ArrayList<>(s.mNetworkRegistrationInfos);
+ s.getNetworkRegistrationInfoList();
mNrFrequencyRange = s.mNrFrequencyRange;
}
/** @hide */
@TestApi
public void setVoiceRoamingType(@RoamingType int type) {
- NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
+ NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
- if (regState == null) {
- regState = new NetworkRegistrationInfo.Builder()
+ if (regInfo == null) {
+ regInfo = new NetworkRegistrationInfo.Builder()
.setDomain(NetworkRegistrationInfo.DOMAIN_CS)
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
.build();
- addNetworkRegistrationInfo(regState);
}
- regState.setRoamingType(type);
+ regInfo.setRoamingType(type);
+ addNetworkRegistrationInfo(regInfo);
}
/** @hide */
/** @hide */
@TestApi
public void setDataRoamingType(@RoamingType int type) {
- NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
+ NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
- if (regState == null) {
- regState = new NetworkRegistrationInfo.Builder()
+ if (regInfo == null) {
+ regInfo = new NetworkRegistrationInfo.Builder()
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
.build();
- addNetworkRegistrationInfo(regState);
}
- regState.setRoamingType(type);
+ regInfo.setRoamingType(type);
+ addNetworkRegistrationInfo(regInfo);
}
/**
Rlog.e(LOG_TAG, "ServiceState.setRilVoiceRadioTechnology() called. It's encouraged to "
+ "use addNetworkRegistrationInfo() instead *******");
// Sync to network registration state
- NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
+ NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
- if (regState == null) {
- regState = new NetworkRegistrationInfo.Builder()
+ if (regInfo == null) {
+ regInfo = new NetworkRegistrationInfo.Builder()
.setDomain(NetworkRegistrationInfo.DOMAIN_CS)
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
.build();
- addNetworkRegistrationInfo(regState);
}
- regState.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
+ regInfo.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
+ addNetworkRegistrationInfo(regInfo);
}
// 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
// is IWLAN.
- NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
+ NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
- if (regState == null) {
- regState = new NetworkRegistrationInfo.Builder()
+ if (regInfo == null) {
+ regInfo = new NetworkRegistrationInfo.Builder()
.setDomain(NetworkRegistrationInfo.DOMAIN_PS)
.setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
.build();
- addNetworkRegistrationInfo(regState);
}
- regState.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
+ regInfo.setAccessNetworkTechnology(rilRadioTechnologyToNetworkType(rt));
+ addNetworkRegistrationInfo(regInfo);
}
/** @hide */
* @hide
*/
public @NRState int getNrState() {
- final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
+ final NetworkRegistrationInfo regInfo = getNetworkRegistrationInfo(
NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
- if (regState == null) return NetworkRegistrationInfo.NR_STATE_NONE;
- return regState.getNrState();
+ if (regInfo == null) return NetworkRegistrationInfo.NR_STATE_NONE;
+ return regInfo.getNrState();
}
/**
@SystemApi
public List<NetworkRegistrationInfo> getNetworkRegistrationInfoList() {
synchronized (mNetworkRegistrationInfos) {
- return new ArrayList<>(mNetworkRegistrationInfos);
+ List<NetworkRegistrationInfo> newList = new ArrayList<>();
+ for (NetworkRegistrationInfo nri : mNetworkRegistrationInfos) {
+ newList.add(new NetworkRegistrationInfo(nri));
+ }
+ return newList;
}
}
synchronized (mNetworkRegistrationInfos) {
for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
if (networkRegistrationInfo.getTransportType() == transportType) {
- list.add(networkRegistrationInfo);
+ list.add(new NetworkRegistrationInfo(networkRegistrationInfo));
}
}
}
synchronized (mNetworkRegistrationInfos) {
for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
if (networkRegistrationInfo.getDomain() == domain) {
- list.add(networkRegistrationInfo);
+ list.add(new NetworkRegistrationInfo(networkRegistrationInfo));
}
}
}
for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
if (networkRegistrationInfo.getTransportType() == transportType
&& networkRegistrationInfo.getDomain() == domain) {
- return networkRegistrationInfo;
+ return new NetworkRegistrationInfo(networkRegistrationInfo);
}
}
}
* @hide
*/
@TestApi
- public void addNetworkRegistrationInfo(NetworkRegistrationInfo regState) {
- if (regState == null) return;
+ public void addNetworkRegistrationInfo(NetworkRegistrationInfo nri) {
+ if (nri == null) return;
synchronized (mNetworkRegistrationInfos) {
for (int i = 0; i < mNetworkRegistrationInfos.size(); i++) {
NetworkRegistrationInfo curRegState = mNetworkRegistrationInfos.get(i);
- if (curRegState.getTransportType() == regState.getTransportType()
- && curRegState.getDomain() == regState.getDomain()) {
+ if (curRegState.getTransportType() == nri.getTransportType()
+ && curRegState.getDomain() == nri.getDomain()) {
mNetworkRegistrationInfos.remove(i);
break;
}
}
- mNetworkRegistrationInfos.add(regState);
+ mNetworkRegistrationInfos.add(new NetworkRegistrationInfo(nri));
}
}