Merge "Remove legacy subscription code" into udc-dev

This commit is contained in:
Jack Yu
2023-04-18 01:56:50 +00:00
committed by Android (Google) Code Review
5 changed files with 21 additions and 178 deletions

View File

@@ -146,10 +146,6 @@
<bool name="config_enhanced_iwlan_handover_check">true</bool>
<java-symbol type="bool" name="config_enhanced_iwlan_handover_check" />
<!-- Whether using the new SubscriptionManagerService or the old SubscriptionController -->
<bool name="config_using_subscription_manager_service">true</bool>
<java-symbol type="bool" name="config_using_subscription_manager_service" />
<!-- Whether asynchronously update the subscription database or not. Async mode increases
the performance, but sync mode reduces the chance of database/cache out-of-sync. -->
<bool name="config_subscription_database_async_update">true</bool>

View File

@@ -11,12 +11,6 @@ chinmayd@google.com
amruthr@google.com
sasindran@google.com
# Temporarily reduced the owner during refactoring
per-file SubscriptionManager.java=set noparent
per-file SubscriptionManager.java=jackyu@google.com,amruthr@google.com
per-file SubscriptionInfo.java=set noparent
per-file SubscriptionInfo.java=jackyu@google.com,amruthr@google.com
# Requiring TL ownership for new carrier config keys.
per-file CarrierConfigManager.java=set noparent
per-file CarrierConfigManager.java=amruthr@google.com,tgunn@google.com,rgreenwalt@google.com,satk@google.com

View File

