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;
105cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        String mPath;
106c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
10722d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville        Message mOnLoaded;
108c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
109c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        ArrayList<byte[]> results;
110c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
111c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        LoadLinearFixedContext(int efid, int recordNum, Message onLoaded) {
11222d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mEfid = efid;
11322d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mRecordNum = recordNum;
11422d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mOnLoaded = onLoaded;
11522d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mLoadAll = false;
116cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mPath = null;
117cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        }
118cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja
119cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        LoadLinearFixedContext(int efid, int recordNum, String path, Message onLoaded) {
120cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mEfid = efid;
121cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mRecordNum = recordNum;
122cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mOnLoaded = onLoaded;
123cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mLoadAll = false;
124cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mPath = path;
125cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        }
126cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja
127cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        LoadLinearFixedContext(int efid, String path, Message onLoaded) {
128cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mEfid = efid;
129cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mRecordNum = 1;
130cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mLoadAll = true;
131cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mOnLoaded = onLoaded;
132cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mPath = path;
133c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
134c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
135c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        LoadLinearFixedContext(int efid, Message onLoaded) {
13622d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mEfid = efid;
13722d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mRecordNum = 1;
13822d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mLoadAll = true;
13922d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville            mOnLoaded = onLoaded;
140cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            mPath = null;
141c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
142c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
143c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
144c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
145c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Default constructor
146c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
147e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka    protected IccFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) {
148e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka        mParentApp = app;
149c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mAid = aid;
150c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mCi = ci;
151c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
152c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
153c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void dispose() {
154c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
155c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
156c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    //***** Public Methods
157c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
158c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
159c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Load a record from a SIM Linear Fixed EF
160c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
161c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param fileid EF id
162cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param path Path of the EF on the card
163c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param recordNum 1-based (not 0-based) record number
164c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param onLoaded
165c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
166c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
167c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
168c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
169cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    public void loadEFLinearFixed(int fileid, String path, int recordNum, Message onLoaded) {
170cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        String efPath = (path == null) ? getEFPath(fileid) : path;
171c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        Message response
172cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
173cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        new LoadLinearFixedContext(fileid, recordNum, efPath, onLoaded));
174c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
175cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath,
176c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
177c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
178c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
179c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
180cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * Load a record from a SIM Linear Fixed EF
181cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *
182cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param fileid EF id
183cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param recordNum 1-based (not 0-based) record number
184cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param onLoaded
185cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *
186cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
187cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *
188cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     */
189cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    public void loadEFLinearFixed(int fileid, int recordNum, Message onLoaded) {
190cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        loadEFLinearFixed(fileid, getEFPath(fileid), recordNum, onLoaded);
191cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    }
192cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja
193cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    /**
194c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Load a image instance record from a SIM Linear Fixed EF-IMG
195c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
196c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param recordNum 1-based (not 0-based) record number
197c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param onLoaded
198c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
199c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
200c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
201c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
202c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void loadEFImgLinearFixed(int recordNum, Message onLoaded) {
203deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim        Message response = obtainMessage(EVENT_GET_RECORD_SIZE_IMG_DONE,
204c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                new LoadLinearFixedContext(IccConstants.EF_IMG, recordNum,
205c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        onLoaded));
206c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
207deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim        mCi.iccIOForApp(COMMAND_GET_RESPONSE, IccConstants.EF_IMG,
208deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim                    getEFPath(IccConstants.EF_IMG), recordNum,
209deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim                    READ_RECORD_MODE_ABSOLUTE, GET_RESPONSE_EF_IMG_SIZE_BYTES,
210deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim                    null, null, mAid, response);
211c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
212c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
213c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
214c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * get record size for a linear fixed EF
215c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
216c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param fileid EF id
217cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param path Path of the EF on the card
218c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param onLoaded ((AsnyncResult)(onLoaded.obj)).result is the recordSize[]
219c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *        int[0] is the record length int[1] is the total length of the EF
220c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *        file int[3] is the number of records in the EF file So int[0] *
221c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *        int[3] = int[1]
222c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
223cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    public void getEFLinearRecordSize(int fileid, String path, Message onLoaded) {
224cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        String efPath = (path == null) ? getEFPath(fileid) : path;
225c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        Message response
226c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                = obtainMessage(EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE,
227cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        new LoadLinearFixedContext(fileid, efPath, onLoaded));
228cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath,
229c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
230c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
231c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
232c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
233cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * get record size for a linear fixed EF
234cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *
235cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param fileid EF id
236cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param onLoaded ((AsnyncResult)(onLoaded.obj)).result is the recordSize[]
237cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *        int[0] is the record length int[1] is the total length of the EF
238cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *        file int[3] is the number of records in the EF file So int[0] *
239cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *        int[3] = int[1]
240cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     */
241cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    public void getEFLinearRecordSize(int fileid, Message onLoaded) {
242cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        getEFLinearRecordSize(fileid, getEFPath(fileid), onLoaded);
243cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    }
244cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja
245cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    /**
246c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Load all records from a SIM Linear Fixed EF
247c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
248c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param fileid EF id
249cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param path Path of the EF on the card
250c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param onLoaded
251c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
252c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * ((AsyncResult)(onLoaded.obj)).result is an ArrayList<byte[]>
253c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
254c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
255cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    public void loadEFLinearFixedAll(int fileid, String path, Message onLoaded) {
256cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        String efPath = (path == null) ? getEFPath(fileid) : path;
257c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
258cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        new LoadLinearFixedContext(fileid, efPath, onLoaded));
259c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
2603c9400dc00a58004f55effe34de8a751659bf567Jack Yu        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, efPath,
261c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
262c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
263c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
264c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
265cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * Load all records from a SIM Linear Fixed EF
266cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *
267cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param fileid EF id
268cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param onLoaded
269cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *
270cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * ((AsyncResult)(onLoaded.obj)).result is an ArrayList<byte[]>
271cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *
272cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     */
273cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    public void loadEFLinearFixedAll(int fileid, Message onLoaded) {
274cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        loadEFLinearFixedAll(fileid, getEFPath(fileid), onLoaded);
275cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    }
276cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja
277cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    /**
278c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Load a SIM Transparent EF
279c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
280c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param fileid EF id
281c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param onLoaded
282c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
283c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
284c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
285c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
286c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
287c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void loadEFTransparent(int fileid, Message onLoaded) {
288c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        Message response = obtainMessage(EVENT_GET_BINARY_SIZE_DONE,
289c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        fileid, 0, onLoaded);
290c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
291c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
292c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
293c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
294c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
295c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
296e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     * Load first @size bytes from SIM Transparent EF
297e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     *
298e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     * @param fileid EF id
299e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     * @param size
300e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     * @param onLoaded
301e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     *
302e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
303e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     *
304e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka     */
305e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka    public void loadEFTransparent(int fileid, int size, Message onLoaded) {
306e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka        Message response = obtainMessage(EVENT_READ_BINARY_DONE,
307e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka                        fileid, 0, onLoaded);
308e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka
309e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka        mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
310e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka                        0, 0, size, null, null, mAid, response);
311e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka    }
312e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka
313e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka    /**
314c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Load a SIM Transparent EF-IMG. Used right after loadEFImgLinearFixed to
315c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * retrive STK's icon data.
316c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
317c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param fileid EF id
318c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param onLoaded
319c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
320c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * ((AsyncResult)(onLoaded.obj)).result is the byte[]
321c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
322c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
323c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void loadEFImgTransparent(int fileid, int highOffset, int lowOffset,
324c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            int length, Message onLoaded) {
325c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0,
326c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                onLoaded);
327c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
328deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim        logd("IccFileHandler: loadEFImgTransparent fileid = " + fileid
3291b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                + " filePath = " + getEFPath(EF_IMG) + " highOffset = " + highOffset
330deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim                + " lowOffset = " + lowOffset + " length = " + length);
3311b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro
3321b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        /* Per TS 31.102, for displaying of Icon, under
333deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim         * DF Telecom and DF Graphics , EF instance(s) (4FXX,transparent files)
334deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim         * are present. The possible image file identifiers (EF instance) for
335deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim         * EF img ( 4F20, linear fixed file) are : 4F01 ... 4F05.
3361b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro         * It should be MF_SIM + DF_TELECOM + DF_GRAPHICS, same path as EF IMG
337deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim         */
3381b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(EF_IMG),
339deb8ccd0fbeae2b2f21f8a4ccc1139a79cccc71ejangeon.kim                highOffset, lowOffset, length, null, null, mAid, response);
340c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
341c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
342c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
343c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Update a record in a linear fixed EF
344c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param fileid EF id
345cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param path Path of the EF on the card
346cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param recordNum 1-based (not 0-based) record number
347cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param data must be exactly as long as the record in the EF
348cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param pin2 for CHV2 operations, otherwist must be null
349cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param onComplete onComplete.obj will be an AsyncResult
350cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     *                   onComplete.obj.userObj will be a IccIoResult on success
351cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     */
352cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    public void updateEFLinearFixed(int fileid, String path, int recordNum, byte[] data,
353cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja            String pin2, Message onComplete) {
354cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        String efPath = (path == null) ? getEFPath(fileid) : path;
355cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, efPath,
356cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        recordNum, READ_RECORD_MODE_ABSOLUTE, data.length,
357cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        IccUtils.bytesToHexString(data), pin2, mAid, onComplete);
358cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    }
359cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja
360cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja    /**
361cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * Update a record in a linear fixed EF
362cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja     * @param fileid EF id
363c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param recordNum 1-based (not 0-based) record number
364c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param data must be exactly as long as the record in the EF
365c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param pin2 for CHV2 operations, otherwist must be null
366c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param onComplete onComplete.obj will be an AsyncResult
367c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *                   onComplete.obj.userObj will be a IccIoResult on success
368c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
369c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void updateEFLinearFixed(int fileid, int recordNum, byte[] data,
370c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            String pin2, Message onComplete) {
371c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid),
372c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        recordNum, READ_RECORD_MODE_ABSOLUTE, data.length,
373c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        IccUtils.bytesToHexString(data), pin2, mAid, onComplete);
374c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
375c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
376c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
377c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Update a transparent EF
378c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param fileid EF id
379c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @param data must be exactly as long as the EF
380c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
381c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void updateEFTransparent(int fileid, byte[] data, Message onComplete) {
382c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mCi.iccIOForApp(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid),
383c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        0, 0, data.length,
384c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        IccUtils.bytesToHexString(data), null, mAid, onComplete);
385c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
386c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
387c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
388c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    //***** Abstract Methods
389c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
390c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
391c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    //***** Private Methods
392c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
393c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    private void sendResult(Message response, Object result, Throwable ex) {
394c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        if (response == null) {
395c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            return;
396c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
397c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
398c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        AsyncResult.forMessage(response, result, ex);
399c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
400c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        response.sendToTarget();
401c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
402c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
4031b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro    private boolean processException(Message response, AsyncResult ar) {
4041b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        IccException iccException;
4051b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        boolean flag = false;
4061b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        IccIoResult result = (IccIoResult) ar.result;
4071b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        if (ar.exception != null) {
4081b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro            sendResult(response, null, ar.exception);
4091b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro            flag = true;
4101b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        } else {
4111b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro            iccException = result.getException();
4121b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro            if (iccException != null) {
4131b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                sendResult(response, null, iccException);
4141b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                flag = true;
4151b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro            }
4161b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        }
4171b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro        return flag;
4181b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro    }
4191b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro
420c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    //***** Overridden from Handler
421c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
422cbaa45bbf2cab852b6c9c3a887e9f803d4e857eaWink Saville    @Override
423c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void handleMessage(Message msg) {
424c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        AsyncResult ar;
425c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        IccIoResult result;
426c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        Message response = null;
427c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        String str;
428c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        LoadLinearFixedContext lc;
429c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
430c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        byte data[];
431c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        int size;
432c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        int fileid;
433c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        int recordSize[];
434cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja        String path = null;
435c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
436c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        try {
437c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            switch (msg.what) {
438c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            case EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE:
439c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                ar = (AsyncResult)msg.obj;
440c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                lc = (LoadLinearFixedContext) ar.userObj;
441c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                result = (IccIoResult) ar.result;
44222d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                response = lc.mOnLoaded;
443c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
4441b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                if (processException(response, (AsyncResult) msg.obj)) {
445c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
446c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
447c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
448c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                data = result.payload;
449c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
450c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE] ||
451c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    EF_TYPE_LINEAR_FIXED != data[RESPONSE_DATA_STRUCTURE]) {
452c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    throw new IccFileTypeMismatch();
453c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
454c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
455c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                recordSize = new int[3];
456c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                recordSize[0] = data[RESPONSE_DATA_RECORD_LENGTH] & 0xFF;
457c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                recordSize[1] = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8)
458c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                       + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff);
459c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                recordSize[2] = recordSize[1] / recordSize[0];
460c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
461c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                sendResult(response, recordSize, null);
462c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                break;
4631b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro
4641b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro             case EVENT_GET_RECORD_SIZE_IMG_DONE:
465c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville             case EVENT_GET_RECORD_SIZE_DONE:
466c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                ar = (AsyncResult)msg.obj;
467c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                lc = (LoadLinearFixedContext) ar.userObj;
468c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                result = (IccIoResult) ar.result;
46922d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                response = lc.mOnLoaded;
470c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
4711b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                if (processException(response, (AsyncResult) msg.obj)) {
472c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
473c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
474c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
475c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                data = result.payload;
476cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                path = lc.mPath;
477c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
478c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE]) {
479c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    throw new IccFileTypeMismatch();
480c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
481c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
482c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                if (EF_TYPE_LINEAR_FIXED != data[RESPONSE_DATA_STRUCTURE]) {
483c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    throw new IccFileTypeMismatch();
484c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
485c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
48622d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                lc.mRecordSize = data[RESPONSE_DATA_RECORD_LENGTH] & 0xFF;
487c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
488c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                size = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8)
489c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                       + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff);
490c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
49122d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                lc.mCountRecords = size / lc.mRecordSize;
492c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
49322d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                 if (lc.mLoadAll) {
49422d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                     lc.results = new ArrayList<byte[]>(lc.mCountRecords);
495c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                 }
496c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
497cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                 if (path == null) {
498cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                     path = getEFPath(lc.mEfid);
499cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                 }
500cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                 mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, path,
50122d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                         lc.mRecordNum,
502c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                         READ_RECORD_MODE_ABSOLUTE,
50322d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                         lc.mRecordSize, null, null, mAid,
504c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                         obtainMessage(EVENT_READ_RECORD_DONE, lc));
505c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                 break;
506c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            case EVENT_GET_BINARY_SIZE_DONE:
507c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                ar = (AsyncResult)msg.obj;
508c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                response = (Message) ar.userObj;
509c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                result = (IccIoResult) ar.result;
510c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
5111b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                if (processException(response, (AsyncResult) msg.obj)) {
512c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
513c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
514c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
515c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                data = result.payload;
516c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
517c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                fileid = msg.arg1;
518c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
519c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                if (TYPE_EF != data[RESPONSE_DATA_FILE_TYPE]) {
520c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    throw new IccFileTypeMismatch();
521c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
522c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
523c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                if (EF_TYPE_TRANSPARENT != data[RESPONSE_DATA_STRUCTURE]) {
524c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    throw new IccFileTypeMismatch();
525c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
526c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
527c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                size = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8)
528c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                       + (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff);
529c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
530c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
531c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                                0, 0, size, null, null, mAid,
532c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                                obtainMessage(EVENT_READ_BINARY_DONE,
533c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                                              fileid, 0, response));
534c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            break;
535c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
5361b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro            case EVENT_READ_IMG_DONE:
537c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            case EVENT_READ_RECORD_DONE:
538c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
539c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                ar = (AsyncResult)msg.obj;
540c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                lc = (LoadLinearFixedContext) ar.userObj;
541c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                result = (IccIoResult) ar.result;
54222d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                response = lc.mOnLoaded;
543cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                path = lc.mPath;
544c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
5451b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                if (processException(response, (AsyncResult) msg.obj)) {
546c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
547c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
548c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
54922d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                if (!lc.mLoadAll) {
550c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    sendResult(response, result.payload, null);
551c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                } else {
552c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    lc.results.add(result.payload);
553c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
55422d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                    lc.mRecordNum++;
555c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
55622d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                    if (lc.mRecordNum > lc.mCountRecords) {
557c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        sendResult(response, lc.results, null);
558c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    } else {
559cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        if (path == null) {
560cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                            path = getEFPath(lc.mEfid);
561cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        }
562cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja
563cfa6dbeaf46193dae1be6779783f6ec2dc09b7abPreeti Ahuja                        mCi.iccIOForApp(COMMAND_READ_RECORD, lc.mEfid, path,
56422d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                                    lc.mRecordNum,
565c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                                    READ_RECORD_MODE_ABSOLUTE,
56622d85a8e3a575a6d01d2c788587971657dfe20c6Wink Saville                                    lc.mRecordSize, null, null, mAid,
567c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                                    obtainMessage(EVENT_READ_RECORD_DONE, lc));
568c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    }
569c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
570c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
571c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            break;
572c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
573c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            case EVENT_READ_BINARY_DONE:
5741b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro            case EVENT_READ_ICON_DONE:
575c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                ar = (AsyncResult)msg.obj;
576c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                response = (Message) ar.userObj;
577c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                result = (IccIoResult) ar.result;
578c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
5791b0331d1901d63ac65efb200b0e19d7aa4eb2b8bduho.ro                if (processException(response, (AsyncResult) msg.obj)) {
580c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
581c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                }
582c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
583c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                sendResult(response, result.payload, null);
584c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            break;
585c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
586c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }} catch (Exception exc) {
587c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            if (response != null) {
588c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                sendResult(response, null, exc);
589c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            } else {
590c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                loge("uncaught exception" + exc);
591c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            }
592c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
593c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
594c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
595c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
596c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Returns the root path of the EF file.
597c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * i.e returns MasterFile + DFfile as a string.
598c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Ex: For EF_ADN on a SIM, it will return "3F007F10"
599c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * This function handles only EFids that are common to
600c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * RUIM, SIM, USIM and other types of Icc cards.
601c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     *
602cbaa45bbf2cab852b6c9c3a887e9f803d4e857eaWink Saville     * @param efid of path to retrieve
603c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * @return root path of the file.
604c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
605c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    protected String getCommonIccEFPath(int efid) {
606c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        switch(efid) {
607c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_ADN:
608c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_FDN:
609c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_MSISDN:
610c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_SDN:
611c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_EXT1:
612c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_EXT2:
613c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_EXT3:
614a8467dd0c524787104b1ccdddc5e8af10ba729edWink Saville        case EF_PSI:
615c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            return MF_SIM + DF_TELECOM;
616c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
617c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_ICCID:
618c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_PL:
619c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            return MF_SIM;
620e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka        case EF_PBR:
621e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka            // we only support global phonebook.
622e287feac673ff68565b766e0e463d105fa9cef9dAlex Yakavenka            return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
623c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        case EF_IMG:
624c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            return MF_SIM + DF_TELECOM + DF_GRAPHICS;
625c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
626c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        return null;
627c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
628c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
629c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    protected abstract String getEFPath(int efid);
630c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    protected abstract void logd(String s);
631c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
632c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    protected abstract void loge(String s);
633c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
634c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville}
635