Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19fab789 authored by Junda Liu's avatar Junda Liu
Browse files

Add public API for sim authentication.

Bug: b/27360179
Change-Id: I95bc51797a808fd754202b671113ee0a60a8b99d
parent 5fe29adc
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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
+9 −1
Original line number Diff line number Diff line
@@ -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
+9 −1
Original line number Diff line number Diff line
@@ -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
+51 −11
Original line number Diff line number Diff line
@@ -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
     *
     * <p>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
     *
     * <p>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);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -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);
}
Loading