Uicc之UiccCardApplication

  UiccCardApplication所担任的任务主要包括创建并向外提供IccFileHandler、IccRecords对象、提供对SIM卡状态的监听等。


一、UiccCardApplication的主要功能


        我们从UiccCardApplication提供的public方法来查看其提供的主要功能。
  1. public void registerForReady(Handler h, int what, Object obj) {}  
  2. public void registerForLocked(Handler h, int what, Object obj) {}  
  3. public void registerForNetworkLocked(Handler h, int what, Object obj) {}  
  4. public AppState getState() {}  
  5. public AppType getType() {}  
  6. public PersoSubState getPersoSubState() {}  
  7. public String getAid() {}  
  8. public PinState getPin1State() {}  
  9. public IccFileHandler getIccFileHandler() {}  
  10. public IccRecords getIccRecords() {}  
  11. public void supplyPin (String pin, Message onComplete) {}  
  12. public void supplyPuk (String puk, String newPin, Message onComplete) {}  
  13. public void supplyPin2 (String pin2, Message onComplete) {}  
  14. public void supplyPuk2 (String puk2, String newPin2, Message onComplete) {}  
  15. public void supplyNetworkDepersonalization (String pin, Message onComplete) {}  
  16. public boolean getIccLockEnabled() {}  
  17. public boolean getIccFdnEnabled() {}  
  18. public void setIccLockEnabled (boolean enabled, String password, Message onComplete) {}  
  19. public void setIccFdnEnabled (boolean enabled, String password, Message onComplete) {}  
  20. public void changeIccLockPassword(String oldPassword, String newPassword, Message onComplete) {}  
  21. public void changeIccFdnPassword(String oldPassword, String newPassword, Message onComplete) {}  
        由此可以看到UiccCardApplication的主要功能:
        1、创建并向外提供IccFileHandler、IccRecords对象
        2、查询当前UiccCardApplication状态信息,主要包括mAppState、mAppType
        3、查询、设置Fdn的状态
        4、查询、设置Pin、Puk状态和密码

        5、提供网络锁、Pin锁、状态OK的监听器


二、UiccCardApplication的初始化过程


        在介绍UiccCard时我们分析到, UiccCard更新时就会创建或者更新UiccCardApplication对象
        我们先来看UiccCardApplication的属性:
  1. public class UiccCardApplication {}  
        与UiccCard类似,其没有父类,然后看构造函数:
  1. UiccCardApplication(UiccCard uiccCard, IccCardApplicationStatus as, Context c, CommandsInterface ci) {  
  2.     mUiccCard = uiccCard;  
  3.     mAppState = as.app_state;  
  4.     mAppType = as.app_type;  
  5.     mPersoSubState = as.perso_substate;  
  6.     mAid = as.aid;  
  7.     mAppLabel = as.app_label;  
  8.     mPin1Replaced = (as.pin1_replaced != 0);  
  9.     mPin1State = as.pin1;  
  10.     mPin2State = as.pin2;  
  11.     mContext = c;  
  12.     mCi = ci;  
  13.   
  14.     //创建IccFileHandler对象  
  15.     mIccFh = createIccFileHandler(as.app_type);  
  16.     //创建IccRecords对象  
  17.     mIccRecords = createIccRecords(as.app_type, mContext, mCi);  
  18.     if (mAppState == AppState.APPSTATE_READY) {  
  19.         //查询fdn号码  
  20.         queryFdn();  
  21.         //查询Pin码状态  
  22.         queryPin1State();  
  23.     }  
  24. }  
        在构造函数中主要完成了四个任务:
        1、创建SIM卡的文件系统管理者IccFileHandler的子类对象:SIMFileHandler/RuimFileHandler/UsimFileHandler/CsimFileHandler/IsimFileHandler
        2、创建SIM卡信息IccRecords的子类对象:SIMRecords/RuimRecords/IsimUiccRecords
        3、查询Fdn号码

        4、查询Pin码状态


三、UiccCardApplication的更新过程


        当Modem的SIM卡或者Radio状态改变时,就会通过UiccController更新UiccCard,然后再由UiccCard更新UiccCardApplication,此时就会调用update()方法:
  1. void update (IccCardApplicationStatus as, Context c, CommandsInterface ci) {  
  2.     synchronized (mLock) {  
  3.         //状态更新  
  4.         mContext = c;  
  5.         mCi = ci;  
  6.         AppType oldAppType = mAppType;  
  7.         AppState oldAppState = mAppState;  
  8.         PersoSubState oldPersoSubState = mPersoSubState;  
  9.         mAppType = as.app_type;  
  10.         mAppState = as.app_state;  
  11.         mPersoSubState = as.perso_substate;  
  12.         mAid = as.aid;  
  13.         mAppLabel = as.app_label;  
  14.         mPin1Replaced = (as.pin1_replaced != 0);  
  15.         mPin1State = as.pin1;  
  16.         mPin2State = as.pin2;  
  17.   
  18.         if (mAppType != oldAppType) {  
  19.             if (mIccFh != null) { mIccFh.dispose();}  
  20.             if (mIccRecords != null) { mIccRecords.dispose();}  
  21.             //重新创建IccFileHandler和IccRecords  
  22.             mIccFh = createIccFileHandler(as.app_type);  
  23.             mIccRecords = createIccRecords(as.app_type, c, ci);  
  24.         }  
  25.   
  26.         if (mPersoSubState != oldPersoSubState && mPersoSubState == PersoSubState.PERSOSUBSTATE_SIM_NETWORK) {  
  27.             //通知网络锁的监听器  
  28.             notifyNetworkLockedRegistrantsIfNeeded(null);  
  29.         }  
  30.   
  31.         if (mAppState != oldAppState) {  
  32.             if (mAppState == AppState.APPSTATE_READY) {  
  33.                 //重新查询Fdn和Pin  
  34.                 queryFdn();  
  35.                 queryPin1State();  
  36.             }  
  37.             //通知网络锁和网络注册的监听器  
  38.             notifyPinLockedRegistrantsIfNeeded(null);  
  39.             notifyReadyRegistrantsIfNeeded(null);  
  40.         }  
  41.     }  
  42. }  
        我们看到,在UiccCardApplication的更新过程中,完成了3个任务:
        1、更新当前状态相关的成员变量
        2、需要时重新构建IccFileHandler、IccRecords,以及重新查询Fdn和Pin
        3、通知监听器

        接下来的章节我们分析由UiccCardApplication创建的 IccFileHandler和IccRecords对象
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值