From 6bf0359b27e43bdd795ed9f3f930541965681aec Mon Sep 17 00:00:00 2001 From: Holly Jiuyu Sun Date: Thu, 17 Jan 2019 14:41:14 -0800 Subject: [PATCH] Handle permission check for multi-active SIMs devices. For download and switch, if the caller can manage (has carrier privilege) on any active sub on any other slots && the caller can manage the active sub on the target slot or there is no active sub on the target slot, we allow the caller to continue download. Otherwise, we require user consent. For getting EID, we now check whether the caller has privilege on the target card with the given cardId. Other logic including the logic for single-active slot still keep the same. Also, open disable sub (switch to empty sub) to privileged carrier apps instead of just system. Bug: 36260308 Bug: 120621262 Test: unit test, test on phone Change-Id: Icfc0c9e9f4303876bceb1adbe217b39b538b347e --- .../android/telephony/euicc/EuiccManager.java | 25 +++++++++++++++++-- .../telephony/euicc/IEuiccController.aidl | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index 0e5c71d6ef90a..1d9dd5fae103b 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -379,7 +379,7 @@ public class EuiccManager { return null; } try { - return getIEuiccController().getEid(mCardId); + return getIEuiccController().getEid(mCardId, mContext.getOpPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -417,6 +417,15 @@ public class EuiccManager { * 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. * + *

On a multi-active SIM device, requires the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission, or a calling app + * only if the targeted eUICC does not currently have an active subscription or the calling app + * is authorized to manage the active subscription on the target eUICC, and the calling app is + * authorized to manage any active subscription on any SIM. Without it, an + * {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback + * intent to prompt the user to accept the download. The caller should also be authorized to + * manage the subscription to be downloaded. + * * @param subscription the subscription to download. * @param switchAfterDownload if true, the profile will be activated upon successful download. * @param callbackIntent a PendingIntent to launch when the operation completes. @@ -619,9 +628,21 @@ public class EuiccManager { * an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback * intent to prompt the user to accept the download. * + *

On a multi-active SIM device, requires the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission, or a calling app + * only if the targeted eUICC does not currently have an active subscription or the calling app + * is authorized to manage the active subscription on the target eUICC, and the calling app is + * authorized to manage any active subscription on any SIM. Without it, an + * {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} will be returned in the callback + * intent to prompt the user to accept the download. The caller should also be authorized to + * manage the subscription to be enabled. + * * @param subscriptionId the ID of the subscription to enable. May be * {@link android.telephony.SubscriptionManager#INVALID_SUBSCRIPTION_ID} to deactivate the - * current profile without activating another profile to replace it. + * current profile without activating another profile to replace it. If it's a disable + * operation, requires the {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} + * permission, or the calling app must be authorized to manage the active subscription on + * the target eUICC. * @param callbackIntent a PendingIntent to launch when the operation completes. */ @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) diff --git a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl index 14a36c8c840d0..20169152539e9 100644 --- a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl +++ b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl @@ -31,7 +31,7 @@ interface IEuiccController { String callingPackage, in PendingIntent callbackIntent); oneway void getDefaultDownloadableSubscriptionList(int cardId, String callingPackage, in PendingIntent callbackIntent); - String getEid(int cardId); + String getEid(int cardId, String callingPackage); int getOtaStatus(int cardId); oneway void downloadSubscription(int cardId, in DownloadableSubscription subscription, boolean switchAfterDownload, String callingPackage, in Bundle resolvedBundle,