Merge "OVERRIDE_NETWORK_TYPE_NR_ADVANCED use a different int id" into sc-dev

This commit is contained in:
SongFerng Wang
2021-03-24 04:19:25 +00:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 3 deletions

View File

@@ -42348,7 +42348,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
}

View File

@@ -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);
}

View File

@@ -84,7 +84,7 @@ public final class TelephonyDisplayInfo implements Parcelable {
* </ul>
* 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";
}
}