1. UiccController收到以下三条消息的时候:
1)IccStatus变化的主动上报: EVENT_ICC_STATUS_CHANGED
F:\ubuntu\code\android-p\frameworks\opt\telephony\src\java\com\android\internal\telephony\uicc\UiccController.java
1 case EVENT_ICC_STATUS_CHANGED: 2 if (DBG) log("Received EVENT_ICC_STATUS_CHANGED, calling getIccCardStatus"); 3 mCis[phoneId].getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, 4 phoneId)); 5 break;
2)Radio状态变为Available或者On:EVENT_RADIO_AVAILABLE or EVENT_RADIO_ON
1 case EVENT_RADIO_AVAILABLE: 2 case EVENT_RADIO_ON: 3 if (DBG) { 4 log("Received EVENT_RADIO_AVAILABLE/EVENT_RADIO_ON, calling " 5 + "getIccCardStatus"); 6 } 7 mCis[phoneId].getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, 8 phoneId));
3)SIM卡信息刷新(为RESET或INIT时):EVENT_SIM_REFRESH
1 private void onSimRefresh(AsyncResult ar, Integer index) { 2 // The card status could have changed. Get the latest state. 3 mCis[index].getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, index)); 4 }
会触发向底层IccCardStatus的查询(见上面红字部分)。
1 mCi.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, index));
2. 根据当前配置的Radio版本号不同,底层会返回上层不同的数据格式。目前telephony已经有两套代码,Google的RIL仓下只有一套代码,暂时不知道Google是什么意思。
/hardware/ril/libril/ril_service.cpp
1 int radio::getIccCardStatusResponse(int slotId, 2 int responseType, int serial, RIL_Errno e, 3 void *response, size_t responseLen) { 4 if (radioService[slotId]->mRadioResponse != NULL) { 5 RadioResponseInfo responseInfo = {}; 6 populateResponseInfo(responseInfo, serial, responseType, e); 7 CardStatus cardStatus = {}; 8 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); 9 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6) 10 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications 11 || p_cur->cdma_subscription_app_index >= p_cur->num_applications 12 || p_cur->ims_subscription_app_index >= p_cur->num_applications) { 13 RLOGE("getIccCardStatusResponse: Invalid response"); 14 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 15 } else { 16 cardStatus.cardState = (CardState) p_cur->card_state; 17 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state; 18 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index; 19 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index; 20 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index; 21 22 RIL_AppStatus *rilAppStatus = p_cur->applications; 23 cardStatus.applications.resize(p_cur->num_applications); 24 AppStatus *appStatus = cardStatus.applications.data(); 25 #if VDBG 26 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications); 27 #endif 28 for (int i = 0; i < p_cur->num_applications; i++) { 29 appStatus[i].appType = (AppType) rilAppStatus[i].app_type; 30 appStatus[i].appState = (AppState) rilAppStatus[i].app_state; 31 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate; 32 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr); 33 appStatus[i].appLabelPtr = convertCharPtrToHidlString( 34 rilAppStatus[i].app_label_ptr); 35 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced; 36 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1; 37 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2; 38 } 39 } 40 41 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 42 getIccCardStatusResponse(responseInfo, cardStatus); // 调用到上层RadioResponse的getIccCardStatusResponse借口。而_1_2的接口暂时没有用到。
43 radioService[slotId]->checkReturnStatus(retStatus);
44 } else {
45 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
46 }
47
48 return 0;
49 }
3. 收到底层的回复时,会触发卡信息的更新。
F:\ubuntu\code\android-p\frameworks\opt\telephony\src\java\com\android\internal\telephony\uicc\UiccController.java
1 case EVENT_GET_ICC_STATUS_DONE: 2 if (DBG) log("Received EVENT_GET_ICC_STATUS_DONE"); 3 onGetIccCardStatusDone(ar, phoneId); 4 break;