@@ -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}
0 commit comments