UiccCardApplication,描述智能卡应用的信息,在UiccCard 中创建,主要包含如下内容
<1> 对应的卡的信息,如APPState,AppType
<2> 读取卡信息的对象,如IccFileHandler,IccRecrods
<3> 对卡状态的数据监听器,如 mReadyRegistrants
UiccCardApplciation只会创建一次,一旦卡的状态发生变化,UiccCardApplication 就会被更新
void update (IccCardApplicationStatus as, Context c, CommandsInterface ci) {
synchronized (mLock) {
if (mDestroyed) {
loge("Application updated after destroyed! Fix me!");
return;
}
if (DBG) log(mAppType + " update. New " + as);
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();}
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 (DBG) log(oldAppType + " changed state: " + oldAppState + " -> " + mAppState);
// If the app state turns to APPSTATE_READY, then query FDN status,
//as it might have failed in earlier attempt.
if (mAppState == AppState.APPSTATE_READY) {
queryFdn();
queryPin1State();
}
notifyPinLockedRegistrantsIfNeeded(null);// 数据发生变化,通知相关对象
notifyReadyRegistrantsIfNeeded(null);// 数据发生变化,通知相关对象
}
}
}
当SIM卡的状态为Ready 的时候,就会通知 具体的IccRecords 去执行 加载SIM卡的信息,以RuimRecords 为例
<1> mParentApp.registerForReady(this, EVENT_APP_READY, null); //注册数据监听
<2> public void onReady() {
fetchRuimRecords();// 读取Records
mCi.getCDMASubscription(obtainMessage(EVENT_GET_CDMA_SUBSCRIPTION_DONE));
}
具体的读取数据的操作是由IccFileHandler 完成的,数据保存在IccRecords 和相关系统属性中。
<1> 对应的卡的信息,如APPState,AppType
<2> 读取卡信息的对象,如IccFileHandler,IccRecrods
<3> 对卡状态的数据监听器,如 mReadyRegistrants
UiccCardApplciation只会创建一次,一旦卡的状态发生变化,UiccCardApplication 就会被更新
void update (IccCardApplicationStatus as, Context c, CommandsInterface ci) {
synchronized (mLock) {
if (mDestroyed) {
loge("Application updated after destroyed! Fix me!");
return;
}
if (DBG) log(mAppType + " update. New " + as);
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();}
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 (DBG) log(oldAppType + " changed state: " + oldAppState + " -> " + mAppState);
// If the app state turns to APPSTATE_READY, then query FDN status,
//as it might have failed in earlier attempt.
if (mAppState == AppState.APPSTATE_READY) {
queryFdn();
queryPin1State();
}
notifyPinLockedRegistrantsIfNeeded(null);// 数据发生变化,通知相关对象
notifyReadyRegistrantsIfNeeded(null);// 数据发生变化,通知相关对象
}
}
}
当SIM卡的状态为Ready 的时候,就会通知 具体的IccRecords 去执行 加载SIM卡的信息,以RuimRecords 为例
<1> mParentApp.registerForReady(this, EVENT_APP_READY, null); //注册数据监听
<2> public void onReady() {
fetchRuimRecords();// 读取Records
mCi.getCDMASubscription(obtainMessage(EVENT_GET_CDMA_SUBSCRIPTION_DONE));
}
具体的读取数据的操作是由IccFileHandler 完成的,数据保存在IccRecords 和相关系统属性中。