Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −3 Original line number Diff line number Diff line Loading @@ -67,10 +67,8 @@ import com.android.telephony.Rlog; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CopyOnWriteArraySet; import java.util.stream.Collectors; /** *@hide Loading Loading @@ -1116,7 +1114,8 @@ public class SubscriptionInfoUpdater extends Handler { private int getEmbeddedProfilePortIndex(String iccId) { UiccSlot[] slots = UiccController.getInstance().getUiccSlots(); for (UiccSlot slot : slots) { if (slot != null && slot.isEuicc() && slot.isIccIdMappedToPortIndex(iccId)) { if (slot != null && slot.isEuicc() && slot.getPortIndexFromIccId(iccId) != TelephonyManager.INVALID_PORT_INDEX) { return slot.getPortIndexFromIccId(iccId); } } Loading src/java/com/android/internal/telephony/euicc/EuiccConnector.java +7 −4 Original line number Diff line number Diff line Loading @@ -235,6 +235,7 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { boolean mSwitchAfterDownload; boolean mForceDeactivateSim; DownloadCommandCallback mCallback; int mPortIndex; Bundle mResolvedBundle; } Loading Loading @@ -451,15 +452,16 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { /** Asynchronously download the given subscription. */ @VisibleForTesting(visibility = PACKAGE) public void downloadSubscription(int cardId, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, Bundle resolvedBundle, DownloadCommandCallback callback) { public void downloadSubscription(int cardId, int portIndex, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, Bundle resolvedBundle, DownloadCommandCallback callback) { DownloadRequest request = new DownloadRequest(); request.mSubscription = subscription; request.mSwitchAfterDownload = switchAfterDownload; request.mForceDeactivateSim = forceDeactivateSim; request.mResolvedBundle = resolvedBundle; request.mCallback = callback; request.mPortIndex = portIndex; sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, cardId, 0 /* arg2 */, request); } Loading Loading @@ -759,7 +761,8 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { } case CMD_DOWNLOAD_SUBSCRIPTION: { DownloadRequest request = (DownloadRequest) message.obj; mEuiccService.downloadSubscription(slotId, 0, mEuiccService.downloadSubscription(slotId, request.mPortIndex, request.mSubscription, request.mSwitchAfterDownload, request.mForceDeactivateSim, Loading src/java/com/android/internal/telephony/euicc/EuiccController.java +79 −39 Original line number Diff line number Diff line Loading @@ -426,13 +426,14 @@ public class EuiccController extends IEuiccController.Stub { break; case EuiccService.RESULT_MUST_DEACTIVATE_SIM: resultCode = RESOLVABLE_ERROR; addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, getOperationForDeactivateSim(), cardId); cardId, TelephonyManager.DEFAULT_PORT_INDEX, false /* usePortIndex */); break; default: resultCode = ERROR; Loading @@ -458,8 +459,13 @@ public class EuiccController extends IEuiccController.Stub { public void downloadSubscription(int cardId, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, Bundle resolvedBundle, PendingIntent callbackIntent) { downloadSubscription(cardId, subscription, switchAfterDownload, callingPackage, false /* forceDeactivateSim */, resolvedBundle, callbackIntent); // If switchAfterDownload is true, set portIndex as // {@link android.telephony.TelephonyManager#INVALID_PORT_INDEX} to resolve the port index. int portIndex = switchAfterDownload ? TelephonyManager.INVALID_PORT_INDEX : TelephonyManager.DEFAULT_PORT_INDEX; downloadSubscription(cardId, portIndex, subscription, switchAfterDownload, callingPackage, false /* forceDeactivateSim */, resolvedBundle, callbackIntent); } /** Loading Loading @@ -541,7 +547,7 @@ public class EuiccController extends IEuiccController.Stub { } } void downloadSubscription(int cardId, DownloadableSubscription subscription, void downloadSubscription(int cardId, int portIndex, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, Bundle resolvedBundle, PendingIntent callbackIntent) { boolean callerCanWriteEmbeddedSubscriptions = callerCanWriteEmbeddedSubscriptions(); Loading @@ -549,11 +555,24 @@ public class EuiccController extends IEuiccController.Stub { long token = Binder.clearCallingIdentity(); try { if (callerCanWriteEmbeddedSubscriptions) { boolean isConsentNeededToResolvePortIndex = false; if (switchAfterDownload && portIndex == TelephonyManager.INVALID_PORT_INDEX) { // If switchAfterDownload is true, resolve the portIndex portIndex = getResolvedPortIndexForSubscriptionSwitch(cardId); isConsentNeededToResolvePortIndex = (portIndex == TelephonyManager.INVALID_PORT_INDEX); } Log.d(TAG, " downloadSubscription cardId: " + cardId + " switchAfterDownload: " + switchAfterDownload + " portIndex: " + portIndex + " forceDeactivateSim: " + forceDeactivateSim + " callingPackage: " + callingPackage + " isConsentNeededToResolvePortIndex: " + isConsentNeededToResolvePortIndex); if (!isConsentNeededToResolvePortIndex && callerCanWriteEmbeddedSubscriptions) { // With WRITE_EMBEDDED_SUBSCRIPTIONS, we can skip profile-specific permission checks // and move straight to the profile download. downloadSubscriptionPrivileged(cardId, token, subscription, switchAfterDownload, forceDeactivateSim, callingPackage, resolvedBundle, callbackIntent); downloadSubscriptionPrivileged(cardId, portIndex, token, subscription, switchAfterDownload, forceDeactivateSim, callingPackage, resolvedBundle, callbackIntent); return; } Loading @@ -567,24 +586,27 @@ public class EuiccController extends IEuiccController.Stub { // Otherwise, the user must provide consent. If it's a single-active SIM device, // determine whether the caller can manage the current profile; if so, we can perform // the download silently; if not, the user must provide consent. if (canManageSubscriptionOnTargetSim(cardId, callingPackage, false, TelephonyManager.INVALID_PORT_INDEX)) { if (!isConsentNeededToResolvePortIndex && canManageSubscriptionOnTargetSim(cardId, callingPackage, true, portIndex)) { mConnector.getDownloadableSubscriptionMetadata(cardId, subscription, forceDeactivateSim, new DownloadSubscriptionGetMetadataCommandCallback(token, subscription, switchAfterDownload, callingPackage, forceDeactivateSim, callbackIntent, false /* withUserConsent */)); callbackIntent, false /* withUserConsent */, portIndex)); } else { Log.i(TAG, "Caller can't manage subscription on target SIM. " Log.i(TAG, "Caller can't manage subscription on target SIM or " + " User consent is required for resolving port index. " + "Ask user's consent first"); Intent extrasIntent = new Intent(); addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadNoPrivilegesOrDeactivateSimCheckMetadata(token, subscription, switchAfterDownload, callingPackage), cardId); subscription, switchAfterDownload, callingPackage), cardId, portIndex, switchAfterDownload /* usePortIndex */); sendResult(callbackIntent, RESOLVABLE_ERROR, extrasIntent); } } finally { Loading @@ -596,15 +618,17 @@ public class EuiccController extends IEuiccController.Stub { private final boolean mSwitchAfterDownload; private final boolean mForceDeactivateSim; private final boolean mWithUserConsent; private final int mPortIndex; DownloadSubscriptionGetMetadataCommandCallback(long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, PendingIntent callbackIntent, boolean withUserConsent) { PendingIntent callbackIntent, boolean withUserConsent, int portIndex) { super(callingToken, subscription, callingPackage, callbackIntent); mSwitchAfterDownload = switchAfterDownload; mForceDeactivateSim = forceDeactivateSim; mWithUserConsent = withUserConsent; mPortIndex = portIndex; } @Override Loading @@ -622,7 +646,7 @@ public class EuiccController extends IEuiccController.Stub { if (checkCarrierPrivilegeInMetadata(subscription, mCallingPackage)) { // Caller can download this profile. Since we already have the user's consent, // proceed to download. downloadSubscriptionPrivileged(cardId, downloadSubscriptionPrivileged(cardId, mPortIndex, mCallingToken, subscription, mSwitchAfterDownload, mForceDeactivateSim, mCallingPackage, null /* resolvedBundle */, mCallbackIntent); Loading @@ -635,7 +659,7 @@ public class EuiccController extends IEuiccController.Stub { // The caller can manage the target SIM. Ask the user's consent to deactivate // the current SIM. Intent extrasIntent = new Intent(); addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, 0 /* resolvableErrors */, Loading @@ -643,7 +667,7 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadNoPrivilegesOrDeactivateSimCheckMetadata( mCallingToken, mSubscription, mSwitchAfterDownload, mCallingPackage), cardId); cardId, mPortIndex, mSwitchAfterDownload /* usePortIndex */); sendResult(mCallbackIntent, RESOLVABLE_ERROR, extrasIntent); return; } Loading @@ -657,7 +681,7 @@ public class EuiccController extends IEuiccController.Stub { if (checkCarrierPrivilegeInMetadata(subscription, mCallingPackage)) { // Caller can download this profile per profile metadata. Also, caller can // manage the subscription on the target SIM, which is already checked. downloadSubscriptionPrivileged(cardId, downloadSubscriptionPrivileged(cardId, mPortIndex, mCallingToken, subscription, mSwitchAfterDownload, mForceDeactivateSim, mCallingPackage, null /* resolvedBundle */, mCallbackIntent); Loading @@ -670,23 +694,27 @@ public class EuiccController extends IEuiccController.Stub { } // Already have user consent. Check metadata first before proceed to download. void downloadSubscriptionPrivilegedCheckMetadata(int cardId, final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { void downloadSubscriptionPrivilegedCheckMetadata(int cardId, int portIndex, final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { Log.d(TAG, " downloadSubscriptionPrivilegedCheckMetadata cardId: " + cardId + " switchAfterDownload: " + switchAfterDownload + " portIndex: " + portIndex + " forceDeactivateSim: " + forceDeactivateSim); mConnector.getDownloadableSubscriptionMetadata(cardId, subscription, forceDeactivateSim, new DownloadSubscriptionGetMetadataCommandCallback(callingToken, subscription, switchAfterDownload, callingPackage, forceDeactivateSim, callbackIntent, true /* withUserConsent */)); true /* withUserConsent */, portIndex)); } // Continue to download subscription without checking anything. void downloadSubscriptionPrivileged(int cardId, final long callingToken, void downloadSubscriptionPrivileged(int cardId, int portIndex, final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { mConnector.downloadSubscription( cardId, portIndex, subscription, switchAfterDownload, forceDeactivateSim, Loading Loading @@ -718,7 +746,7 @@ public class EuiccController extends IEuiccController.Stub { break; case EuiccService.RESULT_MUST_DEACTIVATE_SIM: resultCode = RESOLVABLE_ERROR; addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, callingPackage, 0 /* resolvableErrors */, Loading @@ -726,7 +754,8 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadDeactivateSim( callingToken, subscription, switchAfterDownload, callingPackage), cardId); cardId, portIndex, switchAfterDownload /* usePortIndex */); break; case EuiccService.RESULT_RESOLVABLE_ERRORS: // Same value as the deprecated Loading @@ -739,7 +768,7 @@ public class EuiccController extends IEuiccController.Stub { retried = true; } if (result.getResolvableErrors() != 0) { addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_RESOLVABLE_ERRORS, callingPackage, result.getResolvableErrors(), Loading @@ -747,9 +776,10 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadResolvableErrors( callingToken, subscription, switchAfterDownload, callingPackage, result.getResolvableErrors()), cardId); cardId, portIndex, switchAfterDownload /* usePortIndex */); } else { // Deprecated case addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE, callingPackage, 0 /* resolvableErrors */, Loading @@ -757,7 +787,8 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadConfirmationCode( callingToken, subscription, switchAfterDownload, callingPackage), cardId); cardId, portIndex, switchAfterDownload /* usePortIndex */); } break; default: Loading Loading @@ -863,14 +894,15 @@ public class EuiccController extends IEuiccController.Stub { break; case EuiccService.RESULT_MUST_DEACTIVATE_SIM: resultCode = RESOLVABLE_ERROR; addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, EuiccOperation.forGetDefaultListDeactivateSim( mCallingToken, mCallingPackage), cardId); cardId, TelephonyManager.DEFAULT_PORT_INDEX, false /* usePortIndex */); break; default: resultCode = ERROR; Loading Loading @@ -1128,6 +1160,14 @@ public class EuiccController extends IEuiccController.Stub { int slotIndex = getSlotIndexFromCardId(cardId); // Euicc Slot UiccSlot slot = UiccController.getInstance().getUiccSlot(slotIndex); if (slot == null) { // Check is to make sure crash is avoided in case of slot is null. Log.d(TAG, "Switch to inactive slot, return default port index. slotIndex: " + slotIndex); // This case happens when device is in SS pSIM mode and carrier apps calls // downloadSubscription with switchAfterDownload is set to true. return TelephonyManager.DEFAULT_PORT_INDEX; } if (!slot.isMultipleEnabledProfileSupported()) { Log.d(TAG, "Multiple enabled profiles is not supported, return default port index"); return TelephonyManager.DEFAULT_PORT_INDEX; Loading Loading @@ -1531,14 +1571,14 @@ public class EuiccController extends IEuiccController.Stub { } } /** Add a resolution intent to the given extras intent with the default port index 0 */ public void addResolutionIntentForDefaultPort(Intent extrasIntent, String resolutionAction, /** Add a resolution intent to the given extras intent with invalid subscriptionId */ public void addResolutionIntentWithPort(Intent extrasIntent, String resolutionAction, String callingPackage, int resolvableErrors, boolean confirmationCodeRetried, EuiccOperation op, int cardId) { // use the default port 0 when not specified EuiccOperation op, int cardId, int portIndex, boolean usePortIndex) { // use invalid subscriptionId in case of download/metadata flow addResolutionIntent(extrasIntent, resolutionAction, callingPackage, resolvableErrors, confirmationCodeRetried, op, cardId, TelephonyManager.DEFAULT_PORT_INDEX, false /* usePortIndex */, SubscriptionManager.INVALID_SUBSCRIPTION_ID); confirmationCodeRetried, op, cardId, portIndex, usePortIndex /* usePortIndex */, SubscriptionManager.INVALID_SUBSCRIPTION_ID); } /** Add a resolution intent to the given extras intent. */ Loading src/java/com/android/internal/telephony/euicc/EuiccOperation.java +18 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.service.euicc.EuiccService; import android.telephony.TelephonyManager; import android.telephony.euicc.DownloadableSubscription; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; Loading Loading @@ -276,6 +277,8 @@ public class EuiccOperation implements Parcelable { break; case ACTION_DOWNLOAD_DEACTIVATE_SIM: resolvedDownloadDeactivateSim(cardId, resolutionExtras.getInt(EuiccService.EXTRA_RESOLUTION_PORT_INDEX, TelephonyManager.DEFAULT_PORT_INDEX), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), callbackIntent); break; Loading @@ -286,6 +289,8 @@ public class EuiccOperation implements Parcelable { break; case ACTION_DOWNLOAD_NO_PRIVILEGES_OR_DEACTIVATE_SIM_CHECK_METADATA: resolvedDownloadNoPrivilegesOrDeactivateSimCheckMetadata(cardId, resolutionExtras.getInt(EuiccService.EXTRA_RESOLUTION_PORT_INDEX, TelephonyManager.DEFAULT_PORT_INDEX), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), callbackIntent); break; Loading Loading @@ -353,13 +358,14 @@ public class EuiccOperation implements Parcelable { } } private void resolvedDownloadDeactivateSim(int cardId, boolean consent, private void resolvedDownloadDeactivateSim(int cardId, int portIndex, boolean consent, PendingIntent callbackIntent) { if (consent) { // User has consented; perform the download, but this time, tell the LPA to deactivate // any required active SIMs. EuiccController.get().downloadSubscription( cardId, portIndex, mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, Loading @@ -382,8 +388,12 @@ public class EuiccOperation implements Parcelable { // privilege prompt should also cover permission to deactivate an active SIM, as // the privilege prompt makes it clear that we're switching from the current // carrier. // Action {@link #ACTION_DOWNLOAD_NO_PRIVILEGES} is no more used in platform,this // method will never get called, pass {@link TelephonyManager#DEFAULT_PORT_INDEX} // as portIndex. EuiccController.get().downloadSubscriptionPrivileged( cardId, TelephonyManager.DEFAULT_PORT_INDEX, token, mDownloadableSubscription, mSwitchAfterDownload, Loading @@ -401,7 +411,7 @@ public class EuiccOperation implements Parcelable { } private void resolvedDownloadNoPrivilegesOrDeactivateSimCheckMetadata(int cardId, boolean consent, PendingIntent callbackIntent) { int portIndex, boolean consent, PendingIntent callbackIntent) { if (consent) { // User has consented; perform the download with full privileges. long token = Binder.clearCallingIdentity(); Loading @@ -412,6 +422,7 @@ public class EuiccOperation implements Parcelable { // carrier. EuiccController.get().downloadSubscriptionPrivilegedCheckMetadata( cardId, portIndex, token, mDownloadableSubscription, mSwitchAfterDownload, Loading Loading @@ -439,8 +450,11 @@ public class EuiccOperation implements Parcelable { fail(callbackIntent); } else { mDownloadableSubscription.setConfirmationCode(confirmationCode); // Action {@link #ACTION_DOWNLOAD_CONFIRMATION_CODE} is not any more used from LPA with // targetSDK >=Q, pass {@link TelephonyManager#DEFAULT_PORT_INDEX} as portIndex. EuiccController.get().downloadSubscription( cardId, TelephonyManager.DEFAULT_PORT_INDEX, mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, Loading Loading @@ -475,6 +489,8 @@ public class EuiccOperation implements Parcelable { mDownloadableSubscription.setConfirmationCode(confirmationCode); EuiccController.get().downloadSubscription( cardId, resolvedBundle.getInt(EuiccService.EXTRA_RESOLUTION_PORT_INDEX, TelephonyManager.DEFAULT_PORT_INDEX), mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, Loading src/java/com/android/internal/telephony/uicc/UiccSlot.java +0 −6 Original line number Diff line number Diff line Loading @@ -255,12 +255,6 @@ public class UiccSlot extends Handler { } } public boolean isIccIdMappedToPortIndex(String iccId) { synchronized (mLock) { return mIccIds.containsValue(iccId); } } public int getPortIndexFromIccId(String iccId) { synchronized (mLock) { for (Map.Entry<Integer, String> entry : mIccIds.entrySet()) { Loading Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −3 Original line number Diff line number Diff line Loading @@ -67,10 +67,8 @@ import com.android.telephony.Rlog; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CopyOnWriteArraySet; import java.util.stream.Collectors; /** *@hide Loading Loading @@ -1116,7 +1114,8 @@ public class SubscriptionInfoUpdater extends Handler { private int getEmbeddedProfilePortIndex(String iccId) { UiccSlot[] slots = UiccController.getInstance().getUiccSlots(); for (UiccSlot slot : slots) { if (slot != null && slot.isEuicc() && slot.isIccIdMappedToPortIndex(iccId)) { if (slot != null && slot.isEuicc() && slot.getPortIndexFromIccId(iccId) != TelephonyManager.INVALID_PORT_INDEX) { return slot.getPortIndexFromIccId(iccId); } } Loading
src/java/com/android/internal/telephony/euicc/EuiccConnector.java +7 −4 Original line number Diff line number Diff line Loading @@ -235,6 +235,7 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { boolean mSwitchAfterDownload; boolean mForceDeactivateSim; DownloadCommandCallback mCallback; int mPortIndex; Bundle mResolvedBundle; } Loading Loading @@ -451,15 +452,16 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { /** Asynchronously download the given subscription. */ @VisibleForTesting(visibility = PACKAGE) public void downloadSubscription(int cardId, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, Bundle resolvedBundle, DownloadCommandCallback callback) { public void downloadSubscription(int cardId, int portIndex, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, Bundle resolvedBundle, DownloadCommandCallback callback) { DownloadRequest request = new DownloadRequest(); request.mSubscription = subscription; request.mSwitchAfterDownload = switchAfterDownload; request.mForceDeactivateSim = forceDeactivateSim; request.mResolvedBundle = resolvedBundle; request.mCallback = callback; request.mPortIndex = portIndex; sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, cardId, 0 /* arg2 */, request); } Loading Loading @@ -759,7 +761,8 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { } case CMD_DOWNLOAD_SUBSCRIPTION: { DownloadRequest request = (DownloadRequest) message.obj; mEuiccService.downloadSubscription(slotId, 0, mEuiccService.downloadSubscription(slotId, request.mPortIndex, request.mSubscription, request.mSwitchAfterDownload, request.mForceDeactivateSim, Loading
src/java/com/android/internal/telephony/euicc/EuiccController.java +79 −39 Original line number Diff line number Diff line Loading @@ -426,13 +426,14 @@ public class EuiccController extends IEuiccController.Stub { break; case EuiccService.RESULT_MUST_DEACTIVATE_SIM: resultCode = RESOLVABLE_ERROR; addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, getOperationForDeactivateSim(), cardId); cardId, TelephonyManager.DEFAULT_PORT_INDEX, false /* usePortIndex */); break; default: resultCode = ERROR; Loading @@ -458,8 +459,13 @@ public class EuiccController extends IEuiccController.Stub { public void downloadSubscription(int cardId, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, Bundle resolvedBundle, PendingIntent callbackIntent) { downloadSubscription(cardId, subscription, switchAfterDownload, callingPackage, false /* forceDeactivateSim */, resolvedBundle, callbackIntent); // If switchAfterDownload is true, set portIndex as // {@link android.telephony.TelephonyManager#INVALID_PORT_INDEX} to resolve the port index. int portIndex = switchAfterDownload ? TelephonyManager.INVALID_PORT_INDEX : TelephonyManager.DEFAULT_PORT_INDEX; downloadSubscription(cardId, portIndex, subscription, switchAfterDownload, callingPackage, false /* forceDeactivateSim */, resolvedBundle, callbackIntent); } /** Loading Loading @@ -541,7 +547,7 @@ public class EuiccController extends IEuiccController.Stub { } } void downloadSubscription(int cardId, DownloadableSubscription subscription, void downloadSubscription(int cardId, int portIndex, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, Bundle resolvedBundle, PendingIntent callbackIntent) { boolean callerCanWriteEmbeddedSubscriptions = callerCanWriteEmbeddedSubscriptions(); Loading @@ -549,11 +555,24 @@ public class EuiccController extends IEuiccController.Stub { long token = Binder.clearCallingIdentity(); try { if (callerCanWriteEmbeddedSubscriptions) { boolean isConsentNeededToResolvePortIndex = false; if (switchAfterDownload && portIndex == TelephonyManager.INVALID_PORT_INDEX) { // If switchAfterDownload is true, resolve the portIndex portIndex = getResolvedPortIndexForSubscriptionSwitch(cardId); isConsentNeededToResolvePortIndex = (portIndex == TelephonyManager.INVALID_PORT_INDEX); } Log.d(TAG, " downloadSubscription cardId: " + cardId + " switchAfterDownload: " + switchAfterDownload + " portIndex: " + portIndex + " forceDeactivateSim: " + forceDeactivateSim + " callingPackage: " + callingPackage + " isConsentNeededToResolvePortIndex: " + isConsentNeededToResolvePortIndex); if (!isConsentNeededToResolvePortIndex && callerCanWriteEmbeddedSubscriptions) { // With WRITE_EMBEDDED_SUBSCRIPTIONS, we can skip profile-specific permission checks // and move straight to the profile download. downloadSubscriptionPrivileged(cardId, token, subscription, switchAfterDownload, forceDeactivateSim, callingPackage, resolvedBundle, callbackIntent); downloadSubscriptionPrivileged(cardId, portIndex, token, subscription, switchAfterDownload, forceDeactivateSim, callingPackage, resolvedBundle, callbackIntent); return; } Loading @@ -567,24 +586,27 @@ public class EuiccController extends IEuiccController.Stub { // Otherwise, the user must provide consent. If it's a single-active SIM device, // determine whether the caller can manage the current profile; if so, we can perform // the download silently; if not, the user must provide consent. if (canManageSubscriptionOnTargetSim(cardId, callingPackage, false, TelephonyManager.INVALID_PORT_INDEX)) { if (!isConsentNeededToResolvePortIndex && canManageSubscriptionOnTargetSim(cardId, callingPackage, true, portIndex)) { mConnector.getDownloadableSubscriptionMetadata(cardId, subscription, forceDeactivateSim, new DownloadSubscriptionGetMetadataCommandCallback(token, subscription, switchAfterDownload, callingPackage, forceDeactivateSim, callbackIntent, false /* withUserConsent */)); callbackIntent, false /* withUserConsent */, portIndex)); } else { Log.i(TAG, "Caller can't manage subscription on target SIM. " Log.i(TAG, "Caller can't manage subscription on target SIM or " + " User consent is required for resolving port index. " + "Ask user's consent first"); Intent extrasIntent = new Intent(); addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadNoPrivilegesOrDeactivateSimCheckMetadata(token, subscription, switchAfterDownload, callingPackage), cardId); subscription, switchAfterDownload, callingPackage), cardId, portIndex, switchAfterDownload /* usePortIndex */); sendResult(callbackIntent, RESOLVABLE_ERROR, extrasIntent); } } finally { Loading @@ -596,15 +618,17 @@ public class EuiccController extends IEuiccController.Stub { private final boolean mSwitchAfterDownload; private final boolean mForceDeactivateSim; private final boolean mWithUserConsent; private final int mPortIndex; DownloadSubscriptionGetMetadataCommandCallback(long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, PendingIntent callbackIntent, boolean withUserConsent) { PendingIntent callbackIntent, boolean withUserConsent, int portIndex) { super(callingToken, subscription, callingPackage, callbackIntent); mSwitchAfterDownload = switchAfterDownload; mForceDeactivateSim = forceDeactivateSim; mWithUserConsent = withUserConsent; mPortIndex = portIndex; } @Override Loading @@ -622,7 +646,7 @@ public class EuiccController extends IEuiccController.Stub { if (checkCarrierPrivilegeInMetadata(subscription, mCallingPackage)) { // Caller can download this profile. Since we already have the user's consent, // proceed to download. downloadSubscriptionPrivileged(cardId, downloadSubscriptionPrivileged(cardId, mPortIndex, mCallingToken, subscription, mSwitchAfterDownload, mForceDeactivateSim, mCallingPackage, null /* resolvedBundle */, mCallbackIntent); Loading @@ -635,7 +659,7 @@ public class EuiccController extends IEuiccController.Stub { // The caller can manage the target SIM. Ask the user's consent to deactivate // the current SIM. Intent extrasIntent = new Intent(); addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, 0 /* resolvableErrors */, Loading @@ -643,7 +667,7 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadNoPrivilegesOrDeactivateSimCheckMetadata( mCallingToken, mSubscription, mSwitchAfterDownload, mCallingPackage), cardId); cardId, mPortIndex, mSwitchAfterDownload /* usePortIndex */); sendResult(mCallbackIntent, RESOLVABLE_ERROR, extrasIntent); return; } Loading @@ -657,7 +681,7 @@ public class EuiccController extends IEuiccController.Stub { if (checkCarrierPrivilegeInMetadata(subscription, mCallingPackage)) { // Caller can download this profile per profile metadata. Also, caller can // manage the subscription on the target SIM, which is already checked. downloadSubscriptionPrivileged(cardId, downloadSubscriptionPrivileged(cardId, mPortIndex, mCallingToken, subscription, mSwitchAfterDownload, mForceDeactivateSim, mCallingPackage, null /* resolvedBundle */, mCallbackIntent); Loading @@ -670,23 +694,27 @@ public class EuiccController extends IEuiccController.Stub { } // Already have user consent. Check metadata first before proceed to download. void downloadSubscriptionPrivilegedCheckMetadata(int cardId, final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { void downloadSubscriptionPrivilegedCheckMetadata(int cardId, int portIndex, final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { Log.d(TAG, " downloadSubscriptionPrivilegedCheckMetadata cardId: " + cardId + " switchAfterDownload: " + switchAfterDownload + " portIndex: " + portIndex + " forceDeactivateSim: " + forceDeactivateSim); mConnector.getDownloadableSubscriptionMetadata(cardId, subscription, forceDeactivateSim, new DownloadSubscriptionGetMetadataCommandCallback(callingToken, subscription, switchAfterDownload, callingPackage, forceDeactivateSim, callbackIntent, true /* withUserConsent */)); true /* withUserConsent */, portIndex)); } // Continue to download subscription without checking anything. void downloadSubscriptionPrivileged(int cardId, final long callingToken, void downloadSubscriptionPrivileged(int cardId, int portIndex, final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { mConnector.downloadSubscription( cardId, portIndex, subscription, switchAfterDownload, forceDeactivateSim, Loading Loading @@ -718,7 +746,7 @@ public class EuiccController extends IEuiccController.Stub { break; case EuiccService.RESULT_MUST_DEACTIVATE_SIM: resultCode = RESOLVABLE_ERROR; addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, callingPackage, 0 /* resolvableErrors */, Loading @@ -726,7 +754,8 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadDeactivateSim( callingToken, subscription, switchAfterDownload, callingPackage), cardId); cardId, portIndex, switchAfterDownload /* usePortIndex */); break; case EuiccService.RESULT_RESOLVABLE_ERRORS: // Same value as the deprecated Loading @@ -739,7 +768,7 @@ public class EuiccController extends IEuiccController.Stub { retried = true; } if (result.getResolvableErrors() != 0) { addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_RESOLVABLE_ERRORS, callingPackage, result.getResolvableErrors(), Loading @@ -747,9 +776,10 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadResolvableErrors( callingToken, subscription, switchAfterDownload, callingPackage, result.getResolvableErrors()), cardId); cardId, portIndex, switchAfterDownload /* usePortIndex */); } else { // Deprecated case addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE, callingPackage, 0 /* resolvableErrors */, Loading @@ -757,7 +787,8 @@ public class EuiccController extends IEuiccController.Stub { EuiccOperation.forDownloadConfirmationCode( callingToken, subscription, switchAfterDownload, callingPackage), cardId); cardId, portIndex, switchAfterDownload /* usePortIndex */); } break; default: Loading Loading @@ -863,14 +894,15 @@ public class EuiccController extends IEuiccController.Stub { break; case EuiccService.RESULT_MUST_DEACTIVATE_SIM: resultCode = RESOLVABLE_ERROR; addResolutionIntentForDefaultPort(extrasIntent, addResolutionIntentWithPort(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, EuiccOperation.forGetDefaultListDeactivateSim( mCallingToken, mCallingPackage), cardId); cardId, TelephonyManager.DEFAULT_PORT_INDEX, false /* usePortIndex */); break; default: resultCode = ERROR; Loading Loading @@ -1128,6 +1160,14 @@ public class EuiccController extends IEuiccController.Stub { int slotIndex = getSlotIndexFromCardId(cardId); // Euicc Slot UiccSlot slot = UiccController.getInstance().getUiccSlot(slotIndex); if (slot == null) { // Check is to make sure crash is avoided in case of slot is null. Log.d(TAG, "Switch to inactive slot, return default port index. slotIndex: " + slotIndex); // This case happens when device is in SS pSIM mode and carrier apps calls // downloadSubscription with switchAfterDownload is set to true. return TelephonyManager.DEFAULT_PORT_INDEX; } if (!slot.isMultipleEnabledProfileSupported()) { Log.d(TAG, "Multiple enabled profiles is not supported, return default port index"); return TelephonyManager.DEFAULT_PORT_INDEX; Loading Loading @@ -1531,14 +1571,14 @@ public class EuiccController extends IEuiccController.Stub { } } /** Add a resolution intent to the given extras intent with the default port index 0 */ public void addResolutionIntentForDefaultPort(Intent extrasIntent, String resolutionAction, /** Add a resolution intent to the given extras intent with invalid subscriptionId */ public void addResolutionIntentWithPort(Intent extrasIntent, String resolutionAction, String callingPackage, int resolvableErrors, boolean confirmationCodeRetried, EuiccOperation op, int cardId) { // use the default port 0 when not specified EuiccOperation op, int cardId, int portIndex, boolean usePortIndex) { // use invalid subscriptionId in case of download/metadata flow addResolutionIntent(extrasIntent, resolutionAction, callingPackage, resolvableErrors, confirmationCodeRetried, op, cardId, TelephonyManager.DEFAULT_PORT_INDEX, false /* usePortIndex */, SubscriptionManager.INVALID_SUBSCRIPTION_ID); confirmationCodeRetried, op, cardId, portIndex, usePortIndex /* usePortIndex */, SubscriptionManager.INVALID_SUBSCRIPTION_ID); } /** Add a resolution intent to the given extras intent. */ Loading
src/java/com/android/internal/telephony/euicc/EuiccOperation.java +18 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.service.euicc.EuiccService; import android.telephony.TelephonyManager; import android.telephony.euicc.DownloadableSubscription; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; Loading Loading @@ -276,6 +277,8 @@ public class EuiccOperation implements Parcelable { break; case ACTION_DOWNLOAD_DEACTIVATE_SIM: resolvedDownloadDeactivateSim(cardId, resolutionExtras.getInt(EuiccService.EXTRA_RESOLUTION_PORT_INDEX, TelephonyManager.DEFAULT_PORT_INDEX), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), callbackIntent); break; Loading @@ -286,6 +289,8 @@ public class EuiccOperation implements Parcelable { break; case ACTION_DOWNLOAD_NO_PRIVILEGES_OR_DEACTIVATE_SIM_CHECK_METADATA: resolvedDownloadNoPrivilegesOrDeactivateSimCheckMetadata(cardId, resolutionExtras.getInt(EuiccService.EXTRA_RESOLUTION_PORT_INDEX, TelephonyManager.DEFAULT_PORT_INDEX), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), callbackIntent); break; Loading Loading @@ -353,13 +358,14 @@ public class EuiccOperation implements Parcelable { } } private void resolvedDownloadDeactivateSim(int cardId, boolean consent, private void resolvedDownloadDeactivateSim(int cardId, int portIndex, boolean consent, PendingIntent callbackIntent) { if (consent) { // User has consented; perform the download, but this time, tell the LPA to deactivate // any required active SIMs. EuiccController.get().downloadSubscription( cardId, portIndex, mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, Loading @@ -382,8 +388,12 @@ public class EuiccOperation implements Parcelable { // privilege prompt should also cover permission to deactivate an active SIM, as // the privilege prompt makes it clear that we're switching from the current // carrier. // Action {@link #ACTION_DOWNLOAD_NO_PRIVILEGES} is no more used in platform,this // method will never get called, pass {@link TelephonyManager#DEFAULT_PORT_INDEX} // as portIndex. EuiccController.get().downloadSubscriptionPrivileged( cardId, TelephonyManager.DEFAULT_PORT_INDEX, token, mDownloadableSubscription, mSwitchAfterDownload, Loading @@ -401,7 +411,7 @@ public class EuiccOperation implements Parcelable { } private void resolvedDownloadNoPrivilegesOrDeactivateSimCheckMetadata(int cardId, boolean consent, PendingIntent callbackIntent) { int portIndex, boolean consent, PendingIntent callbackIntent) { if (consent) { // User has consented; perform the download with full privileges. long token = Binder.clearCallingIdentity(); Loading @@ -412,6 +422,7 @@ public class EuiccOperation implements Parcelable { // carrier. EuiccController.get().downloadSubscriptionPrivilegedCheckMetadata( cardId, portIndex, token, mDownloadableSubscription, mSwitchAfterDownload, Loading Loading @@ -439,8 +450,11 @@ public class EuiccOperation implements Parcelable { fail(callbackIntent); } else { mDownloadableSubscription.setConfirmationCode(confirmationCode); // Action {@link #ACTION_DOWNLOAD_CONFIRMATION_CODE} is not any more used from LPA with // targetSDK >=Q, pass {@link TelephonyManager#DEFAULT_PORT_INDEX} as portIndex. EuiccController.get().downloadSubscription( cardId, TelephonyManager.DEFAULT_PORT_INDEX, mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, Loading Loading @@ -475,6 +489,8 @@ public class EuiccOperation implements Parcelable { mDownloadableSubscription.setConfirmationCode(confirmationCode); EuiccController.get().downloadSubscription( cardId, resolvedBundle.getInt(EuiccService.EXTRA_RESOLUTION_PORT_INDEX, TelephonyManager.DEFAULT_PORT_INDEX), mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, Loading
src/java/com/android/internal/telephony/uicc/UiccSlot.java +0 −6 Original line number Diff line number Diff line Loading @@ -255,12 +255,6 @@ public class UiccSlot extends Handler { } } public boolean isIccIdMappedToPortIndex(String iccId) { synchronized (mLock) { return mIccIds.containsValue(iccId); } } public int getPortIndexFromIccId(String iccId) { synchronized (mLock) { for (Map.Entry<Integer, String> entry : mIccIds.entrySet()) { Loading