The Uicccard of UICC

Source: Internet
Author: User
Tags constructor
Uicccard itself does not implement specific functions, just as an indirect interface to Uicccontroller to provide uicccardapplication objects and complete the creation of catservice work, And when the SIM card is plugged in or unplugged, the prompt box will need to restart the device.


first, the main function of Uicccard


We look at its functionality from the main methods provided by Uicccard. [Java] view plain Copy public boolean ISAPPLICATIONONICC (Icccardapplicationstatus.apptype type) {} public UICCC Ardapplication getapplication (int family) {} public uicccardapplication getapplicationindex (int index) {} public void Registerforabsent (Handler h, int what, Object obj) {} public cardstate getcardstate () {} Thus we can see that the main function of Uicccard to be able to;
1. Create and provide uicccardapplication objects to the outside

2. A listener that accepts the presence of a registered SIM card

3. Get the current SIM status object: Cardstate


second, the initialization process of Uicccard


Introduced in the update mechanism that describes Uicccontroller, when Uicccontroller receives a status update message from a SIM card escalation, it updates (update) or creates a Uicccard object:[Java] View plain copy @UiccController .java   private synchronized void ongeticccardstatusdone ( Asyncresult ar)  {       IccCardStatus status =  ( Icccardstatus) ar.result;       if  (muicccard == null)  {            //Create uicccard            muicccard = new uicccard (mcontext, mci, status);        } else {           //Update Uicccard            muicccard.update (mcontext, mci ,  Status);       }        Miccchangedregistrants.notifyregistrants ();  }           Next we look at the nature of this object, and through its inheritance, we can see that he is a uicccard class, not inheriting the other parent classes:[Java]View plain copy public class Uicccard {} then look at his constructor:[Java]View Plain Copy public Uicccard (Context C, Commandsinterface CI, icccardstatus ics) {mcardstate = ics.mcardstate;   Update (c, CI, ICS); }

The simple constructor is to initialize the SIM card state mcardstate in Uicccard and then update its state by calling the update () method.


third, the update process of Uicccard


Uicccard not only calls the update () method in the constructor, but also when Uicccontroller detects a change in the SIM card state, so the update () method here is critical, so let's look at its definition:[Java] View Plain copy public void update (context c, commandsinterface ci, icccardstatus  ics)  {       synchronized  (mLock)  {            if  (mdestroyed)  {                return;           }            CardState oldState = mCardState;            mCardState = ics.mCardState;           mUniversalPinState = ics.mUniversalPinState;            mGsmUmtsSubscriptionAppIndex =  ics.mgsmumtssubscriptionappindex;            Mcdmasubscriptionappindex = ics.mcdmasubscriptionappindex;           mimssubscriptionappindex  = ics.mImsSubscriptionAppIndex;           mcontext  = c;           mCi = ci;           //update applications            if  (DBG)  log (ics.mapplications.length +  " applications");            for  ( int i = 0; i  < muiccapplications.length; i++)  {                if  (muiccapplications[i] == null)  {                    if  (i <  ics.mapplicAtions.length)  {                        //creating Uicccardapplication Objects                          Muiccapplications[i] = new uicccardapplication (This, ics.mapplications[i], mcontext, &NBSP;MCI);                    }               } else  if  (i >= ics.mapplications.length)  {                    muiccapplications[i].dispose ();                    Muiccapplications[i] = null; &nbsP             } else {                    // Update Uicccardapplication Objects                     muiccapplications[i].update (ICS.MAPPLICATIONS[I],&NBSP;MCONTEXT,&NBSP;MCI);                }            }              if   (Muiccapplications.length > 0 && muiccapplications[0] != null)  {               //Create Catservice                mCatService =  Catservice.getinstance (Mci, mcontext,  this);           } else {                if  (Mcatservice != null)  {                    mcatservice.dispose ();                }               mcatservice =  null;           }            sanitizeapplicationindexes ();            radiostate radiostate = mci.getradiostate ();            if  (radiostate == radiostate.radio_on && mlastradiostate  == radiostate. radio_on)  {               if  ( oldstate != cardstate.cardstate_absent && mcardstate ==  cardstate.cardstate_absent)  {                    //sim Card is unplugged, notifies listeners, and pops up the prompt box to restart the phone                     mabsentregistrants.notifyregistrants ();                     Mhandler.sendmessage (Mhandler.obtainmessage (event_card_removed, null));                } else if  (oldstate ==  Cardstate.cardstate_absent && mcardstate != cardstate.cardstate_absent)  {    &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBsp;         //Insert a new SIM card and pop-up prompt box to restart your phone                     mhandler.sendmessage ( Mhandler.obtainmessage (event_card_added, null));                }           }            mLastRadioState = radioState;        }  }           During the initialization of Uicccard, three important tasks were completed:
1, create and update uicccardapplication objects;
2. Initialize Catservice
3, when the SIM card unplugged or inserted action, through the Mhandler object pop-up prompt box whether to
restart the phone

This is the update process for Uicccard.


Iv. Uicccard Detection of SIM card removal/insertion Operation


Below is a brief look at the following uicccard to the SIM card removal/insertion operation.
As previously analyzed, the Uicccard update () process can receive a change in the status of the SIM card, when Uicccard detects a SIM card insertion or removal operation, a prompt will pop up to indicate whether to restart the device.[Java] View Plain copy public void update (context c, commandsinterface ci, icccardstatus  ics)  {       synchronized  (mLock)  {            if  (radiostate == radiostate.radio_on &&  mlastradiostate == radiostate.radio_on)  {                if  (oldstate != cardstate.cardstate_absent &&  mcardstate == cardstate.cardstate_absent)  {                    mabsentregistrants.notifyregistrants ();                    // Remove SIM card operation                     mhandler.senDmessage (Mhandler.obtainmessage (event_card_removed, null));                } else if  (Oldstate == cardstate.cardstate_ absent && mcardstate != cardstate.cardstate_absent)  {                    //inserting the SIM card operation                     Mhandler.sendmessage (Mhandler.obtainmessage (event_card_added, null));                }           }            mLastRadioState = radioState;        }  }           then go to handler for processing: [Java] View plain Copy Protected handler mhandler = new handler ()  {         @Override        public void handlemessage (Message &NBSP;MSG) {           switch  (msg.what)  {                case event_card_removed:                     Oniccswap (false);                    break;                case event_card_added:                    oniccswap (true);                    break;                default:                    loge ("unknown event "  + msg.what);            }       }  };           then enter Oniccswap () in the popup dialog box: [Java] View Plain copy Private void oniccswap (boolean isadded)  {        synchronized  (mLock)  {            dialoginterface.onclicklistener listener = null;            listener = new dialoginterface.onclicklistener ()  {                 @Override                 public void onclick (DialogInterface  Dialog, int which)  {                    synchronized  (mLock)  {                        if  (which  == dialoginterface.button_positive)  {                            //Click the button to restart the device                              PowerManager pm =  (PowerManager)  mcontext .getsystemservice (context.power_ SERVICE);                            pm.reboot ("sim is added.");                         }                    }               }            };           Resources r  = resources.getsystem ();           //load different resources            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) ;           //pop-up dialog            alertdialog dialog = new alertdialog.builder (MContext)                 .settitle (title)                 .setmessage (message)                 .setpositivebutton (buttontxt, listener)                 .create ();            dialog.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);            dialog.show ();       }  }   

This is the procedure that pops up the prompt box.

The following section describes uicccardapplication related content.

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.