Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a65b940c authored by Holly Jiuyu Sun's avatar Holly Jiuyu Sun Committed by android-build-merger
Browse files

Merge "Carrier confirmation code." am: e59c2cf3

am: a1ba9726

Change-Id: I660c60c4c88cea3bbf52520b464c5a387d10ed80
parents 7862a030 a1ba9726
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -411,6 +411,15 @@ public class EuiccController extends IEuiccController.Stub {
                                                callingToken, subscription, switchAfterDownload,
                                                callingToken, subscription, switchAfterDownload,
                                                callingPackage));
                                                callingPackage));
                                break;
                                break;
                            case EuiccService.RESULT_NEED_CONFIRMATION_CODE:
                                resultCode = RESOLVABLE_ERROR;
                                addResolutionIntent(extrasIntent,
                                        EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE,
                                        callingPackage,
                                        EuiccOperation.forDownloadConfirmationCode(
                                                callingToken, subscription, switchAfterDownload,
                                                callingPackage));
                                break;
                            default:
                            default:
                                resultCode = ERROR;
                                resultCode = ERROR;
                                extrasIntent.putExtra(
                                extrasIntent.putExtra(
+36 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Parcelable;
import android.service.euicc.EuiccService;
import android.service.euicc.EuiccService;
import android.telephony.euicc.DownloadableSubscription;
import android.telephony.euicc.DownloadableSubscription;
import android.telephony.euicc.EuiccManager;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
@@ -60,6 +61,7 @@ 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,
    })
    })
    @interface Action {}
    @interface Action {}


@@ -75,6 +77,8 @@ public class EuiccOperation implements Parcelable {
    static final int ACTION_SWITCH_DEACTIVATE_SIM = 5;
    static final int ACTION_SWITCH_DEACTIVATE_SIM = 5;
    @VisibleForTesting
    @VisibleForTesting
    static final int ACTION_SWITCH_NO_PRIVILEGES = 6;
    static final int ACTION_SWITCH_NO_PRIVILEGES = 6;
    @VisibleForTesting
    static final int ACTION_DOWNLOAD_CONFIRMATION_CODE = 7;


    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public final @Action int mAction;
    public final @Action int mAction;
@@ -123,6 +127,17 @@ public class EuiccOperation implements Parcelable {
                subscription,  0 /* subscriptionId */, switchAfterDownload, callingPackage);
                subscription,  0 /* subscriptionId */, switchAfterDownload, callingPackage);
    }
    }


    /**
     * {@link EuiccManager#downloadSubscription} failed with
     * {@link EuiccService#RESULT_NEED_CONFIRMATION_CODE} error.
     */
    public static EuiccOperation forDownloadConfirmationCode(long callingToken,
            DownloadableSubscription subscription, boolean switchAfterDownload,
            String callingPackage) {
        return new EuiccOperation(ACTION_DOWNLOAD_CONFIRMATION_CODE, callingToken,
                subscription, 0 /* subscriptionId */, switchAfterDownload, callingPackage);
    }

    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 */,
@@ -205,6 +220,11 @@ public class EuiccOperation implements Parcelable {
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        callbackIntent);
                        callbackIntent);
                break;
                break;
            case ACTION_DOWNLOAD_CONFIRMATION_CODE:
                resolvedDownloadConfirmationCode(
                        resolutionExtras.getString(EuiccService.RESOLUTION_EXTRA_CONFIRMATION_CODE),
                        callbackIntent);
                break;
            case ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM:
            case ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM:
                resolvedGetDefaultListDeactivateSim(
                resolvedGetDefaultListDeactivateSim(
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
@@ -284,6 +304,22 @@ public class EuiccOperation implements Parcelable {
        }
        }
    }
    }


    private void resolvedDownloadConfirmationCode(String confirmationCode,
            PendingIntent callbackIntent) {
        if (TextUtils.isEmpty(confirmationCode)) {
            fail(callbackIntent);
        } else {
            mDownloadableSubscription.setConfirmationCode(confirmationCode);
            EuiccController.get()
                    .downloadSubscription(
                            mDownloadableSubscription,
                            mSwitchAfterDownload,
                            mCallingPackage,
                            true /* forceDeactivateSim */,
                            callbackIntent);
        }
    }

    private void resolvedGetDefaultListDeactivateSim(
    private void resolvedGetDefaultListDeactivateSim(
            boolean consent, PendingIntent callbackIntent) {
            boolean consent, PendingIntent callbackIntent) {
        if (consent) {
        if (consent) {
+11 −0
Original line number Original line Diff line number Diff line
@@ -349,6 +349,17 @@ public class EuiccControllerTest extends TelephonyTest {
                EuiccOperation.ACTION_DOWNLOAD_DEACTIVATE_SIM);
                EuiccOperation.ACTION_DOWNLOAD_DEACTIVATE_SIM);
    }
    }


    @Test
    public void testDownloadSubscription_needConfirmationCode() throws Exception {
        setHasWriteEmbeddedPermission(true);
        callDownloadSubscription(SUBSCRIPTION, false /* switchAfterDownload */, true /* complete */,
                EuiccService.RESULT_NEED_CONFIRMATION_CODE, "whatever" /* callingPackage */);
        verifyIntentSent(EuiccManager.EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR,
                0 /* detailedCode */);
        verifyResolutionIntent(EuiccService.ACTION_RESOLVE_CONFIRMATION_CODE,
                EuiccOperation.ACTION_DOWNLOAD_CONFIRMATION_CODE);
    }

    @Test
    @Test
    public void testDownloadSubscription_success() throws Exception {
    public void testDownloadSubscription_success() throws Exception {
        setHasWriteEmbeddedPermission(true);
        setHasWriteEmbeddedPermission(true);