Loading src/java/com/android/internal/telephony/SubscriptionController.java +46 −16 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class SubscriptionController extends ISub.Stub { // FIXME: Does not allow for multiple subs in a slot and change to SparseArray private static HashMap<Integer, Integer> mSlotIdxToSubId = new HashMap<Integer, Integer>(); private static int mDefaultVoiceSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; private static final int EVENT_WRITE_MSISDN_DONE = 1; Loading Loading @@ -696,8 +696,8 @@ public class SubscriptionController extends ISub.Stub { // TODO While two subs active, if user deactivats first // one, need to update the default subId with second one. // FIXME: Currently we assume phoneId and slotId may not be true // when we cross map modem or when multiple subs per slot. // FIXME: Currently we assume phoneId == slotId which in the future // may not be true, for instance with multiple subs per slot. // But is true at the moment. mSlotIdxToSubId.put(slotId, subId); int subIdCountMax = getActiveSubInfoCountMax(); Loading @@ -712,7 +712,7 @@ public class SubscriptionController extends ISub.Stub { // Set the default sub if not set or if single sim device if (!SubscriptionManager.isValidSubscriptionId(defaultSubId) || subIdCountMax == 1) { setDefaultSubId(subId); setDefaultFallbackSubId(subId); } // If single sim device, set this subscription as the default for everything if (subIdCountMax == 1) { Loading Loading @@ -1189,9 +1189,21 @@ public class SubscriptionController extends ISub.Stub { @Override public int getDefaultSubId() { //FIXME: Make this smarter, need to handle data only and voice devices int subId = mDefaultVoiceSubId; if (VDBG) logv("[getDefaultSubId] value = " + subId); int subId; boolean isVoiceCapable = mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable); if (isVoiceCapable) { subId = getDefaultVoiceSubId(); if (VDBG) logdl("[getDefaultSubId] isVoiceCapable subId=" + subId); } else { subId = getDefaultDataSubId(); if (VDBG) logdl("[getDefaultSubId] NOT VoiceCapable subId=" + subId); } if ( ! isActiveSubId(subId)) { subId = mDefaultFallbackSubId; if (VDBG) logdl("[getDefaultSubId] NOT active use fall back subId=" + subId); } if (VDBG) logv("[getDefaultSubId]- value = " + subId); return subId; } Loading Loading @@ -1327,18 +1339,17 @@ public class SubscriptionController extends ISub.Stub { * sub is set as default subId. If two or more sub's are active * the first sub is set as default subscription */ // FIXME public void setDefaultSubId(int subId) { private void setDefaultFallbackSubId(int subId) { if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { throw new RuntimeException("setDefaultSubId called with DEFAULT_SUB_ID"); } if (DBG) logdl("[setDefaultSubId] subId=" + subId); if (DBG) logdl("[setDefaultFallbackSubId] subId=" + subId); if (SubscriptionManager.isValidSubscriptionId(subId)) { int phoneId = getPhoneId(subId); if (phoneId >= 0 && (phoneId < TelephonyManager.getDefault().getPhoneCount() || TelephonyManager.getDefault().getSimCount() == 1)) { if (DBG) logdl("[setDefaultSubId] set mDefaultVoiceSubId=" + subId); mDefaultVoiceSubId = subId; if (DBG) logdl("[setDefaultFallbackSubId] set mDefaultFallbackSubId=" + subId); mDefaultFallbackSubId = subId; // Update MCC MNC device configuration information String defaultMccMnc = TelephonyManager.getDefault().getSimOperator(phoneId); MccTable.updateMccMncConfiguration(mContext, defaultMccMnc, false); Loading @@ -1347,14 +1358,14 @@ public class SubscriptionController extends ISub.Stub { Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId, subId); if (VDBG) { logdl("[setDefaultSubId] broadcast default subId changed phoneId=" + phoneId if (DBG) { logdl("[setDefaultFallbackSubId] broadcast default subId changed phoneId=" + phoneId + " subId=" + subId); } mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); } else { if (VDBG) { logdl("[setDefaultSubId] not set invalid phoneId=" + phoneId if (DBG) { logdl("[setDefaultFallbackSubId] not set invalid phoneId=" + phoneId + " subId=" + subId); } } Loading Loading @@ -1494,6 +1505,25 @@ public class SubscriptionController extends ISub.Stub { return subIdArr; } private boolean isActiveSubId(int subId) { boolean retVal = false; if (SubscriptionManager.isValidSubscriptionId(subId)) { Set<Entry<Integer, Integer>> simInfoSet = mSlotIdxToSubId.entrySet(); if (VDBG) logdl("[isActiveSubId] simInfoSet=" + simInfoSet); for (Entry<Integer, Integer> entry: simInfoSet) { if (subId == entry.getValue()) { retVal = true; break; } } } if (VDBG) logdl("[isActiveSubId]- " + retVal); return retVal; } /** * Get the SIM state for the subscriber * @return SIM state as the ordinal of {@See IccCardConstants.State} Loading Loading
src/java/com/android/internal/telephony/SubscriptionController.java +46 −16 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class SubscriptionController extends ISub.Stub { // FIXME: Does not allow for multiple subs in a slot and change to SparseArray private static HashMap<Integer, Integer> mSlotIdxToSubId = new HashMap<Integer, Integer>(); private static int mDefaultVoiceSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; private static final int EVENT_WRITE_MSISDN_DONE = 1; Loading Loading @@ -696,8 +696,8 @@ public class SubscriptionController extends ISub.Stub { // TODO While two subs active, if user deactivats first // one, need to update the default subId with second one. // FIXME: Currently we assume phoneId and slotId may not be true // when we cross map modem or when multiple subs per slot. // FIXME: Currently we assume phoneId == slotId which in the future // may not be true, for instance with multiple subs per slot. // But is true at the moment. mSlotIdxToSubId.put(slotId, subId); int subIdCountMax = getActiveSubInfoCountMax(); Loading @@ -712,7 +712,7 @@ public class SubscriptionController extends ISub.Stub { // Set the default sub if not set or if single sim device if (!SubscriptionManager.isValidSubscriptionId(defaultSubId) || subIdCountMax == 1) { setDefaultSubId(subId); setDefaultFallbackSubId(subId); } // If single sim device, set this subscription as the default for everything if (subIdCountMax == 1) { Loading Loading @@ -1189,9 +1189,21 @@ public class SubscriptionController extends ISub.Stub { @Override public int getDefaultSubId() { //FIXME: Make this smarter, need to handle data only and voice devices int subId = mDefaultVoiceSubId; if (VDBG) logv("[getDefaultSubId] value = " + subId); int subId; boolean isVoiceCapable = mContext.getResources().getBoolean( com.android.internal.R.bool.config_voice_capable); if (isVoiceCapable) { subId = getDefaultVoiceSubId(); if (VDBG) logdl("[getDefaultSubId] isVoiceCapable subId=" + subId); } else { subId = getDefaultDataSubId(); if (VDBG) logdl("[getDefaultSubId] NOT VoiceCapable subId=" + subId); } if ( ! isActiveSubId(subId)) { subId = mDefaultFallbackSubId; if (VDBG) logdl("[getDefaultSubId] NOT active use fall back subId=" + subId); } if (VDBG) logv("[getDefaultSubId]- value = " + subId); return subId; } Loading Loading @@ -1327,18 +1339,17 @@ public class SubscriptionController extends ISub.Stub { * sub is set as default subId. If two or more sub's are active * the first sub is set as default subscription */ // FIXME public void setDefaultSubId(int subId) { private void setDefaultFallbackSubId(int subId) { if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { throw new RuntimeException("setDefaultSubId called with DEFAULT_SUB_ID"); } if (DBG) logdl("[setDefaultSubId] subId=" + subId); if (DBG) logdl("[setDefaultFallbackSubId] subId=" + subId); if (SubscriptionManager.isValidSubscriptionId(subId)) { int phoneId = getPhoneId(subId); if (phoneId >= 0 && (phoneId < TelephonyManager.getDefault().getPhoneCount() || TelephonyManager.getDefault().getSimCount() == 1)) { if (DBG) logdl("[setDefaultSubId] set mDefaultVoiceSubId=" + subId); mDefaultVoiceSubId = subId; if (DBG) logdl("[setDefaultFallbackSubId] set mDefaultFallbackSubId=" + subId); mDefaultFallbackSubId = subId; // Update MCC MNC device configuration information String defaultMccMnc = TelephonyManager.getDefault().getSimOperator(phoneId); MccTable.updateMccMncConfiguration(mContext, defaultMccMnc, false); Loading @@ -1347,14 +1358,14 @@ public class SubscriptionController extends ISub.Stub { Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId, subId); if (VDBG) { logdl("[setDefaultSubId] broadcast default subId changed phoneId=" + phoneId if (DBG) { logdl("[setDefaultFallbackSubId] broadcast default subId changed phoneId=" + phoneId + " subId=" + subId); } mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); } else { if (VDBG) { logdl("[setDefaultSubId] not set invalid phoneId=" + phoneId if (DBG) { logdl("[setDefaultFallbackSubId] not set invalid phoneId=" + phoneId + " subId=" + subId); } } Loading Loading @@ -1494,6 +1505,25 @@ public class SubscriptionController extends ISub.Stub { return subIdArr; } private boolean isActiveSubId(int subId) { boolean retVal = false; if (SubscriptionManager.isValidSubscriptionId(subId)) { Set<Entry<Integer, Integer>> simInfoSet = mSlotIdxToSubId.entrySet(); if (VDBG) logdl("[isActiveSubId] simInfoSet=" + simInfoSet); for (Entry<Integer, Integer> entry: simInfoSet) { if (subId == entry.getValue()) { retVal = true; break; } } } if (VDBG) logdl("[isActiveSubId]- " + retVal); return retVal; } /** * Get the SIM state for the subscriber * @return SIM state as the ordinal of {@See IccCardConstants.State} Loading