Skip to content

Commit f2fbd2e

Browse files
Wink SavilleAndroid (Google) Code Review
authored andcommitted
Merge "Telephony: Make IccFileHandler use ci instead of phone"
2 parents 2e76c99 + 2b75d12 commit f2fbd2e

File tree

5 files changed

+55
-50
lines changed

5 files changed

+55
-50
lines changed

telephony/java/com/android/internal/telephony/IccCard.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,12 @@ public IccCard(PhoneBase phone, String logTag, Boolean is3gpp, Boolean dbg) {
186186
if (phone.mCM.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE
187187
&& phone instanceof CDMALTEPhone) {
188188
mIccRecords = new CdmaLteUiccRecords(phone);
189-
mIccFileHandler = new CdmaLteUiccFileHandler((CDMALTEPhone)phone);
189+
mIccFileHandler = new CdmaLteUiccFileHandler(this, "", mPhone.mCM);
190190
} else {
191191
mIccRecords = is3gpp ? new SIMRecords(phone) : new RuimRecords(phone);
192-
mIccFileHandler = is3gpp ? new SIMFileHandler(phone) : new RuimFileHandler(phone);
192+
// Correct aid will be set later (when GET_SIM_STATUS returns)
193+
mIccFileHandler = is3gpp ? new SIMFileHandler(this, "", mPhone.mCM) :
194+
new RuimFileHandler(this, "", mPhone.mCM);
193195
}
194196
mPhone.mCM.registerForOffOrNotAvailable(mHandler, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
195197
mPhone.mCM.registerForOn(mHandler, EVENT_RADIO_ON, null);
@@ -572,6 +574,7 @@ private void handleIccCardStatus(IccCardStatus newCardStatus) {
572574
}
573575

574576
if (oldState != State.READY && newState == State.READY) {
577+
mIccFileHandler.setAid(getAid());
575578
mIccRecords.onReady();
576579
}
577580
}

telephony/java/com/android/internal/telephony/IccFileHandler.java

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public abstract class IccFileHandler extends Handler implements IccConstants {
9090
static protected final int EVENT_READ_ICON_DONE = 10;
9191

9292
// member variables
93-
protected PhoneBase phone;
93+
protected final CommandsInterface mCi;
94+
protected final IccCard mParentCard;
95+
protected String mAid;
9496

9597
static class LoadLinearFixedContext {
9698

@@ -120,9 +122,10 @@ static class LoadLinearFixedContext {
120122
/**
121123
* Default constructor
122124
*/
123-
protected IccFileHandler(PhoneBase phone) {
124-
super();
125-
this.phone = phone;
125+
protected IccFileHandler(IccCard card, String aid, CommandsInterface ci) {
126+
mParentCard = card;
127+
mAid = aid;
128+
mCi = ci;
126129
}
127130

128131
public void dispose() {
@@ -145,9 +148,8 @@ public void loadEFLinearFixed(int fileid, int recordNum, Message onLoaded) {
145148
= obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
146149
new LoadLinearFixedContext(fileid, recordNum, onLoaded));
147150

148-
phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
149-
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
150-
phone.getIccCard().getAid(), response);
151+
mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
152+
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
151153
}
152154

153155
/**
@@ -165,10 +167,9 @@ public void loadEFImgLinearFixed(int recordNum, Message onLoaded) {
165167
onLoaded));
166168

167169
// TODO(): Verify when path changes are done.
168-
phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, IccConstants.EF_IMG, "img",
170+
mCi.iccIOForApp(COMMAND_GET_RESPONSE, IccConstants.EF_IMG, "img",
169171
recordNum, READ_RECORD_MODE_ABSOLUTE,
170-
GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null,
171-
phone.getIccCard().getAid(), response);
172+
GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null, mAid, response);
172173
}
173174

174175
/**
@@ -184,9 +185,8 @@ public void getEFLinearRecordSize(int fileid, Message onLoaded) {
184185
Message response
185186
= obtainMessage(EVENT_GET_EF_LINEAR_RECORD_SIZE_DONE,
186187
new LoadLinearFixedContext(fileid, onLoaded));
187-
phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
188-
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, phone.getIccCard().getAid(),
189-
response);
188+
mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
189+
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
190190
}
191191

192192
/**
@@ -202,9 +202,8 @@ public void loadEFLinearFixedAll(int fileid, Message onLoaded) {
202202
Message response = obtainMessage(EVENT_GET_RECORD_SIZE_DONE,
203203
new LoadLinearFixedContext(fileid,onLoaded));
204204

205-
phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
206-
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
207-
phone.getIccCard().getAid(), response);
205+
mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
206+
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
208207
}
209208

210209
/**
@@ -221,9 +220,8 @@ public void loadEFTransparent(int fileid, Message onLoaded) {
221220
Message response = obtainMessage(EVENT_GET_BINARY_SIZE_DONE,
222221
fileid, 0, onLoaded);
223222

224-
phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
225-
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null,
226-
phone.getIccCard().getAid(), response);
223+
mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(fileid),
224+
0, 0, GET_RESPONSE_EF_SIZE_BYTES, null, null, mAid, response);
227225
}
228226

229227
/**
@@ -241,8 +239,8 @@ public void loadEFImgTransparent(int fileid, int highOffset, int lowOffset,
241239
Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0,
242240
onLoaded);
243241

244-
phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, "img", highOffset, lowOffset,
245-
length, null, null, phone.getIccCard().getAid(), response);
242+
mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, "img", highOffset, lowOffset,
243+
length, null, null, mAid, response);
246244
}
247245

248246
/**
@@ -256,10 +254,9 @@ public void loadEFImgTransparent(int fileid, int highOffset, int lowOffset,
256254
*/
257255
public void updateEFLinearFixed(int fileid, int recordNum, byte[] data,
258256
String pin2, Message onComplete) {
259-
phone.mCM.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid),
257+
mCi.iccIOForApp(COMMAND_UPDATE_RECORD, fileid, getEFPath(fileid),
260258
recordNum, READ_RECORD_MODE_ABSOLUTE, data.length,
261-
IccUtils.bytesToHexString(data), pin2,
262-
phone.getIccCard().getAid(), onComplete);
259+
IccUtils.bytesToHexString(data), pin2, mAid, onComplete);
263260
}
264261

265262
/**
@@ -268,10 +265,9 @@ public void updateEFLinearFixed(int fileid, int recordNum, byte[] data,
268265
* @param data must be exactly as long as the EF
269266
*/
270267
public void updateEFTransparent(int fileid, byte[] data, Message onComplete) {
271-
phone.mCM.iccIOForApp(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid),
268+
mCi.iccIOForApp(COMMAND_UPDATE_BINARY, fileid, getEFPath(fileid),
272269
0, 0, data.length,
273-
IccUtils.bytesToHexString(data), null,
274-
phone.getIccCard().getAid(), onComplete);
270+
IccUtils.bytesToHexString(data), null, mAid, onComplete);
275271
}
276272

277273

@@ -402,11 +398,10 @@ public void handleMessage(Message msg) {
402398
lc.results = new ArrayList<byte[]>(lc.countRecords);
403399
}
404400

405-
phone.mCM.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
401+
mCi.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
406402
lc.recordNum,
407403
READ_RECORD_MODE_ABSOLUTE,
408-
lc.recordSize, null, null,
409-
phone.getIccCard().getAid(),
404+
lc.recordSize, null, null, mAid,
410405
obtainMessage(EVENT_READ_RECORD_DONE, lc));
411406
break;
412407
case EVENT_GET_BINARY_SIZE_DONE:
@@ -441,9 +436,8 @@ public void handleMessage(Message msg) {
441436
size = ((data[RESPONSE_DATA_FILE_SIZE_1] & 0xff) << 8)
442437
+ (data[RESPONSE_DATA_FILE_SIZE_2] & 0xff);
443438

444-
phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
445-
0, 0, size, null, null,
446-
phone.getIccCard().getAid(),
439+
mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
440+
0, 0, size, null, null, mAid,
447441
obtainMessage(EVENT_READ_BINARY_DONE,
448442
fileid, 0, response));
449443
break;
@@ -477,11 +471,10 @@ public void handleMessage(Message msg) {
477471
if (lc.recordNum > lc.countRecords) {
478472
sendResult(response, lc.results, null);
479473
} else {
480-
phone.mCM.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
474+
mCi.iccIOForApp(COMMAND_READ_RECORD, lc.efid, getEFPath(lc.efid),
481475
lc.recordNum,
482476
READ_RECORD_MODE_ABSOLUTE,
483-
lc.recordSize, null, null,
484-
phone.getIccCard().getAid(),
477+
lc.recordSize, null, null, mAid,
485478
obtainMessage(EVENT_READ_RECORD_DONE, lc));
486479
}
487480
}
@@ -551,5 +544,8 @@ protected String getCommonIccEFPath(int efid) {
551544
protected abstract void logd(String s);
552545

553546
protected abstract void loge(String s);
547+
protected void setAid(String aid) {
548+
mAid = aid;
549+
}
554550

555551
}

