Android4.4 telephony Process analysis data load when--sim card is powered on

Source: Internet
Author: User

This code is based on the MTK platform Android 4.4 As the analysis object, and Google native Aosp a little difference, please read the reader.

This article mainly introduces the SIM card data reading process, when the RF state is in the ready state, at this time uicccardapplication should be in the Appstate.appstate_ready state, we follow this signal down. Read the Android4.4 telephony process Analysis--sim the initialization of the radio and SIM card status update process at the start of this article.

Let's take a look at the sequence diagram of the data load:


STEP1~STEP3, go is the update process, create process reference Android4.4 telephony process Analysis--sim card when the initialization of the article step21 after the steps.

STEP4, FDN (fixed dialing) data for SIM cards are queried via modem.

STEP5, the pin1 status of SIM card is queried by modem.

STEP6~STEP7, Pin1 status will be notified, Icccardproxy will register mpinlockedregistrants.

STEP8~STEP9, the SIM card ready status is sent out.

private void notifyreadyregistrantsifneeded (registrant R) {if (mdestroyed) {return; } if (mappstate = = Appstate.appstate_ready) {if (mpin1state = = Pinstate.pinstate_enabled_not_verified |                    |                    Mpin1state = = Pinstate.pinstate_enabled_blocked | | Mpin1state = = pinstate.pinstate_enabled_perm_blocked) {Loge ("sanity check failed!                APPSTATE was ready while PIN1 was not verified!!! ");            Don ' t notify if application is in insane state return;                } if (r = null) {if (DBG) log ("notifying Registrants:ready");            Mreadyregistrants.notifyregistrants ();                } else {if (DBG) log ("notifying 1 Registrant:ready");            R.notifyregistrant (new AsyncResult (null, NULL, NULL)); }        }    }

if the Pin1 is activated at this point, that is, the SIM card has the Pin1 lock enabled, thesim ready status will not be sent out .

Listening to mreadyregistrants state changes in many objects, mainly: Simrecords (similar to Ruimrecords, Isimuiccrecords), Icccardproxy (SIM card status will be broadcast out), Gsmservicestatetracker (will register the network according to the SIM status), here mainly say Simrecords, read the SIM data.


Step12,fetchsimrecords () Method:

Mtk-end [mtk80601][111215][alps00093395] protected void Fetchsimrecords () {mrecordsrequested = true;        if (DBG) log ("Fetchsimrecords" + mrecordstoload);        Mci.getimsiforapp (Mparentapp.getaid (), Obtainmessage (Event_get_imsi_done));//Read IMSI mrecordstoload++;        Iccfh.loadeftransparent (Ef_iccid, Obtainmessage (Event_get_iccid_done));        mrecordstoload++;        Fixme should examine EF[MSISDN] ' s capability configuration//To determine which are the Voice/data/fax line New Adnrecordloader (phone). LOADFROMEF (Ef_msisdn, Ef_ext1, 1,//obtainmessage (event_get_msisdn_done        ));        recordstoload++;        Record number is subscriber profile mfh.loadeflinearfixed (Ef_mbi, 1, Obtainmessage (Event_get_mbi_done));        mrecordstoload++;        Mfh.loadeftransparent (Ef_ad, Obtainmessage (Event_get_ad_done));        mrecordstoload++; Record number is subscriber profile mfh.loadeflinearfixed (EF_MWIS, 1, Obtainmessage (Event_get_mwis_done));        mrecordstoload++; Also Load cphs-style voice mail indicator, which stores//the same info as Ef[mwis]. If both exist, both is updated//and the Ef[mwis] data is preferred//Please note this must be loaded aft ER Ef[mwis] mfh.loadeftransparent (ef_voice_mail_indicator_cphs, Obtainmessage (event_        Get_voice_mail_indicator_cphs_done));        mrecordstoload++;        Same goes for call Forward Status Indicator:fetch both//Ef[cfis] and Cphs-ef, with Ef[cfis] preferred.        Mfh.loadeflinearfixed (Ef_cfis, 1, Obtainmessage (Event_get_cfis_done));        mrecordstoload++;        Mfh.loadeftransparent (Ef_cff_cphs, Obtainmessage (Event_get_cff_done));        mrecordstoload++;        GETSPNFSM (true, null);        Mfh.loadeftransparent (Ef_spdi, Obtainmessage (Event_get_spdi_done));        mrecordstoload++; Mfh.loadeflinearfixed (EF_PNN, 1, Obtainmessage (EVENT_get_pnn_done));        recordstoload++;        Mfh.loadeftransparent (Ef_sst, Obtainmessage (Event_get_sst_done));        mrecordstoload++;        Mfh.loadeftransparent (Ef_info_cphs, Obtainmessage (Event_get_info_cphs_done));        mrecordstoload++;        Mfh.loadeftransparent (Ef_csp_cphs,obtainmessage (Event_get_csp_cphs_done));        mrecordstoload++;        Mfh.loadeftransparent (Ef_gid1, Obtainmessage (Event_get_gid1_done));        mrecordstoload++;         /* Detail description:this feature provides a interface to get menu title string from Ef_sume */ if (mtelephonyext! = null) {if (Mtelephonyext.issetlanguagebysim ()) {Mfh.loadeftranspa                 Rent (Ef_sume, Obtainmessage (Event_query_menu_title_done));            mrecordstoload++;        }} else {Loge ("fetchsimrecords (): Mtelephonyext is NULL!!!");        } fetchcphsons (); XXX should seek instead of examining them all if (false) {//XXX Mfh.loadeflinearfixedall (ef_sms, Obtainmessage (Event_get_all_sms_done));        mrecordstoload++;                         } if (crash_ril) {String SMS = "0107912160130310f20404d0110041007030208054832b0120" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "ffffffffffffffff Fffffffffffffffffffffffffffffffffffffffffffffffffff "+" ffffffffffffffffffffffffffffffffffffffffff Fffffffffffffffffffffffffff "+" ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff            F "+" ffffffffffffffffffffffffffffff ";            byte[] ba = iccutils.hexstringtobytes (SMS);        Mfh.updateeflinearfixed (ef_sms, 1, BA, NULL, Obtainmessage (Event_mark_sms_read_done, 1));        } if (DBG) log ("Fetchsimrecords" + Mrecordstoload + "requested:" + mrecordsrequested); /* Here, we assuMe the PHB is a ready and try to read the entries.        * If It is not, we'll receive the event Event_phb_ready later.        * Then, we'll ready the PHB entries again.    */Fetchphbrecords ();//read ADN contact person fetchratbalancing (); }

Read the SIM card is to pass the modem, the upper reading modem will have to pass RIL, we read ADN contact Fetchphbrecords () For example, to see the reading process Step13~step22, mainly through the Iccfilehandler implementation, First request the length of the ADN (STEP16~STEP19), and then request the specific ADN contact data step20~step22, the process is to interact with the modem process, the reader can first understand the SIM card file structure, in order to better understand why so read, I'm not very familiar with it.

Step23, get the SIM card built-in emergency number, which is customized by the operator.

STEP24~STEP26, when data that requires load is completed, it is executed, and then mrecordsloadedregistrants notifications are released in onallrecordsloaded.

    protected void onrecordloaded () {        //one record loaded successfully or failed, in either case        //We need to update The recordstoload count        mrecordstoload-= 1;        if (DBG) log ("onrecordloaded" + Mrecordstoload + "requested:" + mrecordsrequested);        if (Mrecordstoload = = 0 && mrecordsrequested = = True) {            onallrecordsloaded ();        } else if (Mrecordstoload &L T 0) {            loge ("Recordstoload <0, programmer error Suspected");            mrecordstoload = 0;        }    }

The steps after step27 are the responses to mrecordsloadedregistrants Listening, which, Icccardproxy heard, will be broadcast to the outside world:

    private void Broadcasticcstatechangedintent (string value, String reason) {synchronized (MLock) {if (Mquietmode) {log ("Quietmode:not Broadcasting Intent Action_sim_state_changed" + value + "re                Ason "+ reason);            Return            } Intent Intent = new Intent (telephonyintents.action_sim_state_changed);            Intent.addflags (intent.flag_receiver_replace_pending);            Intent.putextra (Phoneconstants.phone_name_key, "PHONE");            Intent.putextra (icccardconstants.intent_key_icc_state, value);            Intent.putextra (Icccardconstants.intent_key_locked_reason, REASON);            Intent.putextra (Phoneconstants.gemini_sim_id_key, Msimid); if (DBG) log ("Broadcasting Intent action_sim_state_changed" + value + "Reason" + reason + "SIM ID            "+ Msimid); Activitymanagernative.broadcaststickyintent (Intent, Read_phone_state, USerhandle.user_all);            }} public void Broadcasticcstatechangedextendintent (string value, String reason) {synchronized (MLock) { if (Mquietmode) {log ("Quietmode:not Broadcasting extend Intent action_sim_state_changed" + val                UE + "Reason" + reason);            Return            } Intent Intent = new Intent (telephonyintents.action_sim_state_changed_extend);            Intent.addflags (intent.flag_receiver_replace_pending);            Intent.putextra (Phoneconstants.phone_name_key, "PHONE");            Intent.putextra (icccardconstants.intent_key_icc_state, value);            Intent.putextra (Icccardconstants.intent_key_locked_reason, REASON);            Intent.putextra (Phoneconstants.gemini_sim_id_key, Msimid); if (DBG) log ("Broadcasting Intent Action_sim_state_changed_extend" + value + "Reason" + Reason + "            SIM id "+ msimid); Activitymanagernative.broadcasTstickyintent (Intent, read_phone_state, Userhandle.user_all); }    }

Gsmservicestatetracker will refresh the operator's name and, if necessary, re-select the registration network.


Right-copy the image address and open it in the browser to see a larger image.

Please correct me if there is any wrong place to be continued.


Android4.4 telephony Process analysis data load when--sim card is powered on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.