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

Commit c1c89e47 authored by Jordan Liu's avatar Jordan Liu
Browse files

EuiccManager handles multiple eUICCs using cardId

Bug: 80097562
Test: manual
Change-Id: I61ab60dfe4b97080148c9ee4b180e0a582b10f59
parent 9a788837
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44971,6 +44971,7 @@ package android.telephony.euicc {
  }
  public class EuiccManager {
    method public android.telephony.euicc.EuiccManager createForCardId(int);
    method public void deleteSubscription(int, android.app.PendingIntent);
    method public void downloadSubscription(android.telephony.euicc.DownloadableSubscription, boolean, android.app.PendingIntent);
    method public java.lang.String getEid();
+44 −19
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.TelephonyManager;

import com.android.internal.telephony.euicc.IEuiccController;

@@ -40,7 +41,11 @@ import java.lang.annotation.RetentionPolicy;
 * EuiccManager is the application interface to eUICCs, or eSIMs/embedded SIMs.
 *
 * <p>You do not instantiate this class directly; instead, you retrieve an instance through
 * {@link Context#getSystemService(String)} and {@link Context#EUICC_SERVICE}.
 * {@link Context#getSystemService(String)} and {@link Context#EUICC_SERVICE}. This instance will be
 * created using the default eUICC.
 *
 * <p>On a device with multiple eUICCs, you may want to create multiple EuiccManagers. To do this
 * you can call {@link #createForCardId}.
 *
 * <p>See {@link #isEnabled} before attempting to use these APIs.
 */
@@ -318,10 +323,29 @@ public class EuiccManager {
    public static final int EUICC_OTA_STATUS_UNAVAILABLE = 5;

    private final Context mContext;
    private final int mCardId;

    /** @hide */
    public EuiccManager(Context context) {
        mContext = context;
        TelephonyManager tm = (TelephonyManager)
                context.getSystemService(Context.TELEPHONY_SERVICE);
        mCardId = tm.getCardIdForDefaultEuicc();
    }

    /** @hide */
    private EuiccManager(Context context, int cardId) {
        mContext = context;
        mCardId = cardId;
    }

    /**
     * Create a new EuiccManager object pinned to the given card ID.
     *
     * @return an EuiccManager that uses the given card ID for all calls.
     */
    public EuiccManager createForCardId(int cardId) {
        return new EuiccManager(mContext, cardId);
    }

    /**
@@ -344,7 +368,8 @@ public class EuiccManager {
     * Returns the EID identifying the eUICC hardware.
     *
     * <p>Requires that the calling app has carrier privileges on the active subscription on the
     * eUICC.
     * current eUICC. A calling app with carrier privileges for one eUICC may not necessarily have
     * access to the EID of another eUICC.
     *
     * @return the EID. May be null if {@link #isEnabled()} is false or the eUICC is not ready.
     */
@@ -354,7 +379,7 @@ public class EuiccManager {
            return null;
        }
        try {
            return getIEuiccController().getEid();
            return getIEuiccController().getEid(mCardId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -377,7 +402,7 @@ public class EuiccManager {
            return EUICC_OTA_STATUS_UNAVAILABLE;
        }
        try {
            return getIEuiccController().getOtaStatus();
            return getIEuiccController().getOtaStatus(mCardId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -387,10 +412,10 @@ public class EuiccManager {
     * Attempt to download the given {@link DownloadableSubscription}.
     *
     * <p>Requires the {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission,
     * or the calling app must be authorized to manage both the currently-active subscription and
     * the subscription to be downloaded according to the subscription metadata. Without the former,
     * an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback
     * intent to prompt the user to accept the download.
     * or the calling app must be authorized to manage both the currently-active subscription on the
     * current eUICC and the subscription to be downloaded according to the subscription metadata.
     * Without the former, an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be
     * returned in the callback intent to prompt the user to accept the download.
     *
     * @param subscription the subscription to download.
     * @param switchAfterDownload if true, the profile will be activated upon successful download.
@@ -404,7 +429,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().downloadSubscription(subscription, switchAfterDownload,
            getIEuiccController().downloadSubscription(mCardId, subscription, switchAfterDownload,
                    mContext.getOpPackageName(), null /* resolvedBundle */, callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -471,7 +496,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().continueOperation(resolutionIntent, resolutionExtras);
            getIEuiccController().continueOperation(mCardId, resolutionIntent, resolutionExtras);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -503,8 +528,8 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().getDownloadableSubscriptionMetadata(
                    subscription, mContext.getOpPackageName(), callbackIntent);
            getIEuiccController().getDownloadableSubscriptionMetadata(mCardId, subscription,
                    mContext.getOpPackageName(), callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -533,7 +558,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().getDefaultDownloadableSubscriptionList(
            getIEuiccController().getDefaultDownloadableSubscriptionList(mCardId,
                    mContext.getOpPackageName(), callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -552,7 +577,7 @@ public class EuiccManager {
            return null;
        }
        try {
            return getIEuiccController().getEuiccInfo();
            return getIEuiccController().getEuiccInfo(mCardId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -578,7 +603,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().deleteSubscription(
            getIEuiccController().deleteSubscription(mCardId,
                    subscriptionId, mContext.getOpPackageName(), callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -606,7 +631,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().switchToSubscription(
            getIEuiccController().switchToSubscription(mCardId,
                    subscriptionId, mContext.getOpPackageName(), callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -632,7 +657,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().updateSubscriptionNickname(
            getIEuiccController().updateSubscriptionNickname(mCardId,
                    subscriptionId, nickname, mContext.getOpPackageName(), callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -656,7 +681,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().eraseSubscriptions(callbackIntent);
            getIEuiccController().eraseSubscriptions(mCardId, callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -686,7 +711,7 @@ public class EuiccManager {
            return;
        }
        try {
            getIEuiccController().retainSubscriptionsForFactoryReset(callbackIntent);
            getIEuiccController().retainSubscriptionsForFactoryReset(mCardId, callbackIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+17 −14
Original line number Diff line number Diff line
@@ -24,22 +24,25 @@ import android.telephony.euicc.EuiccInfo;

/** @hide */
interface IEuiccController {
    oneway void continueOperation(in Intent resolutionIntent, in Bundle resolutionExtras);
    oneway void getDownloadableSubscriptionMetadata(in DownloadableSubscription subscription,
    oneway void continueOperation(int cardId, in Intent resolutionIntent,
            in Bundle resolutionExtras);
    oneway void getDownloadableSubscriptionMetadata(int cardId,
            in DownloadableSubscription subscription,
        String callingPackage, in PendingIntent callbackIntent);
    oneway void getDefaultDownloadableSubscriptionList(
    oneway void getDefaultDownloadableSubscriptionList(int cardId,
        String callingPackage, in PendingIntent callbackIntent);
    String getEid();
    int getOtaStatus();
    oneway void downloadSubscription(in DownloadableSubscription subscription,
        boolean switchAfterDownload, String callingPackage, in Bundle resolvedBundle, in PendingIntent callbackIntent);
    EuiccInfo getEuiccInfo();
    oneway void deleteSubscription(int subscriptionId, String callingPackage,
    String getEid(int cardId);
    int getOtaStatus(int cardId);
    oneway void downloadSubscription(int cardId, in DownloadableSubscription subscription,
        boolean switchAfterDownload, String callingPackage, in Bundle resolvedBundle,
        in PendingIntent callbackIntent);
    oneway void switchToSubscription(int subscriptionId, String callingPackage,
    EuiccInfo getEuiccInfo(int cardId);
    oneway void deleteSubscription(int cardId, int subscriptionId, String callingPackage,
        in PendingIntent callbackIntent);
    oneway void updateSubscriptionNickname(int subscriptionId, String nickname,
    oneway void switchToSubscription(int cardId, int subscriptionId, String callingPackage,
        in PendingIntent callbackIntent);
    oneway void updateSubscriptionNickname(int cardId, int subscriptionId, String nickname,
        String callingPackage, in PendingIntent callbackIntent);
    oneway void eraseSubscriptions(in PendingIntent callbackIntent);
    oneway void retainSubscriptionsForFactoryReset(in PendingIntent callbackIntent);
    oneway void eraseSubscriptions(int cardId, in PendingIntent callbackIntent);
    oneway void retainSubscriptionsForFactoryReset(int cardId, in PendingIntent callbackIntent);
}