Loading src/java/com/android/internal/telephony/SubscriptionController.java +170 −34 Original line number Diff line number Diff line Loading @@ -112,6 +112,9 @@ public class SubscriptionController extends ISub.Stub { private static final ParcelUuid INVALID_GROUP_UUID = ParcelUuid.fromString(CarrierConfigManager.REMOVE_GROUP_UUID_STRING); private final LocalLog mLocalLog = new LocalLog(200); private static final int SUB_ID_FOUND = 1; private static final int NO_ENTRY_FOR_SLOT_INDEX = -1; private static final int SUB_ID_NOT_IN_SLOT = -2; // Lock that both mCacheActiveSubInfoList and mCacheOpportunisticSubInfoList use. private Object mSubInfoListLock = new Object(); Loading Loading @@ -146,9 +149,114 @@ public class SubscriptionController extends ISub.Stub { private AppOpsManager mAppOps; // Allows test mocks to avoid SELinux failures on invalidate calls. private static boolean sCachingEnabled = true; // Each slot can have multiple subs. private static Map<Integer, ArrayList<Integer>> sSlotIndexToSubIds = new ConcurrentHashMap<>(); protected static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static class WatchedSlotIndexToSubIds { private Map<Integer, ArrayList<Integer>> mSlotIndexToSubIds = new ConcurrentHashMap<>(); WatchedSlotIndexToSubIds() { } public void clear() { mSlotIndexToSubIds.clear(); invalidateDefaultSubIdCaches(); } public Set<Entry<Integer, ArrayList<Integer>>> entrySet() { return mSlotIndexToSubIds.entrySet(); } // Force all updates to data structure through wrapper. public ArrayList<Integer> getCopy(int slotIndex) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList == null) { return null; } return new ArrayList<Integer>(subIdList); } public void put(int slotIndex, ArrayList<Integer> value) { mSlotIndexToSubIds.put(slotIndex, value); invalidateDefaultSubIdCaches(); } public void remove(int slotIndex) { mSlotIndexToSubIds.remove(slotIndex); invalidateDefaultSubIdCaches(); } public int size() { return mSlotIndexToSubIds.size(); } @VisibleForTesting public Map<Integer, ArrayList<Integer>> getMap() { return mSlotIndexToSubIds; } public int removeFromSubIdList(int slotIndex, int subId) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList == null) { return NO_ENTRY_FOR_SLOT_INDEX; } else { if (subIdList.contains(subId)) { subIdList.remove(new Integer(subId)); if (subIdList.isEmpty()) { mSlotIndexToSubIds.remove(slotIndex); } invalidateDefaultSubIdCaches(); return SUB_ID_FOUND; } else { return SUB_ID_NOT_IN_SLOT; } } } public void addToSubIdList(int slotIndex, Integer value) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList == null) { subIdList = new ArrayList<Integer>(); subIdList.add(value); mSlotIndexToSubIds.put(slotIndex, subIdList); } else { subIdList.add(value); } invalidateDefaultSubIdCaches(); } public void clearSubIdList(int slotIndex) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList != null) { subIdList.clear(); invalidateDefaultSubIdCaches(); } } } protected static class WatchedInt { private int mValue; public WatchedInt(int initialValue) { mValue = initialValue; } public int get() { return mValue; } public void set(int newValue) { mValue = newValue; invalidateDefaultSubIdCaches(); } } private static WatchedSlotIndexToSubIds sSlotIndexToSubIds = new WatchedSlotIndexToSubIds(); protected static WatchedInt sDefaultFallbackSubId = new WatchedInt(SubscriptionManager.INVALID_SUBSCRIPTION_ID); @UnsupportedAppUsage private static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; Loading Loading @@ -222,6 +330,9 @@ public class SubscriptionController extends ISub.Stub { // Cache Setting values cacheSettingValues(); // Initial invalidate activates caching. invalidateDefaultSubIdCaches(); if (DBG) logdl("[SubscriptionController] init by Context"); } Loading Loading @@ -1330,7 +1441,7 @@ public class SubscriptionController extends ISub.Stub { if (!isActiveSubscriptionId(getDefaultSubId())) { // current default is not valid anylonger. set a new default if (DBG) { logdl("[updateDefaultSubIdsIfNeeded] set mDefaultFallbackSubId=" + newDefault); logdl("[updateDefaultSubIdsIfNeeded] set sDefaultFallbackSubId=" + newDefault); } setDefaultFallbackSubId(newDefault, subscriptionType); } Loading Loading @@ -1414,22 +1525,13 @@ public class SubscriptionController extends ISub.Stub { return -1; } refreshCachedActiveSubscriptionInfoList(); // update sSlotIndexToSubIds struct ArrayList<Integer> subIdsList = sSlotIndexToSubIds.get(slotIndex); if (subIdsList == null) { result = sSlotIndexToSubIds.removeFromSubIdList(slotIndex, subId); if (result == NO_ENTRY_FOR_SLOT_INDEX) { loge("sSlotIndexToSubIds has no entry for slotIndex = " + slotIndex); } else { if (subIdsList.contains(subId)) { subIdsList.remove(new Integer(subId)); if (subIdsList.isEmpty()) { sSlotIndexToSubIds.remove(slotIndex); } } else { loge("sSlotIndexToSubIds has no subid: " + subId + ", in index: " + slotIndex); } } else if (result == SUB_ID_NOT_IN_SLOT) { loge("sSlotIndexToSubIds has no subid: " + subId + ", in index: " + slotIndex); } // Since a subscription is removed, if this one is set as default for any setting, // set some other subid as the default. int newDefault = SubscriptionManager.INVALID_SUBSCRIPTION_ID; Loading Loading @@ -2145,7 +2247,7 @@ public class SubscriptionController extends ISub.Stub { } // Convert ArrayList to array ArrayList<Integer> subIds = sSlotIndexToSubIds.get(slotIndex); ArrayList<Integer> subIds = sSlotIndexToSubIds.getCopy(slotIndex); if (subIds != null && subIds.size() > 0) { int[] subIdArr = new int[subIds.size()]; for (int i = 0; i < subIds.size(); i++) { Loading Loading @@ -2272,7 +2374,7 @@ public class SubscriptionController extends ISub.Stub { if (VDBG) logdl("[getDefaultSubId] NOT VoiceCapable subId=" + subId); } if (!isActiveSubId(subId)) { subId = mDefaultFallbackSubId; subId = sDefaultFallbackSubId.get(); if (VDBG) logdl("[getDefaultSubId] NOT active use fall back subId=" + subId); } if (VDBG) logv("[getDefaultSubId]- value = " + subId); Loading @@ -2288,8 +2390,7 @@ public class SubscriptionController extends ISub.Stub { throw new RuntimeException("setDefaultSmsSubId called with DEFAULT_SUB_ID"); } if (DBG) logdl("[setDefaultSmsSubId] subId=" + subId); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MULTI_SIM_SMS_SUBSCRIPTION, subId); setGlobalSetting(Settings.Global.MULTI_SIM_SMS_SUBSCRIPTION, subId); broadcastDefaultSmsSubIdChanged(subId); } Loading Loading @@ -2324,8 +2425,7 @@ public class SubscriptionController extends ISub.Stub { int previousDefaultSub = getDefaultSubId(); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, subId); setGlobalSetting(Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, subId); broadcastDefaultVoiceSubIdChanged(subId); PhoneAccountHandle newHandle = Loading Loading @@ -2425,8 +2525,7 @@ public class SubscriptionController extends ISub.Stub { } int previousDefaultSub = getDefaultSubId(); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, subId); setGlobalSetting(Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, subId); MultiSimSettingController.getInstance().notifyDefaultDataSubChanged(); broadcastDefaultDataSubIdChanged(subId); if (previousDefaultSub != getDefaultSubId()) { Loading Loading @@ -2462,15 +2561,15 @@ public class SubscriptionController extends ISub.Stub { } int previousDefaultSub = getDefaultSubId(); if (isSubscriptionForRemoteSim(subscriptionType)) { mDefaultFallbackSubId = subId; sDefaultFallbackSubId.set(subId); return; } if (SubscriptionManager.isValidSubscriptionId(subId)) { int phoneId = getPhoneId(subId); if (phoneId >= 0 && (phoneId < mTelephonyManager.getPhoneCount() || mTelephonyManager.getSimCount() == 1)) { if (DBG) logdl("[setDefaultFallbackSubId] set mDefaultFallbackSubId=" + subId); mDefaultFallbackSubId = subId; if (DBG) logdl("[setDefaultFallbackSubId] set sDefaultFallbackSubId=" + subId); sDefaultFallbackSubId.set(subId); // Update MCC MNC device configuration information String defaultMccMnc = mTelephonyManager.getSimOperatorNumericForPhone(phoneId); MccTable.updateMccMncConfiguration(mContext, defaultMccMnc); Loading Loading @@ -3766,7 +3865,7 @@ public class SubscriptionController extends ISub.Stub { } private synchronized boolean addToSubIdList(int slotIndex, int subId, int subscriptionType) { ArrayList<Integer> subIdsList = sSlotIndexToSubIds.get(slotIndex); ArrayList<Integer> subIdsList = sSlotIndexToSubIds.getCopy(slotIndex); if (subIdsList == null) { subIdsList = new ArrayList<>(); sSlotIndexToSubIds.put(slotIndex, subIdsList); Loading @@ -3779,11 +3878,11 @@ public class SubscriptionController extends ISub.Stub { } if (isSubscriptionForRemoteSim(subscriptionType)) { // For Remote SIM subscriptions, a slot can have multiple subscriptions. subIdsList.add(subId); sSlotIndexToSubIds.addToSubIdList(slotIndex, subId); } else { // for all other types of subscriptions, a slot can have only one subscription at a time subIdsList.clear(); subIdsList.add(subId); sSlotIndexToSubIds.clearSubIdList(slotIndex); sSlotIndexToSubIds.addToSubIdList(slotIndex, subId); } if (DBG) logdl("slotIndex, subId combo is added to the map."); return true; Loading @@ -3799,7 +3898,7 @@ public class SubscriptionController extends ISub.Stub { */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public Map<Integer, ArrayList<Integer>> getSlotIndexToSubIdsMap() { return sSlotIndexToSubIds; return sSlotIndexToSubIds.getMap(); } /** Loading @@ -3808,7 +3907,7 @@ public class SubscriptionController extends ISub.Stub { */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void resetStaticMembers() { mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; sDefaultFallbackSubId.set(SubscriptionManager.INVALID_SUBSCRIPTION_ID); mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; } Loading Loading @@ -3952,4 +4051,41 @@ public class SubscriptionController extends ISub.Stub { Binder.restoreCallingIdentity(identity); } } /** * @hide */ private void setGlobalSetting(String name, int value) { Settings.Global.putInt(mContext.getContentResolver(), name, value); if (name == Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION || name == Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION) { invalidateDefaultSubIdCaches(); } } /** * @hide */ private static void invalidateDefaultSubIdCaches() { if (sCachingEnabled) { SubscriptionManager.invalidateDefaultSubIdCaches(); } } /** * @hide */ @VisibleForTesting public static void disableCaching() { sCachingEnabled = false; } /** * @hide */ public static void enableCaching() { sCachingEnabled = true; } } src/java/com/android/internal/telephony/vendor/VendorSubscriptionController.java +3 −5 Original line number Diff line number Diff line Loading @@ -16,15 +16,13 @@ package com.android.internal.telephony.vendor; import android.Manifest; import android.content.Context; import android.content.Intent; import android.Manifest; import android.os.AsyncResult; import android.os.Handler; import android.os.Registrant; import android.os.RegistrantList; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; Loading @@ -37,8 +35,8 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.SubscriptionController; import java.util.Iterator; import java.util.List; Loading Loading @@ -244,7 +242,7 @@ public class VendorSubscriptionController extends SubscriptionController { logi("set default phoneaccount to " + subId); mTelecomManager.setUserSelectedOutgoingPhoneAccount(phoneAccountHandle); } if (!isSubProvisioned(mDefaultFallbackSubId)) { if (!isSubProvisioned(sDefaultFallbackSubId.get())) { setDefaultFallbackSubId(mNextActivatedSub.getSubscriptionId(), SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM); } Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -413,6 +413,7 @@ public abstract class TelephonyTest { TAG = tag; MockitoAnnotations.initMocks(this); TelephonyManager.disableServiceHandleCaching(); SubscriptionController.disableCaching(); mPhones = new Phone[] {mPhone}; mImsCallProfile = new ImsCallProfile(); Loading Loading @@ -698,6 +699,7 @@ public abstract class TelephonyTest { restoreInstances(); TelephonyManager.enableServiceHandleCaching(); SubscriptionController.enableCaching(); } protected static void logd(String s) { Loading Loading
src/java/com/android/internal/telephony/SubscriptionController.java +170 −34 Original line number Diff line number Diff line Loading @@ -112,6 +112,9 @@ public class SubscriptionController extends ISub.Stub { private static final ParcelUuid INVALID_GROUP_UUID = ParcelUuid.fromString(CarrierConfigManager.REMOVE_GROUP_UUID_STRING); private final LocalLog mLocalLog = new LocalLog(200); private static final int SUB_ID_FOUND = 1; private static final int NO_ENTRY_FOR_SLOT_INDEX = -1; private static final int SUB_ID_NOT_IN_SLOT = -2; // Lock that both mCacheActiveSubInfoList and mCacheOpportunisticSubInfoList use. private Object mSubInfoListLock = new Object(); Loading Loading @@ -146,9 +149,114 @@ public class SubscriptionController extends ISub.Stub { private AppOpsManager mAppOps; // Allows test mocks to avoid SELinux failures on invalidate calls. private static boolean sCachingEnabled = true; // Each slot can have multiple subs. private static Map<Integer, ArrayList<Integer>> sSlotIndexToSubIds = new ConcurrentHashMap<>(); protected static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static class WatchedSlotIndexToSubIds { private Map<Integer, ArrayList<Integer>> mSlotIndexToSubIds = new ConcurrentHashMap<>(); WatchedSlotIndexToSubIds() { } public void clear() { mSlotIndexToSubIds.clear(); invalidateDefaultSubIdCaches(); } public Set<Entry<Integer, ArrayList<Integer>>> entrySet() { return mSlotIndexToSubIds.entrySet(); } // Force all updates to data structure through wrapper. public ArrayList<Integer> getCopy(int slotIndex) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList == null) { return null; } return new ArrayList<Integer>(subIdList); } public void put(int slotIndex, ArrayList<Integer> value) { mSlotIndexToSubIds.put(slotIndex, value); invalidateDefaultSubIdCaches(); } public void remove(int slotIndex) { mSlotIndexToSubIds.remove(slotIndex); invalidateDefaultSubIdCaches(); } public int size() { return mSlotIndexToSubIds.size(); } @VisibleForTesting public Map<Integer, ArrayList<Integer>> getMap() { return mSlotIndexToSubIds; } public int removeFromSubIdList(int slotIndex, int subId) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList == null) { return NO_ENTRY_FOR_SLOT_INDEX; } else { if (subIdList.contains(subId)) { subIdList.remove(new Integer(subId)); if (subIdList.isEmpty()) { mSlotIndexToSubIds.remove(slotIndex); } invalidateDefaultSubIdCaches(); return SUB_ID_FOUND; } else { return SUB_ID_NOT_IN_SLOT; } } } public void addToSubIdList(int slotIndex, Integer value) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList == null) { subIdList = new ArrayList<Integer>(); subIdList.add(value); mSlotIndexToSubIds.put(slotIndex, subIdList); } else { subIdList.add(value); } invalidateDefaultSubIdCaches(); } public void clearSubIdList(int slotIndex) { ArrayList<Integer> subIdList = mSlotIndexToSubIds.get(slotIndex); if (subIdList != null) { subIdList.clear(); invalidateDefaultSubIdCaches(); } } } protected static class WatchedInt { private int mValue; public WatchedInt(int initialValue) { mValue = initialValue; } public int get() { return mValue; } public void set(int newValue) { mValue = newValue; invalidateDefaultSubIdCaches(); } } private static WatchedSlotIndexToSubIds sSlotIndexToSubIds = new WatchedSlotIndexToSubIds(); protected static WatchedInt sDefaultFallbackSubId = new WatchedInt(SubscriptionManager.INVALID_SUBSCRIPTION_ID); @UnsupportedAppUsage private static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; Loading Loading @@ -222,6 +330,9 @@ public class SubscriptionController extends ISub.Stub { // Cache Setting values cacheSettingValues(); // Initial invalidate activates caching. invalidateDefaultSubIdCaches(); if (DBG) logdl("[SubscriptionController] init by Context"); } Loading Loading @@ -1330,7 +1441,7 @@ public class SubscriptionController extends ISub.Stub { if (!isActiveSubscriptionId(getDefaultSubId())) { // current default is not valid anylonger. set a new default if (DBG) { logdl("[updateDefaultSubIdsIfNeeded] set mDefaultFallbackSubId=" + newDefault); logdl("[updateDefaultSubIdsIfNeeded] set sDefaultFallbackSubId=" + newDefault); } setDefaultFallbackSubId(newDefault, subscriptionType); } Loading Loading @@ -1414,22 +1525,13 @@ public class SubscriptionController extends ISub.Stub { return -1; } refreshCachedActiveSubscriptionInfoList(); // update sSlotIndexToSubIds struct ArrayList<Integer> subIdsList = sSlotIndexToSubIds.get(slotIndex); if (subIdsList == null) { result = sSlotIndexToSubIds.removeFromSubIdList(slotIndex, subId); if (result == NO_ENTRY_FOR_SLOT_INDEX) { loge("sSlotIndexToSubIds has no entry for slotIndex = " + slotIndex); } else { if (subIdsList.contains(subId)) { subIdsList.remove(new Integer(subId)); if (subIdsList.isEmpty()) { sSlotIndexToSubIds.remove(slotIndex); } } else { loge("sSlotIndexToSubIds has no subid: " + subId + ", in index: " + slotIndex); } } else if (result == SUB_ID_NOT_IN_SLOT) { loge("sSlotIndexToSubIds has no subid: " + subId + ", in index: " + slotIndex); } // Since a subscription is removed, if this one is set as default for any setting, // set some other subid as the default. int newDefault = SubscriptionManager.INVALID_SUBSCRIPTION_ID; Loading Loading @@ -2145,7 +2247,7 @@ public class SubscriptionController extends ISub.Stub { } // Convert ArrayList to array ArrayList<Integer> subIds = sSlotIndexToSubIds.get(slotIndex); ArrayList<Integer> subIds = sSlotIndexToSubIds.getCopy(slotIndex); if (subIds != null && subIds.size() > 0) { int[] subIdArr = new int[subIds.size()]; for (int i = 0; i < subIds.size(); i++) { Loading Loading @@ -2272,7 +2374,7 @@ public class SubscriptionController extends ISub.Stub { if (VDBG) logdl("[getDefaultSubId] NOT VoiceCapable subId=" + subId); } if (!isActiveSubId(subId)) { subId = mDefaultFallbackSubId; subId = sDefaultFallbackSubId.get(); if (VDBG) logdl("[getDefaultSubId] NOT active use fall back subId=" + subId); } if (VDBG) logv("[getDefaultSubId]- value = " + subId); Loading @@ -2288,8 +2390,7 @@ public class SubscriptionController extends ISub.Stub { throw new RuntimeException("setDefaultSmsSubId called with DEFAULT_SUB_ID"); } if (DBG) logdl("[setDefaultSmsSubId] subId=" + subId); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MULTI_SIM_SMS_SUBSCRIPTION, subId); setGlobalSetting(Settings.Global.MULTI_SIM_SMS_SUBSCRIPTION, subId); broadcastDefaultSmsSubIdChanged(subId); } Loading Loading @@ -2324,8 +2425,7 @@ public class SubscriptionController extends ISub.Stub { int previousDefaultSub = getDefaultSubId(); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, subId); setGlobalSetting(Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, subId); broadcastDefaultVoiceSubIdChanged(subId); PhoneAccountHandle newHandle = Loading Loading @@ -2425,8 +2525,7 @@ public class SubscriptionController extends ISub.Stub { } int previousDefaultSub = getDefaultSubId(); Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, subId); setGlobalSetting(Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, subId); MultiSimSettingController.getInstance().notifyDefaultDataSubChanged(); broadcastDefaultDataSubIdChanged(subId); if (previousDefaultSub != getDefaultSubId()) { Loading Loading @@ -2462,15 +2561,15 @@ public class SubscriptionController extends ISub.Stub { } int previousDefaultSub = getDefaultSubId(); if (isSubscriptionForRemoteSim(subscriptionType)) { mDefaultFallbackSubId = subId; sDefaultFallbackSubId.set(subId); return; } if (SubscriptionManager.isValidSubscriptionId(subId)) { int phoneId = getPhoneId(subId); if (phoneId >= 0 && (phoneId < mTelephonyManager.getPhoneCount() || mTelephonyManager.getSimCount() == 1)) { if (DBG) logdl("[setDefaultFallbackSubId] set mDefaultFallbackSubId=" + subId); mDefaultFallbackSubId = subId; if (DBG) logdl("[setDefaultFallbackSubId] set sDefaultFallbackSubId=" + subId); sDefaultFallbackSubId.set(subId); // Update MCC MNC device configuration information String defaultMccMnc = mTelephonyManager.getSimOperatorNumericForPhone(phoneId); MccTable.updateMccMncConfiguration(mContext, defaultMccMnc); Loading Loading @@ -3766,7 +3865,7 @@ public class SubscriptionController extends ISub.Stub { } private synchronized boolean addToSubIdList(int slotIndex, int subId, int subscriptionType) { ArrayList<Integer> subIdsList = sSlotIndexToSubIds.get(slotIndex); ArrayList<Integer> subIdsList = sSlotIndexToSubIds.getCopy(slotIndex); if (subIdsList == null) { subIdsList = new ArrayList<>(); sSlotIndexToSubIds.put(slotIndex, subIdsList); Loading @@ -3779,11 +3878,11 @@ public class SubscriptionController extends ISub.Stub { } if (isSubscriptionForRemoteSim(subscriptionType)) { // For Remote SIM subscriptions, a slot can have multiple subscriptions. subIdsList.add(subId); sSlotIndexToSubIds.addToSubIdList(slotIndex, subId); } else { // for all other types of subscriptions, a slot can have only one subscription at a time subIdsList.clear(); subIdsList.add(subId); sSlotIndexToSubIds.clearSubIdList(slotIndex); sSlotIndexToSubIds.addToSubIdList(slotIndex, subId); } if (DBG) logdl("slotIndex, subId combo is added to the map."); return true; Loading @@ -3799,7 +3898,7 @@ public class SubscriptionController extends ISub.Stub { */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public Map<Integer, ArrayList<Integer>> getSlotIndexToSubIdsMap() { return sSlotIndexToSubIds; return sSlotIndexToSubIds.getMap(); } /** Loading @@ -3808,7 +3907,7 @@ public class SubscriptionController extends ISub.Stub { */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void resetStaticMembers() { mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; sDefaultFallbackSubId.set(SubscriptionManager.INVALID_SUBSCRIPTION_ID); mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; } Loading Loading @@ -3952,4 +4051,41 @@ public class SubscriptionController extends ISub.Stub { Binder.restoreCallingIdentity(identity); } } /** * @hide */ private void setGlobalSetting(String name, int value) { Settings.Global.putInt(mContext.getContentResolver(), name, value); if (name == Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION || name == Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION) { invalidateDefaultSubIdCaches(); } } /** * @hide */ private static void invalidateDefaultSubIdCaches() { if (sCachingEnabled) { SubscriptionManager.invalidateDefaultSubIdCaches(); } } /** * @hide */ @VisibleForTesting public static void disableCaching() { sCachingEnabled = false; } /** * @hide */ public static void enableCaching() { sCachingEnabled = true; } }
src/java/com/android/internal/telephony/vendor/VendorSubscriptionController.java +3 −5 Original line number Diff line number Diff line Loading @@ -16,15 +16,13 @@ package com.android.internal.telephony.vendor; import android.Manifest; import android.content.Context; import android.content.Intent; import android.Manifest; import android.os.AsyncResult; import android.os.Handler; import android.os.Registrant; import android.os.RegistrantList; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; Loading @@ -37,8 +35,8 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Log; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.SubscriptionController; import java.util.Iterator; import java.util.List; Loading Loading @@ -244,7 +242,7 @@ public class VendorSubscriptionController extends SubscriptionController { logi("set default phoneaccount to " + subId); mTelecomManager.setUserSelectedOutgoingPhoneAccount(phoneAccountHandle); } if (!isSubProvisioned(mDefaultFallbackSubId)) { if (!isSubProvisioned(sDefaultFallbackSubId.get())) { setDefaultFallbackSubId(mNextActivatedSub.getSubscriptionId(), SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM); } Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -413,6 +413,7 @@ public abstract class TelephonyTest { TAG = tag; MockitoAnnotations.initMocks(this); TelephonyManager.disableServiceHandleCaching(); SubscriptionController.disableCaching(); mPhones = new Phone[] {mPhone}; mImsCallProfile = new ImsCallProfile(); Loading Loading @@ -698,6 +699,7 @@ public abstract class TelephonyTest { restoreInstances(); TelephonyManager.enableServiceHandleCaching(); SubscriptionController.enableCaching(); } protected static void logd(String s) { Loading