diff --git a/core/api/current.txt b/core/api/current.txt index 486dfa7086b1..8f74ae197b73 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -42283,7 +42283,7 @@ package android.telephony.euicc { method public boolean isEnabled(); method public boolean isSimPortAvailable(int); method public void startResolutionActivity(android.app.Activity, int, android.content.Intent, android.app.PendingIntent) throws android.content.IntentSender.SendIntentException; - method @Deprecated @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void switchToSubscription(int, android.app.PendingIntent); + method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void switchToSubscription(int, android.app.PendingIntent); method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void switchToSubscription(int, int, @NonNull android.app.PendingIntent); method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void updateSubscriptionNickname(int, @Nullable String, @NonNull android.app.PendingIntent); field public static final String ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS = "android.telephony.euicc.action.MANAGE_EMBEDDED_SUBSCRIPTIONS"; @@ -42303,6 +42303,7 @@ package android.telephony.euicc { field public static final int ERROR_INSTALL_PROFILE = 10009; // 0x2719 field public static final int ERROR_INVALID_ACTIVATION_CODE = 10001; // 0x2711 field public static final int ERROR_INVALID_CONFIRMATION_CODE = 10002; // 0x2712 + field public static final int ERROR_INVALID_PORT = 10017; // 0x2721 field public static final int ERROR_INVALID_RESPONSE = 10015; // 0x271f field public static final int ERROR_NO_PROFILES_AVAILABLE = 10013; // 0x271d field public static final int ERROR_OPERATION_BUSY = 10016; // 0x2720 diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 5b59b2120e19..5ee4131b326e 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -5309,6 +5309,13 @@ public final class Telephony { */ public static final String COLUMN_PROFILE_CLASS = "profile_class"; + /** + * TelephonyProvider column name for the port index of the active UICC port. + *
Type: INTEGER (int)
+ * @hide + */ + public static final String COLUMN_PORT_INDEX = "port_index"; + /** * A testing profile can be pre-loaded or downloaded onto * the eUICC and provides connectivity to test equipment diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 4b8b590b03ca..974392ea31eb 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -940,6 +940,13 @@ public class SubscriptionManager { */ public static final String PROFILE_CLASS = SimInfo.COLUMN_PROFILE_CLASS; + /** + * TelephonyProvider column name for the port index of the active UICC port. + *Type: INTEGER (int)
+ * @hide + */ + public static final String PORT_INDEX = SimInfo.COLUMN_PORT_INDEX; + /** * TelephonyProvider column name for VoIMS opt-in status. * diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index db1f49760865..a5adf52051b9 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -327,6 +327,9 @@ public class TelephonyManager { */ public static final int DEFAULT_PORT_INDEX = 0; + /** @hide */ + public static final int INVALID_PORT_INDEX = -1; + private final Context mContext; private final int mSubId; @UnsupportedAppUsage diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index c59f410c3c5b..a1e4f29719d2 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -803,6 +803,13 @@ public class EuiccManager { */ public static final int ERROR_OPERATION_BUSY = 10016; + /** + * Failure due to target port is not supported. + * @see #switchToSubscription(int, int, PendingIntent) + */ + public static final int ERROR_INVALID_PORT = 10017; + + private final Context mContext; private int mCardId; @@ -1118,6 +1125,15 @@ public class EuiccManager { * intent to prompt the user to accept the download. The caller should also be authorized to * manage the subscription to be enabled. * + *From Android T, devices might support MEP(Multiple Enabled Profile), the subscription + * can be installed on different port from the eUICC. Calling apps with carrier privilege + * (see {@link TelephonyManager#hasCarrierPrivileges}) over the currently active subscriptions + * can use {@link #switchToSubscription(int, int, PendingIntent)} to specify which port to + * enable the subscription. Otherwise, use this API to enable the subscription on the eUICC + * and the platform will internally resolve a port. If there is no available port, + * an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} might be returned in the callback + * intent to prompt the user to disable an already-active subscription. + * * @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. If it's a disable @@ -1125,12 +1141,7 @@ public class EuiccManager { * 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. - * - * @deprecated From T, callers should use - * {@link #switchToSubscription(int, int, PendingIntent)} instead to specify a port - * index on the card to switch to. */ - @Deprecated @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) { if (!isEnabled()) { @@ -1148,20 +1159,19 @@ public class EuiccManager { /** * Switch to (enable) the given subscription. * - *
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 enabled 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. + *
Requires the {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission, + * or the caller must be having both the carrier privileges + * (see {@link TelephonyManager#hasCarrierPrivileges}) over any currently active subscriptions + * and the subscription to be enabled according to the subscription metadata. + * Without the former permissions, an SecurityException is thrown. * - *
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. + *
If the caller is passing invalid port index, + * an {@link #EMBEDDED_SUBSCRIPTION_RESULT_ERROR} with detailed error code + * {@link #ERROR_INVALID_PORT} will be returned. + * + *
Depending on the target port and permission check, + * an {@link #EMBEDDED_SUBSCRIPTION_RESULT_RESOLVABLE_ERROR} might be returned to the callback + * intent to prompt the user to authorize before the switch. * * @param subscriptionId the ID of the subscription to enable. May be * {@link android.telephony.SubscriptionManager#INVALID_SUBSCRIPTION_ID} to deactivate the