Loading telephony/java/android/telephony/SubscriptionManager.java +33 −0 Original line number Original line Diff line number Diff line Loading @@ -139,6 +139,10 @@ public class SubscriptionManager { public static final String CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY = public static final String CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY = "cache_key.telephony.get_default_data_sub_id"; "cache_key.telephony.get_default_data_sub_id"; /** @hide */ public static final String CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY = "cache_key.telephony.get_active_data_sub_id"; private static final int MAX_CACHE_SIZE = 4; private static final int MAX_CACHE_SIZE = 4; private static PropertyInvalidatedCache<Void, Integer> sDefaultSubIdCache = private static PropertyInvalidatedCache<Void, Integer> sDefaultSubIdCache = Loading @@ -157,6 +161,14 @@ public class SubscriptionManager { return getDefaultDataSubscriptionIdInternal(); return getDefaultDataSubscriptionIdInternal(); }}; }}; private static PropertyInvalidatedCache<Void, Integer> sActiveDataSubIdCache = new PropertyInvalidatedCache<Void, Integer>( MAX_CACHE_SIZE, CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY) { @Override protected Integer recompute(Void query) { return getActiveDataSubscriptionIdInternal(); }}; /** /** * Generates a content {@link Uri} used to receive updates on simInfo change * Generates a content {@link Uri} used to receive updates on simInfo change * on the given subscriptionId * on the given subscriptionId Loading Loading @@ -3285,6 +3297,10 @@ public class SubscriptionManager { * SubscriptionManager.INVALID_SUBSCRIPTION_ID if not. * SubscriptionManager.INVALID_SUBSCRIPTION_ID if not. */ */ public static int getActiveDataSubscriptionId() { public static int getActiveDataSubscriptionId() { return sActiveDataSubIdCache.query(null); } private static int getActiveDataSubscriptionIdInternal() { try { try { ISub iSub = TelephonyManager.getSubscriptionService(); ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { if (iSub != null) { Loading Loading @@ -3320,6 +3336,11 @@ public class SubscriptionManager { PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY); PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY); } } /** @hide */ public static void invalidateActiveDataSubIdCaches() { PropertyInvalidatedCache.invalidateCache(CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY); } /** /** * Clears all process-local binder caches. * Clears all process-local binder caches. * * Loading @@ -3328,5 +3349,17 @@ public class SubscriptionManager { public static void clearCaches() { public static void clearCaches() { sDefaultSubIdCache.clear(); sDefaultSubIdCache.clear(); sDefaultDataSubIdCache.clear(); sDefaultDataSubIdCache.clear(); sActiveDataSubIdCache.clear(); } /** * Allows a test process to disable client-side caching operations. * * @hide */ public static void disableCaching() { sDefaultSubIdCache.disableLocal(); sDefaultDataSubIdCache.disableLocal(); sActiveDataSubIdCache.disableLocal(); } } } } Loading
telephony/java/android/telephony/SubscriptionManager.java +33 −0 Original line number Original line Diff line number Diff line Loading @@ -139,6 +139,10 @@ public class SubscriptionManager { public static final String CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY = public static final String CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY = "cache_key.telephony.get_default_data_sub_id"; "cache_key.telephony.get_default_data_sub_id"; /** @hide */ public static final String CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY = "cache_key.telephony.get_active_data_sub_id"; private static final int MAX_CACHE_SIZE = 4; private static final int MAX_CACHE_SIZE = 4; private static PropertyInvalidatedCache<Void, Integer> sDefaultSubIdCache = private static PropertyInvalidatedCache<Void, Integer> sDefaultSubIdCache = Loading @@ -157,6 +161,14 @@ public class SubscriptionManager { return getDefaultDataSubscriptionIdInternal(); return getDefaultDataSubscriptionIdInternal(); }}; }}; private static PropertyInvalidatedCache<Void, Integer> sActiveDataSubIdCache = new PropertyInvalidatedCache<Void, Integer>( MAX_CACHE_SIZE, CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY) { @Override protected Integer recompute(Void query) { return getActiveDataSubscriptionIdInternal(); }}; /** /** * Generates a content {@link Uri} used to receive updates on simInfo change * Generates a content {@link Uri} used to receive updates on simInfo change * on the given subscriptionId * on the given subscriptionId Loading Loading @@ -3285,6 +3297,10 @@ public class SubscriptionManager { * SubscriptionManager.INVALID_SUBSCRIPTION_ID if not. * SubscriptionManager.INVALID_SUBSCRIPTION_ID if not. */ */ public static int getActiveDataSubscriptionId() { public static int getActiveDataSubscriptionId() { return sActiveDataSubIdCache.query(null); } private static int getActiveDataSubscriptionIdInternal() { try { try { ISub iSub = TelephonyManager.getSubscriptionService(); ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { if (iSub != null) { Loading Loading @@ -3320,6 +3336,11 @@ public class SubscriptionManager { PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY); PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY); } } /** @hide */ public static void invalidateActiveDataSubIdCaches() { PropertyInvalidatedCache.invalidateCache(CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY); } /** /** * Clears all process-local binder caches. * Clears all process-local binder caches. * * Loading @@ -3328,5 +3349,17 @@ public class SubscriptionManager { public static void clearCaches() { public static void clearCaches() { sDefaultSubIdCache.clear(); sDefaultSubIdCache.clear(); sDefaultDataSubIdCache.clear(); sDefaultDataSubIdCache.clear(); sActiveDataSubIdCache.clear(); } /** * Allows a test process to disable client-side caching operations. * * @hide */ public static void disableCaching() { sDefaultSubIdCache.disableLocal(); sDefaultDataSubIdCache.disableLocal(); sActiveDataSubIdCache.disableLocal(); } } } }