telephony/java/com/android/internal/telephony/cdma/CdmaLteUiccFileHandler.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
package com.android.internal.telephony.cdma;
1818

1919
import android.util.Log;
20+
21+
import com.android.internal.telephony.CommandsInterface;
22+
import com.android.internal.telephony.IccCard;
2023
import com.android.internal.telephony.IccConstants;
2124
import com.android.internal.telephony.IccFileHandler;
2225
import android.os.Message;
@@ -27,8 +30,8 @@
2730
public final class CdmaLteUiccFileHandler extends IccFileHandler {
2831
static final String LOG_TAG = "CDMA";
2932

30-
public CdmaLteUiccFileHandler(CDMALTEPhone phone) {
31-
super(phone);
33+
public CdmaLteUiccFileHandler(IccCard card, String aid, CommandsInterface ci) {
34+
super(card, aid, ci);
3235
}
3336

3437
protected String getEFPath(int efid) {
@@ -55,8 +58,8 @@ public void loadEFTransparent(int fileid, Message onLoaded) {
5558
if (fileid == EF_CSIM_EPRL) {
5659
// Entire PRL could be huge. We are only interested in
5760
// the first 4 bytes of the record.
58-
phone.mCM.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
59-
0, 0, 4, null, null, phone.getIccCard().getAid(),
61+
mCi.iccIOForApp(COMMAND_READ_BINARY, fileid, getEFPath(fileid),
62+
0, 0, 4, null, null, mAid,
6063
obtainMessage(EVENT_READ_BINARY_DONE,
6164
fileid, 0, onLoaded));
6265
} else {

telephony/java/com/android/internal/telephony/cdma/RuimFileHandler.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import android.os.*;
2020
import android.util.Log;
2121

22+
import com.android.internal.telephony.CommandsInterface;
23+
import com.android.internal.telephony.IccCard;
2224
import com.android.internal.telephony.IccConstants;
2325
import com.android.internal.telephony.IccException;
2426
import com.android.internal.telephony.IccFileHandler;
@@ -39,8 +41,8 @@ public final class RuimFileHandler extends IccFileHandler {
3941
//***** Instance Variables
4042

4143
//***** Constructor
42-
public RuimFileHandler(PhoneBase phone) {
43-
super(phone);
44+
public RuimFileHandler(IccCard card, String aid, CommandsInterface ci) {
45+
super(card, aid, ci);
4446
}
4547

4648
public void dispose() {
@@ -58,9 +60,9 @@ public void loadEFImgTransparent(int fileid, int highOffset, int lowOffset,
5860
Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0,
5961
onLoaded);
6062

61-
phone.mCM.iccIOForApp(COMMAND_GET_RESPONSE, fileid, "img", 0, 0,
63+
mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, "img", 0, 0,
6264
GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null,
63-
phone.getIccCard().getAid(), response);
65+
mAid, response);
6466
}
6567

6668
@Override

telephony/java/com/android/internal/telephony/gsm/SIMFileHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.os.Message;
2020
import android.util.Log;
2121

22+
import com.android.internal.telephony.CommandsInterface;
2223
import com.android.internal.telephony.IccCard;
2324
import com.android.internal.telephony.IccCardApplication;
2425
import com.android.internal.telephony.IccConstants;
@@ -35,8 +36,8 @@ public final class SIMFileHandler extends IccFileHandler implements IccConstants
3536

3637
//***** Constructor
3738

38-
public SIMFileHandler(PhoneBase phone) {
39-
super(phone);
39+
public SIMFileHandler(IccCard card, String aid, CommandsInterface ci) {
40+
super(card, aid, ci);
4041
}
4142

4243
public void dispose() {
@@ -91,8 +92,8 @@ protected String getEFPath(int efid) {
9192
// The EFids in USIM phone book entries are decided by the card manufacturer.
9293
// So if we don't match any of the cases above and if its a USIM return
9394
// the phone book path.
94-
IccCard card = phone.getIccCard();
95-
if (card != null && card.isApplicationOnIcc(IccCardApplication.AppType.APPTYPE_USIM)) {
95+
if (mParentCard != null
96+
&& mParentCard.isApplicationOnIcc(IccCardApplication.AppType.APPTYPE_USIM)) {
9697
return MF_SIM + DF_TELECOM + DF_PHONEBOOK;
9798
}
9899
Log.e(LOG_TAG, "Error: EF Path being returned in null");

0 commit comments

Comments
 (0)