网络服务状态或者网络信号量是通过Modem 主动上报信息来实现的,相关类有ServiceState,GsmServiceStateTracker,GSMPhone,TelephonyRegistry等。
1.比如现在所处的网络发生变化,RILReciver 收到上报信息,处理 RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 信息。
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
if (RILJ_LOGD) unsljLog(response);
mVoiceNetworkStateRegistrants
.notifyRegistrants(new AsyncResult(null, null, null));
break;
2.经分析 mVoiceNetworkStateRegistrants,是由 GsmServiceStateTracker 构造的。
public GsmServiceStateTracker(GSMPhone phone) {
...
cm.registerForVoiceNetworkStateChanged(this, EVENT_NETWORK_STATE_CHANGED, null);
...
}
3.消息交给 EVENT_NETWORK_STATE_CHANGED 处理。GsmServiceStateTracker 处理 EVENT_NETWORK_STATE_CHANGED 消息
case EVENT_NETWORK_STATE_CHANGED:
pollState();
break;
4.调用 pollState();
default:
// Issue all poll-related commands at once
// then count down the responses, which
// are allowed to arrive out-of-order
1.比如现在所处的网络发生变化,RILReciver 收到上报信息,处理 RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 信息。
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
if (RILJ_LOGD) unsljLog(response);
mVoiceNetworkStateRegistrants
.notifyRegistrants(new AsyncResult(null, null, null));
break;
2.经分析 mVoiceNetworkStateRegistrants,是由 GsmServiceStateTracker 构造的。
public GsmServiceStateTracker(GSMPhone phone) {
...
cm.registerForVoiceNetworkStateChanged(this, EVENT_NETWORK_STATE_CHANGED, null);
...
}
3.消息交给 EVENT_NETWORK_STATE_CHANGED 处理。GsmServiceStateTracker 处理 EVENT_NETWORK_STATE_CHANGED 消息
case EVENT_NETWORK_STATE_CHANGED:
pollState();
break;
4.调用 pollState();
default:
// Issue all poll-related commands at once
// then count down the responses, which
// are allowed to arrive out-of-order

本文详细介绍了Android 4.0中网络状态变化时,从Modem主动上报信息到最终通知应用程序的过程。涉及到的关键组件包括RILReceiver、GsmServiceStateTracker、GSMPhone、TelephonyRegistry等,详细阐述了网络状态变化的处理步骤,以及如何通过ServiceState更新信号强度,并最终反馈给用户界面。
最低0.47元/天 解锁文章
2018

被折叠的 条评论
为什么被折叠?



