API: Separates getting roaming according to overridden or non-overridden

1. New API
 - TelephonyDisplayInfo#IsRoaming returns true if device is roaming
   overridden by carrier config.
 - NetworkRegistrationInfo #isNetworkRoaming, #isNetworkRegistered,
   #isNetworkSearching and #getNetworkResitrationState return
   roaming value of network without overridden by carrier config or
   overlay resource.
2. Deprecated API
 - NetworkRegistrationInfo #isRoaming, #isRegistered, #isSearching
   and #getResitrationState.

Bug: 260017781
Test: atest CtsTelephonyTestCases:NetworkRegistrationInfoTest
Change-Id: I025b64145caa772b27c410ae5836224f2e922fa1
This commit is contained in:
sangyun
2022-11-15 11:02:03 +09:00
parent 331e4ee449
commit 3911738715
9 changed files with 138 additions and 41 deletions

View File

@@ -43514,9 +43514,12 @@ package android.telephony {
method public int getDomain();
method @Nullable public String getRegisteredPlmn();
method public int getTransportType();
method public boolean isRegistered();
method public boolean isRoaming();
method public boolean isSearching();
method public boolean isNetworkRegistered();
method public boolean isNetworkRoaming();
method public boolean isNetworkSearching();
method @Deprecated public boolean isRegistered();
method @Deprecated public boolean isRoaming();
method @Deprecated public boolean isSearching();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.NetworkRegistrationInfo> CREATOR;
field public static final int DOMAIN_CS = 1; // 0x1
@@ -44282,6 +44285,7 @@ package android.telephony {
method public int describeContents();
method public int getNetworkType();
method public int getOverrideNetworkType();
method public boolean isRoaming();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.TelephonyDisplayInfo> CREATOR;
field public static final int OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO = 2; // 0x2

View File

@@ -13270,7 +13270,8 @@ package android.telephony {
public final class NetworkRegistrationInfo implements android.os.Parcelable {
method @Nullable public android.telephony.DataSpecificRegistrationInfo getDataSpecificInfo();
method public int getRegistrationState();
method public int getNetworkRegistrationState();
method @Deprecated public int getRegistrationState();
method public int getRejectCause();
method public int getRoamingType();
method public boolean isEmergencyEnabled();

View File

@@ -231,7 +231,7 @@ public class MobileStatusTracker {
public SignalStrength signalStrength;
public TelephonyDisplayInfo telephonyDisplayInfo =
new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false);
/**
* Empty constructor

View File

@@ -144,7 +144,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final TelephonyDisplayInfo DEFAULT_TELEPHONY_DISPLAY_INFO =
new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false);
static final int MAX_WIFI_ENTRY_COUNT = 3;

View File

@@ -49,7 +49,7 @@ internal class MobileState(
) : ConnectivityState() {
@JvmField var telephonyDisplayInfo = TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UNKNOWN,
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE)
TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false)
@JvmField var serviceState: ServiceState? = null
@JvmField var signalStrength: SignalStrength? = null
@@ -131,7 +131,7 @@ internal class MobileState(
}
fun isRoaming(): Boolean {
return serviceState != null && serviceState!!.roaming
return telephonyDisplayInfo != null && telephonyDisplayInfo.isRoaming
}
/**

View File

@@ -1956,7 +1956,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
&& overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED) {
overrideNetworkType = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE;
}
return new TelephonyDisplayInfo(networkType, overrideNetworkType);
boolean isRoaming = telephonyDisplayInfo.isRoaming();
return new TelephonyDisplayInfo(networkType, overrideNetworkType, isRoaming);
}
public void notifyCallForwardingChanged(boolean cfi) {

View File

@@ -184,10 +184,11 @@ public final class NetworkRegistrationInfo implements Parcelable {
private final int mTransportType;
/**
* The initial registration state
* The true registration state of network, This is not affected by any carrier config or
* resource overlay.
*/
@RegistrationState
private final int mInitialRegistrationState;
private final int mNetworkRegistrationState;
/**
* The registration state that might have been overridden by config
@@ -264,7 +265,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
mDomain = domain;
mTransportType = transportType;
mRegistrationState = registrationState;
mInitialRegistrationState = registrationState;
mNetworkRegistrationState = registrationState;
mRoamingType = (registrationState == REGISTRATION_STATE_ROAMING)
? ServiceState.ROAMING_TYPE_UNKNOWN : ServiceState.ROAMING_TYPE_NOT_ROAMING;
setAccessNetworkTechnology(accessNetworkTechnology);
@@ -320,7 +321,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
mDomain = source.readInt();
mTransportType = source.readInt();
mRegistrationState = source.readInt();
mInitialRegistrationState = source.readInt();
mNetworkRegistrationState = source.readInt();
mRoamingType = source.readInt();
mAccessNetworkTechnology = source.readInt();
mRejectCause = source.readInt();
@@ -347,7 +348,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
mDomain = nri.mDomain;
mTransportType = nri.mTransportType;
mRegistrationState = nri.mRegistrationState;
mInitialRegistrationState = nri.mInitialRegistrationState;
mNetworkRegistrationState = nri.mNetworkRegistrationState;
mRoamingType = nri.mRoamingType;
mAccessNetworkTechnology = nri.mAccessNetworkTechnology;
mIsUsingCarrierAggregation = nri.mIsUsingCarrierAggregation;
@@ -400,39 +401,71 @@ public final class NetworkRegistrationInfo implements Parcelable {
}
/**
* @return The registration state.
* @return The registration state. Note this value can be affected by the carrier config
* override.
*
* @deprecated Use {@link #getNetworkRegistrationState}, which is not affected by any carrier
* config or resource overlay, instead.
* @hide
*/
@Deprecated
@SystemApi
public @RegistrationState int getRegistrationState() {
return mRegistrationState;
}
/**
* @return The initial registration state.
* @return The true registration state of network. (This value is not affected by any carrier
* config or resource overlay override).
*
* @hide
*/
public @RegistrationState int getInitialRegistrationState() {
return mInitialRegistrationState;
@SystemApi
public @RegistrationState int getNetworkRegistrationState() {
return mNetworkRegistrationState;
}
/**
* @return {@code true} if registered on roaming or home network, {@code false} otherwise.
* @return {@code true} if registered on roaming or home network. Note this value can be
* affected by the carrier config override.
*
* @deprecated Use {@link #isNetworkRegistered}, which is not affected by any carrier config or
* resource overlay, instead.
*/
@Deprecated
public boolean isRegistered() {
return mRegistrationState == REGISTRATION_STATE_HOME
|| mRegistrationState == REGISTRATION_STATE_ROAMING;
}
/**
* @return {@code true} if searching for service, {@code false} otherwise.
* @return {@code true} if registered on roaming or home network, {@code false} otherwise. (This
* value is not affected by any carrier config or resource overlay override).
*/
public boolean isNetworkRegistered() {
return mNetworkRegistrationState == REGISTRATION_STATE_HOME
|| mNetworkRegistrationState == REGISTRATION_STATE_ROAMING;
}
/**
* @return {@code true} if searching for service, {@code false} otherwise.
*
* @deprecated Use {@link #isNetworkRegistered}, which is not affected by any carrier config or
* resource overlay, instead.
*/
@Deprecated
public boolean isSearching() {
return mRegistrationState == REGISTRATION_STATE_NOT_REGISTERED_SEARCHING;
}
/**
* @return {@code true} if searching for service, {@code false} otherwise. (This value is not
* affected by any carrier config or resource overlay override).
*/
public boolean isNetworkSearching() {
return mNetworkRegistrationState == REGISTRATION_STATE_NOT_REGISTERED_SEARCHING;
}
/**
* Get the PLMN-ID for this Network Registration, also known as the RPLMN.
*
@@ -450,12 +483,24 @@ public final class NetworkRegistrationInfo implements Parcelable {
}
/**
* @return {@code true} if registered on roaming network, {@code false} otherwise.
* @return {@code true} if registered on roaming network overridden by config. Note this value
* can be affected by the carrier config override.
*
* @deprecated Use {@link TelephonyDisplayInfo#isRoaming} instead.
*/
@Deprecated
public boolean isRoaming() {
return mRoamingType != ServiceState.ROAMING_TYPE_NOT_ROAMING;
}
/**
* @return {@code true} if registered on roaming network. (This value is not affected by any
* carrier config or resource overlay override).
*/
public boolean isNetworkRoaming() {
return mNetworkRegistrationState == REGISTRATION_STATE_ROAMING;
}
/**
* @hide
* @return {@code true} if in service.
@@ -486,7 +531,8 @@ public final class NetworkRegistrationInfo implements Parcelable {
}
/**
* @return the current network roaming type.
* @return the current network roaming type. Note that this value can be possibly overridden by
* the carrier config or resource overlay.
* @hide
*/
@SystemApi
@@ -666,8 +712,8 @@ public final class NetworkRegistrationInfo implements Parcelable {
.append(" transportType=").append(
AccessNetworkConstants.transportTypeToString(mTransportType))
.append(" registrationState=").append(registrationStateToString(mRegistrationState))
.append(" mInitialRegistrationState=")
.append(registrationStateToString(mInitialRegistrationState))
.append(" networkRegistrationState=")
.append(registrationStateToString(mNetworkRegistrationState))
.append(" roamingType=").append(ServiceState.roamingTypeToString(mRoamingType))
.append(" accessNetworkTechnology=")
.append(TelephonyManager.getNetworkTypeName(mAccessNetworkTechnology))
@@ -688,7 +734,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
@Override
public int hashCode() {
return Objects.hash(mDomain, mTransportType, mRegistrationState, mInitialRegistrationState,
return Objects.hash(mDomain, mTransportType, mRegistrationState, mNetworkRegistrationState,
mRoamingType, mAccessNetworkTechnology, mRejectCause, mEmergencyOnly,
mAvailableServices, mCellIdentity, mVoiceSpecificInfo, mDataSpecificInfo, mNrState,
mRplmn, mIsUsingCarrierAggregation);
@@ -706,7 +752,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
return mDomain == other.mDomain
&& mTransportType == other.mTransportType
&& mRegistrationState == other.mRegistrationState
&& mInitialRegistrationState == other.mInitialRegistrationState
&& mNetworkRegistrationState == other.mNetworkRegistrationState
&& mRoamingType == other.mRoamingType
&& mAccessNetworkTechnology == other.mAccessNetworkTechnology
&& mRejectCause == other.mRejectCause
@@ -729,7 +775,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
dest.writeInt(mDomain);
dest.writeInt(mTransportType);
dest.writeInt(mRegistrationState);
dest.writeInt(mInitialRegistrationState);
dest.writeInt(mNetworkRegistrationState);
dest.writeInt(mRoamingType);
dest.writeInt(mAccessNetworkTechnology);
dest.writeInt(mRejectCause);
@@ -826,7 +872,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
private int mTransportType;
@RegistrationState
private int mInitialRegistrationState;
private int mNetworkRegistrationState;
@NetworkType
private int mAccessNetworkTechnology;
@@ -864,7 +910,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
public Builder(@NonNull NetworkRegistrationInfo nri) {
mDomain = nri.mDomain;
mTransportType = nri.mTransportType;
mInitialRegistrationState = nri.mInitialRegistrationState;
mNetworkRegistrationState = nri.mNetworkRegistrationState;
mAccessNetworkTechnology = nri.mAccessNetworkTechnology;
mRejectCause = nri.mRejectCause;
mEmergencyOnly = nri.mEmergencyOnly;
@@ -912,7 +958,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
* @return The same instance of the builder.
*/
public @NonNull Builder setRegistrationState(@RegistrationState int registrationState) {
mInitialRegistrationState = registrationState;
mNetworkRegistrationState = registrationState;
return this;
}
@@ -1031,7 +1077,7 @@ public final class NetworkRegistrationInfo implements Parcelable {
*/
@SystemApi
public @NonNull NetworkRegistrationInfo build() {
return new NetworkRegistrationInfo(mDomain, mTransportType, mInitialRegistrationState,
return new NetworkRegistrationInfo(mDomain, mTransportType, mNetworkRegistrationState,
mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices,
mCellIdentity, mRplmn, mVoiceSpecificRegistrationInfo,
mDataSpecificRegistrationInfo);

View File

@@ -630,11 +630,17 @@ public class ServiceState implements Parcelable {
}
/**
* Get current roaming indicator of phone
* Get current roaming indicator of phone. This roaming state could be overridden by the carrier
* config.
* (note: not just decoding from TS 27.007 7.2)
*
* @see TelephonyDisplayInfo#isRoaming() for visualization purpose.
* @return true if TS 27.007 7.2 roaming is true
* and ONS is different from SPN
* @see CarrierConfigManager#KEY_FORCE_HOME_NETWORK_BOOL
* @see CarrierConfigManager#KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY
* @see CarrierConfigManager#KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY
* @see CarrierConfigManager#KEY_CDMA_ROAMING_NETWORKS_STRING_ARRAY
* @see CarrierConfigManager#KEY_CDMA_NONROAMING_NETWORKS_STRING_ARRAY
*/
public boolean getRoaming() {
return getVoiceRoaming() || getDataRoaming();
@@ -649,8 +655,9 @@ public class ServiceState implements Parcelable {
public boolean getVoiceRoaming() {
return getVoiceRoamingType() != ROAMING_TYPE_NOT_ROAMING;
}
/**
* Get current voice network roaming type
* Get current voice roaming type. This roaming type could be overridden by the carrier config.
* @return roaming type
* @hide
*/
@@ -700,7 +707,7 @@ public class ServiceState implements Parcelable {
}
/**
* Get current data network roaming type
* Get current data roaming type. This roaming type could be overridden by the carrier config.
* @return roaming type
* @hide
*/

View File

@@ -87,10 +87,12 @@ public final class TelephonyDisplayInfo implements Parcelable {
public static final int OVERRIDE_NETWORK_TYPE_NR_ADVANCED = 5;
@NetworkType
private final int mNetworkType;
private final int mNetworkType;
@OverrideNetworkType
private final int mOverrideNetworkType;
private final int mOverrideNetworkType;
private final boolean mIsRoaming;
/**
* Constructor
@@ -98,18 +100,37 @@ public final class TelephonyDisplayInfo implements Parcelable {
* @param networkType Current packet-switching cellular network type
* @param overrideNetworkType The override network type
*
* @deprecated will not use this constructor anymore.
* @hide
*/
@Deprecated
public TelephonyDisplayInfo(@NetworkType int networkType,
@OverrideNetworkType int overrideNetworkType) {
this(networkType, overrideNetworkType, false);
}
/**
* Constructor
*
* @param networkType Current packet-switching cellular network type
* @param overrideNetworkType The override network type
* @param isRoaming True if the device is roaming after override.
*
* @hide
*/
public TelephonyDisplayInfo(@NetworkType int networkType,
@OverrideNetworkType int overrideNetworkType) {
@OverrideNetworkType int overrideNetworkType,
boolean isRoaming) {
mNetworkType = networkType;
mOverrideNetworkType = overrideNetworkType;
mIsRoaming = isRoaming;
}
/** @hide */
public TelephonyDisplayInfo(Parcel p) {
mNetworkType = p.readInt();
mOverrideNetworkType = p.readInt();
mIsRoaming = p.readBoolean();
}
/**
@@ -135,10 +156,25 @@ public final class TelephonyDisplayInfo implements Parcelable {
return mOverrideNetworkType;
}
/**
* Get device is roaming or not. Note the isRoaming is for market branding or visualization
* purposes only. It cannot be treated as the actual roaming device is camped on.
*
* @return True if the device is registered on roaming network overridden by config.
* @see CarrierConfigManager#KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY
* @see CarrierConfigManager#KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY
* @see CarrierConfigManager#KEY_CDMA_ROAMING_NETWORKS_STRING_ARRAY
* @see CarrierConfigManager#KEY_CDMA_NONROAMING_NETWORKS_STRING_ARRAY
*/
public boolean isRoaming() {
return mIsRoaming;
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mNetworkType);
dest.writeInt(mOverrideNetworkType);
dest.writeBoolean(mIsRoaming);
}
public static final @NonNull Parcelable.Creator<TelephonyDisplayInfo> CREATOR =
@@ -165,12 +201,13 @@ public final class TelephonyDisplayInfo implements Parcelable {
if (o == null || getClass() != o.getClass()) return false;
TelephonyDisplayInfo that = (TelephonyDisplayInfo) o;
return mNetworkType == that.mNetworkType
&& mOverrideNetworkType == that.mOverrideNetworkType;
&& mOverrideNetworkType == that.mOverrideNetworkType
&& mIsRoaming == that.mIsRoaming;
}
@Override
public int hashCode() {
return Objects.hash(mNetworkType, mOverrideNetworkType);
return Objects.hash(mNetworkType, mOverrideNetworkType, mIsRoaming);
}
/**
@@ -195,6 +232,7 @@ public final class TelephonyDisplayInfo implements Parcelable {
@Override
public String toString() {
return "TelephonyDisplayInfo {network=" + TelephonyManager.getNetworkTypeName(mNetworkType)
+ ", override=" + overrideNetworkTypeToString(mOverrideNetworkType) + "}";
+ ", overrideNetwork=" + overrideNetworkTypeToString(mOverrideNetworkType)
+ ", isRoaming=" + mIsRoaming + "}";
}
}