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

Commit 2149014e authored by Alex Yakavenka's avatar Alex Yakavenka Committed by Wink Saville
Browse files

Telephony: Fix get_imsi and icc_io

Make get_imsi and icc_io requests to follow ril v6 interface

Change-Id: Ifdbdcfd943f985c759359e59ced82b67195f4163
parent 064d2d65
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -754,6 +754,15 @@ public interface CommandsInterface {
     */
    void getIMSI(Message result);

    /**
     *  returned message
     *  retMsg.obj = AsyncResult ar
     *  ar.exception carries exception on failure
     *  ar.userObject contains the orignal value of result.obj
     *  ar.result is String containing IMSI on success
     */
    void getIMSIForApp(String aid, Message result);

    /**
     *  returned message
     *  retMsg.obj = AsyncResult ar
@@ -1049,6 +1058,14 @@ public interface CommandsInterface {
    void iccIO (int command, int fileid, String path, int p1, int p2, int p3,
            String data, String pin2, Message response);

    /**
     * parameters equivalent to 27.007 AT+CRSM command
     * response.obj will be an AsyncResult
     * response.obj.userObj will be a IccIoResult on success
     */
    void iccIOForApp (int command, int fileid, String path, int p1, int p2, int p3,
            String data, String pin2, String aid, Message response);

    /**
     * (AsyncResult)response.obj).result is an int[] with element [0] set to
     * 1 for "CLIP is provisioned", and 0 for "CLIP is not provisioned".
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import java.util.ArrayList;
 * {@hide}
 */
public class IccCardStatus {
    static final int CARD_MAX_APPS = 8;
    public static final int CARD_MAX_APPS = 8;

    public enum CardState {
        CARDSTATE_ABSENT,
+29 −19
Original line number Diff line number Diff line
@@ -145,8 +145,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
            = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid, recordNum, onLoaded));

        phone.mCM.iccIO(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, response);
        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
                        phone.getIccCard().getAid(), response);
    }

    /**
@@ -164,9 +165,10 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                        onLoaded));

        // TODO(): Verify when path changes are done.
        phone.mCM.iccIO(COMMAND_GET_RESPONSE, IccConstants.EF_IMG, "img",
        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, IccConstants.EF_IMG, "img",
                recordNum, READ_RECORD_MODE_ABSOLUTE,
                GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null, response);
                GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null,
                phone.getIccCard().getAid(), response);
    }

    /**
@@ -182,8 +184,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response
                = obtainMessage(EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid, onLoaded));
        phone.mCM.iccIO(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                    0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, response);
        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                    0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, phone.getIccCard().getAid(),
                    response);
    }

    /**
@@ -199,8 +202,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid,onLoaded));

        phone.mCM.iccIO(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, response);
        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
                        phone.getIccCard().getAid(), response);
    }

    /**
@@ -217,8 +221,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response = obtainMessage(EVENT_GET_BINARY_SIZE_DONE,
                        fileid, 0, onLoaded);

        phone.mCM.iccIO(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, response);
        phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
                        phone.getIccCard().getAid(), response);
    }

    /**
@@ -236,8 +241,8 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0,
                onLoaded);

        phone.mCM.iccIO(COMMAND_READ_BINARY, fileid, "img", highOffset, lowOffset,
                length, null, null, response);
        phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, "img", highOffset, lowOffset,
                length, null, null, phone.getIccCard().getAid(), response);
    }

    /**
@@ -251,9 +256,10 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
     */
    public void updateEFLinearFixed(int fileid, int recordNum, byte[] data,
            String pin2, Message onComplete) {
        phone.mCM.iccIO(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid),
        phone.mCM.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid),
                        recordNum, READ_RECORD_MODE_ABSOLUTE, data.length,
                        IccUtils.bytesToHexString(data), pin2, onComplete);
                        IccUtils.bytesToHexString(data), pin2,
                        phone.getIccCard().getAid(), onComplete);
    }

    /**
@@ -262,9 +268,10 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
     * @param data must be exactly as long as the EF
     */
    public void updateEFTransparent(int fileid, byte[] data, Message onComplete) {
        phone.mCM.iccIO(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid),
        phone.mCM.iccIOForApp(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid),
                        0, 0, data.length,
                        IccUtils.bytesToHexString(data), null, onComplete);
                        IccUtils.bytesToHexString(data), null,
                        phone.getIccCard().getAid(), onComplete);
    }


