the nature of the SIM card is a file system with different partitions, and Iccfilehandler is primarily used to read data from the corresponding partition from the SIM card.
first, the function of Iccfilehandler
Let's see which of the public methods it provides:[Java] View Plain copy public void loadeflinearfixed (int fileid, int recordnum, message onloaded) {} public void loadefimglinearfixed (int recordnum, message onloaded) {} Public void loadeflinearfixedall (int fileid, message onloaded) {} public void loadeftransparent (int fileid, message onLoaded) {} public void loadeftransparent (Int fileid, int size, message onloaded) {} public void loadefimgtransparent (Int fileid, int highoffset, int lowoffset, int length, message onloaded) {} public void geteflinearrecordsize (int fileid, message onloaded) {} public void updateeflinearfixed (int fileid, int recordnum, byte[] data, stRing pin2, message oncomplete) {} public void updateeftransparent (int fileid, byte[] data, message oncomplete) {}
As can be seen from these methods, themain function of Iccfilehandler is to provide the read and write operation of the SIM card file system, when calling these methods, we need to pass the file system address to read and write, and the callback function after reading and writing. The Iccfilehandler notifies the caller after reading the data and passes the return value past .
second, the creation of Iccfilehandler process
because different types of SIM card partitioning information are different, different Iccfilehandler objects are created in uicccardapplication based on the current SIM type:[Java] View plain copy @UiccCardApplication .java Private iccfilehandler createiccfilehandler ( Apptype type) { switch (type) { case APPTYPE_SIM: return new simfilehandler (THIS, MAID, MCI); case APPTYPE_RUIM: return new ruimfilehandler (This, mAid,  MCI); case APPTYPE_USIM: return new usimfilehandler ( THIS, MAID, MCI); case apptype_csim: &nbsP; return new csimfilehandler (this, MAID, MCI); case APPTYPE_ISIM: return new Isimfilehandler (THIS, MAID, MCI); default : return null; } } These classes are inherited from Iccfilehandler. Because different SIM cards differ only in the address information of the partition, these classes ofThe only difference is that the Getefpath () method of the parent class is overridden, such as Simfilehandler:[Java] View plain copy @SIMFileHandler .java protected string getefpath (int efid) { switch (efid) { case ef_sms: return MF_SIM + DF_TELECOM; case ef_ ext6: case EF_MWIS: case EF_MBI: case EF_SPN: case EF_AD: case EF_MBDN: case EF_PNN: case ef_spdi: case EF_SST: case EF_CFIS: case EF_GID1: return mf_sim + df_gsm; case ef_mailbox_ cphs: case EF_VOICE_MAIL_INDICATOR_CPHS: case EF_CFF_CPHS: case EF_SPN_CPHS: case EF_SPN_SHORT_CPHS: case ef_ info_cphs: case EF_CSP_CPHS: return mf_sim + df_gsm; } string path = getcommoniccefpath (EFID); if (path == null) {      RLOG.E (log_tag, "error: ef path being returned in null "); } return path; } and Usimfilehandler's Getefpath () is this: [Java] View plain copy @UsimFileHandler .java protected string getefpath (int efid) { switch (efid) { case ef_sms: case EF_EXT6: case EF_MWIS: case EF_MBI: case ef_ spn: case EF_AD: case EF_MBDN: case ef_pnn: case EF_OPL: case EF_SPDI: case ef_sst: case EF_CFIS: case EF_MAILBOX_CPHS: case EF_VOICE_MAIL_INDICATOR_CPHS: case EF_CFF_CPHS: case EF_SPN_CPHS: case ef_spn_short_cphs: case EF_FDN: case EF_MSISDN: case ef_ext2: case EF_INFO_CPHS: case EF_CSP_CPHS: case ef_gid1: return MF_SIM + DF_ADF; case EF_PBR: return mf_sim + df_telecom + df_phonebook; } string path = getcommoniccefpath (efid); if (path == null) { return MF_SIM + DF_TELECOM + DF_PHONEBOOK; } return path; } You can see that The difference between Simfilehandler and Usimfilehandler lies in the address of the partition.
Then look at the construction process of Iccfilehandler:[Java]View plain copy @IccFileHandler. Java protected Iccfilehandler (Uicccardapplication app, String Aid, Commandsinterface CI) {Mparentapp = app; MAid = aid; MCi = CI; }
Because the primary function of Iccfilehandler is to query the SIM partition information passively, in the construction method, only important contextual information is saved for use.
Third, Iccfilehandler read the process of the file
Since Iccfilehandler's main function is to read the file information, we'll follow up on how he realizes the reading of the information.
Let's look at the most commonly used process for reading linear fixed-length file information.[Java]View plain copy @IccFileHandler. Java public void loadeflinearfixed (int fileid, int recordnum, Message onLoaded) { First read the RECORD's SIZE Message response = Obtainmessage (Event_get_record_size_done, New Loadlinearfixedcontext (Fileid, re Cordnum, onLoaded)); Call Rilj to the modem to read the length of the current partition of the SIM card Mci.iccioforapp (Command_get_response, Fileid, Getefpath (Fileid), 0, 0, get_response_ef_s Ize_bytes, NULL, NULL, MAID, response); In this reading process, not directly read the corresponding partition content, but first read the current partition record length, when the length is taken to read the current record of the specific content:[Java] View Plain copy public void handlemessage (message msg) { asyncresult ar; IccIoResult result; Message response = null; String str; LoadLinearFixedContext lc; byte data[]; int size; int fileid; int recordSize[]; try { switch (msg.what) { case event_get_record_size_img_done: case event_get_record _size_done: //get the raw data from the modem ar = (AsyncResult) msg.obj; lc = (Loadlinearfixedcontext) ar.userobj; result = (iccioresult) ar.result; response = lc.mOnLoaded; if (ProcessException (response, (AsyncResult) msg.obj)) { break; } data = result.payload; if (Type_ef != data[response_data_file_type]) { Throw new iccfiletypemismatch (); } if (Ef_type_linear_fixed != data[response_data_ STRUCTURE]) { throw new iccfiletypemismatch (); } //get the current record length lc.mrecordsize = data[RESPONSE_DATA_RECORD_LENGTH] & 0xFF; size = (Data[response_data_ FILE_SIZE_1]&NBSP;&&NBSP;0XFF) << 8) + (data[response_data_file_size_2] &&NBSP;0XFF); lc.mcountrecords = size / lc.mrecordsize; if (Lc.mloadall) { lc.results = new ArrayList<byte[]> (lc.mcountrecords); } // Plus the record length to read read data again mci.iccioforapp (Command_read_record, lc.mefid, getefpath (Lc.mEfid), lc.mrecordnum, READ_RECORD_MODE_ABSOLUTE, lc.mRecordSize, null, null, mAid, obtainmessage (EVENT_READ_RECORD_DONE,&NBSP;LC)); break; }} catch (EXCEPTION&NBSP;EXC) { &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBS