Merge "Add UNINITIALIZED and rename INVALID" am: b8493ac5eb
am: aa20ef0836
Change-Id: I2ad19b617f0165e7bcabac567463dfe8f4b175c6
diff --git a/api/current.txt b/api/current.txt
index c5fbbeb..060d981 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -43162,7 +43162,6 @@
field public static final String EXTRA_STATE_RINGING;
field public static final String EXTRA_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID";
field public static final String EXTRA_VOICEMAIL_NUMBER = "android.telephony.extra.VOICEMAIL_NUMBER";
- field public static final int INVALID_CARD_ID = -1; // 0xffffffff
field public static final String METADATA_HIDE_VOICEMAIL_SETTINGS_MENU = "android.telephony.HIDE_VOICEMAIL_SETTINGS_MENU";
field public static final int NETWORK_TYPE_1xRTT = 7; // 0x7
field public static final int NETWORK_TYPE_CDMA = 4; // 0x4
@@ -43198,7 +43197,9 @@
field public static final int SIM_STATE_PUK_REQUIRED = 3; // 0x3
field public static final int SIM_STATE_READY = 5; // 0x5
field public static final int SIM_STATE_UNKNOWN = 0; // 0x0
+ field public static final int UNINITIALIZED_CARD_ID = -2; // 0xfffffffe
field public static final int UNKNOWN_CARRIER_ID = -1; // 0xffffffff
+ field public static final int UNSUPPORTED_CARD_ID = -1; // 0xffffffff
field public static final int USSD_ERROR_SERVICE_UNAVAIL = -2; // 0xfffffffe
field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff
field public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";
diff --git a/core/java/android/service/euicc/EuiccService.java b/core/java/android/service/euicc/EuiccService.java
index b84e556..53cc25b 100644
--- a/core/java/android/service/euicc/EuiccService.java
+++ b/core/java/android/service/euicc/EuiccService.java
@@ -76,6 +76,11 @@
* filter with the appropriate action, the {@link #CATEGORY_EUICC_UI} category, and a non-zero
* priority.
*
+ * <p>Old implementations of EuiccService may support passing in slot IDs equal to
+ * {@link android.telephony.SubscriptionManager#INVALID_SIM_SLOT_INDEX}, which allows the LPA to
+ * decide which eUICC to target when there are multiple eUICCs. This behavior is not supported in
+ * Android Q or later.
+ *
* @hide
*/
@SystemApi
@@ -520,7 +525,7 @@
int resultCode = EuiccService.this.onDownloadSubscription(
slotId, subscription, switchAfterDownload, forceDeactivateSim);
result = new DownloadSubscriptionResult(resultCode,
- 0 /* resolvableErrors */, TelephonyManager.INVALID_CARD_ID);
+ 0 /* resolvableErrors */, TelephonyManager.UNSUPPORTED_CARD_ID);
}
try {
callback.onComplete(result);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index b007061..1246dd8 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -229,10 +229,19 @@
public static final int SRVCC_STATE_HANDOVER_CANCELED = 3;
/**
- * An invalid UICC card identifier. See {@link #getCardIdForDefaultEuicc()} and
- * {@link UiccCardInfo#getCardId()}.
+ * A UICC card identifier used if the device does not support the operation.
+ * For example, {@link #getCardIdForDefaultEuicc()} returns this value if the device has no
+ * eUICC, or the eUICC cannot be read.
*/
- public static final int INVALID_CARD_ID = -1;
+ public static final int UNSUPPORTED_CARD_ID = -1;
+
+ /**
+ * A UICC card identifier used before the UICC card is loaded. See
+ * {@link #getCardIdForDefaultEuicc()} and {@link UiccCardInfo#getCardId()}.
+ * <p>
+ * Note that once the UICC card is loaded, the card ID may become {@link #UNSUPPORTED_CARD_ID}.
+ */
+ public static final int UNINITIALIZED_CARD_ID = -2;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@@ -3130,24 +3139,25 @@
}
/**
- * Get the card ID of the default eUICC card. If there is no eUICC, returns
- * {@link #INVALID_CARD_ID}.
+ * Get the card ID of the default eUICC card. If the eUICCs have not yet been loaded, returns
+ * {@link #UNINITIALIZED_CARD_ID}. If there is no eUICC or the device does not support card IDs
+ * for eUICCs, returns {@link #UNSUPPORTED_CARD_ID}.
*
* <p>The card ID is a unique identifier associated with a UICC or eUICC card. Card IDs are
* unique to a device, and always refer to the same UICC or eUICC card unless the device goes
* through a factory reset.
*
- * @return card ID of the default eUICC card.
+ * @return card ID of the default eUICC card, if loaded.
*/
public int getCardIdForDefaultEuicc() {
try {
ITelephony telephony = getITelephony();
if (telephony == null) {
- return INVALID_CARD_ID;
+ return UNINITIALIZED_CARD_ID;
}
return telephony.getCardIdForDefaultEuicc(mSubId, mContext.getOpPackageName());
} catch (RemoteException e) {
- return INVALID_CARD_ID;
+ return UNINITIALIZED_CARD_ID;
}
}
diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java
index 40c6f70..828e3e9 100644
--- a/telephony/java/android/telephony/euicc/EuiccManager.java
+++ b/telephony/java/android/telephony/euicc/EuiccManager.java
@@ -305,7 +305,7 @@
*/
@Nullable
public String getEid() {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
return null;
}
try {
@@ -328,7 +328,7 @@
@SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public int getOtaStatus() {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
return EUICC_OTA_STATUS_UNAVAILABLE;
}
try {
@@ -363,7 +363,7 @@
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void downloadSubscription(DownloadableSubscription subscription,
boolean switchAfterDownload, PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -425,7 +425,7 @@
@SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void continueOperation(Intent resolutionIntent, Bundle resolutionExtras) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
PendingIntent callbackIntent =
resolutionIntent.getParcelableExtra(
EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT);
@@ -462,7 +462,7 @@
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void getDownloadableSubscriptionMetadata(
DownloadableSubscription subscription, PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -492,7 +492,7 @@
@SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void getDefaultDownloadableSubscriptionList(PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -511,7 +511,7 @@
*/
@Nullable
public EuiccInfo getEuiccInfo() {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
return null;
}
try {
@@ -536,7 +536,7 @@
*/
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void deleteSubscription(int subscriptionId, PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -576,7 +576,7 @@
*/
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -602,7 +602,7 @@
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void updateSubscriptionNickname(
int subscriptionId, String nickname, PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -626,7 +626,7 @@
@SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void eraseSubscriptions(PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -656,7 +656,7 @@
* @hide
*/
public void retainSubscriptionsForFactoryReset(PendingIntent callbackIntent) {
- if (!refreshCardIdIfInvalid()) {
+ if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent);
return;
}
@@ -667,16 +667,24 @@
}
}
- private boolean refreshCardIdIfInvalid() {
- if (!isEnabled()) {
- return false;
- }
- // Refresh mCardId if it's invalid.
- if (mCardId == TelephonyManager.INVALID_CARD_ID) {
+ /**
+ * Refreshes the cardId if its uninitialized, and returns whether we should continue the
+ * operation.
+ * <p>
+ * Note that after a successful refresh, the mCardId may be TelephonyManager.UNSUPPORTED_CARD_ID
+ * on older HALs. For backwards compatability, we continue to the LPA and let it decide which
+ * card to use.
+ */
+ private boolean refreshCardIdIfUninitialized() {
+ // Refresh mCardId if its UNINITIALIZED_CARD_ID
+ if (mCardId == TelephonyManager.UNINITIALIZED_CARD_ID) {
TelephonyManager tm = (TelephonyManager)
mContext.getSystemService(Context.TELEPHONY_SERVICE);
mCardId = tm.getCardIdForDefaultEuicc();
}
+ if (mCardId == TelephonyManager.UNINITIALIZED_CARD_ID) {
+ return false;
+ }
return true;
}