From 882677a1d5da786e9df24cfea1a60c3a0695656c Mon Sep 17 00:00:00 2001 From: Ling Ma Date: Tue, 26 Apr 2022 14:21:01 -0700 Subject: [PATCH] Update API doc for accidentally exposed NETWORK_TYPE_BITMASK_LTE_CA NETWORK_TYPE_BITMASK_LTE_CA is not used anywhere even if it's accidentally passed into setAllowedNetworkTypesForReason(). Will be deprecated in U. Fix: 230383206 Test: atest cts/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java Change-Id: Id0c521c4fb74eaf7d73deaf122e923f72b924c18 Merged-In: Id0c521c4fb74eaf7d73deaf122e923f72b924c18 --- .../android/telephony/TelephonyManager.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 71ffd6e2ec9fd..a6e3bb41b87cf 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -9290,6 +9290,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) { + networkTypeBitmask = checkNetworkTypeBitmask(networkTypeBitmask); return telephony.setAllowedNetworkTypesForReason(getSubId(), TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER, networkTypeBitmask); } @@ -9299,6 +9300,20 @@ public class TelephonyManager { return false; } + /** + * If {@link #NETWORK_TYPE_BITMASK_LTE_CA} bit is set, convert it to NETWORK_TYPE_BITMASK_LTE. + * + * @param networkTypeBitmask The networkTypeBitmask being checked + * @return The checked/converted networkTypeBitmask + */ + private long checkNetworkTypeBitmask(@NetworkTypeBitMask long networkTypeBitmask) { + if ((networkTypeBitmask & NETWORK_TYPE_BITMASK_LTE_CA) != 0) { + networkTypeBitmask ^= NETWORK_TYPE_BITMASK_LTE_CA; + networkTypeBitmask |= NETWORK_TYPE_BITMASK_LTE; + } + return networkTypeBitmask; + } + /** * Set the allowed network types of the device. This is for carrier or privileged apps to * enable/disable certain network types on the device. The user preferred network types should @@ -9325,6 +9340,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) { + allowedNetworkTypes = checkNetworkTypeBitmask(allowedNetworkTypes); return telephony.setAllowedNetworkTypesForReason(getSubId(), TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER, allowedNetworkTypes); } @@ -9410,6 +9426,7 @@ public class TelephonyManager { try { ITelephony telephony = getITelephony(); if (telephony != null) { + allowedNetworkTypes = checkNetworkTypeBitmask(allowedNetworkTypes); telephony.setAllowedNetworkTypesForReason(getSubId(), reason, allowedNetworkTypes); } else { @@ -13727,7 +13744,11 @@ public class TelephonyManager { */ public static final long NETWORK_TYPE_BITMASK_LTE = (1 << (NETWORK_TYPE_LTE -1)); /** + * NOT USED; this bitmask is exposed accidentally, will be deprecated in U. + * If used, will be converted to {@link #NETWORK_TYPE_BITMASK_LTE}. * network type bitmask indicating the support of radio tech LTE CA (carrier aggregation). + * + * @see #NETWORK_TYPE_BITMASK_LTE */ public static final long NETWORK_TYPE_BITMASK_LTE_CA = (1 << (NETWORK_TYPE_LTE_CA -1));