From 19fab789264a2d2d314d212c9a5c44eeb11fa590 Mon Sep 17 00:00:00 2001 From: Junda Liu Date: Thu, 10 Mar 2016 09:55:15 -0800 Subject: [PATCH] Add public API for sim authentication. Bug: b/27360179 Change-Id: I95bc51797a808fd754202b671113ee0a60a8b99d --- api/current.txt | 10 ++- api/system-current.txt | 10 ++- api/test-current.txt | 10 ++- .../android/telephony/TelephonyManager.java | 62 +++++++++++++++---- .../internal/telephony/IPhoneSubInfo.aidl | 3 +- .../internal/telephony/PhoneConstants.java | 6 ++ 6 files changed, 86 insertions(+), 15 deletions(-) diff --git a/api/current.txt b/api/current.txt index e253ae1e01b4b..093e954b9774b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -37334,7 +37334,8 @@ package android.telephony { method public java.lang.String getDeviceSoftwareVersion(); method public java.lang.String getGroupIdLevel1(); method public java.lang.String getGroupIdLevel1(int); - method public java.lang.String getIccSimChallengeResponse(int, java.lang.String); + method public java.lang.String getIccAuthentication(int, int, java.lang.String); + method public java.lang.String getIccAuthentication(int, int, int, java.lang.String); method public java.lang.String getLine1AlphaTag(int); method public java.lang.String getLine1Number(); method public java.lang.String getLine1Number(int); @@ -37403,6 +37404,13 @@ package android.telephony { field public static final java.lang.String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL"; field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; + field public static final int APPTYPE_CSIM = 4; // 0x4 + field public static final int APPTYPE_ISIM = 5; // 0x5 + field public static final int APPTYPE_RUIM = 3; // 0x3 + field public static final int APPTYPE_SIM = 1; // 0x1 + field public static final int APPTYPE_USIM = 2; // 0x2 + field public static final int AUTHTYPE_EAP_AKA = 129; // 0x81 + field public static final int AUTHTYPE_EAP_SIM = 128; // 0x80 field public static final int CALL_STATE_IDLE = 0; // 0x0 field public static final int CALL_STATE_OFFHOOK = 2; // 0x2 field public static final int CALL_STATE_RINGING = 1; // 0x1 diff --git a/api/system-current.txt b/api/system-current.txt index c9176ecf03c37..1e0a2a190a3fc 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -40051,7 +40051,8 @@ package android.telephony { method public java.lang.String getDeviceSoftwareVersion(); method public java.lang.String getGroupIdLevel1(); method public java.lang.String getGroupIdLevel1(int); - method public java.lang.String getIccSimChallengeResponse(int, java.lang.String); + method public java.lang.String getIccAuthentication(int, int, java.lang.String); + method public java.lang.String getIccAuthentication(int, int, int, java.lang.String); method public java.lang.String getLine1AlphaTag(int); method public java.lang.String getLine1Number(); method public java.lang.String getLine1Number(int); @@ -40141,6 +40142,13 @@ package android.telephony { field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; field public static final java.lang.String ACTION_SHOW_VOICEMAIL_NOTIFICATION = "android.telephony.action.SHOW_VOICEMAIL_NOTIFICATION"; + field public static final int APPTYPE_CSIM = 4; // 0x4 + field public static final int APPTYPE_ISIM = 5; // 0x5 + field public static final int APPTYPE_RUIM = 3; // 0x3 + field public static final int APPTYPE_SIM = 1; // 0x1 + field public static final int APPTYPE_USIM = 2; // 0x2 + field public static final int AUTHTYPE_EAP_AKA = 129; // 0x81 + field public static final int AUTHTYPE_EAP_SIM = 128; // 0x80 field public static final int CALL_STATE_IDLE = 0; // 0x0 field public static final int CALL_STATE_OFFHOOK = 2; // 0x2 field public static final int CALL_STATE_RINGING = 1; // 0x1 diff --git a/api/test-current.txt b/api/test-current.txt index a7b434ca6f2bb..e10164ff5004e 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -37406,7 +37406,8 @@ package android.telephony { method public java.lang.String getDeviceSoftwareVersion(); method public java.lang.String getGroupIdLevel1(); method public java.lang.String getGroupIdLevel1(int); - method public java.lang.String getIccSimChallengeResponse(int, java.lang.String); + method public java.lang.String getIccAuthentication(int, int, java.lang.String); + method public java.lang.String getIccAuthentication(int, int, int, java.lang.String); method public java.lang.String getLine1AlphaTag(int); method public java.lang.String getLine1Number(); method public java.lang.String getLine1Number(int); @@ -37475,6 +37476,13 @@ package android.telephony { field public static final java.lang.String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL"; field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; + field public static final int APPTYPE_CSIM = 4; // 0x4 + field public static final int APPTYPE_ISIM = 5; // 0x5 + field public static final int APPTYPE_RUIM = 3; // 0x3 + field public static final int APPTYPE_SIM = 1; // 0x1 + field public static final int APPTYPE_USIM = 2; // 0x2 + field public static final int AUTHTYPE_EAP_AKA = 129; // 0x81 + field public static final int AUTHTYPE_EAP_SIM = 128; // 0x80 field public static final int CALL_STATE_IDLE = 0; // 0x0 field public static final int CALL_STATE_OFFHOOK = 2; // 0x2 field public static final int CALL_STATE_RINGING = 1; // 0x1 diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index b482811a18f23..865af7821ac2f 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -3550,7 +3550,7 @@ public class TelephonyManager { * @return the response of ISIM Authetification, or null if not available * @hide * @deprecated - * @see getIccSimChallengeResponse with appType=PhoneConstants.APPTYPE_ISIM + * @see getIccAuthentication with appType=PhoneConstants.APPTYPE_ISIM */ public String getIsimChallengeResponse(String nonce){ try { @@ -3566,21 +3566,60 @@ public class TelephonyManager { } } + // ICC SIM Application Types + public static final int APPTYPE_SIM = PhoneConstants.APPTYPE_SIM; + public static final int APPTYPE_USIM = PhoneConstants.APPTYPE_USIM; + public static final int APPTYPE_RUIM = PhoneConstants.APPTYPE_RUIM; + public static final int APPTYPE_CSIM = PhoneConstants.APPTYPE_CSIM; + public static final int APPTYPE_ISIM = PhoneConstants.APPTYPE_ISIM; + // authContext (parameter P2) when doing SIM challenge, + // per 3GPP TS 31.102 (Section 7.1.2) + public static final int AUTHTYPE_EAP_SIM = PhoneConstants.AUTH_CONTEXT_EAP_SIM; + public static final int AUTHTYPE_EAP_AKA = PhoneConstants.AUTH_CONTEXT_EAP_AKA; + /** - * Returns the response of SIM Authentication through RIL. - * Returns null if the Authentication hasn't been successful - * @param subId subscription ID to be queried - * @param appType ICC application type (@see com.android.internal.telephony.PhoneConstants#APPTYPE_xxx) - * @param data authentication challenge data - * @return the response of SIM Authentication, or null if not available - * @hide + * Returns the response of authentication for the default subscription. + * Returns null if the authentication hasn't been successful + * + *

Requires that the calling app has carrier privileges or READ_PRIVILEGED_PHONE_STATE + * permission. + * + * @param appType the icc application type, like {@link #APPTYPE_USIM} + * @param authType the authentication type, {@link #AUTHTYPE_EAP_AKA} or + * {@link #AUTHTYPE_EAP_SIM} + * @param data authentication challenge data, base64 encoded. + * See 3GPP TS 31.102 7.1.2 for more details. + * @return the response of authentication, or null if not available + * + * @see #hasCarrierPrivileges */ - public String getIccSimChallengeResponse(int subId, int appType, String data) { + public String getIccAuthentication(int appType, int authType, String data) { + return getIccAuthentication(getDefaultSubscription(), appType, authType, data); + } + + /** + * Returns the response of USIM Authentication for specified subId. + * Returns null if the authentication hasn't been successful + * + *

Requires that the calling app has carrier privileges. + * + * @param subId subscription ID used for authentication + * @param appType the icc application type, like {@link #APPTYPE_USIM} + * @param authType the authentication type, {@link #AUTHTYPE_EAP_AKA} or + * {@link #AUTHTYPE_EAP_SIM} + * @param data authentication challenge data, base64 encoded. + * See 3GPP TS 31.102 7.1.2 for more details. + * @return the response of authentication, or null if not available + * + * @see #hasCarrierPrivileges + */ + + public String getIccAuthentication(int subId, int appType, int authType, String data) { try { IPhoneSubInfo info = getSubscriberInfo(); if (info == null) return null; - return info.getIccSimChallengeResponse(subId, appType, data); + return info.getIccSimChallengeResponse(subId, appType, authType, data); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3599,9 +3638,10 @@ public class TelephonyManager { * @param appType ICC application type (@see com.android.internal.telephony.PhoneConstants#APPTYPE_xxx) * @param data authentication challenge data * @return the response of SIM Authentication, or null if not available + * @hide */ public String getIccSimChallengeResponse(int appType, String data) { - return getIccSimChallengeResponse(getDefaultSubscription(), appType, data); + return getIccAuthentication(getDefaultSubscription(), appType, AUTHTYPE_EAP_SIM, data); } /** diff --git a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl index dc2b297f6dbe5..02baa34545363 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl @@ -196,8 +196,9 @@ interface IPhoneSubInfo { * * @param subId subscription ID to be queried * @param appType ICC application type (@see com.android.internal.telephony.PhoneConstants#APPTYPE_xxx) + * @param authType Authentication type, see PhoneConstants#AUTHTYPE_xxx * @param data authentication challenge data * @return challenge response */ - String getIccSimChallengeResponse(int subId, int appType, String data); + String getIccSimChallengeResponse(int subId, int appType, int authType, String data); } diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index ecd89eda45774..1680fe33ead79 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -202,4 +202,10 @@ public class PhoneConstants { public static final int AUDIO_OUTPUT_ENABLE_SPEAKER = 0; public static final int AUDIO_OUTPUT_DISABLE_SPEAKER = 1; public static final int AUDIO_OUTPUT_DEFAULT = AUDIO_OUTPUT_ENABLE_SPEAKER; + + // authContext (parameter P2) when doing SIM challenge, + // per 3GPP TS 31.102 (Section 7.1.2) + public static final int AUTH_CONTEXT_EAP_SIM = 128; + public static final int AUTH_CONTEXT_EAP_AKA = 129; + public static final int AUTH_CONTEXT_UNDEFINED = -1; }