1c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville/* 2c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Copyright (C) 2008 The Android Open Source Project 3c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 4c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Licensed under the Apache License, Version 2.0 (the "License"); 5c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * you may not use this file except in compliance with the License. 6c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * You may obtain a copy of the License at 7c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 8c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * http://www.apache.org/licenses/LICENSE-2.0 9c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 10c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Unless required by applicable law or agreed to in writing, software 11c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * distributed under the License is distributed on an "AS IS" BASIS, 12c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * See the License for the specific language governing permissions and 14c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * limitations under the License. 15c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 16c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 17d720945f2be5ea5fe0faf67e67d9ea0e184eba67Alex Yakavenkapackage com.android.internal.telephony.uicc; 18c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 19c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.os.*; 20d720945f2be5ea5fe0faf67e67d9ea0e184eba67Alex Yakavenkaimport com.android.internal.telephony.CommandsInterface; 21d720945f2be5ea5fe0faf67e67d9ea0e184eba67Alex Yakavenka 22c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport java.util.ArrayList; 23c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 24c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville/** 25c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * {@hide} 26c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 27c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savillepublic abstract class IccFileHandler extends Handler implements IccConstants { 28c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 29c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //from TS 11.11 9.1 or elsewhere 30c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int COMMAND_READ_BINARY = 0xb0; 31c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int COMMAND_UPDATE_BINARY = 0xd6; 32c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int COMMAND_READ_RECORD = 0xb2; 33c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int COMMAND_UPDATE_RECORD = 0xdc; 34c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int COMMAND_SEEK = 0xa2; 35c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int COMMAND_GET_RESPONSE = 0xc0; 36c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 37c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville // from TS 11.11 9.2.5 38c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int READ_RECORD_MODE_ABSOLUTE = 4; 39c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 40c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //***** types of files TS 11.11 9.3 41c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EF_TYPE_TRANSPARENT = 0; 42c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EF_TYPE_LINEAR_FIXED = 1; 43c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EF_TYPE_CYCLIC = 3; 44c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 45c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //***** types of files TS 11.11 9.3 46c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int TYPE_RFU = 0; 47c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int TYPE_MF = 1; 48c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int TYPE_DF = 2; 49c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int TYPE_EF = 4; 50c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 51c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville // size of GET_RESPONSE for EF's 52c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int GET_RESPONSE_EF_SIZE_BYTES = 15; 53c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int GET_RESPONSE_EF_IMG_SIZE_BYTES = 10; 54c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 55c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville // Byte order received in response to COMMAND_GET_RESPONSE 56c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville // Refer TS 51.011 Section 9.2.1 57c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_RFU_1 = 0; 58c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_RFU_2 = 1; 59c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 60c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_FILE_SIZE_1 = 2; 61c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_FILE_SIZE_2 = 3; 62c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 63c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_FILE_ID_1 = 4; 64c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_FILE_ID_2 = 5; 65c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_FILE_TYPE = 6; 66c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_RFU_3 = 7; 67c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_ACCESS_CONDITION_1 = 8; 68c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_ACCESS_CONDITION_2 = 9; 69c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_ACCESS_CONDITION_3 = 10; 70c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_FILE_STATUS = 11; 71c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_LENGTH = 12; 72c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_STRUCTURE = 13; 73c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int RESPONSE_DATA_RECORD_LENGTH = 14; 74c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 75c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 76c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //***** Events 77c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 78c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** Finished retrieving size of transparent EF; start loading. */ 79c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EVENT_GET_BINARY_SIZE_DONE = 4; 80c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** Finished loading contents of transparent EF; post result. */ 81c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EVENT_READ_BINARY_DONE = 5; 82c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** Finished retrieving size of records for linear-fixed EF; now load. */ 83c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EVENT_GET_RECORD_SIZE_DONE = 6; 84c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** Finished loading single record from a linear-fixed EF; post result. */ 85c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EVENT_READ_RECORD_DONE = 7; 86c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** Finished retrieving record size; post result. */ 87c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE = 8; 88c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** Finished retrieving image instance record; post result. */ 89c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EVENT_READ_IMG_DONE = 9; 90c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** Finished retrieving icon data; post result. */ 91c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static protected final int EVENT_READ_ICON_DONE = 10; 92deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim /** Finished retrieving size of record for EFimg now. */ 93deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim static protected final int EVENT_GET_RECORD_SIZE_IMG_DONE = 11; 94c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 95c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville // member variables 96c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville protected final CommandsInterface mCi; 97e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka protected final UiccCardApplication mParentApp; 98e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka protected final String mAid; 99c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 100c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville static class LoadLinearFixedContext { 101c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 10222d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville int mEfid; 10322d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville int mRecordNum, mRecordSize, mCountRecords; 10422d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville boolean mLoadAll; 105c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 10622d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville Message mOnLoaded; 107c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 108c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ArrayList<byte[]> results; 109c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 110c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville LoadLinearFixedContext(int efid, int recordNum, Message onLoaded) { 11122d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mEfid = efid; 11222d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mRecordNum = recordNum; 11322d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mOnLoaded = onLoaded; 11422d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mLoadAll = false; 115c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 116c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 117c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville LoadLinearFixedContext(int efid, Message onLoaded) { 11822d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mEfid = efid; 11922d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mRecordNum = 1; 12022d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mLoadAll = true; 12122d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mOnLoaded = onLoaded; 122c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 123c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 124c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 125c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 126c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Default constructor 127c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 128e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka protected IccFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) { 129e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka mParentApp = app; 130c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mAid = aid; 131c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi = ci; 132c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 133c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 134c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void dispose() { 135c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 136c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 137c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //***** Public Methods 138c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 139c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 140c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Load a record from a SIM Linear Fixed EF 141c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 142c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param fileid EF id 143c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param recordNum 1-based (not 0-based) record number 144c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param onLoaded 145c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 146c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * ((AsyncResult)(onLoaded.obj)).result is the byte[] 147c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 148c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 149c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void loadEFLinearFixed(int fileid, int recordNum, Message onLoaded) { 150c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Message response 151c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville = obtainMessage(EVENT_GET_RECORD_SIZE_DONE, 152c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville new LoadLinearFixedContext(fileid, recordNum, onLoaded)); 153c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 154c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid), 155c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response); 156c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 157c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 158c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 159c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Load a image instance record from a SIM Linear Fixed EF-IMG 160c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 161c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param recordNum 1-based (not 0-based) record number 162c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param onLoaded 163c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 164c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * ((AsyncResult)(onLoaded.obj)).result is the byte[] 165c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 166c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 167c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void loadEFImgLinearFixed(int recordNum, Message onLoaded) { 168deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim Message response = obtainMessage(EVENT_GET_RECORD_SIZE_IMG_DONE, 169c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville new LoadLinearFixedContext(IccConstants.EF_IMG, recordNum, 170c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville onLoaded)); 171c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 172deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim mCi.iccIOForApp(COMMAND_GET_RESPONSE, IccConstants.EF_IMG, 173deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim getEFPath(IccConstants.EF_IMG), recordNum, 174deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim READ_RECORD_MODE_ABSOLUTE, GET_RESPONSE_EF_IMG_SIZE_BYTES, 175deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim null, null, mAid, response); 176c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 177c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 178c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 179c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * get record size for a linear fixed EF 180c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 181c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param fileid EF id 182c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param onLoaded ((AsnyncResult)(onLoaded.obj)).result is the recordSize[] 183c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * int[0] is the record length int[1] is the total length of the EF 184c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * file int[3] is the number of records in the EF file So int[0] * 185c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * int[3] = int[1] 186c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 187c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void getEFLinearRecordSize(int fileid, Message onLoaded) { 188c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Message response 189c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville = obtainMessage(EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE, 190c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville new LoadLinearFixedContext(fileid, onLoaded)); 191c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid), 192c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response); 193c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 194c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 195c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 196c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Load all records from a SIM Linear Fixed EF 197c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 198c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param fileid EF id 199c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param onLoaded 200c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 201c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * ((AsyncResult)(onLoaded.obj)).result is an ArrayList<byte[]> 202c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 203c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 204c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void loadEFLinearFixedAll(int fileid, Message onLoaded) { 205c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE, 206c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville new LoadLinearFixedContext(fileid,onLoaded)); 207c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 208c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid), 209c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response); 210c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 211c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 212c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 213c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Load a SIM Transparent EF 214c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 215c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param fileid EF id 216c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param onLoaded 217c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 218c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * ((AsyncResult)(onLoaded.obj)).result is the byte[] 219c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 220c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 221c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 222c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void loadEFTransparent(int fileid, Message onLoaded) { 223c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Message response = obtainMessage(EVENT_GET_BINARY_SIZE_DONE, 224c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville fileid, 0, onLoaded); 225c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 226c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid), 227c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response); 228c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 229c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 230c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 231e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * Load first @size bytes from SIM Transparent EF 232e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * 233e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * @param fileid EF id 234e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * @param size 235e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * @param onLoaded 236e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * 237e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * ((AsyncResult)(onLoaded.obj)).result is the byte[] 238e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka * 239e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka */ 240e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka public void loadEFTransparent(int fileid, int size, Message onLoaded) { 241e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka Message response = obtainMessage(EVENT_READ_BINARY_DONE, 242e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka fileid, 0, onLoaded); 243e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka 244e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid), 245e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka 0, 0, size, null, null, mAid, response); 246e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka } 247e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka 248e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka /** 249c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Load a SIM Transparent EF-IMG. Used right after loadEFImgLinearFixed to 250c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * retrive STK's icon data. 251c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 252c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param fileid EF id 253c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param onLoaded 254c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 255c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * ((AsyncResult)(onLoaded.obj)).result is the byte[] 256c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 257c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 258c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void loadEFImgTransparent(int fileid, int highOffset, int lowOffset, 259c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville int length, Message onLoaded) { 260c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0, 261c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville onLoaded); 262c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 263deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim logd("IccFileHandler: loadEFImgTransparent fileid = " + fileid 264536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro + " filePath = " + getEFPath(EF_IMG) + " highOffset = " + highOffset 265deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim + " lowOffset = " + lowOffset + " length = " + length); 266536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro 267536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro /* Per TS 31.102, for displaying of Icon, under 268deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim * DF Telecom and DF Graphics , EF instance(s) (4FXX,transparent files) 269deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim * are present. The possible image file identifiers (EF instance) for 270deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim * EF img ( 4F20, linear fixed file) are : 4F01 ... 4F05. 271536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro * It should be MF_SIM + DF_TELECOM + DF_GRAPHICS, same path as EF IMG 272deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim */ 273536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(EF_IMG), 274deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim highOffset, lowOffset, length, null, null, mAid, response); 275c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 276c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 277c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 278c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Update a record in a linear fixed EF 279c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param fileid EF id 280c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param recordNum 1-based (not 0-based) record number 281c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param data must be exactly as long as the record in the EF 282c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param pin2 for CHV2 operations, otherwist must be null 283c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param onComplete onComplete.obj will be an AsyncResult 284c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * onComplete.obj.userObj will be a IccIoResult on success 285c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 286c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void updateEFLinearFixed(int fileid, int recordNum, byte[] data, 287c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String pin2, Message onComplete) { 288c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid), 289c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville recordNum, READ_RECORD_MODE_ABSOLUTE, data.length, 290c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville IccUtils.bytesToHexString(data), pin2, mAid, onComplete); 291c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 292c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 293c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 294c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Update a transparent EF 295c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param fileid EF id 296c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @param data must be exactly as long as the EF 297c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 298c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void updateEFTransparent(int fileid, byte[] data, Message onComplete) { 299c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi.iccIOForApp(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid), 300c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 0, 0, data.length, 301c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville IccUtils.bytesToHexString(data), null, mAid, onComplete); 302c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 303c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 304c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 305c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //***** Abstract Methods 306c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 307c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 308c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //***** Private Methods 309c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 310c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville private void sendResult(Message response, Object result, Throwable ex) { 311c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville if (response == null) { 312c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville return; 313c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 314c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 315c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville AsyncResult.forMessage(response, result, ex); 316c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 317c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville response.sendToTarget(); 318c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 319c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 320536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro private boolean processException(Message response, AsyncResult ar) { 321536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro IccException iccException; 322536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro boolean flag = false; 323536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro IccIoResult result = (IccIoResult) ar.result; 324536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro if (ar.exception != null) { 325536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro sendResult(response, null, ar.exception); 326536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro flag = true; 327536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro } else { 328536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro iccException = result.getException(); 329536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro if (iccException != null) { 330536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro sendResult(response, null, iccException); 331536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro flag = true; 332536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro } 333536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro } 334536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro return flag; 335536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro } 336536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro 337c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville //***** Overridden from Handler 338c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 339cbaa45bbf2cab852b6c9c3a887e9f803d4e857eaWink Saville @Override 340c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville public void handleMessage(Message msg) { 341c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville AsyncResult ar; 342c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville IccIoResult result; 343c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville Message response = null; 344c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville String str; 345c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville LoadLinearFixedContext lc; 346c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 347c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville byte data[]; 348c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville int size; 349c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville int fileid; 350c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville int recordSize[]; 351c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 352c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville try { 353c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville switch (msg.what) { 354c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE: 355c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ar = (AsyncResult)msg.obj; 356c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville lc = (LoadLinearFixedContext) ar.userObj; 357c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville result = (IccIoResult) ar.result; 35822d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville response = lc.mOnLoaded; 359c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 360536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro if (processException(response, (AsyncResult) msg.obj)) { 361c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 362c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 363c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 364c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville data = result.payload; 365c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 366c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE] || 367c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville EF_TYPE_LINEAR_FIXED != data[RESPONSE_DATA_STRUCTURE]) { 368c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville throw new IccFileTypeMismatch(); 369c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 370c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 371c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville recordSize = new int[3]; 372c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville recordSize[0] = data[RESPONSE_DATA_RECORD_LENGTH] & 0xFF; 373c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville recordSize[1] = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8) 374c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff); 375c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville recordSize[2] = recordSize[1] / recordSize[0]; 376c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 377c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville sendResult(response, recordSize, null); 378c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 379536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro 380536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro case EVENT_GET_RECORD_SIZE_IMG_DONE: 381c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EVENT_GET_RECORD_SIZE_DONE: 382c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ar = (AsyncResult)msg.obj; 383c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville lc = (LoadLinearFixedContext) ar.userObj; 384c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville result = (IccIoResult) ar.result; 38522d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville response = lc.mOnLoaded; 386c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 387536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro if (processException(response, (AsyncResult) msg.obj)) { 388c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 389c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 390c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 391c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville data = result.payload; 392c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 393c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE]) { 394c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville throw new IccFileTypeMismatch(); 395c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 396c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 397c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville if (EF_TYPE_LINEAR_FIXED != data[RESPONSE_DATA_STRUCTURE]) { 398c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville throw new IccFileTypeMismatch(); 399c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 400c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 40122d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.mRecordSize = data[RESPONSE_DATA_RECORD_LENGTH] & 0xFF; 402c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 403c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville size = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8) 404c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff); 405c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 40622d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.mCountRecords = size / lc.mRecordSize; 407c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 40822d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville if (lc.mLoadAll) { 40922d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.results = new ArrayList<byte[]>(lc.mCountRecords); 410c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 411c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 41222d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, getEFPath(lc.mEfid), 41322d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.mRecordNum, 414c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville READ_RECORD_MODE_ABSOLUTE, 41522d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.mRecordSize, null, null, mAid, 416c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville obtainMessage(EVENT_READ_RECORD_DONE, lc)); 417c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 418c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EVENT_GET_BINARY_SIZE_DONE: 419c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ar = (AsyncResult)msg.obj; 420c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville response = (Message) ar.userObj; 421c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville result = (IccIoResult) ar.result; 422c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 423536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro if (processException(response, (AsyncResult) msg.obj)) { 424c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 425c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 426c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 427c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville data = result.payload; 428c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 429c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville fileid = msg.arg1; 430c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 431c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE]) { 432c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville throw new IccFileTypeMismatch(); 433c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 434c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 435c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville if (EF_TYPE_TRANSPARENT != data[RESPONSE_DATA_STRUCTURE]) { 436c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville throw new IccFileTypeMismatch(); 437c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 438c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 439c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville size = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8) 440c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff); 441c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 442c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid), 443c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 0, 0, size, null, null, mAid, 444c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville obtainMessage(EVENT_READ_BINARY_DONE, 445c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville fileid, 0, response)); 446c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 447c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 448536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro case EVENT_READ_IMG_DONE: 449c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EVENT_READ_RECORD_DONE: 450c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 451c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ar = (AsyncResult)msg.obj; 452c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville lc = (LoadLinearFixedContext) ar.userObj; 453c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville result = (IccIoResult) ar.result; 45422d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville response = lc.mOnLoaded; 455c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 456536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro if (processException(response, (AsyncResult) msg.obj)) { 457c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 458c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 459c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 46022d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville if (!lc.mLoadAll) { 461c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville sendResult(response, result.payload, null); 462c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } else { 463c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville lc.results.add(result.payload); 464c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 46522d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.mRecordNum++; 466c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 46722d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville if (lc.mRecordNum > lc.mCountRecords) { 468c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville sendResult(response, lc.results, null); 469c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } else { 47022d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, getEFPath(lc.mEfid), 47122d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.mRecordNum, 472c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville READ_RECORD_MODE_ABSOLUTE, 47322d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville lc.mRecordSize, null, null, mAid, 474c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville obtainMessage(EVENT_READ_RECORD_DONE, lc)); 475c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 476c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 477c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 478c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 479c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 480c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EVENT_READ_BINARY_DONE: 481536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro case EVENT_READ_ICON_DONE: 482c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville ar = (AsyncResult)msg.obj; 483c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville response = (Message) ar.userObj; 484c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville result = (IccIoResult) ar.result; 485c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 486536eeeb053efe3f1f60e61ff24bf1a8093d3c879duho.ro if (processException(response, (AsyncResult) msg.obj)) { 487c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 488c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 489c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 490c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville sendResult(response, result.payload, null); 491c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville break; 492c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 493c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville }} catch (Exception exc) { 494c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville if (response != null) { 495c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville sendResult(response, null, exc); 496c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } else { 497c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville loge("uncaught exception" + exc); 498c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 499c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 500c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 501c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 502c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville /** 503c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Returns the root path of the EF file. 504c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * i.e returns MasterFile + DFfile as a string. 505c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Ex: For EF_ADN on a SIM, it will return "3F007F10" 506c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * This function handles only EFids that are common to 507c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * RUIM, SIM, USIM and other types of Icc cards. 508c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * 509cbaa45bbf2cab852b6c9c3a887e9f803d4e857eaWink Saville * @param efid of path to retrieve 510c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * @return root path of the file. 511c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */ 512c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville protected String getCommonIccEFPath(int efid) { 513c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville switch(efid) { 514c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_ADN: 515c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_FDN: 516c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_MSISDN: 517c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_SDN: 518c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_EXT1: 519c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_EXT2: 520c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_EXT3: 521c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville return MF_SIM + DF_TELECOM; 522c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 523c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_ICCID: 524c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_PL: 525c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville return MF_SIM; 526e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka case EF_PBR: 527e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka // we only support global phonebook. 528e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka return MF_SIM + DF_TELECOM + DF_PHONEBOOK; 529c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville case EF_IMG: 530c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville return MF_SIM + DF_TELECOM + DF_GRAPHICS; 531c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 532c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville return null; 533c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville } 534c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 535c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville protected abstract String getEFPath(int efid); 536c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville protected abstract void logd(String s); 537c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 538c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville protected abstract void loge(String s); 539c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville 540c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville} 541