This article mainly tells the Usim card inserts the handset to read the card the Contacts information flow. Overall process summary every time you plug in a SIM card, the contact person in the contact database about the SIM card is removed simstatereceiver by receiving the RIL escalated broadcast of the SIM card status change Simcontactsservice Simcontactsservice asynchronous boot Iccprovider to query the SIM contact person through Iccphonebookinterfacemanager layer call to RIL then layer back, finally construct matrixcursor insert Database First, introduce the role of several classes: Iccprovider: Externally exposed interface, we use it to query the SIM card contacts Information Iccphonebookinterfacemanager:phonebook operation Services Iccphonebookinterfacemanagerproxy: The external Phonebook operation service, the above class agent. Iccrecord: Store some information related to the card adnrecord: a type of contact information is encapsulated after reading Adnrecordcache: Cache contact information in SIM card Adnrecordloader: The class Iccfilehandler that actually obtains ADN information through Iccfilehandler: Initiate a request to RIL, or accept feedback RIL: Initiate a request to the bottom and receive feedback the general flowchart is as follows:
Several important methods are:
Public list<adnrecord> getadnrecordsinef (int efid) {if (Mphone.getcontext (). Checkcallingorselfpermissi On (Android. Manifest.permission.READ_CONTACTS)!= packagemanager.permission_granted) {throw new Securitye
Xception ("Requires android.permission.READ_CONTACTS permission");
} synchronized (Mlock) {checkthread ();
Atomicboolean status = new Atomicboolean (false);
Message response = Mbasehandler.obtainmessage (Event_load_done, status);
Efid = Updateefforicctype (Efid);
if (DBG) logd ("getadnrecordsinef:efid=" + Efid); if (Madncache!= null) {madncache.requestloadalladnlike (Efid, madncache.extension
Efforef (EFID), NULL, response);
Waitforresult (status);
else {Loge ("failure while trying to load from SIM due to uninitialised adncache"); } if (mrecords = null && Efid = = Iccconstants.ef_pbr &&!madncache.ispbrpresent ())
{///If the data is ef_adn via the path of the EF_PBR through the value of the LOGD ("Getadnrecordsinef:load from Ef_adn as PBR ' not present");
Mforceadnusage = true;
Return Getadnrecordsinef (ICCCONSTANTS.EF_ADN);
} return mrecords; private int Updateefforicctype (int efid) {//Check if we are trying to read ADN records if (Efid = = Iccconstants.ef_adn &&!mforceadnusage) {if (mphone.getcurrentuiccapptype () = = Apptype.apptype_usim
|| Mphone.getcurrentuiccapptype () = = Apptype.apptype_csim) {return iccconstants.ef_pbr;//sim card back: Ef_adn, USI
M card returns EF_PBR This return value affects the way we should read the file path in UICC} return efid; }
Public arraylist<adnrecord> Loadeffilesfromusim () {synchronized (Mlock) {if (!mphonebookre
Cords.isempty ()) {if (Mrefreshcache) {Mrefreshcache = false;
RefreshCache ();
return mphonebookrecords;
} if (!mispbrpresent) return null;
Check If the PBR file is present to the cache, if not read it//from the USIM.
if (Mpbrfile = = null) {readpbrfileandwait ();
} if (mpbrfile = null) return null;
int numrecs = MPbrFile.mFileIds.size (); if ((Manrflagsrecord = null) && (Memailflagsrecord = null)) {Manrflagsrecord = new Arraylist[nu
MRECS];
Memailflagsrecord = new Arraylist[numrecs]; for (int i = 0; i < numrecs i++) {Manrflagsrecord[i] = new Arraylist<integer>();
Memailflagsrecord[i] = new arraylist<integer> (); for (int i = 0; i < numrecs i++) {//Read the information inside and put mphonebookrecords in it, this value will affect the mem inside contacts
The value of the total of the SIM card is shown in Orystatusactivity readadnfileandwait (i);
Reademailfileandwait (i);
Readanrfileandwait (i);
//All EF files are loaded, post the response.
return mphonebookrecords; }
Important Log information
Line 10831:07-15 18:52:30.427 D/iccprovider (3714): [Iccprovider] Query line
10835:07-15 18:52:30.427 (3714): [Iccprovider] loadfromef:eftype=28474, subscription=3 //adn line 10837:07-15 18:52:30.429 D/
Simphonebookim (3714): [Simpbinterfacemanager] getadnrecordsinef:efid=20272 //pbr line
10843:07-15 18:52:30.429 d/usimfh (3714): Using Global Phonebook line
10845:07-15 18:52:30.429 d/usimfh (3714): Using L Ocal Phonebook Line
10847:07-15 18:52:30.429 d/iccprovider (3714): [Iccprovider] adnrecords.size=500
Line 10849:07-15 18:52:30.429 D/iccprovider (3714): [Iccprovider] Loadrecord:luoyi, 15202863711, line
33763:07-15 18:5 4:38.049 D/usimphonebookmanager (3714): Loading PBR do line 53039:07-15 18:55:34.067 d/adnrecordcache
(3714): Usi Ng Local Phonebook
Basic knowledge of SIM card
All data on the SIM card is stored as a file in the card data store, as shown in the following illustration:
MF: Represents the root directory, DF: Representative directory, EF: Representative files
Three kinds of EF files: Transparent file transparent/record file Linear fixed/circular file Cydic
On the card, each directory or file has its own ID, called the FID SIM look at the file structure as follows:
The SIM card file system is structured as follows:
which
-3F Master file (MF, filesystem root)
-7F Dedicated file (DF, private files directory)
-2F Elementary file (MF, located in the main files directory)
-6F Elementary file (MF, located in the private files directory)
-SIM: An application for storing GSM user signing information on the User Identification Module (Subscriber Identity module) (GSM/WCDMA/TD-SCDMA) UICC card
-USIM: A General user identification module (Universal Subscriber Identity Module) (GSM/WCDMA/TD-SCDMA) UICC card stores an application of 3G user signing information.
-Usim can include both Usim and SIM two logical modules, or it can include only usim logic modules, the first is called Composite Usim card, that is, it can be compatible with 2G and 3G terminals, and the second is a pure Usim card, which can only be used in 3G terminals. Usim and SIM contrast Usim using two-way authentication, SIM using one-way authentication, so Usim security can be higher; Usim card machine card interface speed of about 230BITS/S, far superior to SIM; Usim can support 4 concurrent logic applications, better than SIM; Relative to the SIM's support for STK, USIM supports richer STK logic channels and makes it possible to initiate multiple services based on Usim (USAT). Each contact can have multiple numbers and multiple nicknames relative to the phone book in Sim,usim