Renamed NetworkRegistrationState to NetworkRegistrationInfo

API review changes. The class covers more information other than
registration state.

Test: Build
Bug: 127657991
Change-Id: I8af36b388182ab08257b64c37078f156d4821709
This commit is contained in:
Jack Yu
2019-03-15 14:49:53 -07:00
parent bed3db4d0b
commit e27d3fde88
11 changed files with 225 additions and 257 deletions

View File

@@ -7679,8 +7679,8 @@ package android.telephony {
field public static final String MBMS_STREAMING_SERVICE_ACTION = "android.telephony.action.EmbmsStreaming"; field public static final String MBMS_STREAMING_SERVICE_ACTION = "android.telephony.action.EmbmsStreaming";
} }
public class NetworkRegistrationState implements android.os.Parcelable { public class NetworkRegistrationInfo implements android.os.Parcelable {
ctor public NetworkRegistrationState(int, int, int, int, int, boolean, @NonNull int[], @Nullable android.telephony.CellIdentity); ctor public NetworkRegistrationInfo(int, int, int, int, int, boolean, @NonNull int[], @Nullable android.telephony.CellIdentity);
method public int describeContents(); method public int describeContents();
method public int getAccessNetworkTechnology(); method public int getAccessNetworkTechnology();
method @NonNull public int[] getAvailableServices(); method @NonNull public int[] getAvailableServices();
@@ -7694,7 +7694,7 @@ package android.telephony {
method public boolean isEmergencyEnabled(); method public boolean isEmergencyEnabled();
method public boolean isRoaming(); method public boolean isRoaming();
method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationState> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationInfo> CREATOR;
field public static final int DOMAIN_CS = 1; // 0x1 field public static final int DOMAIN_CS = 1; // 0x1
field public static final int DOMAIN_PS = 2; // 0x2 field public static final int DOMAIN_PS = 2; // 0x2
field public static final int REG_STATE_DENIED = 3; // 0x3 field public static final int REG_STATE_DENIED = 3; // 0x3
@@ -7710,19 +7710,19 @@ package android.telephony {
field public static final int SERVICE_TYPE_VOICE = 1; // 0x1 field public static final int SERVICE_TYPE_VOICE = 1; // 0x1
} }
public static class NetworkRegistrationState.Builder { public static class NetworkRegistrationInfo.Builder {
ctor public NetworkRegistrationState.Builder(); ctor public NetworkRegistrationInfo.Builder();
method @NonNull public android.telephony.NetworkRegistrationState build(); method @NonNull public android.telephony.NetworkRegistrationInfo build();
method @NonNull public android.telephony.NetworkRegistrationState.Builder setAccessNetworkTechnology(int); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setAccessNetworkTechnology(int);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setAvailableServices(@NonNull int[]); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setAvailableServices(@NonNull int[]);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setCellIdentity(@Nullable android.telephony.CellIdentity); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setCellIdentity(@Nullable android.telephony.CellIdentity);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setDomain(int); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setDomain(int);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setEmergencyOnly(boolean); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setEmergencyOnly(boolean);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setNrStatus(int); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setNrStatus(int);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setRegState(int); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setRegState(int);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setRejectCause(int); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setRejectCause(int);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setRoamingType(int); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setRoamingType(int);
method @NonNull public android.telephony.NetworkRegistrationState.Builder setTransportType(int); method @NonNull public android.telephony.NetworkRegistrationInfo.Builder setTransportType(int);
} }
public abstract class NetworkService extends android.app.Service { public abstract class NetworkService extends android.app.Service {
@@ -7735,13 +7735,13 @@ package android.telephony {
public abstract class NetworkService.NetworkServiceProvider implements java.lang.AutoCloseable { public abstract class NetworkService.NetworkServiceProvider implements java.lang.AutoCloseable {
ctor public NetworkService.NetworkServiceProvider(int); ctor public NetworkService.NetworkServiceProvider(int);
method public abstract void close(); method public abstract void close();
method public void getNetworkRegistrationState(int, @NonNull android.telephony.NetworkServiceCallback); method public void getNetworkRegistrationInfo(int, @NonNull android.telephony.NetworkServiceCallback);
method public final int getSlotIndex(); method public final int getSlotIndex();
method public final void notifyNetworkRegistrationStateChanged(); method public final void notifyNetworkRegistrationInfoChanged();
} }
public class NetworkServiceCallback { public class NetworkServiceCallback {
method public void onGetNetworkRegistrationStateComplete(int, @Nullable android.telephony.NetworkRegistrationState); method public void onGetNetworkRegistrationInfoComplete(int, @Nullable android.telephony.NetworkRegistrationInfo);
field public static final int RESULT_ERROR_BUSY = 3; // 0x3 field public static final int RESULT_ERROR_BUSY = 3; // 0x3
field public static final int RESULT_ERROR_FAILED = 5; // 0x5 field public static final int RESULT_ERROR_FAILED = 5; // 0x5
field public static final int RESULT_ERROR_ILLEGAL_STATE = 4; // 0x4 field public static final int RESULT_ERROR_ILLEGAL_STATE = 4; // 0x4
@@ -7916,12 +7916,10 @@ package android.telephony {
} }
public class ServiceState implements android.os.Parcelable { public class ServiceState implements android.os.Parcelable {
method @Nullable public android.telephony.NetworkRegistrationState getNetworkRegistrationState(int, int); method @Nullable public android.telephony.NetworkRegistrationInfo getNetworkRegistrationInfo(int, int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStates(); method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoList();
method @Deprecated @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStates(int); method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain(int);
method @Deprecated @Nullable public android.telephony.NetworkRegistrationState getNetworkRegistrationStates(int, int); method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForTransportType(int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStatesForDomain(int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationState> getNetworkRegistrationStatesForTransportType(int);
field public static final int ROAMING_TYPE_DOMESTIC = 2; // 0x2 field public static final int ROAMING_TYPE_DOMESTIC = 2; // 0x2
field public static final int ROAMING_TYPE_INTERNATIONAL = 3; // 0x3 field public static final int ROAMING_TYPE_INTERNATIONAL = 3; // 0x3
field public static final int ROAMING_TYPE_NOT_ROAMING = 0; // 0x0 field public static final int ROAMING_TYPE_NOT_ROAMING = 0; // 0x0

View File

@@ -72,7 +72,7 @@ import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.AccessNetworkConstants; import android.telephony.AccessNetworkConstants;
import android.telephony.CellSignalStrength; import android.telephony.CellSignalStrength;
import android.telephony.NetworkRegistrationState; import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.SignalStrength; import android.telephony.SignalStrength;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
@@ -1615,8 +1615,8 @@ public class NetworkMonitor extends StateMachine {
return; return;
} }
// See if the data sub is registered for PS services on cell. // See if the data sub is registered for PS services on cell.
final NetworkRegistrationState nrs = dataSs.getNetworkRegistrationState( final NetworkRegistrationInfo nrs = dataSs.getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, NetworkRegistrationInfo.DOMAIN_PS,
AccessNetworkConstants.TRANSPORT_TYPE_WWAN); AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
latencyBroadcast.putExtra( latencyBroadcast.putExtra(
NetworkMonitorUtils.EXTRA_CELL_ID, NetworkMonitorUtils.EXTRA_CELL_ID,

View File

@@ -22,7 +22,7 @@ import android.net.NetworkCapabilities;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.provider.Settings.Global; import android.provider.Settings.Global;
import android.telephony.NetworkRegistrationState; import android.telephony.NetworkRegistrationInfo;
import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.SignalStrength; import android.telephony.SignalStrength;
@@ -475,7 +475,7 @@ public class MobileSignalController extends SignalController<
if (mServiceState == null) return null; if (mServiceState == null) return null;
int nrStatus = mServiceState.getNrStatus(); int nrStatus = mServiceState.getNrStatus();
if (nrStatus == NetworkRegistrationState.NR_STATUS_CONNECTED) { if (nrStatus == NetworkRegistrationInfo.NR_STATUS_CONNECTED) {
// Check if the NR 5G is using millimeter wave and the icon is config. // Check if the NR 5G is using millimeter wave and the icon is config.
if (mServiceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE) { if (mServiceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE) {
if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED_MMWAVE)) { if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED_MMWAVE)) {
@@ -488,11 +488,11 @@ public class MobileSignalController extends SignalController<
if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED)) { if (mConfig.nr5GIconMap.containsKey(Config.NR_CONNECTED)) {
return mConfig.nr5GIconMap.get(Config.NR_CONNECTED); return mConfig.nr5GIconMap.get(Config.NR_CONNECTED);
} }
} else if (nrStatus == NetworkRegistrationState.NR_STATUS_NOT_RESTRICTED) { } else if (nrStatus == NetworkRegistrationInfo.NR_STATUS_NOT_RESTRICTED) {
if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED)) { if (mConfig.nr5GIconMap.containsKey(Config.NR_NOT_RESTRICTED)) {
return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED); return mConfig.nr5GIconMap.get(Config.NR_NOT_RESTRICTED);
} }
} else if (nrStatus == NetworkRegistrationState.NR_STATUS_RESTRICTED) { } else if (nrStatus == NetworkRegistrationInfo.NR_STATUS_RESTRICTED) {
if (mConfig.nr5GIconMap.containsKey(Config.NR_RESTRICTED)) { if (mConfig.nr5GIconMap.containsKey(Config.NR_RESTRICTED)) {
return mConfig.nr5GIconMap.get(Config.NR_RESTRICTED); return mConfig.nr5GIconMap.get(Config.NR_RESTRICTED);
} }

View File

@@ -7,7 +7,7 @@ import static org.mockito.Mockito.when;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
import android.os.Looper; import android.os.Looper;
import android.telephony.NetworkRegistrationState; import android.telephony.NetworkRegistrationInfo;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
@@ -151,7 +151,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
updateDataConnectionState(TelephonyManager.DATA_CONNECTED, updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE); TelephonyManager.NETWORK_TYPE_LTE);
ServiceState ss = Mockito.mock(ServiceState.class); ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationState.NR_STATUS_CONNECTED).when(ss).getNrStatus(); doReturn(NetworkRegistrationInfo.NR_STATUS_CONNECTED).when(ss).getNrStatus();
doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange(); doReturn(ServiceState.FREQUENCY_RANGE_HIGH).when(ss).getNrFrequencyRange();
mPhoneStateListener.onServiceStateChanged(ss); mPhoneStateListener.onServiceStateChanged(ss);
@@ -165,7 +165,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
updateDataConnectionState(TelephonyManager.DATA_CONNECTED, updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE); TelephonyManager.NETWORK_TYPE_LTE);
ServiceState ss = Mockito.mock(ServiceState.class); ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationState.NR_STATUS_CONNECTED).when(ss).getNrStatus(); doReturn(NetworkRegistrationInfo.NR_STATUS_CONNECTED).when(ss).getNrStatus();
doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(ss).getNrFrequencyRange(); doReturn(ServiceState.FREQUENCY_RANGE_MMWAVE).when(ss).getNrFrequencyRange();
mPhoneStateListener.onServiceStateChanged(ss); mPhoneStateListener.onServiceStateChanged(ss);
@@ -179,7 +179,7 @@ public class NetworkControllerDataTest extends NetworkControllerBaseTest {
updateDataConnectionState(TelephonyManager.DATA_CONNECTED, updateDataConnectionState(TelephonyManager.DATA_CONNECTED,
TelephonyManager.NETWORK_TYPE_LTE); TelephonyManager.NETWORK_TYPE_LTE);
ServiceState ss = Mockito.mock(ServiceState.class); ServiceState ss = Mockito.mock(ServiceState.class);
doReturn(NetworkRegistrationState.NR_STATUS_RESTRICTED).when(ss).getNrStatus(); doReturn(NetworkRegistrationInfo.NR_STATUS_RESTRICTED).when(ss).getNrStatus();
mPhoneStateListener.onServiceStateChanged(mServiceState); mPhoneStateListener.onServiceStateChanged(mServiceState);
verifyDataIndicators(TelephonyIcons.ICON_LTE); verifyDataIndicators(TelephonyIcons.ICON_LTE);

View File

@@ -25,7 +25,7 @@ oneway interface INetworkService
{ {
void createNetworkServiceProvider(int slotId); void createNetworkServiceProvider(int slotId);
void removeNetworkServiceProvider(int slotId); void removeNetworkServiceProvider(int slotId);
void getNetworkRegistrationState(int slotId, int domain, INetworkServiceCallback callback); void getNetworkRegistrationInfo(int slotId, int domain, INetworkServiceCallback callback);
void registerForNetworkRegistrationStateChanged(int slotId, INetworkServiceCallback callback); void registerForNetworkRegistrationInfoChanged(int slotId, INetworkServiceCallback callback);
void unregisterForNetworkRegistrationStateChanged(int slotId, INetworkServiceCallback callback); void unregisterForNetworkRegistrationInfoChanged(int slotId, INetworkServiceCallback callback);
} }

View File

@@ -16,7 +16,7 @@
package android.telephony; package android.telephony;
import android.telephony.NetworkRegistrationState; import android.telephony.NetworkRegistrationInfo;
/** /**
* Network service call back interface * Network service call back interface
@@ -24,6 +24,6 @@ import android.telephony.NetworkRegistrationState;
*/ */
oneway interface INetworkServiceCallback oneway interface INetworkServiceCallback
{ {
void onGetNetworkRegistrationStateComplete(int result, in NetworkRegistrationState state); void onGetNetworkRegistrationInfoComplete(int result, in NetworkRegistrationInfo state);
void onNetworkStateChanged(); void onNetworkStateChanged();
} }

View File

@@ -16,4 +16,4 @@
package android.telephony; package android.telephony;
parcelable NetworkRegistrationState; parcelable NetworkRegistrationInfo;

View File

@@ -32,11 +32,11 @@ import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* Description of a mobile network registration state * Description of a mobile network registration info
* @hide * @hide
*/ */
@SystemApi @SystemApi
public class NetworkRegistrationState implements Parcelable { public class NetworkRegistrationInfo implements Parcelable {
/** /**
* Network domain * Network domain
* @hide * @hide
@@ -184,12 +184,12 @@ public class NetworkRegistrationState implements Parcelable {
* @param cellIdentity The identity representing a unique cell or wifi AP. Set to null if the * @param cellIdentity The identity representing a unique cell or wifi AP. Set to null if the
* information is not available. * information is not available.
*/ */
public NetworkRegistrationState(@Domain int domain, @TransportType int transportType, public NetworkRegistrationInfo(@Domain int domain, @TransportType int transportType,
@RegState int regState, @RegState int regState,
@NetworkType int accessNetworkTechnology, int rejectCause, @NetworkType int accessNetworkTechnology, int rejectCause,
boolean emergencyOnly, boolean emergencyOnly,
@NonNull @ServiceType int[] availableServices, @NonNull @ServiceType int[] availableServices,
@Nullable CellIdentity cellIdentity) { @Nullable CellIdentity cellIdentity) {
mDomain = domain; mDomain = domain;
mTransportType = transportType; mTransportType = transportType;
mRegState = regState; mRegState = regState;
@@ -204,13 +204,15 @@ public class NetworkRegistrationState implements Parcelable {
} }
/** /**
* Constructor for voice network registration states. * Constructor for voice network registration info.
* @hide * @hide
*/ */
public NetworkRegistrationState(int domain, @TransportType int transportType, int regState, public NetworkRegistrationInfo(int domain, @TransportType int transportType, int regState,
int accessNetworkTechnology, int rejectCause, boolean emergencyOnly, int accessNetworkTechnology, int rejectCause,
int[] availableServices, @Nullable CellIdentity cellIdentity, boolean cssSupported, boolean emergencyOnly, int[] availableServices,
int roamingIndicator, int systemIsInPrl, int defaultRoamingIndicator) { @Nullable CellIdentity cellIdentity, boolean cssSupported,
int roamingIndicator, int systemIsInPrl,
int defaultRoamingIndicator) {
this(domain, transportType, regState, accessNetworkTechnology, rejectCause, emergencyOnly, this(domain, transportType, regState, accessNetworkTechnology, rejectCause, emergencyOnly,
availableServices, cellIdentity); availableServices, cellIdentity);
@@ -219,14 +221,16 @@ public class NetworkRegistrationState implements Parcelable {
} }
/** /**
* Constructor for data network registration states. * Constructor for data network registration info.
* @hide * @hide
*/ */
public NetworkRegistrationState(int domain, @TransportType int transportType, int regState, public NetworkRegistrationInfo(int domain, @TransportType int transportType, int regState,
int accessNetworkTechnology, int rejectCause, boolean emergencyOnly, int accessNetworkTechnology, int rejectCause,
int[] availableServices, @Nullable CellIdentity cellIdentity, int maxDataCalls, boolean emergencyOnly, int[] availableServices,
boolean isDcNrRestricted, boolean isNrAvailable, boolean isEndcAvailable, @Nullable CellIdentity cellIdentity, int maxDataCalls,
LteVopsSupportInfo lteVopsSupportInfo) { boolean isDcNrRestricted, boolean isNrAvailable,
boolean isEndcAvailable,
LteVopsSupportInfo lteVopsSupportInfo) {
this(domain, transportType, regState, accessNetworkTechnology, rejectCause, emergencyOnly, this(domain, transportType, regState, accessNetworkTechnology, rejectCause, emergencyOnly,
availableServices, cellIdentity); availableServices, cellIdentity);
@@ -235,7 +239,7 @@ public class NetworkRegistrationState implements Parcelable {
updateNrStatus(mDataSpecificStates); updateNrStatus(mDataSpecificStates);
} }
private NetworkRegistrationState(Parcel source) { private NetworkRegistrationInfo(Parcel source) {
mDomain = source.readInt(); mDomain = source.readInt();
mTransportType = source.readInt(); mTransportType = source.readInt();
mRegState = source.readInt(); mRegState = source.readInt();
@@ -433,7 +437,7 @@ public class NetworkRegistrationState implements Parcelable {
@Override @Override
public String toString() { public String toString() {
return new StringBuilder("NetworkRegistrationState{") return new StringBuilder("NetworkRegistrationInfo{")
.append(" domain=").append((mDomain == DOMAIN_CS) ? "CS" : "PS") .append(" domain=").append((mDomain == DOMAIN_CS) ? "CS" : "PS")
.append(" transportType=").append( .append(" transportType=").append(
AccessNetworkConstants.transportTypeToString(mTransportType)) AccessNetworkConstants.transportTypeToString(mTransportType))
@@ -465,11 +469,11 @@ public class NetworkRegistrationState implements Parcelable {
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (!(o instanceof NetworkRegistrationState)) { if (!(o instanceof NetworkRegistrationInfo)) {
return false; return false;
} }
NetworkRegistrationState other = (NetworkRegistrationState) o; NetworkRegistrationInfo other = (NetworkRegistrationInfo) o;
return mDomain == other.mDomain return mDomain == other.mDomain
&& mTransportType == other.mTransportType && mTransportType == other.mTransportType
&& mRegState == other.mRegState && mRegState == other.mRegState
@@ -528,46 +532,46 @@ public class NetworkRegistrationState implements Parcelable {
} }
} }
public static final @android.annotation.NonNull Parcelable.Creator<NetworkRegistrationState> CREATOR = public static final @NonNull Parcelable.Creator<NetworkRegistrationInfo> CREATOR =
new Parcelable.Creator<NetworkRegistrationState>() { new Parcelable.Creator<NetworkRegistrationInfo>() {
@Override @Override
public NetworkRegistrationState createFromParcel(Parcel source) { public NetworkRegistrationInfo createFromParcel(Parcel source) {
return new NetworkRegistrationState(source); return new NetworkRegistrationInfo(source);
} }
@Override @Override
public NetworkRegistrationState[] newArray(int size) { public NetworkRegistrationInfo[] newArray(int size) {
return new NetworkRegistrationState[size]; return new NetworkRegistrationInfo[size];
} }
}; };
/** /**
* @hide * @hide
*/ */
public NetworkRegistrationState sanitizeLocationInfo() { public NetworkRegistrationInfo sanitizeLocationInfo() {
NetworkRegistrationState result = copy(); NetworkRegistrationInfo result = copy();
result.mCellIdentity = null; result.mCellIdentity = null;
return result; return result;
} }
private NetworkRegistrationState copy() { private NetworkRegistrationInfo copy() {
Parcel p = Parcel.obtain(); Parcel p = Parcel.obtain();
this.writeToParcel(p, 0); this.writeToParcel(p, 0);
p.setDataPosition(0); p.setDataPosition(0);
NetworkRegistrationState result = new NetworkRegistrationState(p); NetworkRegistrationInfo result = new NetworkRegistrationInfo(p);
p.recycle(); p.recycle();
return result; return result;
} }
/** /**
* Provides a convenient way to set the fields of a {@link NetworkRegistrationState} when * Provides a convenient way to set the fields of a {@link NetworkRegistrationInfo} when
* creating a new instance. * creating a new instance.
* *
* <p>The example below shows how you might create a new {@code NetworkRegistrationState}: * <p>The example below shows how you might create a new {@code NetworkRegistrationInfo}:
* *
* <pre><code> * <pre><code>
* *
* NetworkRegistrationState nrs = new NetworkRegistrationState.Builder() * NetworkRegistrationInfo nrs = new NetworkRegistrationInfo.Builder()
* .setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS) * .setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS)
* .setApnName("apn.example.com") * .setApnName("apn.example.com")
* .setEntryName("Example Carrier APN") * .setEntryName("Example Carrier APN")
@@ -736,12 +740,12 @@ public class NetworkRegistrationState implements Parcelable {
} }
/** /**
* Build the NetworkRegistrationState. * Build the NetworkRegistrationInfo.
* *
* @return the NetworkRegistrationState object. * @return the NetworkRegistrationInfo object.
*/ */
public @NonNull NetworkRegistrationState build() { public @NonNull NetworkRegistrationInfo build() {
return new NetworkRegistrationState(mDomain, mTransportType, mRegState, return new NetworkRegistrationInfo(mDomain, mTransportType, mRegState,
mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices, mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices,
mCellIdentity); mCellIdentity);
} }

View File

@@ -27,7 +27,7 @@ import android.os.IBinder;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.RemoteException; import android.os.RemoteException;
import android.telephony.NetworkRegistrationState.Domain; import android.telephony.NetworkRegistrationInfo.Domain;
import android.util.SparseArray; import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
@@ -59,10 +59,10 @@ public abstract class NetworkService extends Service {
private static final int NETWORK_SERVICE_CREATE_NETWORK_SERVICE_PROVIDER = 1; private static final int NETWORK_SERVICE_CREATE_NETWORK_SERVICE_PROVIDER = 1;
private static final int NETWORK_SERVICE_REMOVE_NETWORK_SERVICE_PROVIDER = 2; private static final int NETWORK_SERVICE_REMOVE_NETWORK_SERVICE_PROVIDER = 2;
private static final int NETWORK_SERVICE_REMOVE_ALL_NETWORK_SERVICE_PROVIDERS = 3; private static final int NETWORK_SERVICE_REMOVE_ALL_NETWORK_SERVICE_PROVIDERS = 3;
private static final int NETWORK_SERVICE_GET_REGISTRATION_STATE = 4; private static final int NETWORK_SERVICE_GET_REGISTRATION_INFO = 4;
private static final int NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE = 5; private static final int NETWORK_SERVICE_REGISTER_FOR_INFO_CHANGE = 5;
private static final int NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE = 6; private static final int NETWORK_SERVICE_UNREGISTER_FOR_INFO_CHANGE = 6;
private static final int NETWORK_SERVICE_INDICATION_NETWORK_STATE_CHANGED = 7; private static final int NETWORK_SERVICE_INDICATION_NETWORK_INFO_CHANGED = 7;
private final HandlerThread mHandlerThread; private final HandlerThread mHandlerThread;
@@ -86,7 +86,7 @@ public abstract class NetworkService extends Service {
private final int mSlotIndex; private final int mSlotIndex;
private final List<INetworkServiceCallback> private final List<INetworkServiceCallback>
mNetworkRegistrationStateChangedCallbacks = new ArrayList<>(); mNetworkRegistrationInfoChangedCallbacks = new ArrayList<>();
/** /**
* Constructor * Constructor
@@ -104,38 +104,38 @@ public abstract class NetworkService extends Service {
} }
/** /**
* API to get network registration state. The result will be passed to the callback. * API to get network registration info. The result will be passed to the callback.
* @param domain Network domain * @param domain Network domain
* @param callback The callback for reporting network registration state * @param callback The callback for reporting network registration info
*/ */
public void getNetworkRegistrationState(@Domain int domain, public void getNetworkRegistrationInfo(@Domain int domain,
@NonNull NetworkServiceCallback callback) { @NonNull NetworkServiceCallback callback) {
callback.onGetNetworkRegistrationStateComplete( callback.onGetNetworkRegistrationInfoComplete(
NetworkServiceCallback.RESULT_ERROR_UNSUPPORTED, null); NetworkServiceCallback.RESULT_ERROR_UNSUPPORTED, null);
} }
/** /**
* Notify the system that network registration state is changed. * Notify the system that network registration info is changed.
*/ */
public final void notifyNetworkRegistrationStateChanged() { public final void notifyNetworkRegistrationInfoChanged() {
mHandler.obtainMessage(NETWORK_SERVICE_INDICATION_NETWORK_STATE_CHANGED, mHandler.obtainMessage(NETWORK_SERVICE_INDICATION_NETWORK_INFO_CHANGED,
mSlotIndex, 0, null).sendToTarget(); mSlotIndex, 0, null).sendToTarget();
} }
private void registerForStateChanged(@NonNull INetworkServiceCallback callback) { private void registerForInfoChanged(@NonNull INetworkServiceCallback callback) {
synchronized (mNetworkRegistrationStateChangedCallbacks) { synchronized (mNetworkRegistrationInfoChangedCallbacks) {
mNetworkRegistrationStateChangedCallbacks.add(callback); mNetworkRegistrationInfoChangedCallbacks.add(callback);
} }
} }
private void unregisterForStateChanged(@NonNull INetworkServiceCallback callback) { private void unregisterForInfoChanged(@NonNull INetworkServiceCallback callback) {
synchronized (mNetworkRegistrationStateChangedCallbacks) { synchronized (mNetworkRegistrationInfoChangedCallbacks) {
mNetworkRegistrationStateChangedCallbacks.remove(callback); mNetworkRegistrationInfoChangedCallbacks.remove(callback);
} }
} }
private void notifyStateChangedToCallbacks() { private void notifyInfoChangedToCallbacks() {
for (INetworkServiceCallback callback : mNetworkRegistrationStateChangedCallbacks) { for (INetworkServiceCallback callback : mNetworkRegistrationInfoChangedCallbacks) {
try { try {
callback.onNetworkStateChanged(); callback.onNetworkStateChanged();
} catch (RemoteException exception) { } catch (RemoteException exception) {
@@ -189,24 +189,24 @@ public abstract class NetworkService extends Service {
} }
mServiceMap.clear(); mServiceMap.clear();
break; break;
case NETWORK_SERVICE_GET_REGISTRATION_STATE: case NETWORK_SERVICE_GET_REGISTRATION_INFO:
if (serviceProvider == null) break; if (serviceProvider == null) break;
int domainId = message.arg2; int domainId = message.arg2;
serviceProvider.getNetworkRegistrationState(domainId, serviceProvider.getNetworkRegistrationInfo(domainId,
new NetworkServiceCallback(callback)); new NetworkServiceCallback(callback));
break; break;
case NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE: case NETWORK_SERVICE_REGISTER_FOR_INFO_CHANGE:
if (serviceProvider == null) break; if (serviceProvider == null) break;
serviceProvider.registerForStateChanged(callback); serviceProvider.registerForInfoChanged(callback);
break; break;
case NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE: case NETWORK_SERVICE_UNREGISTER_FOR_INFO_CHANGE:
if (serviceProvider == null) break; if (serviceProvider == null) break;
serviceProvider.unregisterForStateChanged(callback); serviceProvider.unregisterForInfoChanged(callback);
break; break;
case NETWORK_SERVICE_INDICATION_NETWORK_STATE_CHANGED: case NETWORK_SERVICE_INDICATION_NETWORK_INFO_CHANGED:
if (serviceProvider == null) break; if (serviceProvider == null) break;
serviceProvider.notifyStateChangedToCallbacks(); serviceProvider.notifyInfoChangedToCallbacks();
break; break;
default: default:
break; break;
@@ -280,23 +280,23 @@ public abstract class NetworkService extends Service {
} }
@Override @Override
public void getNetworkRegistrationState( public void getNetworkRegistrationInfo(
int slotIndex, int domain, INetworkServiceCallback callback) { int slotIndex, int domain, INetworkServiceCallback callback) {
mHandler.obtainMessage(NETWORK_SERVICE_GET_REGISTRATION_STATE, slotIndex, mHandler.obtainMessage(NETWORK_SERVICE_GET_REGISTRATION_INFO, slotIndex,
domain, callback).sendToTarget(); domain, callback).sendToTarget();
} }
@Override @Override
public void registerForNetworkRegistrationStateChanged( public void registerForNetworkRegistrationInfoChanged(
int slotIndex, INetworkServiceCallback callback) { int slotIndex, INetworkServiceCallback callback) {
mHandler.obtainMessage(NETWORK_SERVICE_REGISTER_FOR_STATE_CHANGE, slotIndex, mHandler.obtainMessage(NETWORK_SERVICE_REGISTER_FOR_INFO_CHANGE, slotIndex,
0, callback).sendToTarget(); 0, callback).sendToTarget();
} }
@Override @Override
public void unregisterForNetworkRegistrationStateChanged( public void unregisterForNetworkRegistrationInfoChanged(
int slotIndex, INetworkServiceCallback callback) { int slotIndex, INetworkServiceCallback callback) {
mHandler.obtainMessage(NETWORK_SERVICE_UNREGISTER_FOR_STATE_CHANGE, slotIndex, mHandler.obtainMessage(NETWORK_SERVICE_UNREGISTER_FOR_INFO_CHANGE, slotIndex,
0, callback).sendToTarget(); 0, callback).sendToTarget();
} }
} }

View File

@@ -28,8 +28,8 @@ import java.lang.ref.WeakReference;
/** /**
* Network service callback. Object of this class is passed to NetworkServiceProvider upon * Network service callback. Object of this class is passed to NetworkServiceProvider upon
* calling getNetworkRegistrationState, to receive asynchronous feedback from NetworkServiceProvider * calling getNetworkRegistrationInfo, to receive asynchronous feedback from NetworkServiceProvider
* upon onGetNetworkRegistrationStateComplete. It's like a wrapper of INetworkServiceCallback * upon onGetNetworkRegistrationInfoComplete. It's like a wrapper of INetworkServiceCallback
* because INetworkServiceCallback can't be a parameter type in public APIs. * because INetworkServiceCallback can't be a parameter type in public APIs.
* *
* @hide * @hide
@@ -70,20 +70,20 @@ public class NetworkServiceCallback {
/** /**
* Called to indicate result of * Called to indicate result of
* {@link NetworkServiceProvider#getNetworkRegistrationState(int, NetworkServiceCallback)} * {@link NetworkServiceProvider#getNetworkRegistrationInfo(int, NetworkServiceCallback)}
* *
* @param result Result status like {@link NetworkServiceCallback#RESULT_SUCCESS} or * @param result Result status like {@link NetworkServiceCallback#RESULT_SUCCESS} or
* {@link NetworkServiceCallback#RESULT_ERROR_UNSUPPORTED} * {@link NetworkServiceCallback#RESULT_ERROR_UNSUPPORTED}
* @param state The state information to be returned to callback. * @param state The state information to be returned to callback.
*/ */
public void onGetNetworkRegistrationStateComplete(int result, public void onGetNetworkRegistrationInfoComplete(int result,
@Nullable NetworkRegistrationState state) { @Nullable NetworkRegistrationInfo state) {
INetworkServiceCallback callback = mCallback.get(); INetworkServiceCallback callback = mCallback.get();
if (callback != null) { if (callback != null) {
try { try {
callback.onGetNetworkRegistrationStateComplete(result, state); callback.onGetNetworkRegistrationInfoComplete(result, state);
} catch (RemoteException e) { } catch (RemoteException e) {
Rlog.e(mTag, "Failed to onGetNetworkRegistrationStateComplete on the remote"); Rlog.e(mTag, "Failed to onGetNetworkRegistrationInfoComplete on the remote");
} }
} else { } else {
Rlog.e(mTag, "Weak reference of callback is null."); Rlog.e(mTag, "Weak reference of callback is null.");

View File

@@ -29,8 +29,8 @@ import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.telephony.AccessNetworkConstants.AccessNetworkType; import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.NetworkRegistrationState.Domain; import android.telephony.NetworkRegistrationInfo.Domain;
import android.telephony.NetworkRegistrationState.NRStatus; import android.telephony.NetworkRegistrationInfo.NRStatus;
import android.text.TextUtils; import android.text.TextUtils;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@@ -349,7 +349,7 @@ public class ServiceState implements Parcelable {
* Reference: 3GPP TS 36.104 5.4.3 */ * Reference: 3GPP TS 36.104 5.4.3 */
private int mLteEarfcnRsrpBoost = 0; private int mLteEarfcnRsrpBoost = 0;
private List<NetworkRegistrationState> mNetworkRegistrationStates = new ArrayList<>(); private List<NetworkRegistrationInfo> mNetworkRegistrationInfos = new ArrayList<>();
/** /**
* get String description of roaming type * get String description of roaming type
@@ -432,8 +432,8 @@ public class ServiceState implements Parcelable {
mCellBandwidths = s.mCellBandwidths == null ? null : mCellBandwidths = s.mCellBandwidths == null ? null :
Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length); Arrays.copyOf(s.mCellBandwidths, s.mCellBandwidths.length);
mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost; mLteEarfcnRsrpBoost = s.mLteEarfcnRsrpBoost;
mNetworkRegistrationStates = s.mNetworkRegistrationStates == null ? null : mNetworkRegistrationInfos = s.mNetworkRegistrationInfos == null ? null :
new ArrayList<>(s.mNetworkRegistrationStates); new ArrayList<>(s.mNetworkRegistrationInfos);
mNrFrequencyRange = s.mNrFrequencyRange; mNrFrequencyRange = s.mNrFrequencyRange;
} }
@@ -466,8 +466,8 @@ public class ServiceState implements Parcelable {
mIsEmergencyOnly = in.readInt() != 0; mIsEmergencyOnly = in.readInt() != 0;
mIsUsingCarrierAggregation = in.readInt() != 0; mIsUsingCarrierAggregation = in.readInt() != 0;
mLteEarfcnRsrpBoost = in.readInt(); mLteEarfcnRsrpBoost = in.readInt();
mNetworkRegistrationStates = new ArrayList<>(); mNetworkRegistrationInfos = new ArrayList<>();
in.readList(mNetworkRegistrationStates, NetworkRegistrationState.class.getClassLoader()); in.readList(mNetworkRegistrationInfos, NetworkRegistrationInfo.class.getClassLoader());
mChannelNumber = in.readInt(); mChannelNumber = in.readInt();
mCellBandwidths = in.createIntArray(); mCellBandwidths = in.createIntArray();
mNrFrequencyRange = in.readInt(); mNrFrequencyRange = in.readInt();
@@ -495,7 +495,7 @@ public class ServiceState implements Parcelable {
out.writeInt(mIsEmergencyOnly ? 1 : 0); out.writeInt(mIsEmergencyOnly ? 1 : 0);
out.writeInt(mIsUsingCarrierAggregation ? 1 : 0); out.writeInt(mIsUsingCarrierAggregation ? 1 : 0);
out.writeInt(mLteEarfcnRsrpBoost); out.writeInt(mLteEarfcnRsrpBoost);
out.writeList(mNetworkRegistrationStates); out.writeList(mNetworkRegistrationInfos);
out.writeInt(mChannelNumber); out.writeInt(mChannelNumber);
out.writeIntArray(mCellBandwidths); out.writeIntArray(mCellBandwidths);
out.writeInt(mNrFrequencyRange); out.writeInt(mNrFrequencyRange);
@@ -620,8 +620,8 @@ public class ServiceState implements Parcelable {
*/ */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @RoamingType int getVoiceRoamingType() { public @RoamingType int getVoiceRoamingType() {
final NetworkRegistrationState regState = getNetworkRegistrationState( final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) { if (regState != null) {
return regState.getRoamingType(); return regState.getRoamingType();
} }
@@ -644,10 +644,10 @@ public class ServiceState implements Parcelable {
* @hide * @hide
*/ */
public boolean getDataRoamingFromRegistration() { public boolean getDataRoamingFromRegistration() {
final NetworkRegistrationState regState = getNetworkRegistrationState( final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) { if (regState != null) {
return (regState.getRegState() == NetworkRegistrationState.REG_STATE_ROAMING); return (regState.getRegState() == NetworkRegistrationInfo.REG_STATE_ROAMING);
} }
return false; return false;
} }
@@ -659,8 +659,8 @@ public class ServiceState implements Parcelable {
*/ */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @RoamingType int getDataRoamingType() { public @RoamingType int getDataRoamingType() {
final NetworkRegistrationState regState = getNetworkRegistrationState( final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) { if (regState != null) {
return regState.getRoamingType(); return regState.getRoamingType();
} }
@@ -858,7 +858,7 @@ public class ServiceState implements Parcelable {
mIsEmergencyOnly, mIsEmergencyOnly,
mIsUsingCarrierAggregation, mIsUsingCarrierAggregation,
mLteEarfcnRsrpBoost, mLteEarfcnRsrpBoost,
mNetworkRegistrationStates, mNetworkRegistrationInfos,
mNrFrequencyRange); mNrFrequencyRange);
} }
@@ -888,9 +888,9 @@ public class ServiceState implements Parcelable {
s.mCdmaDefaultRoamingIndicator) s.mCdmaDefaultRoamingIndicator)
&& mIsEmergencyOnly == s.mIsEmergencyOnly && mIsEmergencyOnly == s.mIsEmergencyOnly
&& mIsUsingCarrierAggregation == s.mIsUsingCarrierAggregation) && mIsUsingCarrierAggregation == s.mIsUsingCarrierAggregation)
&& (mNetworkRegistrationStates == null ? s.mNetworkRegistrationStates == null : && (mNetworkRegistrationInfos == null
s.mNetworkRegistrationStates != null && ? s.mNetworkRegistrationInfos == null : s.mNetworkRegistrationInfos != null
mNetworkRegistrationStates.containsAll(s.mNetworkRegistrationStates)) && mNetworkRegistrationInfos.containsAll(s.mNetworkRegistrationInfos))
&& mNrFrequencyRange == s.mNrFrequencyRange; && mNrFrequencyRange == s.mNrFrequencyRange;
} }
@@ -1043,7 +1043,7 @@ public class ServiceState implements Parcelable {
.append(", mIsEmergencyOnly=").append(mIsEmergencyOnly) .append(", mIsEmergencyOnly=").append(mIsEmergencyOnly)
.append(", mIsUsingCarrierAggregation=").append(mIsUsingCarrierAggregation) .append(", mIsUsingCarrierAggregation=").append(mIsUsingCarrierAggregation)
.append(", mLteEarfcnRsrpBoost=").append(mLteEarfcnRsrpBoost) .append(", mLteEarfcnRsrpBoost=").append(mLteEarfcnRsrpBoost)
.append(", mNetworkRegistrationStates=").append(mNetworkRegistrationStates) .append(", mNetworkRegistrationInfos=").append(mNetworkRegistrationInfos)
.append(", mNrFrequencyRange=").append(mNrFrequencyRange) .append(", mNrFrequencyRange=").append(mNrFrequencyRange)
.append("}").toString(); .append("}").toString();
} }
@@ -1073,7 +1073,7 @@ public class ServiceState implements Parcelable {
mIsEmergencyOnly = false; mIsEmergencyOnly = false;
mIsUsingCarrierAggregation = false; mIsUsingCarrierAggregation = false;
mLteEarfcnRsrpBoost = 0; mLteEarfcnRsrpBoost = 0;
mNetworkRegistrationStates = new ArrayList<>(); mNetworkRegistrationInfos = new ArrayList<>();
mNrFrequencyRange = FREQUENCY_RANGE_UNKNOWN; mNrFrequencyRange = FREQUENCY_RANGE_UNKNOWN;
} }
@@ -1130,14 +1130,14 @@ public class ServiceState implements Parcelable {
/** @hide */ /** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public void setVoiceRoamingType(@RoamingType int type) { public void setVoiceRoamingType(@RoamingType int type) {
NetworkRegistrationState regState = getNetworkRegistrationState( NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) { if (regState == null) {
regState = new NetworkRegistrationState( regState = new NetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0,
false, null, null); false, null, null);
addNetworkRegistrationState(regState); addNetworkRegistrationInfo(regState);
} }
regState.setRoamingType(type); regState.setRoamingType(type);
} }
@@ -1151,14 +1151,14 @@ public class ServiceState implements Parcelable {
/** @hide */ /** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public void setDataRoamingType(@RoamingType int type) { public void setDataRoamingType(@RoamingType int type) {
NetworkRegistrationState regState = getNetworkRegistrationState( NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) { if (regState == null) {
regState = new NetworkRegistrationState( regState = new NetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0, ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0,
false, null, null); false, null, null);
addNetworkRegistrationState(regState); addNetworkRegistrationInfo(regState);
} }
regState.setRoamingType(type); regState.setRoamingType(type);
} }
@@ -1326,14 +1326,14 @@ public class ServiceState implements Parcelable {
this.mRilVoiceRadioTechnology = rt; this.mRilVoiceRadioTechnology = rt;
// sync to network registration state // sync to network registration state
NetworkRegistrationState regState = getNetworkRegistrationState( NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) { if (regState == null) {
regState = new NetworkRegistrationState( regState = new NetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN,
0, false, null, null); 0, false, null, null);
addNetworkRegistrationState(regState); addNetworkRegistrationInfo(regState);
} }
regState.setAccessNetworkTechnology( regState.setAccessNetworkTechnology(
rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology)); rilRadioTechnologyToNetworkType(mRilVoiceRadioTechnology));
@@ -1353,15 +1353,15 @@ public class ServiceState implements Parcelable {
mRilDataRadioTechnology); mRilDataRadioTechnology);
// sync to network registration state // sync to network registration state
NetworkRegistrationState regState = getNetworkRegistrationState( NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) { if (regState == null) {
regState = new NetworkRegistrationState( regState = new NetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN, NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN,
0, false, null, null); 0, false, null, null);
addNetworkRegistrationState(regState); addNetworkRegistrationInfo(regState);
} }
regState.setAccessNetworkTechnology( regState.setAccessNetworkTechnology(
rilRadioTechnologyToNetworkType(mRilDataRadioTechnology)); rilRadioTechnologyToNetworkType(mRilDataRadioTechnology));
@@ -1391,9 +1391,9 @@ public class ServiceState implements Parcelable {
* @hide * @hide
*/ */
public @NRStatus int getNrStatus() { public @NRStatus int getNrStatus() {
final NetworkRegistrationState regState = getNetworkRegistrationState( final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) return NetworkRegistrationState.NR_STATUS_NONE; if (regState == null) return NetworkRegistrationInfo.NR_STATUS_NONE;
return regState.getNrStatus(); return regState.getNrStatus();
} }
@@ -1576,19 +1576,19 @@ public class ServiceState implements Parcelable {
/** @hide */ /** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @TelephonyManager.NetworkType int getDataNetworkType() { public @TelephonyManager.NetworkType int getDataNetworkType() {
final NetworkRegistrationState iwlanRegState = getNetworkRegistrationState( final NetworkRegistrationInfo iwlanRegState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN); NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
if (iwlanRegState != null if (iwlanRegState != null
&& iwlanRegState.getRegState() == NetworkRegistrationState.REG_STATE_HOME) { && iwlanRegState.getRegState() == NetworkRegistrationInfo.REG_STATE_HOME) {
// If the device is on IWLAN, return IWLAN as the network type. This is to simulate the // If the device is on IWLAN, return IWLAN as the network type. This is to simulate the
// behavior of legacy mode device. In the future caller should use // behavior of legacy mode device. In the future caller should use
// getNetworkRegistrationState() to retrieve the actual data network type on cellular // getNetworkRegistrationInfo() to retrieve the actual data network type on cellular
// or on IWLAN. // or on IWLAN.
return iwlanRegState.getAccessNetworkTechnology(); return iwlanRegState.getAccessNetworkTechnology();
} }
final NetworkRegistrationState regState = getNetworkRegistrationState( final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) { if (regState != null) {
return regState.getAccessNetworkTechnology(); return regState.getAccessNetworkTechnology();
} }
@@ -1598,8 +1598,8 @@ public class ServiceState implements Parcelable {
/** @hide */ /** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @TelephonyManager.NetworkType int getVoiceNetworkType() { public @TelephonyManager.NetworkType int getVoiceNetworkType() {
final NetworkRegistrationState regState = getNetworkRegistrationState( final NetworkRegistrationInfo regState = getNetworkRegistrationInfo(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) { if (regState != null) {
return regState.getAccessNetworkTechnology(); return regState.getAccessNetworkTechnology();
} }
@@ -1762,52 +1762,36 @@ public class ServiceState implements Parcelable {
} }
/** /**
* Get all of the available network registration states. * Get all of the available network registration info.
* *
* @return List of {@link NetworkRegistrationState} * @return List of {@link NetworkRegistrationInfo}
* @hide * @hide
*/ */
@NonNull @NonNull
@SystemApi @SystemApi
public List<NetworkRegistrationState> getNetworkRegistrationStates() { public List<NetworkRegistrationInfo> getNetworkRegistrationInfoList() {
synchronized (mNetworkRegistrationStates) { synchronized (mNetworkRegistrationInfos) {
return new ArrayList<>(mNetworkRegistrationStates); return new ArrayList<>(mNetworkRegistrationInfos);
} }
} }
/** /**
* Get the network registration states for the transport type. * Get the network registration info list for the transport type.
* *
* @param transportType The transport type * @param transportType The transport type
* @return List of {@link NetworkRegistrationState} * @return List of {@link NetworkRegistrationInfo}
* @hide
*
* @deprecated Use {@link #getNetworkRegistrationStatesForTransportType(int)}
*/
@NonNull
@Deprecated
@SystemApi
public List<NetworkRegistrationState> getNetworkRegistrationStates(int transportType) {
return getNetworkRegistrationStatesForTransportType(transportType);
}
/**
* Get the network registration states for the transport type.
*
* @param transportType The transport type
* @return List of {@link NetworkRegistrationState}
* @hide * @hide
*/ */
@NonNull @NonNull
@SystemApi @SystemApi
public List<NetworkRegistrationState> getNetworkRegistrationStatesForTransportType( public List<NetworkRegistrationInfo> getNetworkRegistrationInfoListForTransportType(
@TransportType int transportType) { @TransportType int transportType) {
List<NetworkRegistrationState> list = new ArrayList<>(); List<NetworkRegistrationInfo> list = new ArrayList<>();
synchronized (mNetworkRegistrationStates) { synchronized (mNetworkRegistrationInfos) {
for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) { for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
if (networkRegistrationState.getTransportType() == transportType) { if (networkRegistrationInfo.getTransportType() == transportType) {
list.add(networkRegistrationState); list.add(networkRegistrationInfo);
} }
} }
} }
@@ -1816,22 +1800,22 @@ public class ServiceState implements Parcelable {
} }
/** /**
* Get the network registration states for the network domain. * Get the network registration info list for the network domain.
* *
* @param domain The network {@link NetworkRegistrationState.Domain domain} * @param domain The network {@link NetworkRegistrationInfo.Domain domain}
* @return List of {@link NetworkRegistrationState} * @return List of {@link NetworkRegistrationInfo}
* @hide * @hide
*/ */
@NonNull @NonNull
@SystemApi @SystemApi
public List<NetworkRegistrationState> getNetworkRegistrationStatesForDomain( public List<NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain(
@Domain int domain) { @Domain int domain) {
List<NetworkRegistrationState> list = new ArrayList<>(); List<NetworkRegistrationInfo> list = new ArrayList<>();
synchronized (mNetworkRegistrationStates) { synchronized (mNetworkRegistrationInfos) {
for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) { for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
if (networkRegistrationState.getDomain() == domain) { if (networkRegistrationInfo.getDomain() == domain) {
list.add(networkRegistrationState); list.add(networkRegistrationInfo);
} }
} }
} }
@@ -1842,39 +1826,21 @@ public class ServiceState implements Parcelable {
/** /**
* Get the network registration state for the transport type and network domain. * Get the network registration state for the transport type and network domain.
* *
* @param domain The network {@link NetworkRegistrationState.Domain domain} * @param domain The network {@link NetworkRegistrationInfo.Domain domain}
* @param transportType The transport type * @param transportType The transport type
* @return The matching {@link NetworkRegistrationState} * @return The matching {@link NetworkRegistrationInfo}
* @hide
*
* @deprecated Use {@link #getNetworkRegistrationState(int, int)}
*/
@Nullable
@Deprecated
@SystemApi
public NetworkRegistrationState getNetworkRegistrationStates(@Domain int domain,
@TransportType int transportType) {
return getNetworkRegistrationState(domain, transportType);
}
/**
* Get the network registration state for the transport type and network domain.
*
* @param domain The network {@link NetworkRegistrationState.Domain domain}
* @param transportType The transport type
* @return The matching {@link NetworkRegistrationState}
* @hide * @hide
* *
*/ */
@Nullable @Nullable
@SystemApi @SystemApi
public NetworkRegistrationState getNetworkRegistrationState(@Domain int domain, public NetworkRegistrationInfo getNetworkRegistrationInfo(@Domain int domain,
@TransportType int transportType) { @TransportType int transportType) {
synchronized (mNetworkRegistrationStates) { synchronized (mNetworkRegistrationInfos) {
for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) { for (NetworkRegistrationInfo networkRegistrationInfo : mNetworkRegistrationInfos) {
if (networkRegistrationState.getTransportType() == transportType if (networkRegistrationInfo.getTransportType() == transportType
&& networkRegistrationState.getDomain() == domain) { && networkRegistrationInfo.getDomain() == domain) {
return networkRegistrationState; return networkRegistrationInfo;
} }
} }
} }
@@ -1885,20 +1851,20 @@ public class ServiceState implements Parcelable {
/** /**
* @hide * @hide
*/ */
public void addNetworkRegistrationState(NetworkRegistrationState regState) { public void addNetworkRegistrationInfo(NetworkRegistrationInfo regState) {
if (regState == null) return; if (regState == null) return;
synchronized (mNetworkRegistrationStates) { synchronized (mNetworkRegistrationInfos) {
for (int i = 0; i < mNetworkRegistrationStates.size(); i++) { for (int i = 0; i < mNetworkRegistrationInfos.size(); i++) {
NetworkRegistrationState curRegState = mNetworkRegistrationStates.get(i); NetworkRegistrationInfo curRegState = mNetworkRegistrationInfos.get(i);
if (curRegState.getTransportType() == regState.getTransportType() if (curRegState.getTransportType() == regState.getTransportType()
&& curRegState.getDomain() == regState.getDomain()) { && curRegState.getDomain() == regState.getDomain()) {
mNetworkRegistrationStates.remove(i); mNetworkRegistrationInfos.remove(i);
break; break;
} }
} }
mNetworkRegistrationStates.add(regState); mNetworkRegistrationInfos.add(regState);
} }
} }
@@ -1913,15 +1879,15 @@ public class ServiceState implements Parcelable {
/** /**
* Returns a copy of self with location-identifying information removed. * Returns a copy of self with location-identifying information removed.
* Always clears the NetworkRegistrationState's CellIdentity fields, but if removeCoarseLocation * Always clears the NetworkRegistrationInfo's CellIdentity fields, but if removeCoarseLocation
* is true, clears other info as well. * is true, clears other info as well.
* @hide * @hide
*/ */
public ServiceState sanitizeLocationInfo(boolean removeCoarseLocation) { public ServiceState sanitizeLocationInfo(boolean removeCoarseLocation) {
ServiceState state = new ServiceState(this); ServiceState state = new ServiceState(this);
if (state.mNetworkRegistrationStates != null) { if (state.mNetworkRegistrationInfos != null) {
state.mNetworkRegistrationStates = state.mNetworkRegistrationStates.stream() state.mNetworkRegistrationInfos = state.mNetworkRegistrationInfos.stream()
.map(NetworkRegistrationState::sanitizeLocationInfo) .map(NetworkRegistrationInfo::sanitizeLocationInfo)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if (!removeCoarseLocation) return state; if (!removeCoarseLocation) return state;