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

Commit bf8d655c authored by Shareef Ali's avatar Shareef Ali Committed by Gerrit Code Review
Browse files

Merge "Telephony: Specify file path when reading contacts from EF_ADN" into cm-10.2

parents 8ad356a7 51cd6505
Loading
Loading
Loading
Loading
+37 −6
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.os.Looper;
import android.os.Message;
import android.telephony.Rlog;

import com.android.internal.telephony.uicc.IccConstants;

public class AdnRecordLoader extends Handler {
    final static String LOG_TAG = "AdnRecordLoader";
    final static boolean VDBG = false;
@@ -64,6 +66,14 @@ public class AdnRecordLoader extends Handler {
        mFh = fh;
    }

    private String getEFPath(int efid) {
        if (efid == IccConstants.EF_ADN) {
            return IccConstants.MF_SIM + IccConstants.DF_TELECOM;
        }

        return null;
    }

    /**
     * Resulting AdnRecord is placed in response.obj.result
     * or response.obj.exception is set
@@ -76,9 +86,15 @@ public class AdnRecordLoader extends Handler {
        mRecordNumber = recordNumber;
        mUserResponse = response;

        if (ef == IccConstants.EF_ADN) {
            mFh.loadEFLinearFixed(
                        ef, getEFPath(ef), recordNumber,
                        obtainMessage(EVENT_ADN_LOAD_DONE));
        } else {
            mFh.loadEFLinearFixed(
                    ef, recordNumber,
                    obtainMessage(EVENT_ADN_LOAD_DONE));
        }

    }

@@ -94,10 +110,20 @@ public class AdnRecordLoader extends Handler {
        mExtensionEF = extensionEF;
        mUserResponse = response;

        /* If we are loading from EF_ADN, specifically
         * specify the path as well, since, on some cards,
         * the fileid is not unique.
         */
        if (ef == IccConstants.EF_ADN) {

            mFh.loadEFLinearFixedAll(
                    ef, getEFPath(ef),
                    obtainMessage(EVENT_ADN_LOAD_ALL_DONE));
        } else {
            mFh.loadEFLinearFixedAll(
                        ef,
                        obtainMessage(EVENT_ADN_LOAD_ALL_DONE));

        }
    }

    /**
@@ -121,9 +147,14 @@ public class AdnRecordLoader extends Handler {
        mUserResponse = response;
        mPin2 = pin2;

        if (ef == IccConstants.EF_ADN) {
            mFh.getEFLinearRecordSize( ef, getEFPath(ef),
                obtainMessage(EVENT_EF_LINEAR_RECORD_SIZE_DONE, adn));
        } else {
            mFh.getEFLinearRecordSize( ef,
                    obtainMessage(EVENT_EF_LINEAR_RECORD_SIZE_DONE, adn));
        }
    }

    //***** Overridden from Handler

+101 −11
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        int mEfid;
        int mRecordNum, mRecordSize, mCountRecords;
        boolean mLoadAll;
        String mPath;

        Message mOnLoaded;

@@ -112,6 +113,23 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
            mRecordNum = recordNum;
            mOnLoaded = onLoaded;
            mLoadAll = false;
            this.mPath = null;
        }

        LoadLinearFixedContext(int efid, int recordNum, String path, Message onLoaded) {
            this.mEfid = efid;
            this.mRecordNum = recordNum;
            this.mOnLoaded = onLoaded;
            this.mLoadAll = false;
            this.mPath = path;
        }

        LoadLinearFixedContext(int efid, String path, Message onLoaded) {
            this.mEfid = efid;
            this.mRecordNum = 1;
            this.mLoadAll = true;
            this.mOnLoaded = onLoaded;
            this.mPath = path;
        }

        LoadLinearFixedContext(int efid, Message onLoaded) {
@@ -119,6 +137,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
            mRecordNum = 1;
            mLoadAll = true;
            mOnLoaded = onLoaded;
            this.mPath = null;
        }
    }

@@ -140,21 +159,36 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
     * Load a record from a SIM Linear Fixed EF
     *
     * @param fileid EF id
     * @param path Path of the EF on the card
     * @param recordNum 1-based (not 0-based) record number
     * @param onLoaded
     *
     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
     *
     */
    public void loadEFLinearFixed(int fileid, int recordNum, Message onLoaded) {
    public void loadEFLinearFixed(int fileid, String path, int recordNum, Message onLoaded) {
        Message response
                = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid, recordNum, onLoaded));
                        new LoadLinearFixedContext(fileid, recordNum, path, onLoaded));

        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, path,
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
    }

    /**
     * Load a record from a SIM Linear Fixed EF
     *
     * @param fileid EF id
     * @param recordNum 1-based (not 0-based) record number
     * @param onLoaded
     *
     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
     *
     */
    public void loadEFLinearFixed(int fileid, int recordNum, Message onLoaded) {
        loadEFLinearFixed(fileid, getEFPath(fileid), recordNum, onLoaded);
    }

    /**
     * Load a image instance record from a SIM Linear Fixed EF-IMG
     *
@@ -179,19 +213,33 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
     * get record size for a linear fixed EF
     *
     * @param fileid EF id
     * @param path Path of the EF on the card
     * @param onLoaded ((AsnyncResult)(onLoaded.obj)).result is the recordSize[]
     *        int[0] is the record length int[1] is the total length of the EF
     *        file int[3] is the number of records in the EF file So int[0] *
     *        int[3] = int[1]
     */
    public void getEFLinearRecordSize(int fileid, Message onLoaded) {
    public void getEFLinearRecordSize(int fileid, String path, Message onLoaded) {
        Message response
                = obtainMessage(EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid, onLoaded));
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
                        new LoadLinearFixedContext(fileid, path, onLoaded));
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, path,
                    0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
    }

    /**
     * get record size for a linear fixed EF
     *
     * @param fileid EF id
     * @param onLoaded ((AsnyncResult)(onLoaded.obj)).result is the recordSize[]
     *        int[0] is the record length int[1] is the total length of the EF
     *        file int[3] is the number of records in the EF file So int[0] *
     *        int[3] = int[1]
     */
    public void getEFLinearRecordSize(int fileid, Message onLoaded) {
        getEFLinearRecordSize(fileid, getEFPath(fileid), onLoaded);
    }

    /**
     * Load all records from a SIM Linear Fixed EF
     *
@@ -202,13 +250,28 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
     *
     */
    public void loadEFLinearFixedAll(int fileid, Message onLoaded) {
        loadEFLinearFixedAll(fileid, getEFPath(fileid), onLoaded);
    }

    /**
     * Load all records from a SIM Linear Fixed EF
     *
     * @param fileid EF id
     * @param path Path of the EF on the card
     * @param onLoaded
     *
     * ((AsyncResult)(onLoaded.obj)).result is an ArrayList<byte[]>
     *
     */
    public void loadEFLinearFixedAll(int fileid, String path, Message onLoaded) {
        Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
                        new LoadLinearFixedContext(fileid,onLoaded));
                        new LoadLinearFixedContext(fileid, path, onLoaded));

        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, path,
                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
    }


    /**
     * Load a SIM Transparent EF
     *
@@ -270,6 +333,23 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                highOffset, lowOffset,length, null, null, mAid, response);
    }

    /**
     * Update a record in a linear fixed EF
     * @param fileid EF id
     * @param path Path of the EF on the card
     * @param recordNum 1-based (not 0-based) record number
     * @param data must be exactly as long as the record in the EF
     * @param pin2 for CHV2 operations, otherwist must be null
     * @param onComplete onComplete.obj will be an AsyncResult
     *                   onComplete.obj.userObj will be a IccIoResult on success
     */
    public void updateEFLinearFixed(int fileid, String path, int recordNum, byte[] data,
            String pin2, Message onComplete) {
        mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, path,
                        recordNum, READ_RECORD_MODE_ABSOLUTE, data.length,
                        IccUtils.bytesToHexString(data), pin2, mAid, onComplete);
    }

    /**
     * Update a record in a linear fixed EF
     * @param fileid EF id
@@ -329,6 +409,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
        int fileid;
        int recordNum;
        int recordSize[];
        String path = null;

        try {
            switch (msg.what) {
@@ -442,6 +523,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                data = result.payload;
                fileid = lc.mEfid;
                recordNum = lc.mRecordNum;
                path = lc.mPath;

                if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE]) {
                    throw new IccFileTypeMismatch();
@@ -462,7 +544,10 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                     lc.results = new ArrayList<byte[]>(lc.mCountRecords);
                 }

                 mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, getEFPath(lc.mEfid),
                 if (path == null) {
                     path = getEFPath(lc.mEfid);
                 }
                 mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, path,
                         lc.mRecordNum,
                         READ_RECORD_MODE_ABSOLUTE,
                         lc.mRecordSize, null, null, mAid,
@@ -512,6 +597,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                lc = (LoadLinearFixedContext) ar.userObj;
                result = (IccIoResult) ar.result;
                response = lc.mOnLoaded;
                path = lc.mPath;

                if (ar.exception != null) {
                    sendResult(response, null, ar.exception);
@@ -535,7 +621,11 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
                    if (lc.mRecordNum > lc.mCountRecords) {
                        sendResult(response, lc.results, null);
                    } else {
                        mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, getEFPath(lc.mEfid),
                        if (path == null) {
                            path = getEFPath(lc.mEfid);
                        }

                        mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, path,
                                    lc.mRecordNum,
                                    READ_RECORD_MODE_ABSOLUTE,
                                    lc.mRecordSize, null, null, mAid,