diff options
9 files changed, 136 insertions, 39 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 5eedef5416ea..9da95c0800a4 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -43608,9 +43608,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 @@ -44380,6 +44383,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 diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 5efd0d79fb34..46f51c7bb515 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -13298,7 +13298,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(); diff --git a/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java b/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java index 39b4b8e16708..35e3dd3379f0 100644 --- a/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java +++ b/packages/SettingsLib/src/com/android/settingslib/mobile/MobileStatusTracker.java @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java index a4ce6b363041..534155cf096c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileState.kt b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileState.kt index 1fb6a982fdf3..c37b01fff578 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileState.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/MobileState.kt @@ -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 } /** diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index e234c47e700a..992281828f51 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -1992,7 +1992,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) { diff --git a/telephony/java/android/telephony/NetworkRegistrationInfo.java b/telephony/java/android/telephony/NetworkRegistrationInfo.java index cbd3df4fcd9a..b0552b4a18a3 100644 --- a/telephony/java/android/telephony/NetworkRegistrationInfo.java +++ b/telephony/java/android/telephony/NetworkRegistrationInfo.java @@ -210,10 +210,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 @@ -290,7 +291,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); @@ -350,7 +351,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(); @@ -377,7 +378,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; @@ -430,10 +431,14 @@ 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() { if (mRegistrationState == REGISTRATION_STATE_EMERGENCY) { @@ -449,30 +454,58 @@ public final class NetworkRegistrationInfo implements Parcelable { } /** - * @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 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. * * <p>If the device is registered, this will return the registered PLMN-ID. If registration @@ -489,13 +522,25 @@ 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. */ @@ -525,7 +570,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 @@ -706,8 +752,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)) @@ -728,7 +774,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); @@ -746,7 +792,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 @@ -769,7 +815,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); @@ -866,7 +912,7 @@ public final class NetworkRegistrationInfo implements Parcelable { private int mTransportType; @RegistrationState - private int mInitialRegistrationState; + private int mNetworkRegistrationState; @NetworkType private int mAccessNetworkTechnology; @@ -904,7 +950,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; @@ -952,7 +998,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; } @@ -1071,7 +1117,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); diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index cd1a40ac7b18..523d0b0e55f4 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -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 */ diff --git a/telephony/java/android/telephony/TelephonyDisplayInfo.java b/telephony/java/android/telephony/TelephonyDisplayInfo.java index f4e2ade643c7..e01b10eed4db 100644 --- a/telephony/java/android/telephony/TelephonyDisplayInfo.java +++ b/telephony/java/android/telephony/TelephonyDisplayInfo.java @@ -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, + 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 + "}"; } } |