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

Commit 8e3b1a63 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "EUICC API changes to support error resolution."

parents dbe270ce cfa70fa0
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -46,14 +46,14 @@ public final class DownloadResult implements Parcelable {
    @IntDef({
            RESULT_OK,
            RESULT_GENERIC_ERROR,
            RESULT_MUST_DEACTIVATE_REMOVABLE_SIM,
            RESULT_MUST_DEACTIVATE_SIM,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ResultCode {}

    public static final int RESULT_OK = 0;
    public static final int RESULT_GENERIC_ERROR = 1;
    public static final int RESULT_MUST_DEACTIVATE_REMOVABLE_SIM = 2;
    public static final int RESULT_MUST_DEACTIVATE_SIM = 2;

    /** Result of the operation - one of the RESULT_* constants. */
    public final @ResultCode int result;
@@ -83,11 +83,10 @@ public final class DownloadResult implements Parcelable {
    }

    /**
     * Return a result indicating that the removable SIM must be deactivated to perform the
     * operation.
     * Return a result indicating that an active SIM must be deactivated to perform the operation.
     */
    public static DownloadResult mustDeactivateRemovableSim() {
        return new DownloadResult(RESULT_MUST_DEACTIVATE_REMOVABLE_SIM, 0);
    public static DownloadResult mustDeactivateSim() {
        return new DownloadResult(RESULT_MUST_DEACTIVATE_SIM, 0);
    }

    /**
+45 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.telephony.euicc.DownloadableSubscription;
import android.util.ArraySet;

/**
 * Service interface linking the system with an eUICC local profile assistant (LPA) application.
@@ -74,6 +75,33 @@ public abstract class EuiccService extends Service {
    public static final String ACTION_PROVISION_EMBEDDED_SUBSCRIPTION =
            "android.service.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION";

    // LUI resolution actions. These are called by the platform to resolve errors in situations that
    // require user interaction.
    // TODO(b/33075886): Define extras for any input parameters to these dialogs once they are
    // more scoped out.
    /** Alert the user that this action will result in an active SIM being deactivated. */
    public static final String ACTION_RESOLVE_DEACTIVATE_SIM =
            "android.service.euicc.action.RESOLVE_DEACTIVATE_SIM";
    /**
     * Alert the user about a download/switch being done for an app that doesn't currently have
     * carrier privileges.
     */
    public static final String ACTION_RESOLVE_NO_PRIVILEGES =
            "android.service.euicc.action.RESOLVE_NO_PRIVILEGES";
    /**
     * List of all valid resolution actions for validation purposes.
     * @hide
     */
    public static final ArraySet<String> RESOLUTION_ACTIONS;
    static {
        RESOLUTION_ACTIONS = new ArraySet<>();
        RESOLUTION_ACTIONS.add(EuiccService.ACTION_RESOLVE_DEACTIVATE_SIM);
        RESOLUTION_ACTIONS.add(EuiccService.ACTION_RESOLVE_NO_PRIVILEGES);
    }

    /** Boolean extra for resolution actions indicating whether the user granted consent. */
    public static final String RESOLUTION_EXTRA_CONSENT = "consent";

    private final IEuiccService.Stub mStubWrapper;

    public EuiccService() {
@@ -107,11 +135,15 @@ public abstract class EuiccService extends Service {
     * @param slotId ID of the SIM slot to use when starting the download. This is currently not
     *     populated but is here to future-proof the APIs.
     * @param subscription A subscription whose metadata needs to be populated.
     * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the
     *     eUICC, perform this action automatically. Otherwise,
     *     {@link GetDownloadableSubscriptionMetadataResult#mustDeactivateSim()} should be returned
     *     to allow the user to consent to this operation first.
     * @return The result of the operation.
     * @see android.telephony.euicc.EuiccManager#getDownloadableSubscriptionMetadata
     */
    public abstract GetDownloadableSubscriptionMetadataResult getDownloadableSubscriptionMetadata(
            int slotId, DownloadableSubscription subscription);
            int slotId, DownloadableSubscription subscription, boolean forceDeactivateSim);

    /**
     * Download the given subscription.
@@ -121,11 +153,16 @@ public abstract class EuiccService extends Service {
     * @param subscription The subscription to download.
     * @param switchAfterDownload If true, the subscription should be enabled upon successful
     *     download.
     * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the
     *     eUICC, perform this action automatically. Otherwise,
     *     {@link DownloadResult#mustDeactivateSim()} should be returned to allow the user to
     *     consent to this operation first.
     * @return the result of the download operation.
     * @see android.telephony.euicc.EuiccManager#downloadSubscription
     */
    public abstract DownloadResult downloadSubscription(int slotId,
            DownloadableSubscription subscription, boolean switchAfterDownload);
            DownloadableSubscription subscription, boolean switchAfterDownload,
            boolean forceDeactivateSim);

    /**
     * Wrapper around IEuiccService that forwards calls to implementations of {@link EuiccService}.
@@ -133,9 +170,10 @@ public abstract class EuiccService extends Service {
    private class IEuiccServiceWrapper extends IEuiccService.Stub {
        @Override
        public void downloadSubscription(int slotId, DownloadableSubscription subscription,
                boolean switchAfterDownload, IDownloadSubscriptionCallback callback) {
                boolean switchAfterDownload, boolean forceDeactivateSim,
                IDownloadSubscriptionCallback callback) {
            DownloadResult result = EuiccService.this.downloadSubscription(
                    slotId, subscription, switchAfterDownload);
                    slotId, subscription, switchAfterDownload, forceDeactivateSim);
            try {
                callback.onComplete(result);
            } catch (RemoteException e) {
@@ -156,9 +194,11 @@ public abstract class EuiccService extends Service {
        @Override
        public void getDownloadableSubscriptionMetadata(int slotId,
                DownloadableSubscription subscription,
                boolean forceDeactivateSim,
                IGetDownloadableSubscriptionMetadataCallback callback) {
            GetDownloadableSubscriptionMetadataResult result =
                    EuiccService.this.getDownloadableSubscriptionMetadata(slotId, subscription);
                    EuiccService.this.getDownloadableSubscriptionMetadata(
                            slotId, subscription, forceDeactivateSim);
            try {
                callback.onComplete(result);
            } catch (RemoteException e) {
+5 −6
Original line number Diff line number Diff line
@@ -49,13 +49,13 @@ public final class GetDownloadableSubscriptionMetadataResult implements Parcelab
    @IntDef({
            RESULT_OK,
            RESULT_GENERIC_ERROR,
            RESULT_MUST_DEACTIVATE_REMOVABLE_SIM,
            RESULT_MUST_DEACTIVATE_SIM,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ResultCode {}

    public static final int RESULT_OK = 0;
    public static final int RESULT_MUST_DEACTIVATE_REMOVABLE_SIM = 1;
    public static final int RESULT_MUST_DEACTIVATE_SIM = 1;
    public static final int RESULT_GENERIC_ERROR = 2;

    /** Result of the operation - one of the RESULT_* constants. */
@@ -100,11 +100,10 @@ public final class GetDownloadableSubscriptionMetadataResult implements Parcelab
    }

    /**
     * Return a result indicating that the removable SIM must be deactivated to perform the
     * operation.
     * Return a result indicating that an active SIM must be deactivated to perform the operation.
     */
    public static GetDownloadableSubscriptionMetadataResult mustDeactivateRemovableSim() {
        return new GetDownloadableSubscriptionMetadataResult(RESULT_MUST_DEACTIVATE_REMOVABLE_SIM,
    public static GetDownloadableSubscriptionMetadataResult mustDeactivateSim() {
        return new GetDownloadableSubscriptionMetadataResult(RESULT_MUST_DEACTIVATE_SIM,
                null /* subscription */, 0 /* detailedCode */);
    }

+3 −2
Original line number Diff line number Diff line
@@ -24,8 +24,9 @@ import android.telephony.euicc.DownloadableSubscription;
/** @hide */
oneway interface IEuiccService {
    void downloadSubscription(int slotId, in DownloadableSubscription subscription,
            boolean switchAfterDownload, in IDownloadSubscriptionCallback callback);
            boolean switchAfterDownload, boolean forceDeactivateSim,
            in IDownloadSubscriptionCallback callback);
    void getDownloadableSubscriptionMetadata(int slotId, in DownloadableSubscription subscription,
            in IGetDownloadableSubscriptionMetadataCallback callback);
            boolean forceDeactivateSim, in IGetDownloadableSubscriptionMetadataCallback callback);
    void getEid(int slotId, in IGetEidCallback callback);
}
 No newline at end of file
+0 −37
Original line number Diff line number Diff line
@@ -56,8 +56,6 @@ public final class DownloadableSubscription implements Parcelable {
    // see getCarrierName and setCarrierName
    @Nullable
    private String carrierName;
    // see isConsentGranted and setConsentGranted
    private boolean consentGranted;
    // see getAccessRules and setAccessRules
    private UiccAccessRule[] accessRules;

@@ -69,7 +67,6 @@ public final class DownloadableSubscription implements Parcelable {
    private DownloadableSubscription(Parcel in) {
        encodedActivationCode = in.readString();
        carrierName = in.readString();
        consentGranted = in.readInt() == 1;
        accessRules = in.createTypedArray(UiccAccessRule.CREATOR);
    }

@@ -110,28 +107,6 @@ public final class DownloadableSubscription implements Parcelable {
        return carrierName;
    }


    /**
     * Mark this download as being consented to by the user.
     * @hide
     */
    public void setConsentGranted() {
        consentGranted = true;
    }

    /**
     * Returns whether the user has granted consent to download this subscription.
     *
     * <p>The {@link android.service.euicc.EuiccService} implementation should permit a subscription
     * download if this is set, even if the calling app doesn't have permission to download it.
     * @hide
     *
     * TODO(b/35851809): Make this a SystemApi.
     */
    public boolean isConsentGranted() {
        return consentGranted;
    }

    /**
     * Returns the {@link UiccAccessRule}s dictating access to this subscription.
     *
@@ -156,22 +131,10 @@ public final class DownloadableSubscription implements Parcelable {
        this.accessRules = accessRules;
    }

    /**
     * Unset any untrusted fields.
     *
     * <p>Should be called by the platform whenever an instance is received from an untrusted
     * source to reset any secure fields that may only be set by the platform.
     * @hide
     */
    public final void clearUntrustedFields() {
        this.consentGranted = false;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(encodedActivationCode);
        dest.writeString(carrierName);
        dest.writeInt(consentGranted ? 1 : 0);
        dest.writeTypedArray(accessRules, flags);
    }

Loading