Loading src/java/com/android/internal/telephony/euicc/EuiccConnector.java +9 −4 Original line number Original line Diff line number Diff line Loading @@ -30,10 +30,12 @@ import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo; import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.RemoteException; import android.os.RemoteException; import android.service.euicc.DownloadSubscriptionResult; import android.service.euicc.EuiccService; import android.service.euicc.EuiccService; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; Loading Loading @@ -225,13 +227,14 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { boolean mSwitchAfterDownload; boolean mSwitchAfterDownload; boolean mForceDeactivateSim; boolean mForceDeactivateSim; DownloadCommandCallback mCallback; DownloadCommandCallback mCallback; Bundle mResolvedBundle; } } /** Callback class for {@link #downloadSubscription}. */ /** Callback class for {@link #downloadSubscription}. */ @VisibleForTesting(visibility = PACKAGE) @VisibleForTesting(visibility = PACKAGE) public interface DownloadCommandCallback extends BaseEuiccCommandCallback { public interface DownloadCommandCallback extends BaseEuiccCommandCallback { /** Called when the download has completed (though it may have failed). */ /** Called when the download has completed (though it may have failed). */ void onDownloadComplete(int result); void onDownloadComplete(DownloadSubscriptionResult result); } } interface GetEuiccProfileInfoListCommandCallback extends BaseEuiccCommandCallback { interface GetEuiccProfileInfoListCommandCallback extends BaseEuiccCommandCallback { Loading Loading @@ -423,11 +426,12 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { @VisibleForTesting(visibility = PACKAGE) @VisibleForTesting(visibility = PACKAGE) public void downloadSubscription(DownloadableSubscription subscription, public void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, boolean switchAfterDownload, boolean forceDeactivateSim, DownloadCommandCallback callback) { Bundle resolvedBundle, DownloadCommandCallback callback) { DownloadRequest request = new DownloadRequest(); DownloadRequest request = new DownloadRequest(); request.mSubscription = subscription; request.mSubscription = subscription; request.mSwitchAfterDownload = switchAfterDownload; request.mSwitchAfterDownload = switchAfterDownload; request.mForceDeactivateSim = forceDeactivateSim; request.mForceDeactivateSim = forceDeactivateSim; request.mResolvedBundle = resolvedBundle; request.mCallback = callback; request.mCallback = callback; sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, request); sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, request); } } Loading Loading @@ -709,9 +713,10 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { request.mSubscription, request.mSubscription, request.mSwitchAfterDownload, request.mSwitchAfterDownload, request.mForceDeactivateSim, request.mForceDeactivateSim, request.mResolvedBundle, new IDownloadSubscriptionCallback.Stub() { new IDownloadSubscriptionCallback.Stub() { @Override @Override public void onComplete(int result) { public void onComplete(DownloadSubscriptionResult result) { sendMessage(CMD_COMMAND_COMPLETE, (Runnable) () -> { sendMessage(CMD_COMMAND_COMPLETE, (Runnable) () -> { ((DownloadCommandCallback) callback) ((DownloadCommandCallback) callback) .onDownloadComplete(result); .onDownloadComplete(result); Loading src/java/com/android/internal/telephony/euicc/EuiccController.java +51 −21 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.Bundle; import android.os.ServiceManager; import android.os.ServiceManager; import android.provider.Settings; import android.provider.Settings; import android.service.euicc.DownloadSubscriptionResult; import android.service.euicc.EuiccService; import android.service.euicc.EuiccService; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; Loading Loading @@ -274,6 +275,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, getOperationForDeactivateSim()); getOperationForDeactivateSim()); break; break; Loading Loading @@ -301,14 +303,15 @@ public class EuiccController extends IEuiccController.Stub { @Override @Override public void downloadSubscription(DownloadableSubscription subscription, public void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, PendingIntent callbackIntent) { boolean switchAfterDownload, String callingPackage, Bundle resolvedBundle, PendingIntent callbackIntent) { downloadSubscription(subscription, switchAfterDownload, callingPackage, downloadSubscription(subscription, switchAfterDownload, callingPackage, false /* forceDeactivateSim */, callbackIntent); false /* forceDeactivateSim */, resolvedBundle, callbackIntent); } } void downloadSubscription(DownloadableSubscription subscription, void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, PendingIntent callbackIntent) { Bundle resolvedBundle, PendingIntent callbackIntent) { boolean callerCanWriteEmbeddedSubscriptions = callerCanWriteEmbeddedSubscriptions(); boolean callerCanWriteEmbeddedSubscriptions = callerCanWriteEmbeddedSubscriptions(); mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage); mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage); Loading @@ -318,7 +321,7 @@ public class EuiccController extends IEuiccController.Stub { // With WRITE_EMBEDDED_SUBSCRIPTIONS, we can skip profile-specific permission checks // With WRITE_EMBEDDED_SUBSCRIPTIONS, we can skip profile-specific permission checks // and move straight to the profile download. // and move straight to the profile download. downloadSubscriptionPrivileged(token, subscription, switchAfterDownload, downloadSubscriptionPrivileged(token, subscription, switchAfterDownload, forceDeactivateSim, callingPackage, callbackIntent); forceDeactivateSim, callingPackage, resolvedBundle, callbackIntent); return; return; } } // Without WRITE_EMBEDDED_SUBSCRIPTIONS, the caller *must* be whitelisted per the // Without WRITE_EMBEDDED_SUBSCRIPTIONS, the caller *must* be whitelisted per the Loading Loading @@ -355,6 +358,7 @@ public class EuiccController extends IEuiccController.Stub { Intent extrasIntent = new Intent(); Intent extrasIntent = new Intent(); addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadNoPrivileges( EuiccOperation.forDownloadNoPrivileges( mCallingToken, mSubscription, mSwitchAfterDownload, mCallingToken, mSubscription, mSwitchAfterDownload, Loading Loading @@ -400,7 +404,8 @@ public class EuiccController extends IEuiccController.Stub { if (canManageActiveSubscription(mCallingPackage)) { if (canManageActiveSubscription(mCallingPackage)) { downloadSubscriptionPrivileged( downloadSubscriptionPrivileged( mCallingToken, subscription, mSwitchAfterDownload, mCallingToken, subscription, mSwitchAfterDownload, mForceDeactivateSim, mCallingPackage, mCallbackIntent); mForceDeactivateSim, mCallingPackage, null /* resolvedBundle */, mCallbackIntent); return; return; } } Loading @@ -408,6 +413,7 @@ public class EuiccController extends IEuiccController.Stub { Intent extrasIntent = new Intent(); Intent extrasIntent = new Intent(); addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadNoPrivileges( EuiccOperation.forDownloadNoPrivileges( mCallingToken, subscription, mSwitchAfterDownload, mCallingToken, subscription, mSwitchAfterDownload, Loading @@ -429,18 +435,19 @@ public class EuiccController extends IEuiccController.Stub { void downloadSubscriptionPrivileged(final long callingToken, void downloadSubscriptionPrivileged(final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { final PendingIntent callbackIntent) { mConnector.downloadSubscription( mConnector.downloadSubscription( subscription, subscription, switchAfterDownload, switchAfterDownload, forceDeactivateSim, forceDeactivateSim, resolvedBundle, new EuiccConnector.DownloadCommandCallback() { new EuiccConnector.DownloadCommandCallback() { @Override @Override public void onDownloadComplete(int result) { public void onDownloadComplete(DownloadSubscriptionResult result) { Intent extrasIntent = new Intent(); Intent extrasIntent = new Intent(); final int resultCode; final int resultCode; switch (result) { switch (result.getResult()) { case EuiccService.RESULT_OK: case EuiccService.RESULT_OK: resultCode = OK; resultCode = OK; // Now that a profile has been successfully downloaded, mark the // Now that a profile has been successfully downloaded, mark the Loading @@ -465,30 +472,47 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, callingPackage, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadDeactivateSim( EuiccOperation.forDownloadDeactivateSim( callingToken, subscription, switchAfterDownload, callingToken, subscription, switchAfterDownload, callingPackage)); callingPackage)); break; break; case EuiccService.RESULT_NEED_CONFIRMATION_CODE: case EuiccService.RESULT_RESOLVABLE_ERRORS: // Same value as the deprecated // {@link EuiccService#RESULT_NEED_CONFIRMATION_CODE}. For the // deprecated case, the resolvableErrors is set as 0 in // EuiccService. resultCode = RESOLVABLE_ERROR; resultCode = RESOLVABLE_ERROR; boolean retried = false; boolean retried = false; if (!TextUtils.isEmpty(subscription.getConfirmationCode())) { if (!TextUtils.isEmpty(subscription.getConfirmationCode())) { retried = true; retried = true; } } if (result.getResolvableErrors() != 0) { addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_RESOLVABLE_ERRORS, callingPackage, result.getResolvableErrors(), retried, EuiccOperation.forDownloadResolvableErrors( callingToken, subscription, switchAfterDownload, callingPackage, result.getResolvableErrors())); } else { // Deprecated case addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE, EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE, callingPackage, callingPackage, 0 /* resolvableErrors */, retried /* confirmationCodeRetried */, retried /* confirmationCodeRetried */, EuiccOperation.forDownloadConfirmationCode( EuiccOperation.forDownloadConfirmationCode( callingToken, subscription, switchAfterDownload, callingToken, subscription, switchAfterDownload, callingPackage)); callingPackage)); } break; break; default: default: resultCode = ERROR; resultCode = ERROR; extrasIntent.putExtra( extrasIntent.putExtra( EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE, EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE, result); result.getResult()); break; break; } } Loading Loading @@ -587,6 +611,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forGetDefaultListDeactivateSim( EuiccOperation.forGetDefaultListDeactivateSim( mCallingToken, mCallingPackage)); mCallingToken, mCallingPackage)); Loading Loading @@ -739,6 +764,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, callingPackage, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forSwitchNoPrivileges( EuiccOperation.forSwitchNoPrivileges( token, subscriptionId, callingPackage)); token, subscriptionId, callingPackage)); Loading Loading @@ -785,6 +811,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, callingPackage, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forSwitchDeactivateSim( EuiccOperation.forSwitchDeactivateSim( callingToken, subscriptionId, callingPackage)); callingToken, subscriptionId, callingPackage)); Loading Loading @@ -953,11 +980,14 @@ public class EuiccController extends IEuiccController.Stub { /** Add a resolution intent to the given extras intent. */ /** Add a resolution intent to the given extras intent. */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void addResolutionIntent(Intent extrasIntent, String resolutionAction, public void addResolutionIntent(Intent extrasIntent, String resolutionAction, String callingPackage, boolean confirmationCodeRetried, EuiccOperation op) { String callingPackage, int resolvableErrors, boolean confirmationCodeRetried, EuiccOperation op) { Intent intent = new Intent(EuiccManager.ACTION_RESOLVE_ERROR); Intent intent = new Intent(EuiccManager.ACTION_RESOLVE_ERROR); intent.putExtra(EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_ACTION, intent.putExtra(EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_ACTION, resolutionAction); resolutionAction); intent.putExtra(EuiccService.EXTRA_RESOLUTION_CALLING_PACKAGE, callingPackage); intent.putExtra(EuiccService.EXTRA_RESOLUTION_CALLING_PACKAGE, callingPackage); // TODO(jiuyu): Also pass cardId in the intent. intent.putExtra(EuiccService.EXTRA_RESOLVABLE_ERRORS, resolvableErrors); intent.putExtra(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE_RETRIED, intent.putExtra(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE_RETRIED, confirmationCodeRetried); confirmationCodeRetried); intent.putExtra(EXTRA_OPERATION, op); intent.putExtra(EXTRA_OPERATION, op); Loading src/java/com/android/internal/telephony/euicc/EuiccOperation.java +101 −11 Original line number Original line Diff line number Diff line Loading @@ -61,7 +61,10 @@ public class EuiccOperation implements Parcelable { ACTION_GET_METADATA_DEACTIVATE_SIM, ACTION_GET_METADATA_DEACTIVATE_SIM, ACTION_DOWNLOAD_DEACTIVATE_SIM, ACTION_DOWNLOAD_DEACTIVATE_SIM, ACTION_DOWNLOAD_NO_PRIVILEGES, ACTION_DOWNLOAD_NO_PRIVILEGES, ACTION_DOWNLOAD_CONFIRMATION_CODE, ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM, ACTION_SWITCH_DEACTIVATE_SIM, ACTION_SWITCH_NO_PRIVILEGES, ACTION_DOWNLOAD_RESOLVABLE_ERRORS, }) }) @interface Action {} @interface Action {} Loading @@ -78,7 +81,13 @@ public class EuiccOperation implements Parcelable { @VisibleForTesting @VisibleForTesting static final int ACTION_SWITCH_NO_PRIVILEGES = 6; static final int ACTION_SWITCH_NO_PRIVILEGES = 6; @VisibleForTesting @VisibleForTesting static final int ACTION_DOWNLOAD_CONFIRMATION_CODE = 7; static final int ACTION_DOWNLOAD_RESOLVABLE_ERRORS = 7; /** * @deprecated Use ACTION_DOWNLOAD_RESOLVABLE_ERRORS and pass the resolvable errors in bit map. */ @VisibleForTesting @Deprecated static final int ACTION_DOWNLOAD_CONFIRMATION_CODE = 8; @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public final @Action int mAction; public final @Action int mAction; Loading @@ -91,6 +100,8 @@ public class EuiccOperation implements Parcelable { private final boolean mSwitchAfterDownload; private final boolean mSwitchAfterDownload; @Nullable @Nullable private final String mCallingPackage; private final String mCallingPackage; @Nullable private final int mResolvableErrors; /** /** * {@link EuiccManager#getDownloadableSubscriptionMetadata} failed with * {@link EuiccManager#getDownloadableSubscriptionMetadata} failed with Loading Loading @@ -130,7 +141,12 @@ public class EuiccOperation implements Parcelable { /** /** * {@link EuiccManager#downloadSubscription} failed with * {@link EuiccManager#downloadSubscription} failed with * {@link EuiccService#RESULT_NEED_CONFIRMATION_CODE} error. * {@link EuiccService#RESULT_NEED_CONFIRMATION_CODE} error. * * @deprecated Use * {@link #forDownloadResolvableErrors(long, DownloadableSubscription, boolean, String, int)} * instead. */ */ @Deprecated public static EuiccOperation forDownloadConfirmationCode(long callingToken, public static EuiccOperation forDownloadConfirmationCode(long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage) { String callingPackage) { Loading @@ -138,6 +154,18 @@ public class EuiccOperation implements Parcelable { subscription, 0 /* subscriptionId */, switchAfterDownload, callingPackage); subscription, 0 /* subscriptionId */, switchAfterDownload, callingPackage); } } /** * {@link EuiccManager#downloadSubscription} failed with * {@link EuiccService#RESULT_RESOLVABLE_ERRORS} error. */ public static EuiccOperation forDownloadResolvableErrors(long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, int resolvableErrors) { return new EuiccOperation(ACTION_DOWNLOAD_RESOLVABLE_ERRORS, callingToken, subscription, 0 /* subscriptionId */, switchAfterDownload, callingPackage, resolvableErrors); } static EuiccOperation forGetDefaultListDeactivateSim(long callingToken, String callingPackage) { static EuiccOperation forGetDefaultListDeactivateSim(long callingToken, String callingPackage) { return new EuiccOperation(ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM, callingToken, return new EuiccOperation(ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM, callingToken, null /* downloadableSubscription */, 0 /* subscriptionId */, null /* downloadableSubscription */, 0 /* subscriptionId */, Loading @@ -158,6 +186,22 @@ public class EuiccOperation implements Parcelable { false /* switchAfterDownload */, callingPackage); false /* switchAfterDownload */, callingPackage); } } EuiccOperation(@Action int action, long callingToken, @Nullable DownloadableSubscription downloadableSubscription, int subscriptionId, boolean switchAfterDownload, String callingPackage, int resolvableErrors) { mAction = action; mCallingToken = callingToken; mDownloadableSubscription = downloadableSubscription; mSubscriptionId = subscriptionId; mSwitchAfterDownload = switchAfterDownload; mCallingPackage = callingPackage; mResolvableErrors = resolvableErrors; } EuiccOperation(@Action int action, EuiccOperation(@Action int action, long callingToken, long callingToken, @Nullable DownloadableSubscription downloadableSubscription, @Nullable DownloadableSubscription downloadableSubscription, Loading @@ -170,6 +214,7 @@ public class EuiccOperation implements Parcelable { mSubscriptionId = subscriptionId; mSubscriptionId = subscriptionId; mSwitchAfterDownload = switchAfterDownload; mSwitchAfterDownload = switchAfterDownload; mCallingPackage = callingPackage; mCallingPackage = callingPackage; mResolvableErrors = 0; } } EuiccOperation(Parcel in) { EuiccOperation(Parcel in) { Loading @@ -179,6 +224,7 @@ public class EuiccOperation implements Parcelable { mSubscriptionId = in.readInt(); mSubscriptionId = in.readInt(); mSwitchAfterDownload = in.readBoolean(); mSwitchAfterDownload = in.readBoolean(); mCallingPackage = in.readString(); mCallingPackage = in.readString(); mResolvableErrors = in.readInt(); } } @Override @Override Loading @@ -189,6 +235,7 @@ public class EuiccOperation implements Parcelable { dest.writeInt(mSubscriptionId); dest.writeInt(mSubscriptionId); dest.writeBoolean(mSwitchAfterDownload); dest.writeBoolean(mSwitchAfterDownload); dest.writeString(mCallingPackage); dest.writeString(mCallingPackage); dest.writeInt(mResolvableErrors); } } /** /** Loading Loading @@ -220,11 +267,14 @@ public class EuiccOperation implements Parcelable { resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), callbackIntent); callbackIntent); break; break; case ACTION_DOWNLOAD_CONFIRMATION_CODE: case ACTION_DOWNLOAD_CONFIRMATION_CODE: // Deprecated case resolvedDownloadConfirmationCode( resolvedDownloadConfirmationCode( resolutionExtras.getString(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE), resolutionExtras.getString(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE), callbackIntent); callbackIntent); break; break; case ACTION_DOWNLOAD_RESOLVABLE_ERRORS: resolvedDownloadResolvableErrors(resolutionExtras, callbackIntent); break; case ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM: case ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM: resolvedGetDefaultListDeactivateSim( resolvedGetDefaultListDeactivateSim( resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), Loading Loading @@ -272,6 +322,7 @@ public class EuiccOperation implements Parcelable { mSwitchAfterDownload, mSwitchAfterDownload, mCallingPackage, mCallingPackage, true /* forceDeactivateSim */, true /* forceDeactivateSim */, null /* resolvedBundle */, callbackIntent); callbackIntent); } else { } else { // User has not consented; fail the operation. // User has not consented; fail the operation. Loading @@ -294,6 +345,7 @@ public class EuiccOperation implements Parcelable { mSwitchAfterDownload, mSwitchAfterDownload, true /* forceDeactivateSim */, true /* forceDeactivateSim */, mCallingPackage, mCallingPackage, null /* resolvedBundle */, callbackIntent); callbackIntent); } finally { } finally { Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token); Loading @@ -304,18 +356,56 @@ public class EuiccOperation implements Parcelable { } } } } /** * @deprecated The resolvable errors in download step are solved by * {@link #resolvedDownloadResolvableErrors(Bundle, PendingIntent)} from Q. */ @Deprecated private void resolvedDownloadConfirmationCode(String confirmationCode, private void resolvedDownloadConfirmationCode(String confirmationCode, PendingIntent callbackIntent) { PendingIntent callbackIntent) { if (TextUtils.isEmpty(confirmationCode)) { if (TextUtils.isEmpty(confirmationCode)) { fail(callbackIntent); fail(callbackIntent); } else { } else { mDownloadableSubscription.setConfirmationCode(confirmationCode); mDownloadableSubscription.setConfirmationCode(confirmationCode); EuiccController.get() EuiccController.get().downloadSubscription( .downloadSubscription( mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, true /* forceDeactivateSim */, null, callbackIntent); } } private void resolvedDownloadResolvableErrors(Bundle resolvedBundle, PendingIntent callbackIntent) { boolean pass = true; String confirmationCode = null; if ((mResolvableErrors & EuiccService.RESOLVABLE_ERROR_POLICY_RULES) != 0) { if (!resolvedBundle.getBoolean(EuiccService.EXTRA_RESOLUTION_ALLOW_POLICY_RULES)) { pass = false; } } if ((mResolvableErrors & EuiccService.RESOLVABLE_ERROR_CONFIRMATION_CODE) != 0) { confirmationCode = resolvedBundle.getString( EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE); // The check here just makes sure the entered confirmation code is non-empty. The actual // check to valid the confirmation code is done by LPA on the ensuing download attemp. if (TextUtils.isEmpty(confirmationCode)) { pass = false; } } if (!pass) { fail(callbackIntent); } else { mDownloadableSubscription.setConfirmationCode(confirmationCode); EuiccController.get().downloadSubscription( mDownloadableSubscription, mDownloadableSubscription, mSwitchAfterDownload, mSwitchAfterDownload, mCallingPackage, mCallingPackage, true /* forceDeactivateSim */, true /* forceDeactivateSim */, resolvedBundle, callbackIntent); callbackIntent); } } } } Loading src/java/com/android/internal/telephony/uicc/euicc/EuiccCard.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -566,14 +566,16 @@ public class EuiccCard extends UiccCard { int size = nodes.size(); int size = nodes.size(); for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) { Asn1Node node = nodes.get(i); Asn1Node node = nodes.get(i); List<Asn1Node> opIdNodes = node.getChild(Tags.TAG_CTX_COMP_1).getChildren(); List<Asn1Node> opIdNodes = node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_COMP_1).getChildren(); int opIdSize = opIdNodes.size(); int opIdSize = opIdNodes.size(); CarrierIdentifier[] opIds = new CarrierIdentifier[opIdSize]; CarrierIdentifier[] opIds = new CarrierIdentifier[opIdSize]; for (int j = 0; j < opIdSize; j++) { for (int j = 0; j < opIdSize; j++) { opIds[j] = buildCarrierIdentifier(opIdNodes.get(j)); opIds[j] = buildCarrierIdentifier(opIdNodes.get(j)); } } builder.add(node.getChild(Tags.TAG_CTX_0).asBits(), Arrays.asList(opIds), builder.add(node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_0).asBits(), node.getChild(Tags.TAG_CTX_2).asBits()); Arrays.asList(opIds), node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_2).asBits()); } } return builder.build(); return builder.build(); }, }, Loading src/java/com/android/internal/telephony/uicc/euicc/Tags.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ class Tags { // Universal tags // Universal tags static final int TAG_UNI_2 = 0x02; static final int TAG_UNI_2 = 0x02; static final int TAG_UNI_4 = 0x04; static final int TAG_UNI_4 = 0x04; static final int TAG_SEQUENCE = 0x30; // Context tags for primitive types // Context tags for primitive types static final int TAG_CTX_0 = 0x80; static final int TAG_CTX_0 = 0x80; static final int TAG_CTX_1 = 0x81; static final int TAG_CTX_1 = 0x81; Loading Loading
src/java/com/android/internal/telephony/euicc/EuiccConnector.java +9 −4 Original line number Original line Diff line number Diff line Loading @@ -30,10 +30,12 @@ import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo; import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.RemoteException; import android.os.RemoteException; import android.service.euicc.DownloadSubscriptionResult; import android.service.euicc.EuiccService; import android.service.euicc.EuiccService; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; Loading Loading @@ -225,13 +227,14 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { boolean mSwitchAfterDownload; boolean mSwitchAfterDownload; boolean mForceDeactivateSim; boolean mForceDeactivateSim; DownloadCommandCallback mCallback; DownloadCommandCallback mCallback; Bundle mResolvedBundle; } } /** Callback class for {@link #downloadSubscription}. */ /** Callback class for {@link #downloadSubscription}. */ @VisibleForTesting(visibility = PACKAGE) @VisibleForTesting(visibility = PACKAGE) public interface DownloadCommandCallback extends BaseEuiccCommandCallback { public interface DownloadCommandCallback extends BaseEuiccCommandCallback { /** Called when the download has completed (though it may have failed). */ /** Called when the download has completed (though it may have failed). */ void onDownloadComplete(int result); void onDownloadComplete(DownloadSubscriptionResult result); } } interface GetEuiccProfileInfoListCommandCallback extends BaseEuiccCommandCallback { interface GetEuiccProfileInfoListCommandCallback extends BaseEuiccCommandCallback { Loading Loading @@ -423,11 +426,12 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { @VisibleForTesting(visibility = PACKAGE) @VisibleForTesting(visibility = PACKAGE) public void downloadSubscription(DownloadableSubscription subscription, public void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, boolean switchAfterDownload, boolean forceDeactivateSim, DownloadCommandCallback callback) { Bundle resolvedBundle, DownloadCommandCallback callback) { DownloadRequest request = new DownloadRequest(); DownloadRequest request = new DownloadRequest(); request.mSubscription = subscription; request.mSubscription = subscription; request.mSwitchAfterDownload = switchAfterDownload; request.mSwitchAfterDownload = switchAfterDownload; request.mForceDeactivateSim = forceDeactivateSim; request.mForceDeactivateSim = forceDeactivateSim; request.mResolvedBundle = resolvedBundle; request.mCallback = callback; request.mCallback = callback; sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, request); sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, request); } } Loading Loading @@ -709,9 +713,10 @@ public class EuiccConnector extends StateMachine implements ServiceConnection { request.mSubscription, request.mSubscription, request.mSwitchAfterDownload, request.mSwitchAfterDownload, request.mForceDeactivateSim, request.mForceDeactivateSim, request.mResolvedBundle, new IDownloadSubscriptionCallback.Stub() { new IDownloadSubscriptionCallback.Stub() { @Override @Override public void onComplete(int result) { public void onComplete(DownloadSubscriptionResult result) { sendMessage(CMD_COMMAND_COMPLETE, (Runnable) () -> { sendMessage(CMD_COMMAND_COMPLETE, (Runnable) () -> { ((DownloadCommandCallback) callback) ((DownloadCommandCallback) callback) .onDownloadComplete(result); .onDownloadComplete(result); Loading
src/java/com/android/internal/telephony/euicc/EuiccController.java +51 −21 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.Bundle; import android.os.ServiceManager; import android.os.ServiceManager; import android.provider.Settings; import android.provider.Settings; import android.service.euicc.DownloadSubscriptionResult; import android.service.euicc.EuiccService; import android.service.euicc.EuiccService; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; Loading Loading @@ -274,6 +275,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, getOperationForDeactivateSim()); getOperationForDeactivateSim()); break; break; Loading Loading @@ -301,14 +303,15 @@ public class EuiccController extends IEuiccController.Stub { @Override @Override public void downloadSubscription(DownloadableSubscription subscription, public void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, PendingIntent callbackIntent) { boolean switchAfterDownload, String callingPackage, Bundle resolvedBundle, PendingIntent callbackIntent) { downloadSubscription(subscription, switchAfterDownload, callingPackage, downloadSubscription(subscription, switchAfterDownload, callingPackage, false /* forceDeactivateSim */, callbackIntent); false /* forceDeactivateSim */, resolvedBundle, callbackIntent); } } void downloadSubscription(DownloadableSubscription subscription, void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, boolean switchAfterDownload, String callingPackage, boolean forceDeactivateSim, PendingIntent callbackIntent) { Bundle resolvedBundle, PendingIntent callbackIntent) { boolean callerCanWriteEmbeddedSubscriptions = callerCanWriteEmbeddedSubscriptions(); boolean callerCanWriteEmbeddedSubscriptions = callerCanWriteEmbeddedSubscriptions(); mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage); mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage); Loading @@ -318,7 +321,7 @@ public class EuiccController extends IEuiccController.Stub { // With WRITE_EMBEDDED_SUBSCRIPTIONS, we can skip profile-specific permission checks // With WRITE_EMBEDDED_SUBSCRIPTIONS, we can skip profile-specific permission checks // and move straight to the profile download. // and move straight to the profile download. downloadSubscriptionPrivileged(token, subscription, switchAfterDownload, downloadSubscriptionPrivileged(token, subscription, switchAfterDownload, forceDeactivateSim, callingPackage, callbackIntent); forceDeactivateSim, callingPackage, resolvedBundle, callbackIntent); return; return; } } // Without WRITE_EMBEDDED_SUBSCRIPTIONS, the caller *must* be whitelisted per the // Without WRITE_EMBEDDED_SUBSCRIPTIONS, the caller *must* be whitelisted per the Loading Loading @@ -355,6 +358,7 @@ public class EuiccController extends IEuiccController.Stub { Intent extrasIntent = new Intent(); Intent extrasIntent = new Intent(); addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadNoPrivileges( EuiccOperation.forDownloadNoPrivileges( mCallingToken, mSubscription, mSwitchAfterDownload, mCallingToken, mSubscription, mSwitchAfterDownload, Loading Loading @@ -400,7 +404,8 @@ public class EuiccController extends IEuiccController.Stub { if (canManageActiveSubscription(mCallingPackage)) { if (canManageActiveSubscription(mCallingPackage)) { downloadSubscriptionPrivileged( downloadSubscriptionPrivileged( mCallingToken, subscription, mSwitchAfterDownload, mCallingToken, subscription, mSwitchAfterDownload, mForceDeactivateSim, mCallingPackage, mCallbackIntent); mForceDeactivateSim, mCallingPackage, null /* resolvedBundle */, mCallbackIntent); return; return; } } Loading @@ -408,6 +413,7 @@ public class EuiccController extends IEuiccController.Stub { Intent extrasIntent = new Intent(); Intent extrasIntent = new Intent(); addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadNoPrivileges( EuiccOperation.forDownloadNoPrivileges( mCallingToken, subscription, mSwitchAfterDownload, mCallingToken, subscription, mSwitchAfterDownload, Loading @@ -429,18 +435,19 @@ public class EuiccController extends IEuiccController.Stub { void downloadSubscriptionPrivileged(final long callingToken, void downloadSubscriptionPrivileged(final long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, final String callingPackage, boolean forceDeactivateSim, final String callingPackage, Bundle resolvedBundle, final PendingIntent callbackIntent) { final PendingIntent callbackIntent) { mConnector.downloadSubscription( mConnector.downloadSubscription( subscription, subscription, switchAfterDownload, switchAfterDownload, forceDeactivateSim, forceDeactivateSim, resolvedBundle, new EuiccConnector.DownloadCommandCallback() { new EuiccConnector.DownloadCommandCallback() { @Override @Override public void onDownloadComplete(int result) { public void onDownloadComplete(DownloadSubscriptionResult result) { Intent extrasIntent = new Intent(); Intent extrasIntent = new Intent(); final int resultCode; final int resultCode; switch (result) { switch (result.getResult()) { case EuiccService.RESULT_OK: case EuiccService.RESULT_OK: resultCode = OK; resultCode = OK; // Now that a profile has been successfully downloaded, mark the // Now that a profile has been successfully downloaded, mark the Loading @@ -465,30 +472,47 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, callingPackage, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forDownloadDeactivateSim( EuiccOperation.forDownloadDeactivateSim( callingToken, subscription, switchAfterDownload, callingToken, subscription, switchAfterDownload, callingPackage)); callingPackage)); break; break; case EuiccService.RESULT_NEED_CONFIRMATION_CODE: case EuiccService.RESULT_RESOLVABLE_ERRORS: // Same value as the deprecated // {@link EuiccService#RESULT_NEED_CONFIRMATION_CODE}. For the // deprecated case, the resolvableErrors is set as 0 in // EuiccService. resultCode = RESOLVABLE_ERROR; resultCode = RESOLVABLE_ERROR; boolean retried = false; boolean retried = false; if (!TextUtils.isEmpty(subscription.getConfirmationCode())) { if (!TextUtils.isEmpty(subscription.getConfirmationCode())) { retried = true; retried = true; } } if (result.getResolvableErrors() != 0) { addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_RESOLVABLE_ERRORS, callingPackage, result.getResolvableErrors(), retried, EuiccOperation.forDownloadResolvableErrors( callingToken, subscription, switchAfterDownload, callingPackage, result.getResolvableErrors())); } else { // Deprecated case addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE, EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE, callingPackage, callingPackage, 0 /* resolvableErrors */, retried /* confirmationCodeRetried */, retried /* confirmationCodeRetried */, EuiccOperation.forDownloadConfirmationCode( EuiccOperation.forDownloadConfirmationCode( callingToken, subscription, switchAfterDownload, callingToken, subscription, switchAfterDownload, callingPackage)); callingPackage)); } break; break; default: default: resultCode = ERROR; resultCode = ERROR; extrasIntent.putExtra( extrasIntent.putExtra( EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE, EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE, result); result.getResult()); break; break; } } Loading Loading @@ -587,6 +611,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, mCallingPackage, mCallingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forGetDefaultListDeactivateSim( EuiccOperation.forGetDefaultListDeactivateSim( mCallingToken, mCallingPackage)); mCallingToken, mCallingPackage)); Loading Loading @@ -739,6 +764,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, EuiccService.ACTION_RESOLVE_NO_PRIVILEGES, callingPackage, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forSwitchNoPrivileges( EuiccOperation.forSwitchNoPrivileges( token, subscriptionId, callingPackage)); token, subscriptionId, callingPackage)); Loading Loading @@ -785,6 +811,7 @@ public class EuiccController extends IEuiccController.Stub { addResolutionIntent(extrasIntent, addResolutionIntent(extrasIntent, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM, callingPackage, callingPackage, 0 /* resolvableErrors */, false /* confirmationCodeRetried */, false /* confirmationCodeRetried */, EuiccOperation.forSwitchDeactivateSim( EuiccOperation.forSwitchDeactivateSim( callingToken, subscriptionId, callingPackage)); callingToken, subscriptionId, callingPackage)); Loading Loading @@ -953,11 +980,14 @@ public class EuiccController extends IEuiccController.Stub { /** Add a resolution intent to the given extras intent. */ /** Add a resolution intent to the given extras intent. */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void addResolutionIntent(Intent extrasIntent, String resolutionAction, public void addResolutionIntent(Intent extrasIntent, String resolutionAction, String callingPackage, boolean confirmationCodeRetried, EuiccOperation op) { String callingPackage, int resolvableErrors, boolean confirmationCodeRetried, EuiccOperation op) { Intent intent = new Intent(EuiccManager.ACTION_RESOLVE_ERROR); Intent intent = new Intent(EuiccManager.ACTION_RESOLVE_ERROR); intent.putExtra(EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_ACTION, intent.putExtra(EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_ACTION, resolutionAction); resolutionAction); intent.putExtra(EuiccService.EXTRA_RESOLUTION_CALLING_PACKAGE, callingPackage); intent.putExtra(EuiccService.EXTRA_RESOLUTION_CALLING_PACKAGE, callingPackage); // TODO(jiuyu): Also pass cardId in the intent. intent.putExtra(EuiccService.EXTRA_RESOLVABLE_ERRORS, resolvableErrors); intent.putExtra(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE_RETRIED, intent.putExtra(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE_RETRIED, confirmationCodeRetried); confirmationCodeRetried); intent.putExtra(EXTRA_OPERATION, op); intent.putExtra(EXTRA_OPERATION, op); Loading
src/java/com/android/internal/telephony/euicc/EuiccOperation.java +101 −11 Original line number Original line Diff line number Diff line Loading @@ -61,7 +61,10 @@ public class EuiccOperation implements Parcelable { ACTION_GET_METADATA_DEACTIVATE_SIM, ACTION_GET_METADATA_DEACTIVATE_SIM, ACTION_DOWNLOAD_DEACTIVATE_SIM, ACTION_DOWNLOAD_DEACTIVATE_SIM, ACTION_DOWNLOAD_NO_PRIVILEGES, ACTION_DOWNLOAD_NO_PRIVILEGES, ACTION_DOWNLOAD_CONFIRMATION_CODE, ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM, ACTION_SWITCH_DEACTIVATE_SIM, ACTION_SWITCH_NO_PRIVILEGES, ACTION_DOWNLOAD_RESOLVABLE_ERRORS, }) }) @interface Action {} @interface Action {} Loading @@ -78,7 +81,13 @@ public class EuiccOperation implements Parcelable { @VisibleForTesting @VisibleForTesting static final int ACTION_SWITCH_NO_PRIVILEGES = 6; static final int ACTION_SWITCH_NO_PRIVILEGES = 6; @VisibleForTesting @VisibleForTesting static final int ACTION_DOWNLOAD_CONFIRMATION_CODE = 7; static final int ACTION_DOWNLOAD_RESOLVABLE_ERRORS = 7; /** * @deprecated Use ACTION_DOWNLOAD_RESOLVABLE_ERRORS and pass the resolvable errors in bit map. */ @VisibleForTesting @Deprecated static final int ACTION_DOWNLOAD_CONFIRMATION_CODE = 8; @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public final @Action int mAction; public final @Action int mAction; Loading @@ -91,6 +100,8 @@ public class EuiccOperation implements Parcelable { private final boolean mSwitchAfterDownload; private final boolean mSwitchAfterDownload; @Nullable @Nullable private final String mCallingPackage; private final String mCallingPackage; @Nullable private final int mResolvableErrors; /** /** * {@link EuiccManager#getDownloadableSubscriptionMetadata} failed with * {@link EuiccManager#getDownloadableSubscriptionMetadata} failed with Loading Loading @@ -130,7 +141,12 @@ public class EuiccOperation implements Parcelable { /** /** * {@link EuiccManager#downloadSubscription} failed with * {@link EuiccManager#downloadSubscription} failed with * {@link EuiccService#RESULT_NEED_CONFIRMATION_CODE} error. * {@link EuiccService#RESULT_NEED_CONFIRMATION_CODE} error. * * @deprecated Use * {@link #forDownloadResolvableErrors(long, DownloadableSubscription, boolean, String, int)} * instead. */ */ @Deprecated public static EuiccOperation forDownloadConfirmationCode(long callingToken, public static EuiccOperation forDownloadConfirmationCode(long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage) { String callingPackage) { Loading @@ -138,6 +154,18 @@ public class EuiccOperation implements Parcelable { subscription, 0 /* subscriptionId */, switchAfterDownload, callingPackage); subscription, 0 /* subscriptionId */, switchAfterDownload, callingPackage); } } /** * {@link EuiccManager#downloadSubscription} failed with * {@link EuiccService#RESULT_RESOLVABLE_ERRORS} error. */ public static EuiccOperation forDownloadResolvableErrors(long callingToken, DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, int resolvableErrors) { return new EuiccOperation(ACTION_DOWNLOAD_RESOLVABLE_ERRORS, callingToken, subscription, 0 /* subscriptionId */, switchAfterDownload, callingPackage, resolvableErrors); } static EuiccOperation forGetDefaultListDeactivateSim(long callingToken, String callingPackage) { static EuiccOperation forGetDefaultListDeactivateSim(long callingToken, String callingPackage) { return new EuiccOperation(ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM, callingToken, return new EuiccOperation(ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM, callingToken, null /* downloadableSubscription */, 0 /* subscriptionId */, null /* downloadableSubscription */, 0 /* subscriptionId */, Loading @@ -158,6 +186,22 @@ public class EuiccOperation implements Parcelable { false /* switchAfterDownload */, callingPackage); false /* switchAfterDownload */, callingPackage); } } EuiccOperation(@Action int action, long callingToken, @Nullable DownloadableSubscription downloadableSubscription, int subscriptionId, boolean switchAfterDownload, String callingPackage, int resolvableErrors) { mAction = action; mCallingToken = callingToken; mDownloadableSubscription = downloadableSubscription; mSubscriptionId = subscriptionId; mSwitchAfterDownload = switchAfterDownload; mCallingPackage = callingPackage; mResolvableErrors = resolvableErrors; } EuiccOperation(@Action int action, EuiccOperation(@Action int action, long callingToken, long callingToken, @Nullable DownloadableSubscription downloadableSubscription, @Nullable DownloadableSubscription downloadableSubscription, Loading @@ -170,6 +214,7 @@ public class EuiccOperation implements Parcelable { mSubscriptionId = subscriptionId; mSubscriptionId = subscriptionId; mSwitchAfterDownload = switchAfterDownload; mSwitchAfterDownload = switchAfterDownload; mCallingPackage = callingPackage; mCallingPackage = callingPackage; mResolvableErrors = 0; } } EuiccOperation(Parcel in) { EuiccOperation(Parcel in) { Loading @@ -179,6 +224,7 @@ public class EuiccOperation implements Parcelable { mSubscriptionId = in.readInt(); mSubscriptionId = in.readInt(); mSwitchAfterDownload = in.readBoolean(); mSwitchAfterDownload = in.readBoolean(); mCallingPackage = in.readString(); mCallingPackage = in.readString(); mResolvableErrors = in.readInt(); } } @Override @Override Loading @@ -189,6 +235,7 @@ public class EuiccOperation implements Parcelable { dest.writeInt(mSubscriptionId); dest.writeInt(mSubscriptionId); dest.writeBoolean(mSwitchAfterDownload); dest.writeBoolean(mSwitchAfterDownload); dest.writeString(mCallingPackage); dest.writeString(mCallingPackage); dest.writeInt(mResolvableErrors); } } /** /** Loading Loading @@ -220,11 +267,14 @@ public class EuiccOperation implements Parcelable { resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), callbackIntent); callbackIntent); break; break; case ACTION_DOWNLOAD_CONFIRMATION_CODE: case ACTION_DOWNLOAD_CONFIRMATION_CODE: // Deprecated case resolvedDownloadConfirmationCode( resolvedDownloadConfirmationCode( resolutionExtras.getString(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE), resolutionExtras.getString(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE), callbackIntent); callbackIntent); break; break; case ACTION_DOWNLOAD_RESOLVABLE_ERRORS: resolvedDownloadResolvableErrors(resolutionExtras, callbackIntent); break; case ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM: case ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM: resolvedGetDefaultListDeactivateSim( resolvedGetDefaultListDeactivateSim( resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT), Loading Loading @@ -272,6 +322,7 @@ public class EuiccOperation implements Parcelable { mSwitchAfterDownload, mSwitchAfterDownload, mCallingPackage, mCallingPackage, true /* forceDeactivateSim */, true /* forceDeactivateSim */, null /* resolvedBundle */, callbackIntent); callbackIntent); } else { } else { // User has not consented; fail the operation. // User has not consented; fail the operation. Loading @@ -294,6 +345,7 @@ public class EuiccOperation implements Parcelable { mSwitchAfterDownload, mSwitchAfterDownload, true /* forceDeactivateSim */, true /* forceDeactivateSim */, mCallingPackage, mCallingPackage, null /* resolvedBundle */, callbackIntent); callbackIntent); } finally { } finally { Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token); Loading @@ -304,18 +356,56 @@ public class EuiccOperation implements Parcelable { } } } } /** * @deprecated The resolvable errors in download step are solved by * {@link #resolvedDownloadResolvableErrors(Bundle, PendingIntent)} from Q. */ @Deprecated private void resolvedDownloadConfirmationCode(String confirmationCode, private void resolvedDownloadConfirmationCode(String confirmationCode, PendingIntent callbackIntent) { PendingIntent callbackIntent) { if (TextUtils.isEmpty(confirmationCode)) { if (TextUtils.isEmpty(confirmationCode)) { fail(callbackIntent); fail(callbackIntent); } else { } else { mDownloadableSubscription.setConfirmationCode(confirmationCode); mDownloadableSubscription.setConfirmationCode(confirmationCode); EuiccController.get() EuiccController.get().downloadSubscription( .downloadSubscription( mDownloadableSubscription, mSwitchAfterDownload, mCallingPackage, true /* forceDeactivateSim */, null, callbackIntent); } } private void resolvedDownloadResolvableErrors(Bundle resolvedBundle, PendingIntent callbackIntent) { boolean pass = true; String confirmationCode = null; if ((mResolvableErrors & EuiccService.RESOLVABLE_ERROR_POLICY_RULES) != 0) { if (!resolvedBundle.getBoolean(EuiccService.EXTRA_RESOLUTION_ALLOW_POLICY_RULES)) { pass = false; } } if ((mResolvableErrors & EuiccService.RESOLVABLE_ERROR_CONFIRMATION_CODE) != 0) { confirmationCode = resolvedBundle.getString( EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE); // The check here just makes sure the entered confirmation code is non-empty. The actual // check to valid the confirmation code is done by LPA on the ensuing download attemp. if (TextUtils.isEmpty(confirmationCode)) { pass = false; } } if (!pass) { fail(callbackIntent); } else { mDownloadableSubscription.setConfirmationCode(confirmationCode); EuiccController.get().downloadSubscription( mDownloadableSubscription, mDownloadableSubscription, mSwitchAfterDownload, mSwitchAfterDownload, mCallingPackage, mCallingPackage, true /* forceDeactivateSim */, true /* forceDeactivateSim */, resolvedBundle, callbackIntent); callbackIntent); } } } } Loading
src/java/com/android/internal/telephony/uicc/euicc/EuiccCard.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -566,14 +566,16 @@ public class EuiccCard extends UiccCard { int size = nodes.size(); int size = nodes.size(); for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) { Asn1Node node = nodes.get(i); Asn1Node node = nodes.get(i); List<Asn1Node> opIdNodes = node.getChild(Tags.TAG_CTX_COMP_1).getChildren(); List<Asn1Node> opIdNodes = node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_COMP_1).getChildren(); int opIdSize = opIdNodes.size(); int opIdSize = opIdNodes.size(); CarrierIdentifier[] opIds = new CarrierIdentifier[opIdSize]; CarrierIdentifier[] opIds = new CarrierIdentifier[opIdSize]; for (int j = 0; j < opIdSize; j++) { for (int j = 0; j < opIdSize; j++) { opIds[j] = buildCarrierIdentifier(opIdNodes.get(j)); opIds[j] = buildCarrierIdentifier(opIdNodes.get(j)); } } builder.add(node.getChild(Tags.TAG_CTX_0).asBits(), Arrays.asList(opIds), builder.add(node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_0).asBits(), node.getChild(Tags.TAG_CTX_2).asBits()); Arrays.asList(opIds), node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_2).asBits()); } } return builder.build(); return builder.build(); }, }, Loading
src/java/com/android/internal/telephony/uicc/euicc/Tags.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ class Tags { // Universal tags // Universal tags static final int TAG_UNI_2 = 0x02; static final int TAG_UNI_2 = 0x02; static final int TAG_UNI_4 = 0x04; static final int TAG_UNI_4 = 0x04; static final int TAG_SEQUENCE = 0x30; // Context tags for primitive types // Context tags for primitive types static final int TAG_CTX_0 = 0x80; static final int TAG_CTX_0 = 0x80; static final int TAG_CTX_1 = 0x81; static final int TAG_CTX_1 = 0x81; Loading