@@ -395,10 +402,11 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                     lc.results = new ArrayList<byte[]>(lc.countRecords);
                 }

                 phone.mCM.iccIO(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                 phone.mCM.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                         lc.recordNum,
                         READ_RECORD_MODE_ABSOLUTE,
                         lc.recordSize, null, null,
                         phone.getIccCard().getAid(),
                         obtainMessage(EVENT_READ_RECORD_DONE, lc));
                 break;
            case EVENT_GET_BINARY_SIZE_DONE:
@@ -433,8 +441,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                size = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8)
                       + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff);

                phone.mCM.iccIO(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                                0, 0, size, null, null,
                                phone.getIccCard().getAid(),
                                obtainMessage(EVENT_READ_BINARY_DONE,
                                              fileid, 0, response));
            break;
@@ -468,10 +477,11 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                    if (lc.recordNum > lc.countRecords) {
                        sendResult(response, lc.results, null);
                    } else {
                        phone.mCM.iccIO(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                        phone.mCM.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
                                    lc.recordNum,
                                    READ_RECORD_MODE_ABSOLUTE,
                                    lc.recordSize, null, null,
                                    phone.getIccCard().getAid(),
                                    obtainMessage(EVENT_READ_RECORD_DONE, lc));
                    }
                }
+21 −3
Original line number Diff line number Diff line
@@ -880,9 +880,19 @@ public final class RIL extends BaseCommands implements CommandsInterface {

    public void
    getIMSI(Message result) {
        getIMSIForApp(null, result);
    }

    public void
    getIMSIForApp(String aid, Message result) {
        RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMSI, result);

        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
        rr.mp.writeInt(1);
        rr.mp.writeString(aid);

        if (RILJ_LOGD) riljLog(rr.serialString() +
                              "> getIMSI: " + requestToString(rr.mRequest)
                              + " aid: " + aid);

        send(rr);
    }
@@ -1435,6 +1445,11 @@ public final class RIL extends BaseCommands implements CommandsInterface {
    public void
    iccIO (int command, int fileid, String path, int p1, int p2, int p3,
            String data, String pin2, Message result) {
        iccIOForApp(command, fileid, path, p1, p2, p3, data, pin2, null, result);
    }
    public void
    iccIOForApp (int command, int fileid, String path, int p1, int p2, int p3,
            String data, String pin2, String aid, Message result) {
        //Note: This RIL request has not been renamed to ICC,
        //       but this request is also valid for SIM and RUIM
        RILRequest rr
@@ -1448,12 +1463,15 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        rr.mp.writeInt(p3);
        rr.mp.writeString(data);
        rr.mp.writeString(pin2);
        rr.mp.writeString(aid);

        if (RILJ_LOGD) riljLog(rr.serialString() + "> iccIO: " + requestToString(rr.mRequest)
        if (RILJ_LOGD) riljLog(rr.serialString() + "> iccIO: "
                + requestToString(rr.mRequest)
                + " 0x" + Integer.toHexString(command)
                + " 0x" + Integer.toHexString(fileid) + " "
                + " path: " + path + ","
                + p1 + "," + p2 + "," + p3);
                + p1 + "," + p2 + "," + p3
                + " aid: " + aid);

        send(rr);
    }
+2 −2
Original line number Diff line number Diff line
@@ -55,8 +55,8 @@ public final class CdmaLteUiccFileHandler extends IccFileHandler {
        if (fileid == EF_CSIM_EPRL) {
            // Entire PRL could be huge. We are only interested in
            // the first 4 bytes of the record.
            phone.mCM.iccIO(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                            0, 0, 4, null, null,
            phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
                            0, 0, 4, null, null, phone.getIccCard().getAid(),
                            obtainMessage(EVENT_READ_BINARY_DONE,
                                          fileid, 0, onLoaded));
        } else {
Loading