背景
基于 Android U/V 代码。
疑问:注册状态是仅看数据吗?通过hasRegistered 确认?从代码看是data 和voice combine的 。
目标:分析注册过程中,Modem返回的code值得含义,以及MD和AP code的映射关系。
功能说明
网络已注册(驻网成功)跟能上网是两码事,比如驻网了也能上不了网。
IMS注册失败跟驻网也是两种功能场景,如ims注册失败,但是网络已经注册。
代码
ServiceStateTracker.java
package com.android.internal.telephony;
/**
* {@hide}
*/
public class ServiceStateTracker extends Handler {
static final String LOG_TAG = "SST";
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public ServiceState mSS;
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private ServiceState mNewSS;
// A placeholder service state which will always be out of service. This is broadcast to
// listeners when the subscription ID for a phone becomes invalid so that they get a final
// state update.
private final ServiceState mOutOfServiceSS;
private void pollStateDone() {
if (!mPhone.isPhoneTypeGsm()) {
updateRoamingState();
}
//设备之前未在服务区但现在已经成功注册到网络。
//因此不是指示当时是否驻网,而是表示是否有变化切换到注册。
boolean hasRegistered =
mSS.getState() != ServiceState.STATE_IN_SERVICE
&& mNewSS.getState() == ServiceState.STATE_IN_SERVICE;
//同上的逻辑,从有服务到无服务。
boolean hasDeregistered =
mSS.getState() == ServiceState.STATE_IN_SERVICE
&& mNewSS.getState() != ServiceState.STATE_IN_SERVICE;
boolean hasAirplaneModeOnChanged =
mSS.getState() != ServiceState.STATE_POWER_OFF
&& mNewSS.getState() == ServiceState.STATE_POWER_OFF;
boolean hasAirplaneModeOffChanged =
mSS.getState() == ServiceState.STATE_POWER_OFF
&& mNewSS.getState() != ServiceState.STATE_POWER_OFF;
SparseBooleanArray hasDataAttached = new SparseBooleanArray();
SparseBooleanArray hasDataDetached = new SparseBooleanArray();
SparseBooleanArray hasRilDataRadioTechnologyChanged = new SparseBooleanArray();
SparseBooleanArray hasDataRegStateChanged = new SparseBooleanArray();
boolean hasChanged = !mNewSS.equals(mSS);
if (DBG) {
log("pollStateDone:"
+ " hasRegistered = " + hasRegistered
+ " hasDeregistered = " + hasDeregistered
+ " hasDataAttached = " + hasDataAttached
+ " hasDataDetached = " + hasDataDetached
+ " hasDataRegStateChanged = " + hasDataRegStateChanged
+ " hasRilVoiceRadioTechnologyChanged = " + hasRilVoiceRadioTechnologyChanged
+ " hasRilDataRadioTechnologyChanged = " + hasRilDataRadioTechnologyChanged
+ " hasDataTransportPreferenceChanged = " + hasDataTransportPreferenceChanged
+ " hasChanged = " + hasChanged
+ " hasVoiceRoamingOn = " + hasVoiceRoamingOn
+ " hasVoiceRoamingOff = " + hasVoiceRoamingOff
+ " hasDataRoamingOn =" + hasDataRoamingOn
+ " hasDataRoamingOff = " + hasDataRoamingOff
+ " hasLocationChanged = " + hasLocationChanged
+ " has4gHandoff = " + has4gHandoff
+ " hasMultiApnSupport = " + hasMultiApnSupport
+ " hasLostMultiApnSupport = " + hasLostMultiApnSupport
+ " hasCssIndicatorChanged =