Loading src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java +11 −7 Original line number Diff line number Diff line Loading @@ -1815,13 +1815,14 @@ public class SubscriptionDatabaseManager extends Handler { * Load the database from content provider to the cache. */ private void loadDatabaseInternal() { logl("loadDatabaseInternal"); log("loadDatabaseInternal"); try (Cursor cursor = mContext.getContentResolver().query( SimInfo.CONTENT_URI, null, null, null, null)) { mReadWriteLock.writeLock().lock(); try { Map<Integer, SubscriptionInfoInternal> newAllSubscriptionInfoInternalCache = new HashMap<>(); boolean changed = false; while (cursor != null && cursor.moveToNext()) { SubscriptionInfoInternal subInfo = createSubscriptionInfoFromCursor(cursor); newAllSubscriptionInfoInternalCache.put(subInfo.getSubscriptionId(), subInfo); Loading @@ -1829,9 +1830,11 @@ public class SubscriptionDatabaseManager extends Handler { .get(subInfo.getSubscriptionId()), subInfo)) { mCallback.invokeFromExecutor(() -> mCallback.onSubscriptionChanged( subInfo.getSubscriptionId())); changed = true; } } if (changed) { mAllSubscriptionInfoInternalCache.clear(); mAllSubscriptionInfoInternalCache.putAll(newAllSubscriptionInfoInternalCache); Loading @@ -1839,6 +1842,7 @@ public class SubscriptionDatabaseManager extends Handler { + " records from the subscription database."); mAllSubscriptionInfoInternalCache.forEach( (subId, subInfo) -> log(" " + subInfo.toString())); } } finally { mReadWriteLock.writeLock().unlock(); } Loading src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +70 −48 Original line number Diff line number Diff line Loading @@ -392,6 +392,7 @@ public class SubscriptionManagerService extends ISub.Stub { * @param looper The looper for the handler. */ public SubscriptionManagerService(@NonNull Context context, @NonNull Looper looper) { logl("Created SubscriptionManagerService"); sInstance = this; mContext = context; mTelephonyManager = context.getSystemService(TelephonyManager.class); Loading Loading @@ -551,16 +552,16 @@ public class SubscriptionManagerService extends ISub.Stub { } }); SubscriptionManager.invalidateSubscriptionManagerServiceCaches(); SubscriptionManager.invalidateSubscriptionManagerServiceEnabledCaches(); mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateEmbeddedSubscriptions(); } }, new IntentFilter(Intent.ACTION_USER_UNLOCKED)); SubscriptionManager.invalidateSubscriptionManagerServiceCaches(); SubscriptionManager.invalidateSubscriptionManagerServiceEnabledCaches(); logl("created"); logl("Registered iSub service"); } /** Loading Loading @@ -923,9 +924,11 @@ public class SubscriptionManagerService extends ISub.Stub { .forEach(subInfo -> { mSubscriptionDatabaseManager.setSimSlotIndex(subInfo.getSubscriptionId(), SubscriptionManager.INVALID_SIM_SLOT_INDEX); mSubscriptionDatabaseManager.setPortIndex(subInfo.getSubscriptionId(), TelephonyManager.INVALID_PORT_INDEX); }); updateGroupDisabled(); logl("markSubscriptionsInactive: " + slotMappingToString()); logl("markSubscriptionsInactive: current mapping " + slotMappingToString()); } /** Loading Loading @@ -961,17 +964,19 @@ public class SubscriptionManagerService extends ISub.Stub { } /** * Get the embedded profile port index by ICCID. * Get the port index by ICCID. * * @param iccId The ICCID. * @return The port index. */ private int getEmbeddedProfilePortIndex(String iccId) { UiccSlot[] slots = UiccController.getInstance().getUiccSlots(); private int getPortIndex(@NonNull String iccId) { UiccSlot[] slots = mUiccController.getUiccSlots(); for (UiccSlot slot : slots) { if (slot != null && slot.isEuicc() && slot.getPortIndexFromIccId(iccId) != TelephonyManager.INVALID_PORT_INDEX) { return slot.getPortIndexFromIccId(iccId); if (slot != null) { int portIndex = slot.getPortIndexFromIccId(iccId); if (portIndex != TelephonyManager.INVALID_PORT_INDEX) { return portIndex; } } } return TelephonyManager.INVALID_PORT_INDEX; Loading Loading @@ -1029,6 +1034,13 @@ public class SubscriptionManagerService extends ISub.Stub { Set<Integer> embeddedSubs = new ArraySet<>(); log("updateEmbeddedSubscriptions: start to get euicc profiles."); for (UiccSlot slot : mUiccController.getUiccSlots()) { if (slot != null) { log(" " + slot.toString()); } } for (int cardId : cardIds) { GetEuiccProfileInfoListResult result = mEuiccController .blockingGetEuiccProfileInfoList(cardId); Loading Loading @@ -1080,7 +1092,7 @@ public class SubscriptionManagerService extends ISub.Stub { builder.setDisplayNameSource(SubscriptionManager.NAME_SOURCE_CARRIER); } builder.setProfileClass(embeddedProfile.getProfileClass()); builder.setPortIndex(getEmbeddedProfilePortIndex(embeddedProfile.getIccid())); builder.setPortIndex(getPortIndex(embeddedProfile.getIccid())); CarrierIdentifier cid = embeddedProfile.getCarrierIdentifier(); if (cid != null) { Loading Loading @@ -1221,7 +1233,7 @@ public class SubscriptionManagerService extends ISub.Stub { } if (mSimState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN) { log("areAllSubscriptionsLoaded: SIM state is still unknown."); log("areAllSubscriptionsLoaded: SIM " + phoneId + " state is still unknown."); return false; } } Loading @@ -1230,20 +1242,26 @@ public class SubscriptionManagerService extends ISub.Stub { } /** * Update the subscriptions on the logical SIM slot index (i.e. phone id). * Update the subscription on the logical SIM slot index (i.e. phone id). * * @param phoneId The phone id (i.e. Logical SIM slot index) */ private void updateSubscriptions(int phoneId) { private void updateSubscription(int phoneId) { int simState = mSimState[phoneId]; log("updateSubscriptions: phoneId=" + phoneId + ", simState=" log("updateSubscription: phoneId=" + phoneId + ", simState=" + TelephonyManager.simStateToString(simState)); for (UiccSlot slot : mUiccController.getUiccSlots()) { if (slot != null) { log(" " + slot.toString()); } } if (simState == TelephonyManager.SIM_STATE_ABSENT) { if (mSlotIndexToSubId.containsKey(phoneId)) { int subId = mSlotIndexToSubId.get(phoneId); // Re-enable the SIM when it's removed, so it will be in enabled state when it gets // re-inserted again. (pre-U behavior) log("updateSubscriptions: Re-enable Uicc application on sub " + subId); log("updateSubscription: Re-enable Uicc application on sub " + subId); mSubscriptionDatabaseManager.setUiccApplicationsEnabled(subId, true); // When sim is absent, set the port index to invalid port index. (pre-U behavior) mSubscriptionDatabaseManager.setPortIndex(subId, Loading @@ -1255,45 +1273,49 @@ public class SubscriptionManagerService extends ISub.Stub { // final state. IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard(); if (!iccCard.isEmptyProfile() && areUiccAppsEnabledOnCard(phoneId)) { log("updateSubscriptions: SIM_STATE_NOT_READY is not a final state. Will update " log("updateSubscription: SIM_STATE_NOT_READY is not a final state. Will update " + "subscription later."); return; } if (!areUiccAppsEnabledOnCard(phoneId)) { logl("updateSubscriptions: UICC app disabled on slot " + phoneId); logl("updateSubscription: UICC app disabled on slot " + phoneId); markSubscriptionsInactive(phoneId); } } String iccId = getIccId(phoneId); log("updateSubscriptions: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId) log("updateSubscription: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId) + " on phone " + phoneId); // For eSIM switching, SIM absent will not happen. Below is to exam if we find ICCID // mismatch on the SIM slot, we need to mark all subscriptions on that logical slot invalid // first. The correct subscription will be assigned the correct slot later. if (mSubscriptionDatabaseManager.getAllSubscriptions().stream() .anyMatch(subInfo -> subInfo.getSimSlotIndex() == phoneId && !iccId.equals(subInfo.getIccId()))) { log("updateSubscriptions: iccId changed for phone " + phoneId); // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on that // logical slot invalid first. The correct subscription will be assigned the correct slot // later. SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager.getAllSubscriptions() .stream() .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals(sub.getIccId())) .findFirst() .orElse(null); if (subInfo != null) { log("updateSubscription: Found previous active sub " + subInfo.getSubscriptionId() + " that doesn't match current iccid on slot " + phoneId + "."); markSubscriptionsInactive(phoneId); } if (!TextUtils.isEmpty(iccId)) { // Check if the subscription already existed. SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager .getSubscriptionInfoInternalByIccId(iccId); subInfo = mSubscriptionDatabaseManager.getSubscriptionInfoInternalByIccId(iccId); int subId; if (subInfo == null) { // This is a new SIM card. Insert a new record. subId = insertSubscriptionInfo(iccId, phoneId, null, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM); logl("updateSubscriptions: Inserted a new subscription. subId=" + subId logl("updateSubscription: Inserted a new subscription. subId=" + subId + ", phoneId=" + phoneId); } else { subId = subInfo.getSubscriptionId(); log("updateSubscriptions: Found existing subscription. subId= " + subId log("updateSubscription: Found existing subscription. subId= " + subId + ", phoneId=" + phoneId); } Loading @@ -1302,7 +1324,7 @@ public class SubscriptionManagerService extends ISub.Stub { mSlotIndexToSubId.put(phoneId, subId); // Update the SIM slot index. This will make the subscription active. mSubscriptionDatabaseManager.setSimSlotIndex(subId, phoneId); logl("updateSubscriptions: " + slotMappingToString()); logl("updateSubscription: current mapping " + slotMappingToString()); } // Update the card id. Loading @@ -1315,11 +1337,7 @@ public class SubscriptionManagerService extends ISub.Stub { } // Update the port index. UiccSlot slot = mUiccController.getUiccSlotForPhone(phoneId); if (slot != null && !slot.isEuicc()) { int portIndex = slot.getPortIndexFromIccId(iccId); mSubscriptionDatabaseManager.setPortIndex(subId, portIndex); } mSubscriptionDatabaseManager.setPortIndex(subId, getPortIndex(iccId)); if (simState == TelephonyManager.SIM_STATE_LOADED) { String mccMnc = mTelephonyManager.getSimOperatorNumeric(subId); Loading @@ -1329,7 +1347,7 @@ public class SubscriptionManagerService extends ISub.Stub { } setMccMnc(subId, mccMnc); } else { loge("updateSubscriptions: mcc/mnc is empty"); loge("updateSubscription: mcc/mnc is empty"); } String iso = TelephonyManager.getSimCountryIsoForPhone(phoneId); Loading @@ -1337,7 +1355,7 @@ public class SubscriptionManagerService extends ISub.Stub { if (!TextUtils.isEmpty(iso)) { setCountryIso(subId, iso); } else { loge("updateSubscriptions: sim country iso is null"); loge("updateSubscription: sim country iso is null"); } String msisdn = mTelephonyManager.getLine1Number(subId); Loading @@ -1363,10 +1381,10 @@ public class SubscriptionManagerService extends ISub.Stub { mSubscriptionDatabaseManager.setHplmns(subId, hplmns); } } else { loge("updateSubscriptions: ICC records are not available."); loge("updateSubscription: ICC records are not available."); } } else { loge("updateSubscriptions: ICC card is not available."); loge("updateSubscription: ICC card is not available."); } // Attempt to restore SIM specific settings when SIM is loaded. Loading @@ -1374,12 +1392,16 @@ public class SubscriptionManagerService extends ISub.Stub { SubscriptionManager.SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI, SubscriptionManager.RESTORE_SIM_SPECIFIC_SETTINGS_METHOD_NAME, iccId, null); log("Reload the database."); mSubscriptionDatabaseManager.reloadDatabase(); } log("updateSubscription: " + mSubscriptionDatabaseManager .getSubscriptionInfoInternal(subId)); } else { log("updateSubscriptions: No ICCID available for phone " + phoneId); log("updateSubscription: No ICCID available for phone " + phoneId); mSlotIndexToSubId.remove(phoneId); logl("updateSubscriptions: " + slotMappingToString()); logl("updateSubscription: current mapping " + slotMappingToString()); } if (areAllSubscriptionsLoaded()) { Loading Loading @@ -1946,7 +1968,7 @@ public class SubscriptionManagerService extends ISub.Stub { int subId = insertSubscriptionInfo(iccId, slotIndex, displayName, subscriptionType); updateGroupDisabled(); mSlotIndexToSubId.put(slotIndex, subId); logl("addSubInfo: " + slotMappingToString()); logl("addSubInfo: current mapping " + slotMappingToString()); } else { // Record already exists. loge("Subscription record already existed."); Loading Loading @@ -3741,7 +3763,7 @@ public class SubscriptionManagerService extends ISub.Stub { // active again. (pre-U behavior) mSubscriptionDatabaseManager.setUiccApplicationsEnabled( mSlotIndexToSubId.get(slotIndex), true); updateSubscriptions(slotIndex); updateSubscription(slotIndex); } }); } Loading Loading @@ -3773,7 +3795,7 @@ public class SubscriptionManagerService extends ISub.Stub { case TelephonyManager.SIM_STATE_CARD_IO_ERROR: case TelephonyManager.SIM_STATE_LOADED: case TelephonyManager.SIM_STATE_NOT_READY: updateSubscriptions(slotIndex); updateSubscription(slotIndex); break; case TelephonyManager.SIM_STATE_CARD_RESTRICTED: default: Loading Loading @@ -3844,9 +3866,9 @@ public class SubscriptionManagerService extends ISub.Stub { */ @NonNull private String slotMappingToString() { return mSlotIndexToSubId.entrySet().stream() .map(e -> "Slot " + e.getKey() + ": subId=" + e.getValue()) .collect(Collectors.joining(", ")); return "[" + mSlotIndexToSubId.entrySet().stream() .map(e -> "slot " + e.getKey() + ": subId=" + e.getValue()) .collect(Collectors.joining(", ")) + "]"; } /** Loading src/java/com/android/internal/telephony/uicc/PinStorage.java +11 −7 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import android.telephony.CarrierConfigManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager.SimState; import android.util.Base64; import android.util.IndentingPrintWriter; import android.util.SparseArray; import com.android.internal.R; Loading Loading @@ -1209,8 +1210,10 @@ public class PinStorage extends Handler { Rlog.e(TAG, msg, tr); } void dump(FileDescriptor fd, PrintWriter pw, String[] args) { void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); pw.println("PinStorage:"); pw.increaseIndent(); pw.println("mIsDeviceSecure=" + mIsDeviceSecure); pw.println("mIsDeviceLocked=" + mIsDeviceLocked); pw.println("isLongTermSecretKey=" + (boolean) (mLongTermSecretKey != null)); Loading @@ -1226,5 +1229,6 @@ public class PinStorage extends Handler { pw.println(" pin=" + storedPins.valueAt(i).toString()); } } pw.decreaseIndent(); } } src/java/com/android/internal/telephony/uicc/UiccCard.java +12 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.Context; import android.os.Build; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.IndentingPrintWriter; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.uicc.IccCardStatus.CardState; Loading Loading @@ -213,15 +214,20 @@ public class UiccCard { Rlog.e(LOG_TAG, msg); } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); pw.println("UiccCard:"); pw.increaseIndent(); pw.println("mCardState=" + mCardState); pw.println("mCardId=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mCardId)); pw.println("mNumberOfPorts=" + mUiccPorts.size()); pw.println("mSupportedMepMode=" + mSupportedMepMode); pw.println(); pw.println("mUiccPorts= size=" + mUiccPorts.size()); pw.increaseIndent(); for (UiccPort uiccPort : mUiccPorts.values()) { uiccPort.dump(fd, pw, args); } pw.decreaseIndent(); pw.decreaseIndent(); } } src/java/com/android/internal/telephony/uicc/UiccCardApplication.java +22 −34 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.os.Handler; import android.os.Message; import android.os.Registrant; import android.os.RegistrantList; import android.util.IndentingPrintWriter; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.CommandsInterface; Loading Loading @@ -984,8 +985,10 @@ public class UiccCardApplication { Rlog.e(LOG_TAG, msg); } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("UiccCardApplication: " + this); public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); pw.println("UiccCardApplication: "); pw.increaseIndent(); pw.println("mUiccProfile=" + mUiccProfile); pw.println("mAppState=" + mAppState); pw.println("mAppType=" + mAppType); Loading @@ -999,25 +1002,10 @@ public class UiccCardApplication { pw.println("mDesiredFdnEnabled=" + mDesiredFdnEnabled); pw.println("mIccLockEnabled=" + mIccLockEnabled); pw.println("mDesiredPinLocked=" + mDesiredPinLocked); pw.println(" mCi=" + mCi); pw.println("mIccRecords=" + mIccRecords); pw.println("mIccFh=" + mIccFh); pw.println("mDestroyed=" + mDestroyed); pw.println(" mReadyRegistrants: size=" + mReadyRegistrants.size()); for (int i = 0; i < mReadyRegistrants.size(); i++) { pw.println(" mReadyRegistrants[" + i + "]=" + ((Registrant)mReadyRegistrants.get(i)).getHandler()); } pw.println(" mPinLockedRegistrants: size=" + mPinLockedRegistrants.size()); for (int i = 0; i < mPinLockedRegistrants.size(); i++) { pw.println(" mPinLockedRegistrants[" + i + "]=" + ((Registrant)mPinLockedRegistrants.get(i)).getHandler()); } pw.println(" mNetworkLockedRegistrants: size=" + mNetworkLockedRegistrants.size()); for (int i = 0; i < mNetworkLockedRegistrants.size(); i++) { pw.println(" mNetworkLockedRegistrants[" + i + "]=" + ((Registrant)mNetworkLockedRegistrants.get(i)).getHandler()); } pw.decreaseIndent(); pw.flush(); } } Loading
src/java/com/android/internal/telephony/subscription/SubscriptionDatabaseManager.java +11 −7 Original line number Diff line number Diff line Loading @@ -1815,13 +1815,14 @@ public class SubscriptionDatabaseManager extends Handler { * Load the database from content provider to the cache. */ private void loadDatabaseInternal() { logl("loadDatabaseInternal"); log("loadDatabaseInternal"); try (Cursor cursor = mContext.getContentResolver().query( SimInfo.CONTENT_URI, null, null, null, null)) { mReadWriteLock.writeLock().lock(); try { Map<Integer, SubscriptionInfoInternal> newAllSubscriptionInfoInternalCache = new HashMap<>(); boolean changed = false; while (cursor != null && cursor.moveToNext()) { SubscriptionInfoInternal subInfo = createSubscriptionInfoFromCursor(cursor); newAllSubscriptionInfoInternalCache.put(subInfo.getSubscriptionId(), subInfo); Loading @@ -1829,9 +1830,11 @@ public class SubscriptionDatabaseManager extends Handler { .get(subInfo.getSubscriptionId()), subInfo)) { mCallback.invokeFromExecutor(() -> mCallback.onSubscriptionChanged( subInfo.getSubscriptionId())); changed = true; } } if (changed) { mAllSubscriptionInfoInternalCache.clear(); mAllSubscriptionInfoInternalCache.putAll(newAllSubscriptionInfoInternalCache); Loading @@ -1839,6 +1842,7 @@ public class SubscriptionDatabaseManager extends Handler { + " records from the subscription database."); mAllSubscriptionInfoInternalCache.forEach( (subId, subInfo) -> log(" " + subInfo.toString())); } } finally { mReadWriteLock.writeLock().unlock(); } Loading
src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +70 −48 Original line number Diff line number Diff line Loading @@ -392,6 +392,7 @@ public class SubscriptionManagerService extends ISub.Stub { * @param looper The looper for the handler. */ public SubscriptionManagerService(@NonNull Context context, @NonNull Looper looper) { logl("Created SubscriptionManagerService"); sInstance = this; mContext = context; mTelephonyManager = context.getSystemService(TelephonyManager.class); Loading Loading @@ -551,16 +552,16 @@ public class SubscriptionManagerService extends ISub.Stub { } }); SubscriptionManager.invalidateSubscriptionManagerServiceCaches(); SubscriptionManager.invalidateSubscriptionManagerServiceEnabledCaches(); mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateEmbeddedSubscriptions(); } }, new IntentFilter(Intent.ACTION_USER_UNLOCKED)); SubscriptionManager.invalidateSubscriptionManagerServiceCaches(); SubscriptionManager.invalidateSubscriptionManagerServiceEnabledCaches(); logl("created"); logl("Registered iSub service"); } /** Loading Loading @@ -923,9 +924,11 @@ public class SubscriptionManagerService extends ISub.Stub { .forEach(subInfo -> { mSubscriptionDatabaseManager.setSimSlotIndex(subInfo.getSubscriptionId(), SubscriptionManager.INVALID_SIM_SLOT_INDEX); mSubscriptionDatabaseManager.setPortIndex(subInfo.getSubscriptionId(), TelephonyManager.INVALID_PORT_INDEX); }); updateGroupDisabled(); logl("markSubscriptionsInactive: " + slotMappingToString()); logl("markSubscriptionsInactive: current mapping " + slotMappingToString()); } /** Loading Loading @@ -961,17 +964,19 @@ public class SubscriptionManagerService extends ISub.Stub { } /** * Get the embedded profile port index by ICCID. * Get the port index by ICCID. * * @param iccId The ICCID. * @return The port index. */ private int getEmbeddedProfilePortIndex(String iccId) { UiccSlot[] slots = UiccController.getInstance().getUiccSlots(); private int getPortIndex(@NonNull String iccId) { UiccSlot[] slots = mUiccController.getUiccSlots(); for (UiccSlot slot : slots) { if (slot != null && slot.isEuicc() && slot.getPortIndexFromIccId(iccId) != TelephonyManager.INVALID_PORT_INDEX) { return slot.getPortIndexFromIccId(iccId); if (slot != null) { int portIndex = slot.getPortIndexFromIccId(iccId); if (portIndex != TelephonyManager.INVALID_PORT_INDEX) { return portIndex; } } } return TelephonyManager.INVALID_PORT_INDEX; Loading Loading @@ -1029,6 +1034,13 @@ public class SubscriptionManagerService extends ISub.Stub { Set<Integer> embeddedSubs = new ArraySet<>(); log("updateEmbeddedSubscriptions: start to get euicc profiles."); for (UiccSlot slot : mUiccController.getUiccSlots()) { if (slot != null) { log(" " + slot.toString()); } } for (int cardId : cardIds) { GetEuiccProfileInfoListResult result = mEuiccController .blockingGetEuiccProfileInfoList(cardId); Loading Loading @@ -1080,7 +1092,7 @@ public class SubscriptionManagerService extends ISub.Stub { builder.setDisplayNameSource(SubscriptionManager.NAME_SOURCE_CARRIER); } builder.setProfileClass(embeddedProfile.getProfileClass()); builder.setPortIndex(getEmbeddedProfilePortIndex(embeddedProfile.getIccid())); builder.setPortIndex(getPortIndex(embeddedProfile.getIccid())); CarrierIdentifier cid = embeddedProfile.getCarrierIdentifier(); if (cid != null) { Loading Loading @@ -1221,7 +1233,7 @@ public class SubscriptionManagerService extends ISub.Stub { } if (mSimState[phoneId] == TelephonyManager.SIM_STATE_UNKNOWN) { log("areAllSubscriptionsLoaded: SIM state is still unknown."); log("areAllSubscriptionsLoaded: SIM " + phoneId + " state is still unknown."); return false; } } Loading @@ -1230,20 +1242,26 @@ public class SubscriptionManagerService extends ISub.Stub { } /** * Update the subscriptions on the logical SIM slot index (i.e. phone id). * Update the subscription on the logical SIM slot index (i.e. phone id). * * @param phoneId The phone id (i.e. Logical SIM slot index) */ private void updateSubscriptions(int phoneId) { private void updateSubscription(int phoneId) { int simState = mSimState[phoneId]; log("updateSubscriptions: phoneId=" + phoneId + ", simState=" log("updateSubscription: phoneId=" + phoneId + ", simState=" + TelephonyManager.simStateToString(simState)); for (UiccSlot slot : mUiccController.getUiccSlots()) { if (slot != null) { log(" " + slot.toString()); } } if (simState == TelephonyManager.SIM_STATE_ABSENT) { if (mSlotIndexToSubId.containsKey(phoneId)) { int subId = mSlotIndexToSubId.get(phoneId); // Re-enable the SIM when it's removed, so it will be in enabled state when it gets // re-inserted again. (pre-U behavior) log("updateSubscriptions: Re-enable Uicc application on sub " + subId); log("updateSubscription: Re-enable Uicc application on sub " + subId); mSubscriptionDatabaseManager.setUiccApplicationsEnabled(subId, true); // When sim is absent, set the port index to invalid port index. (pre-U behavior) mSubscriptionDatabaseManager.setPortIndex(subId, Loading @@ -1255,45 +1273,49 @@ public class SubscriptionManagerService extends ISub.Stub { // final state. IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard(); if (!iccCard.isEmptyProfile() && areUiccAppsEnabledOnCard(phoneId)) { log("updateSubscriptions: SIM_STATE_NOT_READY is not a final state. Will update " log("updateSubscription: SIM_STATE_NOT_READY is not a final state. Will update " + "subscription later."); return; } if (!areUiccAppsEnabledOnCard(phoneId)) { logl("updateSubscriptions: UICC app disabled on slot " + phoneId); logl("updateSubscription: UICC app disabled on slot " + phoneId); markSubscriptionsInactive(phoneId); } } String iccId = getIccId(phoneId); log("updateSubscriptions: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId) log("updateSubscription: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId) + " on phone " + phoneId); // For eSIM switching, SIM absent will not happen. Below is to exam if we find ICCID // mismatch on the SIM slot, we need to mark all subscriptions on that logical slot invalid // first. The correct subscription will be assigned the correct slot later. if (mSubscriptionDatabaseManager.getAllSubscriptions().stream() .anyMatch(subInfo -> subInfo.getSimSlotIndex() == phoneId && !iccId.equals(subInfo.getIccId()))) { log("updateSubscriptions: iccId changed for phone " + phoneId); // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on that // logical slot invalid first. The correct subscription will be assigned the correct slot // later. SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager.getAllSubscriptions() .stream() .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals(sub.getIccId())) .findFirst() .orElse(null); if (subInfo != null) { log("updateSubscription: Found previous active sub " + subInfo.getSubscriptionId() + " that doesn't match current iccid on slot " + phoneId + "."); markSubscriptionsInactive(phoneId); } if (!TextUtils.isEmpty(iccId)) { // Check if the subscription already existed. SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager .getSubscriptionInfoInternalByIccId(iccId); subInfo = mSubscriptionDatabaseManager.getSubscriptionInfoInternalByIccId(iccId); int subId; if (subInfo == null) { // This is a new SIM card. Insert a new record. subId = insertSubscriptionInfo(iccId, phoneId, null, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM); logl("updateSubscriptions: Inserted a new subscription. subId=" + subId logl("updateSubscription: Inserted a new subscription. subId=" + subId + ", phoneId=" + phoneId); } else { subId = subInfo.getSubscriptionId(); log("updateSubscriptions: Found existing subscription. subId= " + subId log("updateSubscription: Found existing subscription. subId= " + subId + ", phoneId=" + phoneId); } Loading @@ -1302,7 +1324,7 @@ public class SubscriptionManagerService extends ISub.Stub { mSlotIndexToSubId.put(phoneId, subId); // Update the SIM slot index. This will make the subscription active. mSubscriptionDatabaseManager.setSimSlotIndex(subId, phoneId); logl("updateSubscriptions: " + slotMappingToString()); logl("updateSubscription: current mapping " + slotMappingToString()); } // Update the card id. Loading @@ -1315,11 +1337,7 @@ public class SubscriptionManagerService extends ISub.Stub { } // Update the port index. UiccSlot slot = mUiccController.getUiccSlotForPhone(phoneId); if (slot != null && !slot.isEuicc()) { int portIndex = slot.getPortIndexFromIccId(iccId); mSubscriptionDatabaseManager.setPortIndex(subId, portIndex); } mSubscriptionDatabaseManager.setPortIndex(subId, getPortIndex(iccId)); if (simState == TelephonyManager.SIM_STATE_LOADED) { String mccMnc = mTelephonyManager.getSimOperatorNumeric(subId); Loading @@ -1329,7 +1347,7 @@ public class SubscriptionManagerService extends ISub.Stub { } setMccMnc(subId, mccMnc); } else { loge("updateSubscriptions: mcc/mnc is empty"); loge("updateSubscription: mcc/mnc is empty"); } String iso = TelephonyManager.getSimCountryIsoForPhone(phoneId); Loading @@ -1337,7 +1355,7 @@ public class SubscriptionManagerService extends ISub.Stub { if (!TextUtils.isEmpty(iso)) { setCountryIso(subId, iso); } else { loge("updateSubscriptions: sim country iso is null"); loge("updateSubscription: sim country iso is null"); } String msisdn = mTelephonyManager.getLine1Number(subId); Loading @@ -1363,10 +1381,10 @@ public class SubscriptionManagerService extends ISub.Stub { mSubscriptionDatabaseManager.setHplmns(subId, hplmns); } } else { loge("updateSubscriptions: ICC records are not available."); loge("updateSubscription: ICC records are not available."); } } else { loge("updateSubscriptions: ICC card is not available."); loge("updateSubscription: ICC card is not available."); } // Attempt to restore SIM specific settings when SIM is loaded. Loading @@ -1374,12 +1392,16 @@ public class SubscriptionManagerService extends ISub.Stub { SubscriptionManager.SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI, SubscriptionManager.RESTORE_SIM_SPECIFIC_SETTINGS_METHOD_NAME, iccId, null); log("Reload the database."); mSubscriptionDatabaseManager.reloadDatabase(); } log("updateSubscription: " + mSubscriptionDatabaseManager .getSubscriptionInfoInternal(subId)); } else { log("updateSubscriptions: No ICCID available for phone " + phoneId); log("updateSubscription: No ICCID available for phone " + phoneId); mSlotIndexToSubId.remove(phoneId); logl("updateSubscriptions: " + slotMappingToString()); logl("updateSubscription: current mapping " + slotMappingToString()); } if (areAllSubscriptionsLoaded()) { Loading Loading @@ -1946,7 +1968,7 @@ public class SubscriptionManagerService extends ISub.Stub { int subId = insertSubscriptionInfo(iccId, slotIndex, displayName, subscriptionType); updateGroupDisabled(); mSlotIndexToSubId.put(slotIndex, subId); logl("addSubInfo: " + slotMappingToString()); logl("addSubInfo: current mapping " + slotMappingToString()); } else { // Record already exists. loge("Subscription record already existed."); Loading Loading @@ -3741,7 +3763,7 @@ public class SubscriptionManagerService extends ISub.Stub { // active again. (pre-U behavior) mSubscriptionDatabaseManager.setUiccApplicationsEnabled( mSlotIndexToSubId.get(slotIndex), true); updateSubscriptions(slotIndex); updateSubscription(slotIndex); } }); } Loading Loading @@ -3773,7 +3795,7 @@ public class SubscriptionManagerService extends ISub.Stub { case TelephonyManager.SIM_STATE_CARD_IO_ERROR: case TelephonyManager.SIM_STATE_LOADED: case TelephonyManager.SIM_STATE_NOT_READY: updateSubscriptions(slotIndex); updateSubscription(slotIndex); break; case TelephonyManager.SIM_STATE_CARD_RESTRICTED: default: Loading Loading @@ -3844,9 +3866,9 @@ public class SubscriptionManagerService extends ISub.Stub { */ @NonNull private String slotMappingToString() { return mSlotIndexToSubId.entrySet().stream() .map(e -> "Slot " + e.getKey() + ": subId=" + e.getValue()) .collect(Collectors.joining(", ")); return "[" + mSlotIndexToSubId.entrySet().stream() .map(e -> "slot " + e.getKey() + ": subId=" + e.getValue()) .collect(Collectors.joining(", ")) + "]"; } /** Loading
src/java/com/android/internal/telephony/uicc/PinStorage.java +11 −7 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import android.telephony.CarrierConfigManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager.SimState; import android.util.Base64; import android.util.IndentingPrintWriter; import android.util.SparseArray; import com.android.internal.R; Loading Loading @@ -1209,8 +1210,10 @@ public class PinStorage extends Handler { Rlog.e(TAG, msg, tr); } void dump(FileDescriptor fd, PrintWriter pw, String[] args) { void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); pw.println("PinStorage:"); pw.increaseIndent(); pw.println("mIsDeviceSecure=" + mIsDeviceSecure); pw.println("mIsDeviceLocked=" + mIsDeviceLocked); pw.println("isLongTermSecretKey=" + (boolean) (mLongTermSecretKey != null)); Loading @@ -1226,5 +1229,6 @@ public class PinStorage extends Handler { pw.println(" pin=" + storedPins.valueAt(i).toString()); } } pw.decreaseIndent(); } }
src/java/com/android/internal/telephony/uicc/UiccCard.java +12 −6 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.Context; import android.os.Build; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.IndentingPrintWriter; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.uicc.IccCardStatus.CardState; Loading Loading @@ -213,15 +214,20 @@ public class UiccCard { Rlog.e(LOG_TAG, msg); } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); pw.println("UiccCard:"); pw.increaseIndent(); pw.println("mCardState=" + mCardState); pw.println("mCardId=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mCardId)); pw.println("mNumberOfPorts=" + mUiccPorts.size()); pw.println("mSupportedMepMode=" + mSupportedMepMode); pw.println(); pw.println("mUiccPorts= size=" + mUiccPorts.size()); pw.increaseIndent(); for (UiccPort uiccPort : mUiccPorts.values()) { uiccPort.dump(fd, pw, args); } pw.decreaseIndent(); pw.decreaseIndent(); } }
src/java/com/android/internal/telephony/uicc/UiccCardApplication.java +22 −34 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.os.Handler; import android.os.Message; import android.os.Registrant; import android.os.RegistrantList; import android.util.IndentingPrintWriter; import com.android.internal.telephony.CommandException; import com.android.internal.telephony.CommandsInterface; Loading Loading @@ -984,8 +985,10 @@ public class UiccCardApplication { Rlog.e(LOG_TAG, msg); } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("UiccCardApplication: " + this); public void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " "); pw.println("UiccCardApplication: "); pw.increaseIndent(); pw.println("mUiccProfile=" + mUiccProfile); pw.println("mAppState=" + mAppState); pw.println("mAppType=" + mAppType); Loading @@ -999,25 +1002,10 @@ public class UiccCardApplication { pw.println("mDesiredFdnEnabled=" + mDesiredFdnEnabled); pw.println("mIccLockEnabled=" + mIccLockEnabled); pw.println("mDesiredPinLocked=" + mDesiredPinLocked); pw.println(" mCi=" + mCi); pw.println("mIccRecords=" + mIccRecords); pw.println("mIccFh=" + mIccFh); pw.println("mDestroyed=" + mDestroyed); pw.println(" mReadyRegistrants: size=" + mReadyRegistrants.size()); for (int i = 0; i < mReadyRegistrants.size(); i++) { pw.println(" mReadyRegistrants[" + i + "]=" + ((Registrant)mReadyRegistrants.get(i)).getHandler()); } pw.println(" mPinLockedRegistrants: size=" + mPinLockedRegistrants.size()); for (int i = 0; i < mPinLockedRegistrants.size(); i++) { pw.println(" mPinLockedRegistrants[" + i + "]=" + ((Registrant)mPinLockedRegistrants.get(i)).getHandler()); } pw.println(" mNetworkLockedRegistrants: size=" + mNetworkLockedRegistrants.size()); for (int i = 0; i < mNetworkLockedRegistrants.size(); i++) { pw.println(" mNetworkLockedRegistrants[" + i + "]=" + ((Registrant)mNetworkLockedRegistrants.get(i)).getHandler()); } pw.decreaseIndent(); pw.flush(); } }