Loading src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java +25 −12 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading @@ -77,9 +87,8 @@ public class AdnRecordLoader extends Handler { mUserResponse = response; mFh.loadEFLinearFixed( ef, recordNumber, ef, getEFPath(ef), recordNumber, obtainMessage(EVENT_ADN_LOAD_DONE)); } Loading @@ -94,10 +103,13 @@ 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. */ mFh.loadEFLinearFixedAll( ef, ef, getEFPath(ef), obtainMessage(EVENT_ADN_LOAD_ALL_DONE)); } /** Loading @@ -121,7 +133,7 @@ public class AdnRecordLoader extends Handler { mUserResponse = response; mPin2 = pin2; mFh.getEFLinearRecordSize( ef, mFh.getEFLinearRecordSize( ef, getEFPath(ef), obtainMessage(EVENT_EF_LINEAR_RECORD_SIZE_DONE, adn)); } Loading Loading @@ -163,7 +175,8 @@ public class AdnRecordLoader extends Handler { ar.exception); } mFh.updateEFLinearFixed(mEf, mRecordNumber, mFh.updateEFLinearFixed(mEf, getEFPath(mEf), mRecordNumber, data, mPin2, obtainMessage(EVENT_UPDATE_RECORD_DONE)); mPendingExtLoads = 1; Loading src/java/com/android/internal/telephony/uicc/IccFileHandler.java +105 −12 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { int mEfid; int mRecordNum, mRecordSize, mCountRecords; boolean mLoadAll; String mPath; Message mOnLoaded; Loading @@ -112,6 +113,23 @@ public abstract class IccFileHandler extends Handler implements IccConstants { mRecordNum = recordNum; mOnLoaded = onLoaded; mLoadAll = false; mPath = null; } LoadLinearFixedContext(int efid, int recordNum, String path, Message onLoaded) { mEfid = efid; mRecordNum = recordNum; mOnLoaded = onLoaded; mLoadAll = false; mPath = path; } LoadLinearFixedContext(int efid, String path, Message onLoaded) { mEfid = efid; mRecordNum = 1; mLoadAll = true; mOnLoaded = onLoaded; mPath = path; } LoadLinearFixedContext(int efid, Message onLoaded) { Loading @@ -119,6 +137,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { mRecordNum = 1; mLoadAll = true; mOnLoaded = onLoaded; mPath = null; } } Loading @@ -140,21 +159,37 @@ 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) { String efPath = (path == null) ? getEFPath(fileid) : path; Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE, new LoadLinearFixedContext(fileid, recordNum, onLoaded)); new LoadLinearFixedContext(fileid, recordNum, efPath, onLoaded)); mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid), mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath, 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 * Loading @@ -179,36 +214,66 @@ 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) { String efPath = (path == null) ? getEFPath(fileid) : path; 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, efPath, onLoaded)); mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath, 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 * * @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, Message onLoaded) { public void loadEFLinearFixedAll(int fileid, String path, Message onLoaded) { String efPath = (path == null) ? getEFPath(fileid) : path; Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE, new LoadLinearFixedContext(fileid,onLoaded)); new LoadLinearFixedContext(fileid, efPath, 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 all records from a SIM Linear Fixed EF * * @param fileid EF id * @param onLoaded * * ((AsyncResult)(onLoaded.obj)).result is an ArrayList<byte[]> * */ public void loadEFLinearFixedAll(int fileid, Message onLoaded) { loadEFLinearFixedAll(fileid, getEFPath(fileid), onLoaded); } /** * Load a SIM Transparent EF * Loading Loading @@ -274,6 +339,24 @@ 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) { String efPath = (path == null) ? getEFPath(fileid) : path; mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, efPath, 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 Loading Loading @@ -348,6 +431,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { int size; int fileid; int recordSize[]; String path = null; try { switch (msg.what) { Loading Loading @@ -389,6 +473,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { } data = result.payload; path = lc.mPath; if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE]) { throw new IccFileTypeMismatch(); Loading @@ -409,7 +494,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, Loading Loading @@ -452,6 +540,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { lc = (LoadLinearFixedContext) ar.userObj; result = (IccIoResult) ar.result; response = lc.mOnLoaded; path = lc.mPath; if (processException(response, (AsyncResult) msg.obj)) { break; Loading @@ -467,7 +556,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, Loading Loading
src/java/com/android/internal/telephony/uicc/AdnRecordLoader.java +25 −12 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading @@ -77,9 +87,8 @@ public class AdnRecordLoader extends Handler { mUserResponse = response; mFh.loadEFLinearFixed( ef, recordNumber, ef, getEFPath(ef), recordNumber, obtainMessage(EVENT_ADN_LOAD_DONE)); } Loading @@ -94,10 +103,13 @@ 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. */ mFh.loadEFLinearFixedAll( ef, ef, getEFPath(ef), obtainMessage(EVENT_ADN_LOAD_ALL_DONE)); } /** Loading @@ -121,7 +133,7 @@ public class AdnRecordLoader extends Handler { mUserResponse = response; mPin2 = pin2; mFh.getEFLinearRecordSize( ef, mFh.getEFLinearRecordSize( ef, getEFPath(ef), obtainMessage(EVENT_EF_LINEAR_RECORD_SIZE_DONE, adn)); } Loading Loading @@ -163,7 +175,8 @@ public class AdnRecordLoader extends Handler { ar.exception); } mFh.updateEFLinearFixed(mEf, mRecordNumber, mFh.updateEFLinearFixed(mEf, getEFPath(mEf), mRecordNumber, data, mPin2, obtainMessage(EVENT_UPDATE_RECORD_DONE)); mPendingExtLoads = 1; Loading
src/java/com/android/internal/telephony/uicc/IccFileHandler.java +105 −12 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { int mEfid; int mRecordNum, mRecordSize, mCountRecords; boolean mLoadAll; String mPath; Message mOnLoaded; Loading @@ -112,6 +113,23 @@ public abstract class IccFileHandler extends Handler implements IccConstants { mRecordNum = recordNum; mOnLoaded = onLoaded; mLoadAll = false; mPath = null; } LoadLinearFixedContext(int efid, int recordNum, String path, Message onLoaded) { mEfid = efid; mRecordNum = recordNum; mOnLoaded = onLoaded; mLoadAll = false; mPath = path; } LoadLinearFixedContext(int efid, String path, Message onLoaded) { mEfid = efid; mRecordNum = 1; mLoadAll = true; mOnLoaded = onLoaded; mPath = path; } LoadLinearFixedContext(int efid, Message onLoaded) { Loading @@ -119,6 +137,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { mRecordNum = 1; mLoadAll = true; mOnLoaded = onLoaded; mPath = null; } } Loading @@ -140,21 +159,37 @@ 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) { String efPath = (path == null) ? getEFPath(fileid) : path; Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE, new LoadLinearFixedContext(fileid, recordNum, onLoaded)); new LoadLinearFixedContext(fileid, recordNum, efPath, onLoaded)); mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid), mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath, 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 * Loading @@ -179,36 +214,66 @@ 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) { String efPath = (path == null) ? getEFPath(fileid) : path; 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, efPath, onLoaded)); mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath, 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 * * @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, Message onLoaded) { public void loadEFLinearFixedAll(int fileid, String path, Message onLoaded) { String efPath = (path == null) ? getEFPath(fileid) : path; Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE, new LoadLinearFixedContext(fileid,onLoaded)); new LoadLinearFixedContext(fileid, efPath, 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 all records from a SIM Linear Fixed EF * * @param fileid EF id * @param onLoaded * * ((AsyncResult)(onLoaded.obj)).result is an ArrayList<byte[]> * */ public void loadEFLinearFixedAll(int fileid, Message onLoaded) { loadEFLinearFixedAll(fileid, getEFPath(fileid), onLoaded); } /** * Load a SIM Transparent EF * Loading Loading @@ -274,6 +339,24 @@ 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) { String efPath = (path == null) ? getEFPath(fileid) : path; mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, efPath, 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 Loading Loading @@ -348,6 +431,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { int size; int fileid; int recordSize[]; String path = null; try { switch (msg.what) { Loading Loading @@ -389,6 +473,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { } data = result.payload; path = lc.mPath; if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE]) { throw new IccFileTypeMismatch(); Loading @@ -409,7 +494,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, Loading Loading @@ -452,6 +540,7 @@ public abstract class IccFileHandler extends Handler implements IccConstants { lc = (LoadLinearFixedContext) ar.userObj; result = (IccIoResult) ar.result; response = lc.mOnLoaded; path = lc.mPath; if (processException(response, (AsyncResult) msg.obj)) { break; Loading @@ -467,7 +556,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, Loading