Merge "EuiccManager handles multiple eUICCs using cardId"

This commit is contained in:
Jordan Liu
2019-01-17 20:24:09 +00:00
committed by Gerrit Code Review
3 changed files with 62 additions and 33 deletions

View File

@@ -43431,6 +43431,7 @@ package android.telephony.euicc {
} }
public class EuiccManager { public class EuiccManager {
method public android.telephony.euicc.EuiccManager createForCardId(int);
method public void deleteSubscription(int, android.app.PendingIntent); method public void deleteSubscription(int, android.app.PendingIntent);
method public void downloadSubscription(android.telephony.euicc.DownloadableSubscription, boolean, android.app.PendingIntent); method public void downloadSubscription(android.telephony.euicc.DownloadableSubscription, boolean, android.app.PendingIntent);
method public java.lang.String getEid(); method public java.lang.String getEid();

View File

@@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.euicc.IEuiccController; 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. * 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 * <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. * <p>See {@link #isEnabled} before attempting to use these APIs.
*/ */
@@ -248,10 +253,29 @@ public class EuiccManager {
public static final int EUICC_OTA_STATUS_UNAVAILABLE = 5; public static final int EUICC_OTA_STATUS_UNAVAILABLE = 5;
private final Context mContext; private final Context mContext;
private final int mCardId;
/** @hide */ /** @hide */
public EuiccManager(Context context) { public EuiccManager(Context context) {
mContext = 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);
} }
/** /**
@@ -274,7 +298,8 @@ public class EuiccManager {
* Returns the EID identifying the eUICC hardware. * Returns the EID identifying the eUICC hardware.
* *
* <p>Requires that the calling app has carrier privileges on the active subscription on the * <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. * @return the EID. May be null if {@link #isEnabled()} is false or the eUICC is not ready.
*/ */
@@ -284,7 +309,7 @@ public class EuiccManager {
return null; return null;
} }
try { try {
return getIEuiccController().getEid(); return getIEuiccController().getEid(mCardId);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -307,7 +332,7 @@ public class EuiccManager {
return EUICC_OTA_STATUS_UNAVAILABLE; return EUICC_OTA_STATUS_UNAVAILABLE;
} }
try { try {
return getIEuiccController().getOtaStatus(); return getIEuiccController().getOtaStatus(mCardId);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -317,10 +342,10 @@ public class EuiccManager {
* Attempt to download the given {@link DownloadableSubscription}. * Attempt to download the given {@link DownloadableSubscription}.
* *
* <p>Requires the {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission, * <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 * or the calling app must be authorized to manage both the currently-active subscription on the
* the subscription to be downloaded according to the subscription metadata. Without the former, * current eUICC and the subscription to be downloaded according to the subscription metadata.
* an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback * Without the former, an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be
* intent to prompt the user to accept the download. * returned in the callback intent to prompt the user to accept the download.
* *
* @param subscription the subscription to download. * @param subscription the subscription to download.
* @param switchAfterDownload if true, the profile will be activated upon successful download. * @param switchAfterDownload if true, the profile will be activated upon successful download.
@@ -334,7 +359,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().downloadSubscription(subscription, switchAfterDownload, getIEuiccController().downloadSubscription(mCardId, subscription, switchAfterDownload,
mContext.getOpPackageName(), null /* resolvedBundle */, callbackIntent); mContext.getOpPackageName(), null /* resolvedBundle */, callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
@@ -401,7 +426,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().continueOperation(resolutionIntent, resolutionExtras); getIEuiccController().continueOperation(mCardId, resolutionIntent, resolutionExtras);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -433,8 +458,8 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().getDownloadableSubscriptionMetadata( getIEuiccController().getDownloadableSubscriptionMetadata(mCardId, subscription,
subscription, mContext.getOpPackageName(), callbackIntent); mContext.getOpPackageName(), callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -463,7 +488,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().getDefaultDownloadableSubscriptionList( getIEuiccController().getDefaultDownloadableSubscriptionList(mCardId,
mContext.getOpPackageName(), callbackIntent); mContext.getOpPackageName(), callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
@@ -482,7 +507,7 @@ public class EuiccManager {
return null; return null;
} }
try { try {
return getIEuiccController().getEuiccInfo(); return getIEuiccController().getEuiccInfo(mCardId);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -508,7 +533,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().deleteSubscription( getIEuiccController().deleteSubscription(mCardId,
subscriptionId, mContext.getOpPackageName(), callbackIntent); subscriptionId, mContext.getOpPackageName(), callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
@@ -536,7 +561,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().switchToSubscription( getIEuiccController().switchToSubscription(mCardId,
subscriptionId, mContext.getOpPackageName(), callbackIntent); subscriptionId, mContext.getOpPackageName(), callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
@@ -562,7 +587,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().updateSubscriptionNickname( getIEuiccController().updateSubscriptionNickname(mCardId,
subscriptionId, nickname, mContext.getOpPackageName(), callbackIntent); subscriptionId, nickname, mContext.getOpPackageName(), callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
@@ -586,7 +611,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().eraseSubscriptions(callbackIntent); getIEuiccController().eraseSubscriptions(mCardId, callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -616,7 +641,7 @@ public class EuiccManager {
return; return;
} }
try { try {
getIEuiccController().retainSubscriptionsForFactoryReset(callbackIntent); getIEuiccController().retainSubscriptionsForFactoryReset(mCardId, callbackIntent);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }

View File

@@ -24,22 +24,25 @@ import android.telephony.euicc.EuiccInfo;
/** @hide */ /** @hide */
interface IEuiccController { interface IEuiccController {
oneway void continueOperation(in Intent resolutionIntent, in Bundle resolutionExtras); oneway void continueOperation(int cardId, in Intent resolutionIntent,
oneway void getDownloadableSubscriptionMetadata(in DownloadableSubscription subscription, in Bundle resolutionExtras);
oneway void getDownloadableSubscriptionMetadata(int cardId,
in DownloadableSubscription subscription,
String callingPackage, in PendingIntent callbackIntent); String callingPackage, in PendingIntent callbackIntent);
oneway void getDefaultDownloadableSubscriptionList( oneway void getDefaultDownloadableSubscriptionList(int cardId,
String callingPackage, in PendingIntent callbackIntent); String callingPackage, in PendingIntent callbackIntent);
String getEid(); String getEid(int cardId);
int getOtaStatus(); int getOtaStatus(int cardId);
oneway void downloadSubscription(in DownloadableSubscription subscription, oneway void downloadSubscription(int cardId, in DownloadableSubscription subscription,
boolean switchAfterDownload, String callingPackage, in Bundle resolvedBundle, in PendingIntent callbackIntent); boolean switchAfterDownload, String callingPackage, in Bundle resolvedBundle,
EuiccInfo getEuiccInfo();
oneway void deleteSubscription(int subscriptionId, String callingPackage,
in PendingIntent callbackIntent); 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); 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); String callingPackage, in PendingIntent callbackIntent);
oneway void eraseSubscriptions(in PendingIntent callbackIntent); oneway void eraseSubscriptions(int cardId, in PendingIntent callbackIntent);
oneway void retainSubscriptionsForFactoryReset(in PendingIntent callbackIntent); oneway void retainSubscriptionsForFactoryReset(int cardId, in PendingIntent callbackIntent);
} }