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

Commit 463f2211 authored by Jake Hamby's avatar Jake Hamby
Browse files

Add ISIM application support for LTE devices.

- Add methods to TelephonyManager to provide access to IMS records on
  the ISIM application of the UICC, as well as access to the ISIM
  AKA authentication algorithm.

- Add support for the new IMS methods to CDMALTEPhone, using the helper class
  ImsUiccRecords to load the IMS records from the ISIM. The same approach
  can be used to implement IMS support for UMTS/LTE devices.

- There is a new RIL request, RIL_REQUEST_ISIM_AUTHENTICATION, which is
  used to perform IMS AKA authentication using the algorithm on the ISIM
  application of the UICC. The challenge nonce and response are both encoded
  as Base64 strings.

Change-Id: I73367c7d9bc573d0d883d68adf09891de1319129
parent b59997f7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -582,6 +582,12 @@
        android:label="@string/permlab_readPhoneState"
        android:description="@string/permdesc_readPhoneState" />

    <!-- Allows read access to privileged phone state.
         @hide Used internally. -->
    <permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
        android:permissionGroup="android.permission-group.PHONE_CALLS"
        android:protectionLevel="signatureOrSystem" />

    <!-- ================================== -->
    <!-- Permissions for sdcard interaction -->
    <!-- ================================== -->
