Add UNINITIALIZED and rename INVALID

UNINITIALIZED_CARD_ID is for before the card ID is ready.
INVALID_CARD_ID is renamed to UNSUPPORTED_CARD_ID and it is used if the
card ID is known to be unsupported.

Bug: 122978614
Test: atest UiccControllerTest
Change-Id: Ia2315d9b38ef35b30d9b96b6436c08fa4404e4df
This commit is contained in:
Jordan Liu
2019-02-01 14:15:05 -08:00
parent 1f0613f659
commit cb47d1dcc7
4 changed files with 52 additions and 28 deletions

View File

@@ -45201,7 +45201,6 @@ package android.telephony {
field public static final String EXTRA_STATE_RINGING; 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_SUBSCRIPTION_ID = "android.telephony.extra.SUBSCRIPTION_ID";
field public static final String EXTRA_VOICEMAIL_NUMBER = "android.telephony.extra.VOICEMAIL_NUMBER"; 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 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_1xRTT = 7; // 0x7
field public static final int NETWORK_TYPE_CDMA = 4; // 0x4 field public static final int NETWORK_TYPE_CDMA = 4; // 0x4
@@ -45237,7 +45236,9 @@ package android.telephony {
field public static final int SIM_STATE_PUK_REQUIRED = 3; // 0x3 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_READY = 5; // 0x5
field public static final int SIM_STATE_UNKNOWN = 0; // 0x0 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 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_ERROR_SERVICE_UNAVAIL = -2; // 0xfffffffe
field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff
field public static final String VVM_TYPE_CVVM = "vvm_type_cvvm"; field public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";

View File

@@ -76,6 +76,11 @@ import java.util.concurrent.atomic.AtomicInteger;
* filter with the appropriate action, the {@link #CATEGORY_EUICC_UI} category, and a non-zero * filter with the appropriate action, the {@link #CATEGORY_EUICC_UI} category, and a non-zero
* priority. * 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 * @hide
*/ */
@SystemApi @SystemApi
@@ -546,7 +551,7 @@ public abstract class EuiccService extends Service {
int resultCode = EuiccService.this.onDownloadSubscription( int resultCode = EuiccService.this.onDownloadSubscription(
slotId, subscription, switchAfterDownload, forceDeactivateSim); slotId, subscription, switchAfterDownload, forceDeactivateSim);
result = new DownloadSubscriptionResult(resultCode, result = new DownloadSubscriptionResult(resultCode,
0 /* resolvableErrors */, TelephonyManager.INVALID_CARD_ID); 0 /* resolvableErrors */, TelephonyManager.UNSUPPORTED_CARD_ID);
} }
try { try {
callback.onComplete(result); callback.onComplete(result);

View File

@@ -229,10 +229,19 @@ public class TelephonyManager {
public static final int SRVCC_STATE_HANDOVER_CANCELED = 3; public static final int SRVCC_STATE_HANDOVER_CANCELED = 3;
/** /**
* An invalid UICC card identifier. See {@link #getCardIdForDefaultEuicc()} and * A UICC card identifier used if the device does not support the operation.
* {@link UiccCardInfo#getCardId()}. * 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 */ /** @hide */
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@@ -3178,24 +3187,25 @@ public class TelephonyManager {
} }
/** /**
* Get the card ID of the default eUICC card. If there is no eUICC, returns * Get the card ID of the default eUICC card. If the eUICCs have not yet been loaded, returns
* {@link #INVALID_CARD_ID}. * {@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 * <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 * unique to a device, and always refer to the same UICC or eUICC card unless the device goes
* through a factory reset. * 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() { public int getCardIdForDefaultEuicc() {
try { try {
ITelephony telephony = getITelephony(); ITelephony telephony = getITelephony();
if (telephony == null) { if (telephony == null) {
return INVALID_CARD_ID; return UNINITIALIZED_CARD_ID;
} }
return telephony.getCardIdForDefaultEuicc(mSubId, mContext.getOpPackageName()); return telephony.getCardIdForDefaultEuicc(mSubId, mContext.getOpPackageName());
} catch (RemoteException e) { } catch (RemoteException e) {
return INVALID_CARD_ID; return UNINITIALIZED_CARD_ID;
} }
} }

View File

@@ -460,7 +460,7 @@ public class EuiccManager {
*/ */
@Nullable @Nullable
public String getEid() { public String getEid() {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
return null; return null;
} }
try { try {
@@ -483,7 +483,7 @@ public class EuiccManager {
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public int getOtaStatus() { public int getOtaStatus() {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
return EUICC_OTA_STATUS_UNAVAILABLE; return EUICC_OTA_STATUS_UNAVAILABLE;
} }
try { try {
@@ -518,7 +518,7 @@ public class EuiccManager {
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void downloadSubscription(DownloadableSubscription subscription, public void downloadSubscription(DownloadableSubscription subscription,
boolean switchAfterDownload, PendingIntent callbackIntent) { boolean switchAfterDownload, PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -580,7 +580,7 @@ public class EuiccManager {
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void continueOperation(Intent resolutionIntent, Bundle resolutionExtras) { public void continueOperation(Intent resolutionIntent, Bundle resolutionExtras) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
PendingIntent callbackIntent = PendingIntent callbackIntent =
resolutionIntent.getParcelableExtra( resolutionIntent.getParcelableExtra(
EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT); EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT);
@@ -617,7 +617,7 @@ public class EuiccManager {
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void getDownloadableSubscriptionMetadata( public void getDownloadableSubscriptionMetadata(
DownloadableSubscription subscription, PendingIntent callbackIntent) { DownloadableSubscription subscription, PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -647,7 +647,7 @@ public class EuiccManager {
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void getDefaultDownloadableSubscriptionList(PendingIntent callbackIntent) { public void getDefaultDownloadableSubscriptionList(PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -666,7 +666,7 @@ public class EuiccManager {
*/ */
@Nullable @Nullable
public EuiccInfo getEuiccInfo() { public EuiccInfo getEuiccInfo() {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
return null; return null;
} }
try { try {
@@ -691,7 +691,7 @@ public class EuiccManager {
*/ */
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void deleteSubscription(int subscriptionId, PendingIntent callbackIntent) { public void deleteSubscription(int subscriptionId, PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -731,7 +731,7 @@ public class EuiccManager {
*/ */
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) { public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -757,7 +757,7 @@ public class EuiccManager {
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void updateSubscriptionNickname( public void updateSubscriptionNickname(
int subscriptionId, String nickname, PendingIntent callbackIntent) { int subscriptionId, String nickname, PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -781,7 +781,7 @@ public class EuiccManager {
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS)
public void eraseSubscriptions(PendingIntent callbackIntent) { public void eraseSubscriptions(PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -811,7 +811,7 @@ public class EuiccManager {
* @hide * @hide
*/ */
public void retainSubscriptionsForFactoryReset(PendingIntent callbackIntent) { public void retainSubscriptionsForFactoryReset(PendingIntent callbackIntent) {
if (!refreshCardIdIfInvalid()) { if (!refreshCardIdIfUninitialized()) {
sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent);
return; return;
} }
@@ -822,16 +822,24 @@ public class EuiccManager {
} }
} }
private boolean refreshCardIdIfInvalid() { /**
if (!isEnabled()) { * Refreshes the cardId if its uninitialized, and returns whether we should continue the
return false; * operation.
} * <p>
// Refresh mCardId if it's invalid. * Note that after a successful refresh, the mCardId may be TelephonyManager.UNSUPPORTED_CARD_ID
if (mCardId == TelephonyManager.INVALID_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) TelephonyManager tm = (TelephonyManager)
mContext.getSystemService(Context.TELEPHONY_SERVICE); mContext.getSystemService(Context.TELEPHONY_SERVICE);
mCardId = tm.getCardIdForDefaultEuicc(); mCardId = tm.getCardIdForDefaultEuicc();
} }
if (mCardId == TelephonyManager.UNINITIALIZED_CARD_ID) {
return false;
}
return true; return true;
} }