@@ -331,8 +331,8 @@ public final class TelephonyPermissions {
* Same as {@link #checkCallingOrSelfReadSubscriberIdentifiers(Context, int, String, String,
* String)} except this allows an additional parameter reportFailure. Caller may not want to
* report a failure when this is an internal/intermediate check, for example,
* SubscriptionController calls this with an INVALID_SUBID to check if caller has the required
* permissions to bypass carrier privilege checks.
* SubscriptionManagerService calls this with an INVALID_SUBID to check if caller has the
* required permissions to bypass carrier privilege checks.
* @param reportFailure Indicates if failure should be reported.
*/
public static boolean checkCallingOrSelfReadSubscriberIdentifiers(Context context, int subId,

View File

@@ -91,8 +91,7 @@ import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
* SubscriptionManager is the application interface to SubscriptionController
* and provides information about the current Telephony Subscriptions.
* Subscription manager provides the mobile subscription information.
*/
@SystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)
@RequiresFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION)
@@ -119,13 +118,12 @@ public class SubscriptionManager {
public static final int DEFAULT_SUBSCRIPTION_ID = Integer.MAX_VALUE;
/**
* Indicates the caller wants the default phone id.
* Used in SubscriptionController and Phone but do we really need it???
* Indicates the default phone id.
* @hide
*/
public static final int DEFAULT_PHONE_INDEX = Integer.MAX_VALUE;
/** Indicates the caller wants the default slot id. NOT used remove? */
/** Indicates the default slot index. */
/** @hide */
public static final int DEFAULT_SIM_SLOT_INDEX = Integer.MAX_VALUE;
@@ -141,29 +139,10 @@ public class SubscriptionManager {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static final Uri CONTENT_URI = SimInfo.CONTENT_URI;
private static final String CACHE_KEY_DEFAULT_SUB_ID_PROPERTY =
"cache_key.telephony.get_default_sub_id";
private static final String CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY =
"cache_key.telephony.get_default_data_sub_id";
private static final String CACHE_KEY_DEFAULT_SMS_SUB_ID_PROPERTY =
"cache_key.telephony.get_default_sms_sub_id";
private static final String CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY =
"cache_key.telephony.get_active_data_sub_id";
private static final String CACHE_KEY_SLOT_INDEX_PROPERTY =
"cache_key.telephony.get_slot_index";
/** The IPC cache key shared by all subscription manager service cacheable properties. */
private static final String CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY =
"cache_key.telephony.subscription_manager_service";
/** The temporarily cache key to indicate whether subscription manager service is enabled. */
private static final String CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_ENABLED_PROPERTY =
"cache_key.telephony.subscription_manager_service_enabled";
/** @hide */
public static final String GET_SIM_SPECIFIC_SETTINGS_METHOD_NAME = "getSimSpecificSettings";
@@ -273,83 +252,41 @@ public class SubscriptionManager {
}
}
private static VoidPropertyInvalidatedCache<Integer> sDefaultSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultSubId,
CACHE_KEY_DEFAULT_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static VoidPropertyInvalidatedCache<Integer> sGetDefaultSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultSubId,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static VoidPropertyInvalidatedCache<Integer> sDefaultDataSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultDataSubId,
CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static VoidPropertyInvalidatedCache<Integer> sGetDefaultDataSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultDataSubId,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static VoidPropertyInvalidatedCache<Integer> sDefaultSmsSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultSmsSubId,
CACHE_KEY_DEFAULT_SMS_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static VoidPropertyInvalidatedCache<Integer> sGetDefaultSmsSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultSmsSubId,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static VoidPropertyInvalidatedCache<Integer> sActiveDataSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getActiveDataSubscriptionId,
CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static VoidPropertyInvalidatedCache<Integer> sGetActiveDataSubscriptionIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getActiveDataSubscriptionId,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static IntegerPropertyInvalidatedCache<Integer> sSlotIndexCache =
new IntegerPropertyInvalidatedCache<>(ISub::getSlotIndex,
CACHE_KEY_SLOT_INDEX_PROPERTY,
INVALID_SIM_SLOT_INDEX);
private static IntegerPropertyInvalidatedCache<Integer> sGetSlotIndexCache =
new IntegerPropertyInvalidatedCache<>(ISub::getSlotIndex,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
INVALID_SIM_SLOT_INDEX);
private static IntegerPropertyInvalidatedCache<Integer> sSubIdCache =
new IntegerPropertyInvalidatedCache<>(ISub::getSubId,
CACHE_KEY_SLOT_INDEX_PROPERTY,
INVALID_SUBSCRIPTION_ID);
private static IntegerPropertyInvalidatedCache<Integer> sGetSubIdCache =
new IntegerPropertyInvalidatedCache<>(ISub::getSubId,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
INVALID_SUBSCRIPTION_ID);
/** Cache depends on getDefaultSubId, so we use the defaultSubId cache key */
private static IntegerPropertyInvalidatedCache<Integer> sPhoneIdCache =
new IntegerPropertyInvalidatedCache<>(ISub::getPhoneId,
CACHE_KEY_DEFAULT_SUB_ID_PROPERTY,
INVALID_PHONE_INDEX);
private static IntegerPropertyInvalidatedCache<Integer> sGetPhoneIdCache =
new IntegerPropertyInvalidatedCache<>(ISub::getPhoneId,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
INVALID_PHONE_INDEX);
//TODO: Removed before U AOSP public release.
private static VoidPropertyInvalidatedCache<Boolean> sIsSubscriptionManagerServiceEnabled =
new VoidPropertyInvalidatedCache<>(ISub::isSubscriptionManagerServiceEnabled,
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_ENABLED_PROPERTY,
false);
/**
* Generates a content {@link Uri} used to receive updates on simInfo change
* on the given subscriptionId
@@ -1455,17 +1392,6 @@ public class SubscriptionManager {
mContext = context;
}
/**
* @return {@code true} if the new subscription manager service is used. This is temporary and
* will be removed before Android 14 release.
*
* @hide
*/
//TODO: Removed before U AOSP public release.
public static boolean isSubscriptionManagerServiceEnabled() {
return sIsSubscriptionManagerServiceEnabled.query(null);
}
private NetworkPolicyManager getNetworkPolicyManager() {
return (NetworkPolicyManager) mContext
.getSystemService(Context.NETWORK_POLICY_SERVICE);
@@ -1520,7 +1446,7 @@ public class SubscriptionManager {
+ " listener=" + listener);
}
// We use the TelephonyRegistry as it runs in the system and thus is always
// available. Where as SubscriptionController could crash and not be available
// available.
TelephonyRegistryManager telephonyRegistryManager = (TelephonyRegistryManager)
mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE);
if (telephonyRegistryManager != null) {
@@ -1550,7 +1476,7 @@ public class SubscriptionManager {
+ " listener=" + listener);
}
// We use the TelephonyRegistry as it runs in the system and thus is always
// available where as SubscriptionController could crash and not be available
// available.
TelephonyRegistryManager telephonyRegistryManager = (TelephonyRegistryManager)
mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE);
if (telephonyRegistryManager != null) {
@@ -1608,7 +1534,7 @@ public class SubscriptionManager {
}
// We use the TelephonyRegistry as it runs in the system and thus is always
// available where as SubscriptionController could crash and not be available
// available.
TelephonyRegistryManager telephonyRegistryManager = (TelephonyRegistryManager)
mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE);
if (telephonyRegistryManager != null) {
@@ -2149,9 +2075,9 @@ public class SubscriptionManager {
Log.e(LOG_TAG, "[removeSubscriptionInfoRecord]- ISub service is null");
return;
}
int result = iSub.removeSubInfo(uniqueId, subscriptionType);
if (result < 0) {
Log.e(LOG_TAG, "Removal of subscription didn't succeed: error = " + result);
boolean result = iSub.removeSubInfo(uniqueId, subscriptionType);
if (!result) {
Log.e(LOG_TAG, "Removal of subscription didn't succeed");
} else {
logd("successfully removed subscription");
}
@@ -2236,8 +2162,7 @@ public class SubscriptionManager {
* subscriptionId doesn't have an associated slot index.
*/
public static int getSlotIndex(int subscriptionId) {
if (isSubscriptionManagerServiceEnabled()) return sGetSlotIndexCache.query(subscriptionId);
return sSlotIndexCache.query(subscriptionId);
return sGetSlotIndexCache.query(subscriptionId);
}
/**
@@ -2294,15 +2219,13 @@ public class SubscriptionManager {
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
if (isSubscriptionManagerServiceEnabled()) return sGetSubIdCache.query(slotIndex);
return sSubIdCache.query(slotIndex);
return sGetSubIdCache.query(slotIndex);
}
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public static int getPhoneId(int subId) {
if (isSubscriptionManagerServiceEnabled()) return sGetPhoneIdCache.query(subId);
return sPhoneIdCache.query(subId);
return sGetPhoneIdCache.query(subId);
}
private static void logd(String msg) {
@@ -2323,8 +2246,7 @@ public class SubscriptionManager {
* @return the "system" default subscription id.
*/
public static int getDefaultSubscriptionId() {
if (isSubscriptionManagerServiceEnabled()) return sGetDefaultSubIdCache.query(null);
return sDefaultSubIdCache.query(null);
return sGetDefaultSubIdCache.query(null);
}
/**
@@ -2412,8 +2334,7 @@ public class SubscriptionManager {
* @return the default SMS subscription Id.
*/
public static int getDefaultSmsSubscriptionId() {
if (isSubscriptionManagerServiceEnabled()) return sGetDefaultSmsSubIdCache.query(null);
return sDefaultSmsSubIdCache.query(null);
return sGetDefaultSmsSubIdCache.query(null);
}
/**
@@ -2447,8 +2368,7 @@ public class SubscriptionManager {
* @return the default data subscription Id.
*/
public static int getDefaultDataSubscriptionId() {
if (isSubscriptionManagerServiceEnabled()) return sGetDefaultDataSubIdCache.query(null);
return sDefaultDataSubIdCache.query(null);
return sGetDefaultDataSubIdCache.query(null);
}
/**
@@ -3912,10 +3832,7 @@ public class SubscriptionManager {
* @see TelephonyCallback.ActiveDataSubscriptionIdListener
*/
public static int getActiveDataSubscriptionId() {
if (isSubscriptionManagerServiceEnabled()) {
return sGetActiveDataSubscriptionIdCache.query(null);
}
return sActiveDataSubIdCache.query(null);
return sGetActiveDataSubscriptionIdCache.query(null);
}
/**
@@ -3933,62 +3850,17 @@ public class SubscriptionManager {
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
}
/** @hide */
public static void invalidateDefaultSubIdCaches() {
PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_SUB_ID_PROPERTY);
}
/** @hide */
public static void invalidateDefaultDataSubIdCaches() {
PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY);
}
/** @hide */
public static void invalidateDefaultSmsSubIdCaches() {
PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_SMS_SUB_ID_PROPERTY);
}
/** @hide */
public static void invalidateActiveDataSubIdCaches() {
if (isSubscriptionManagerServiceEnabled()) {
PropertyInvalidatedCache.invalidateCache(
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY);
} else {
PropertyInvalidatedCache.invalidateCache(CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY);
}
}
/** @hide */
public static void invalidateSlotIndexCaches() {
PropertyInvalidatedCache.invalidateCache(CACHE_KEY_SLOT_INDEX_PROPERTY);
}
/** @hide */
public static void invalidateSubscriptionManagerServiceCaches() {
PropertyInvalidatedCache.invalidateCache(CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY);
}
/** @hide */
//TODO: Removed before U AOSP public release.
public static void invalidateSubscriptionManagerServiceEnabledCaches() {
PropertyInvalidatedCache.invalidateCache(
CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_ENABLED_PROPERTY);
}
/**
* Allows a test process to disable client-side caching operations.
*
* @hide
*/
public static void disableCaching() {
sDefaultSubIdCache.disableLocal();
sDefaultDataSubIdCache.disableLocal();
sActiveDataSubIdCache.disableLocal();
sDefaultSmsSubIdCache.disableLocal();
sSlotIndexCache.disableLocal();
sSubIdCache.disableLocal();
sPhoneIdCache.disableLocal();
sGetDefaultSubIdCache.disableLocal();
sGetDefaultDataSubIdCache.disableLocal();
sGetActiveDataSubscriptionIdCache.disableLocal();
@@ -3996,8 +3868,6 @@ public class SubscriptionManager {
sGetSlotIndexCache.disableLocal();
sGetSubIdCache.disableLocal();
sGetPhoneIdCache.disableLocal();
sIsSubscriptionManagerServiceEnabled.disableLocal();
}
/**
@@ -4005,14 +3875,6 @@ public class SubscriptionManager {
*
* @hide */
public static void clearCaches() {
sDefaultSubIdCache.clear();
sDefaultDataSubIdCache.clear();
sActiveDataSubIdCache.clear();
sDefaultSmsSubIdCache.clear();
sSlotIndexCache.clear();
sSubIdCache.clear();
sPhoneIdCache.clear();
sGetDefaultSubIdCache.clear();
sGetDefaultDataSubIdCache.clear();
sGetActiveDataSubscriptionIdCache.clear();
@@ -4020,8 +3882,6 @@ public class SubscriptionManager {
sGetSlotIndexCache.clear();
sGetSubIdCache.clear();
sGetPhoneIdCache.clear();
sIsSubscriptionManagerServiceEnabled.clear();
}
/**

View File

@@ -129,9 +129,9 @@ interface ISub {
* @param uniqueId This is the unique identifier for the subscription within the specific
* subscription type.
* @param subscriptionType the type of subscription to be removed
* @return 0 if success, < 0 on error.
* @return true if success, false on error.
*/
int removeSubInfo(String uniqueId, int subscriptionType);
boolean removeSubInfo(String uniqueId, int subscriptionType);
/**
* Set SIM icon tint color by simInfo index
@@ -260,7 +260,7 @@ interface ISub {
int[] getActiveSubIdList(boolean visibleOnly);
int setSubscriptionProperty(int subId, String propKey, String propValue);
void setSubscriptionProperty(int subId, String propKey, String propValue);
String getSubscriptionProperty(int subId, String propKey, String callingPackage,
String callingFeatureId);
@@ -353,13 +353,6 @@ interface ISub {
*/
List<SubscriptionInfo> getSubscriptionInfoListAssociatedWithUser(in UserHandle userHandle);
/**
* @return {@code true} if using SubscriptionManagerService instead of
* SubscriptionController.
*/
//TODO: Removed before U AOSP public release.
boolean isSubscriptionManagerServiceEnabled();
/**
* Called during setup wizard restore flow to attempt to restore the backed up sim-specific
* configs to device for all existing SIMs in the subscription database