Android4.X Read SIM card SMS and contact related class instance analysis

  • 2020-09-28 09:09:23
  • OfStack

This article is an example of es1EN4.X reading SIM card SMS and contact related classes. To share for your reference, the details are as follows:

1. IccSmsInterfaceManager

There are two main functions of this class

< 1 > Send SMS data via SMSDispatcher
< 2 > Update and query SIM card SMS data

IccSmsInterfaceManager is an Binder service class, and the Binder interface is ISms.
Binder service will be registered when IccSmsInterfaceManager is created.
IccSmsInterfaceManager is created in PhonProxy and holds the corresponding PhoneBase object.
When reading SMS data on SIM card, it is read by IccFileHandler of PhoneBase. IccFileHandler calls RIL object to send commands to Modem. The relevant code is as follows:

fh.loadEFLinearFixedAll(IccConstants.EF_SMS, response);

When saving SMS data to the SIM card, it is done through the RIL object of PhoneBase, and the RIL object issues commands to Modem. The relevant codes are as follows:


if (PhoneConstants.PHONE_TYPE_GSM == mPhone.getPhoneType()) {
 mPhone.mCi.writeSmsToSim(status, IccUtils.bytesToHexString(smsc),
   IccUtils.bytesToHexString(pdu), response);
} else {
 mPhone.mCi.writeSmsToRuim(status, IccUtils.bytesToHexString(pdu),
   response);
}

2. IccPhoneBookInterfaceManagerProxy

This class is primarily used to update and query contact data on the SIM card. It is an agent for IccPhoneBookInterfaceManager. IccPhoneBookInterfaceManager is 1 Binder service. Depending on PhoneBase, IccPhoneBookInterfaceManager has two implementation classes, SimPhoneBookInterfaceManager and ES63en.IccPhoneBookInterfaceManager, constructed during the creation of the PhoneBase object, which will hold one PhoneBase object.

IccPhoneBookInterfaceManagerProxy is constructed during the creation of the PhoneProxy object. The creation of IccPhoneBookInterfaceManagerProxy completes the registration of Binder service IccPhoneBookInterfaceManager and holds IccPhoneBookInterfaceManager objects.
IccPhoneBookInterfaceManager holds 1 AdnRecordCache. Object. This object is from IccRecords. IccRecords comes from the PhoneBase object. PhoneBase updates IccRecords corresponding to SIM CARDS by monitoring the status of UiccController.

It is understood that every time the status of the SIM card changes, UiccController first updates the status of the SIM card through UiccCardApplication and updates the data read from the SIM card. The listener of UiccController (PhoneBase,IccCardProxy) is then notified that the data related to the SIM card has changed and they can update the data (IccRecords).

Hopefully, this article has helped you with Android programming.


Related articles: