系统版本:Android4.4
D/RILJ ( 623): Starting RILReceiver
I/RILJ ( 623): Connected to 'rild' socket =》RIL层log分析一般都是从rild已经连接开始
D/RILJ ( 623): [UNSL]< UNSOL_RIL_CONNECTED {9} =》一旦rild连接后,reference-ril.cpp会上报“UNSOL_RIL_CONNECTED"
D/RILJ ( 623): [3648]> RADIO_POWER offD/RILJ ( 623): [3651]> RIL_REQUEST_SET_CELL_INFO_LIST_RATE
RIL.java一旦受到“UNSOL_RIL_CONNECTED”会做如下处理(对应上面几行log):
case RIL_UNSOL_RIL_CONNECTED: {
if (RILJ_LOGD) unsljLogRet(response, ret);
// Initial conditions
setRadioPower(false, null); //RADIO_POWER off
setPreferredNetworkType(mPreferredNetworkType, null); //REQUEST_SET_PREFERRED_NETWORK_TYPE
setCdmaSubscriptionSource(mCdmaSubscription, null); //RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE
setCellInfoListRate(Integer.MAX_VALUE, null); //RIL_REQUEST_SET_CELL_INFO_LIST_RATE
notifyRegistrantsRilConnectionChanged(((int[])ret)[0]);
break;
D/RILJ ( 623): [UNSL]< UNSOL_RESPONSE_RADIO_STATE_CHANGED RADIO_OFF
D/RILJ ( 623): [3652]> SCREEN_STATE: true
D/RILJ ( 623): [3648]< RADIO_POWER
D/RILJ ( 623): setPhoneType=1 old value=0
D/RILJ ( 623): [3653]> RADIO_POWER on
switch(response) {
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
/* has bonus radio state int */
RadioState newState = getRadioStateFromInt(p.readInt());
if (RILJ_LOGD) unsljLogMore(response, newState.toString());
switchToRadioState(newState);
break;
D/RILJ ( 623): [UNSL]<
UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED
D/RILJ ( 623): [3661]> QUERY_NETWORK_SELECTION_MODE
“UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED”是“reference-ril.cpp”上报给RIL.java最重要的一个状态,一旦模块的网络状态改变都要上报“UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED”,“CEREG:/CREG/CGREG”等状态改变都要上报;
reference-ril.cpp代码上报:
static void onUnsolicited (const char *s, const char *sms_pdu)
{
......................
else if (strStartsWith(s,"+CGREG:")
) {
RIL_onUnsolicitedResponse (
RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED,
NULL, 0);
#ifdef WORKAROUND_FAKE_CGEV
RIL_requestTimedCallback (onDataCallListChanged, NULL, NULL);
#endif /* WORKAROUND_FAKE_CGEV */
}
......................
}
RIL.java收到“UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED”会调用到“ pollState();”轮询当前网络状态:
RIL.java
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
if (RILJ_LOGD) unsljLog(response);
mVoiceNetworkStateRegistrants
.notifyRegistrants(new AsyncResult(null, null, null));
break;
GsmServiceStateTracker.java
mCi.registerForVoiceNetworkStateChanged(this, EVENT_NETWORK_STATE_CHANGED, null);
case EVENT_NETWORK_STATE_CHANGED:
pollState();
break;
private void pollState() {
mPollingContext = new int[1];
mPollingContext[0] = 0;
switch (mCi.getRadioState()) {
case RADIO_UNAVAILABLE:
mNewSS.setStateOutOfService();
mNewCellLoc.setStateInvalid();
setSignalStrengthDefaultValues();
mGotCountryCode = false;
mNitzUpdatedTime = false;
pollStateDone();
break;
case RADIO_OFF:
mNewSS.setStateOff();
mNewCellLoc.setStateInvalid();
setSignalStrengthDefaultValues();
mGotCountryCode = false;
mNitzUpdatedTime = false;
pollStateDone();
break;
default:
// Issue all poll-related commands at once
// then count down the responses, which
// are allowed to arrive out-of-order
mPollingContext[0]++;
mCi.getOperator(
obtainMessage(
EVENT_POLL_STATE_OPERATOR, mPollingContext)); //OPERATOR
mPollingContext[0]++;
mCi.getDataRegistrationState(
obtainMessage(
EVENT_POLL_STATE_GPRS, mPollingContext)); //DATA_REGISTRATION_STATE
mPollingContext[0]++;
mCi.getVoiceRegistrationState(
obtainMessage(
EVENT_POLL_STATE_REGISTRATION, mPollingContext)); //VOICE_REGISTRATION_STATE
mPollingContext[0]++;
mCi.getNetworkSelectionMode(
obtainMessage(
EVENT_POLL_STATE_NETWORK_SELECTION_MODE, mPollingContext)); //QUERY_NETWORK_SELECTION_MODE
break;
}
}