+49 −0
Original line number Diff line number Diff line
@@ -832,6 +832,55 @@ public class TelephonyManager {
        }
    }

    /**
     * Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
     * @return the IMPI, or null if not present or not loaded
     * @hide
     */
    public String getIsimImpi() {
        try {
            return getSubscriberInfo().getIsimImpi();
        } catch (RemoteException ex) {
            return null;
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            return null;
        }
    }

    /**
     * Returns the IMS home network domain name that was loaded from the ISIM.
     * @return the IMS domain name, or null if not present or not loaded
     * @hide
     */
    public String getIsimDomain() {
        try {
            return getSubscriberInfo().getIsimDomain();
        } catch (RemoteException ex) {
            return null;
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            return null;
        }
    }

    /**
     * Returns the IMS public user identities (IMPU) that were loaded from the ISIM.
     * @return an array of IMPU strings, with one IMPU per string, or null if
     *      not present or not loaded
     * @hide
     */
    public String[] getIsimImpu() {
        try {
            return getSubscriberInfo().getIsimImpu();
        } catch (RemoteException ex) {
            return null;
        } catch (NullPointerException ex) {
            // This could happen before phone restarts due to crashing
            return null;
        }
    }

    private IPhoneSubInfo getSubscriberInfo() {
        // get it each time because that process crashes a lot
        return IPhoneSubInfo.Stub.asInterface(ServiceManager.getService("iphonesubinfo"));
+13 −6
Original line number Diff line number Diff line
@@ -1489,11 +1489,8 @@ public interface CommandsInterface {

    /**
     * Setup a packet data connection On successful completion, the result
     * message will return the following: [0] indicating PDP CID, which is
     * generated by RIL. This Connection ID is used in both GSM/UMTS and CDMA
     * modes [1] indicating the network interface name for GSM/UMTS or CDMA [2]
     * indicating the IP address for this interface for GSM/UMTS and NULL in the
     * case of CDMA
     * message will return a {@link DataCallState} object containing the connection
     * information.
     *
     * @param radioTechnology
     *            indicates whether to setup connection on radio technology CDMA
@@ -1569,7 +1566,7 @@ public interface CommandsInterface {
    /**
     * Request the status of the ICC and UICC cards.
     *
     * @param response
     * @param result
     *          Callback message containing {@link IccCardStatus} structure for the card.
     */
    public void getIccCardStatus(Message result);
@@ -1583,4 +1580,14 @@ public interface CommandsInterface {
     * or {@link Phone#LTE_ON_CDMA_TRUE}
     */
    public int getLteOnCdmaMode();

    /**
     * Request the ISIM application on the UICC to perform the AKA
     * challenge/response algorithm for IMS authentication. The nonce string
     * and challenge response are Base64 encoded Strings.
     *
     * @param nonce the nonce string to pass with the ISIM authentication request
     * @param response a callback message with the String response in the obj field
     */
    public void requestIsimAuthentication(String nonce, Message response);
}
+19 −0
Original line number Diff line number Diff line
@@ -67,4 +67,23 @@ interface IPhoneSubInfo {
     * Retrieves the alpha identifier associated with the voice mail number.
     */
    String getVoiceMailAlphaTag();

    /**
     * Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
     * @return the IMPI, or null if not present or not loaded
     */
    String getIsimImpi();

    /**
     * Returns the IMS home network domain name that was loaded from the ISIM.
     * @return the IMS domain name, or null if not present or not loaded
     */
    String getIsimDomain();

    /**
     * Returns the IMS public user identities (IMPU) that were loaded from the ISIM.
     * @return an array of IMPU strings, with one IMPU per string, or null if
     *      not present or not loaded
     */
    String[] getIsimImpu();
}
+61 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.os.Message;
import android.os.Registrant;
import android.os.RegistrantList;

import com.android.internal.telephony.ims.IsimRecords;

/**
 * {@hide}
 */
@@ -70,6 +72,24 @@ public abstract class IccRecords extends Handler implements IccConstants {
    // ***** Event Constants
    protected static final int EVENT_SET_MSISDN_DONE = 30;

    public static final int EVENT_GET_ICC_RECORD_DONE = 100;

    /**
     * Generic ICC record loaded callback. Subclasses can call EF load methods on
     * {@link IccFileHandler} passing a Message for onLoaded with the what field set to
     * {@link #EVENT_GET_ICC_RECORD_DONE} and the obj field set to an instance
     * of this interface. The {@link #handleMessage} method in this class will print a
     * log message using {@link #getEfName()} and decrement {@link #recordsToLoad}.
     *
     * If the record load was successful, {@link #onRecordLoaded} will be called with the result.
     * Otherwise, an error log message will be output by {@link #handleMessage} and
     * {@link #onRecordLoaded} will not be called.
     */
    public interface IccRecordLoaded {
        String getEfName();
        void onRecordLoaded(AsyncResult ar);
    }

    // ***** Constructor

    public IccRecords(PhoneBase p) {
@@ -234,7 +254,32 @@ public abstract class IccRecords extends Handler implements IccConstants {

    //***** Overridden from Handler
    @Override
    public abstract void handleMessage(Message msg);
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case EVENT_GET_ICC_RECORD_DONE:
                try {
                    AsyncResult ar = (AsyncResult) msg.obj;
                    IccRecordLoaded recordLoaded = (IccRecordLoaded) ar.userObj;
                    if (DBG) log(recordLoaded.getEfName() + " LOADED");

                    if (ar.exception != null) {
                        loge("Record Load Exception: " + ar.exception);
                    } else {
                        recordLoaded.onRecordLoaded(ar);
                    }
                }catch (RuntimeException exc) {
                    // I don't want these exceptions to be fatal
                    loge("Exception parsing SIM record: " + exc);
                } finally {
                    // Count up record load responses even if they are fails
                    onRecordLoaded();
                }
                break;

            default:
                super.handleMessage(msg);
        }
    }

    protected abstract void onRecordLoaded();

@@ -303,4 +348,19 @@ public abstract class IccRecords extends Handler implements IccConstants {
     * @param s is the string to write
     */
    protected abstract void log(String s);

    /**
     * Write error string to log file.
     *
     * @param s is the string to write
     */
    protected abstract void loge(String s);

    /**
     * Return an interface to retrieve the ISIM records for IMS, if available.
     * @return the interface to retrieve the ISIM records, or null if not supported
     */
    public IsimRecords getIsimRecords() {
        return null;
    }
}
Loading