Android 7.0 UICC Analysis (ii)

Source: Internet
Author: User

This article explains the Uicccard class

/frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/uicccard.java

The Ongeticccardstatusdone () method of the Uicccontroller class, which icccardstatus create or update Uicccard objects based on the acquired SIM status information;

    Private synchronized voidongeticccardstatusdone (AsyncResult ar, Integer index) {... Icccardstatus Status=(icccardstatus) Ar.result; if(Muicccards[index] = =NULL) {            //Create New CardMuicccards[index] =NewUicccard (Mcontext, Mcis[index], status, index); } Else {            //Update already existing cardmuicccards[index].update (Mcontext, Mcis[index], status); }        .......    }

The Uicccard class is also constructed by calling the update () method to update the SIM card status information;

     Public int Phoneid) {        = ics.mcardstate;         = Phoneid;        Update (c, CI, ICS);    }

Update () method for the Uicccard class:

1. Match the Uicccardapplication object in the Muiccapplication list according to the Icccardstatus parameter, updated by the update () method of the Uicccardapplication class. Otherwise create a Uicccardapplication object;

2. Call the Createandupdatecatservice () method to create or update the Catservice object;

3, Get radiostate status, update Cardstate, issue SIM card Plug and unplug messages;

     Public voidUpdate (Context C, Commandsinterface CI, icccardstatus ics) {...//Update Applications            if(DBG) log (ics.mApplications.length + "Applications"));  for(inti = 0; i < muiccapplications.length; i++) {                if(Muiccapplications[i] = =NULL) {                    //Create newly added applications                    if(I <ics.mApplications.length) {Muiccapplications[i]=NewUicccardapplication ( This, Ics.mapplications[i], Mcontext, mCi); }                } Else if(I >=ics.mApplications.length) {//Delete removed ApplicationsMuiccapplications[i].dispose (); Muiccapplications[i]=NULL; } Else {                    //Update the restmuiccapplications[i].update (Ics.mapplications[i], mcontext, mCi);//Call Uicccardapplication.java }} createandupdatecatservice (); //Catservice            .......... Radiostate radiostate=mci.getradiostate (); if(DBG) log ("update:radiostate=" + radiostate + "mlastradiostate=" +mlastradiostate); //No notifications while radio are off or we just powering up            if(Radiostate = = radiostate.radio_on && Mlastradiostate = =radiostate.radio_on) {                if(oldstate! = cardstate.cardstate_absent &&mcardstate==cardstate.cardstate_absent) {                    if(DBG) log ("Update:notify card removed");                    Mabsentregistrants.notifyregistrants (); Mhandler.sendmessage (Mhandler.obtainmessage (event_card_removed,NULL)); } Else if(oldstate = = Cardstate.cardstate_absent &&mcardstate!=cardstate.cardstate_absent) {                    if(DBG) log ("Update:notify card added"); Mhandler.sendmessage (Mhandler.obtainmessage (event_card_added,NULL)); }} mlastradiostate=radiostate; }    }

Createandupdatecatservice () method, create or update Catservice:

    protected voidCreateandupdatecatservice () {if(Muiccapplications.length > 0 && muiccapplications[0]! =NULL) {            //Initialize or reinitialize Catservice            if(Mcatservice = =NULL) {Mcatservice= Catservice.getinstance (MCi, Mcontext, This, Mphoneid); } Else{(catservice) mcatservice). Update (MCi, Mcontext, This); }        } Else {            if(Mcatservice! =NULL) {mcatservice.dispose (); } Mcatservice=NULL; }    }


Messages event_card_removed, event_card_added are handled in the Handlemessage () method of the Uicccard class:

    protectedHandler Mhandler =NewHandler () {@Override Public voidhandlemessage (Message msg) {Switch(msg.what) { CaseEvent_card_removed:oniccswap (false);  Break;  CaseEvent_card_added:oniccswap (true);  Break;        .........            } }    };

Oniccswap () method, determine whether the common card block, if it is returned directly, otherwise call Promptforrestart ():

    Private void Oniccswap (boolean  isadded) {        boolean ishotswapsupported =  Mcontext.getresources (). Getboolean (                r.bool.config_hotswapcapable);         if // to the domestic dual SIM card block design left the interface            Log ("oniccswap:ishotswapsupported is true, and don ' t prompt for rebooting")            ; return ;        }        Log ("oniccswap:ishotswapsupported is false, prompt for rebooting");        Promptforrestart (isadded);    }

Promptforrestart () method, toggle sim card, pop-up prompt box:

    Private voidPromptforrestart (Booleanisadded) {        synchronized(mLock) {FinalResources res =mcontext.getresources (); FinalString dialogcomponent =res.getstring (r.string.config_icchotswappromptforrestartdialogcomponent); if(Dialogcomponent! =NULL) {Intent Intent=NewIntent (). SetComponent (Componentname.unflattenfromstring (dialogcomponent)). Addflags (Intent.fla                G_activity_new_task). PutExtra (extra_icc_card_added, isadded); Try{mcontext.startactivity (intent); return; } Catch(activitynotfoundexception e) {Loge ("Unable to find ICC HotSwap prompt for restart activity:" +e); }            }            //Todo:here We assume the device can ' t handle SIM hot-swap//and have to reboot. We may want to add a property,//e.g. reboot_on_sim_swap, to indicate if modem support//Hot-swap.Dialoginterface.onclicklistener listener =NULL; //Todo:simrecords is not the reset while SIM ABSENT ( only the reset while//radio_off_or_not_available). Has to reset in both both//added or removed situation.Listener =NewDialoginterface.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {                    synchronized(mLock) {if(Which = =dialoginterface.button_positive) {                            if(DBG) log ("Reboot due to SIM swap"); PowerManager pm=(PowerManager) mcontext. Getsystemservice (Context.power_service); Pm.reboot ("SIM is added.");            }                    }                }            }; Resources R=Resources.getsystem (); String title= (isadded)?r.getstring (r.string.sim_added_title): r.getstring (R.string.sim_removed_title); String message= (isadded)?r.getstring (r.string.sim_added_message): r.getstring (R.string.sim_removed_message); String Buttontxt=r.getstring (R.string.sim_restart_button); Alertdialog Dialog=NewAlertdialog.builder (Mcontext). Settitle (title). Setmessage (message). Setpositivebutt            On (buttontxt, listener). Create ();            Dialog.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);        Dialog.show (); }    }

Android 7.0 UICC Analysis (ii)

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.