From 2fe9e3748ae17ed15e7b3ff28139b91d00d0350e Mon Sep 17 00:00:00 2001 From: Jordan Liu Date: Thu, 6 Dec 2018 16:11:08 -0800 Subject: Add API to get card ID for default eUICC getCardIdForDefaultEuicc() returns the cardId of the default eUICC. Bug: 80097562 Test: manual, UiccControllerTest Change-Id: Iee001ce354184dff4862a92b6bda261797c19e56 --- api/system-current.txt | 2 ++ .../java/android/telephony/TelephonyManager.java | 35 ++++++++++++++++++++++ .../com/android/internal/telephony/ITelephony.aidl | 13 ++++++++ 3 files changed, 50 insertions(+) diff --git a/api/system-current.txt b/api/system-current.txt index 4aaed7a83ffb..7d508150a832 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5335,6 +5335,7 @@ package android.telephony { method public void enableVideoCalling(boolean); method public java.lang.String getAidForAppType(int); method public java.util.List getAllowedCarriers(int); + method public int getCardIdForDefaultEuicc(); method public java.util.List getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); method public java.lang.String getCdmaMdn(); @@ -5400,6 +5401,7 @@ package android.telephony { field public static final java.lang.String EXTRA_SIM_STATE = "android.telephony.extra.SIM_STATE"; field public static final java.lang.String EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL = "android.telephony.extra.VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL"; field public static final java.lang.String EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING = "android.telephony.extra.VOICEMAIL_SCRAMBLED_PIN_STRING"; + field public static final int INVALID_CARD_ID = -1; // 0xffffffff field public static final long MAX_NUMBER_VERIFICATION_TIMEOUT_MILLIS = 60000L; // 0xea60L field public static final int NETWORK_MODE_CDMA_EVDO = 4; // 0x4 field public static final int NETWORK_MODE_CDMA_NO_EVDO = 5; // 0x5 diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 585c0e40d478..2f4a5193bbba 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -225,6 +225,13 @@ public class TelephonyManager { @SystemApi public static final int SRVCC_STATE_HANDOVER_CANCELED = 3; + /** + * An invalid card identifier. + * @hide + */ + @SystemApi + public static final int INVALID_CARD_ID = -1; + /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef(prefix = {"SRVCC_STATE_"}, @@ -3090,6 +3097,34 @@ public class TelephonyManager { } } + /** + * Get the card ID of the default eUICC card. If there is no eUICC, returns + * {@link #INVALID_CARD_ID}. + * + *

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. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * + * @return card ID of the default eUICC card. + * @hide + */ + @SystemApi + @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges + @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) + public int getCardIdForDefaultEuicc() { + try { + ITelephony telephony = getITelephony(); + if (telephony == null) { + return INVALID_CARD_ID; + } + return telephony.getCardIdForDefaultEuicc(mSubId, mContext.getOpPackageName()); + } catch (RemoteException e) { + return INVALID_CARD_ID; + } + } + /** * Gets all the UICC slots. The objects in the array can be null if the slot info is not * available, which is possible between phone process starting and getting slot info from modem. diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 8a1fb7bc8ff0..5a06f6aaf7ea 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1481,6 +1481,19 @@ interface ITelephony { */ SignalStrength getSignalStrength(int subId); + /** + * Get the card ID of the default eUICC card. If there is no eUICC, returns + * {@link #INVALID_CARD_ID}. + * + *

Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * + * @param subId subscription ID used for authentication + * @param callingPackage package making the call + * @return card ID of the default eUICC card. + * @hide + */ + int getCardIdForDefaultEuicc(int subId, String callingPackage); + /** * Get slot info for all the UICC slots. * @return UiccSlotInfo array. -- cgit v1.2.3-59-g8ed1b