UiccCardApplication所担任的任务主要包括创建并向外提供IccFileHandler、IccRecords对象、提供对SIM卡状态的监听等。
public void registerForReady(Handler h, int what, Object obj) {} public void registerForLocked(Handler h, int what, Object obj) {} public void registerForNetworkLocked(Handler h, int what, Object obj) {} public AppState getState() {} public AppType getType() {} public PersoSubState getPersoSubState() {} public String getAid() {} public PinState getPin1State() {} public IccFileHandler getIccFileHandler() {} public IccRecords getIccRecords() {} public void supplyPin (String pin, Message onComplete) {} public void supplyPuk (String puk, String newPin, Message onComplete) {} public void supplyPin2 (String pin2, Message onComplete) {} public void supplyPuk2 (String puk2, String newPin2, Message onComplete) {} public void supplyNetworkDepersonalization (String pin, Message onComplete) {} public boolean getIccLockEnabled() {} public boolean getIccFdnEnabled() {} public void setIccLockEnabled (boolean enabled, String password, Message onComplete) {} public void setIccFdnEnabled (boolean enabled, String password, Message onComplete) {} public void changeIccLockPassword(String oldPassword, String newPassword, Message onComplete) {} public void changeIccFdnPassword(String oldPassword, String newPassword, Message onComplete) {}由此可以看到UiccCardApplication的主要功能:
5、提供网络锁、Pin锁、状态OK的监听器
public class UiccCardApplication {}与UiccCard类似,其没有父类,然后看构造函数:
UiccCardApplication(UiccCard uiccCard, IccCardApplicationStatus as, Context c, CommandsInterface ci) { mUiccCard = uiccCard; mAppState = as.app_state; mAppType = as.app_type; mPersoSubState = as.perso_substate; mAid = as.aid; mAppLabel = as.app_label; mPin1Replaced = (as.pin1_replaced != 0); mPin1State = as.pin1; mPin2State = as.pin2; mContext = c; mCi = ci; //创建IccFileHandler对象 mIccFh = createIccFileHandler(as.app_type); //创建IccRecords对象 mIccRecords = createIccRecords(as.app_type, mContext, mCi); if (mAppState == AppState.APPSTATE_READY) { //查询fdn号码 queryFdn(); //查询Pin码状态 queryPin1State(); } }在构造函数中主要完成了四个任务:
4、查询Pin码状态
void update (IccCardApplicationStatus as, Context c, CommandsInterface ci) { synchronized (mLock) { //状态更新 mContext = c; mCi = ci; AppType oldAppType = mAppType; AppState oldAppState = mAppState; PersoSubState oldPersoSubState = mPersoSubState; mAppType = as.app_type; mAppState = as.app_state; mPersoSubState = as.perso_substate; mAid = as.aid; mAppLabel = as.app_label; mPin1Replaced = (as.pin1_replaced != 0); mPin1State = as.pin1; mPin2State = as.pin2; if (mAppType != oldAppType) { if (mIccFh != null) { mIccFh.dispose();} if (mIccRecords != null) { mIccRecords.dispose();} //重新创建IccFileHandler和IccRecords mIccFh = createIccFileHandler(as.app_type); mIccRecords = createIccRecords(as.app_type, c, ci); } if (mPersoSubState != oldPersoSubState && mPersoSubState == PersoSubState.PERSOSUBSTATE_SIM_NETWORK) { //通知网络锁的监听器 notifyNetworkLockedRegistrantsIfNeeded(null); } if (mAppState != oldAppState) { if (mAppState == AppState.APPSTATE_READY) { //重新查询Fdn和Pin queryFdn(); queryPin1State(); } //通知网络锁和网络注册的监听器 notifyPinLockedRegistrantsIfNeeded(null); notifyReadyRegistrantsIfNeeded(null); } } }我们看到,在UiccCardApplication的更新过程中,完成了3个任务: