diff --git a/core/api/current.txt b/core/api/current.txt index bc74372d4638f..179d02923ece1 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -42338,7 +42338,7 @@ package android.telephony { field public static final int OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO = 2; // 0x2 field public static final int OVERRIDE_NETWORK_TYPE_LTE_CA = 1; // 0x1 field public static final int OVERRIDE_NETWORK_TYPE_NONE = 0; // 0x0 - field public static final int OVERRIDE_NETWORK_TYPE_NR_ADVANCED = 4; // 0x4 + field public static final int OVERRIDE_NETWORK_TYPE_NR_ADVANCED = 5; // 0x5 field public static final int OVERRIDE_NETWORK_TYPE_NR_NSA = 3; // 0x3 field @Deprecated public static final int OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE = 4; // 0x4 } diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 7276c78b398c9..411fc6778984e 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -154,6 +154,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; int phoneId = SubscriptionManager.INVALID_SIM_SLOT_INDEX; + int targetSdk; boolean matchTelephonyCallbackEvent(int event) { return (callback != null) && (this.eventList.contains(event)); @@ -919,6 +920,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } r.phoneId = phoneId; r.eventList = events; + r.targetSdk = TelephonyPermissions.getTargetSdk(mContext, callingPackage); + if (DBG) { log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId); } @@ -1748,6 +1751,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED) && idMatchWithoutDefaultPhoneCheck(r.subId, subId)) { try { + if (r.targetSdk <= android.os.Build.VERSION_CODES.R) { + telephonyDisplayInfo = + getBackwardCompatibleTelephonyDisplayInfo( + telephonyDisplayInfo); + } r.callback.onDisplayInfoChanged(telephonyDisplayInfo); } catch (RemoteException ex) { mRemoveList.add(r.binder); @@ -1759,6 +1767,19 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + private TelephonyDisplayInfo getBackwardCompatibleTelephonyDisplayInfo( + @NonNull TelephonyDisplayInfo telephonyDisplayInfo) { + int networkType = telephonyDisplayInfo.getNetworkType(); + int overrideNetworkType = telephonyDisplayInfo.getOverrideNetworkType(); + if (networkType == TelephonyManager.NETWORK_TYPE_NR) { + overrideNetworkType = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE; + } else if (networkType == TelephonyManager.NETWORK_TYPE_LTE + && overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED) { + overrideNetworkType = TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE; + } + return new TelephonyDisplayInfo(networkType, overrideNetworkType); + } + public void notifyCallForwardingChanged(boolean cfi) { notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi); } diff --git a/telephony/java/android/telephony/TelephonyDisplayInfo.java b/telephony/java/android/telephony/TelephonyDisplayInfo.java index 2f89bfb60d3d1..88c66acdca6fe 100644 --- a/telephony/java/android/telephony/TelephonyDisplayInfo.java +++ b/telephony/java/android/telephony/TelephonyDisplayInfo.java @@ -84,7 +84,7 @@ public final class TelephonyDisplayInfo implements Parcelable { * * One of the use case is that UX can show a different icon, for example, "5G+" */ - public static final int OVERRIDE_NETWORK_TYPE_NR_ADVANCED = 4; + public static final int OVERRIDE_NETWORK_TYPE_NR_ADVANCED = 5; @NetworkType private final int mNetworkType; @@ -186,7 +186,8 @@ public final class TelephonyDisplayInfo implements Parcelable { case OVERRIDE_NETWORK_TYPE_LTE_CA: return "LTE_CA"; case OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: return "LTE_ADV_PRO"; case OVERRIDE_NETWORK_TYPE_NR_NSA: return "NR_NSA"; - case OVERRIDE_NETWORK_TYPE_NR_ADVANCED: return "NR_NSA_MMWAVE"; + case OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE: return "NR_NSA_MMWAVE"; + case OVERRIDE_NETWORK_TYPE_NR_ADVANCED: return "NR_ADVANCED"; default: return "UNKNOWN"; } }