網絡變化流程

Step 1:註冊監聽事件
ServiceStateTracker在構造函數就會通過registerForNetworkRegistrationStateChanged註冊網絡狀態的變化監聽,處理事件爲EVENT_NETWORK_STATE_CHANGED

Step 2:modem主動上報

01-25 10:13:56.717 D/RILJ    (3636): [UNSL]< UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED [SUB0]

Ril.java的processUnsolicited處理主動上報事件的,對應的事件爲RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED

Step 3:處理主動上報
GsmServiceStateTracker收到EVENT_NETWORK_STATE_CHANGED就會調用PollState來獲取狀態

01-25 10:13:56.727 D/RILJ   (3636): [5596]> OPERATOR [SUB0] 獲取運營商
01-25 10:13:56.727 D/RILJ   (3636): [5597]> DATA_REGISTRATION_STATE [SUB0]  獲取PS狀態
01-25 10:13:56.727 D/RILJ   (3636): [5598]> VOICE_REGISTRATION_STATE [SUB0]  獲取CS狀態
01-25 10:13:56.727 D/RILJ   (3636): [5599]> QUERY_NETWORK_SELECTION_MODE [SUB0]  獲取網絡模式

01-25 10:13:56.737 D/RILJ    (3636): [5597]< DATA_REGISTRATION_STATE {1, null, 0037ac1f, 14, null, 20, 4118, 470, 3648543, null, null} [SUB0]

01-25 10:13:56.747 D/RILJ    (3636): [5596]< OPERATOR {CHN-UNICOM, UNICOM, 46001} [SUB0]
01-25 10:13:56.757 D/RILJ    (3636): [5598]< VOICE_REGISTRATION_STATE {1, 1016, 0037ac1f, 14, null, null, null, 0, null, null, 1, null, null, 0, null} [SUB0]
01-25 10:13:56.757 D/RILJ    (3636): [5599]< QUERY_NETWORK_SELECTION_MODE {0} [SUB0]

等4個請求都返回了,調用pollStateDone來進行狀態的上報,這裏有一個mPollingContext,在向底層發請求會遞增,底層返回能遞減,等於0就認爲返回完成。

Step 4: 上報狀態
在GsmServiceStateTracker:pollStateDone

01-25 10:13:56.767 D/QtiGsmSST(3636): [GsmSST] Poll ServiceState done:  oldSS=[0 0 voice home data home CHN-UNICOM UNICOM 46001 CHN-UNICOM UNICOM 46001  LTE LTE CSS not supported -1 -1 RoamInd=-1 DefRoamInd=-1 EmergOnly=false IsDataRoamingFromRegistration=false] newSS=[0 0 voice home data home CHN-UNICOM UNICOM 46001 CHN-UNICOM UNICOM 46001  LTE LTE CSS not supported -1 -1 RoamInd=-1 DefRoamInd=-1 EmergOnly=false IsDataRoamingFromRegistration=false] oldMaxDataCalls=20 mNewMaxDataCalls=20 oldReasonDataDenied=-1 mNewReasonDataDenied=-1

下一步調用GsmPhone的notifyServiceStateChanged
下一步調用PhoneBase:notifyServiceStateChangedP
下一步調用DefaultPhoneNotifier:notifyServiceState(通常作爲是否上報的標準)
下一步調用TelephonyRegistry:notifyServiceStateForPhoneId,這裏就會調用應用註冊的回調函數onServiceStateChanged

對應的log流程

//modem主動上報NETWORK_STATE_CHANGED
04-18 15:12:31.408  2320  2414 D RILJ    : [UNSL]< UNSOL_RESPONSE_NETWORK_STATE_CHANGED [SUB0]
04-18 15:12:31.408  2320  2537 D NetworkRegistrationManager: onNetworkStateChanged

//serviceStateTracker.java中的handleMessage對收到的消息進行處理,調用pollState()方法
04-18 15:12:31.409  2320  2320 D SST     : [0] pollState: modemTriggered=true

//pollState()方法中通過,調用RIL對象的getOperator方法獲取運營商基本信息,getNetworkSelectionMode方法選擇運營商網絡類型等基本服務信息
04-18 15:12:31.413  2320  2320 D RILJ    : [4118]> OPERATOR [SUB0]
04-18 15:12:31.417  2320  2537 D RILJ    : [4119]> DATA_REGISTRATION_STATE [SUB0]
04-18 15:12:31.419  2320  2537 D RILJ    : [4120]> VOICE_REGISTRATION_STATE [SUB0]
04-18 14:56:03.780  2320  2320 D RILJ    : [3676]> QUERY_NETWORK_SELECTION_MODE [SUB0]
04-18 15:12:31.423  2320  2414 D RILJ    : [4118]< OPERATOR {CHN-CT, CT, 46011} [SUB0]
04-18 15:12:31.433  2320  2414 D RILJ    : [4119]< DATA_REGISTRATION_STATE {.regState = REG_HOME, .rat = 14, .reasonDataDenied = 0, .maxDataCalls = 20, .cellIdentity = {.cellInfoType = LTE, .cellIdentityGsm = [], .cellIdentityWcdma = [], .cellIdentityCdma = [], .cellIdentityLte = [{.base = {.mcc = 460, .mnc = 11, .ci = 39138610, .pci = 173, .tac = 9568, .earfcn = 1825}, .operatorNames = {.alphaLong = CHN-CT, .alphaShort = CT}, .bandwidth = 2147483647}], .cellIdentityTdscdma = []}} [SUB0]
04-18 15:12:31.434  2320  2414 D RILJ    : [4120]< VOICE_REGISTRATION_STATE {.regState = REG_HOME, .rat = 6, .cssSupported = false, .roamingIndicator = 1, .systemIsInPrl = 1, .defaultRoamingIndicator = -1, .reasonForDenial = 0, .cellIdentity = {.cellInfoType = CDMA, .cellIdentityGsm = [], .cellIdentityWcdma = [], .cellIdentityCdma = [{.base = {.networkId = 54, .systemId = 13938, .baseStationId = 4305, .longitude = 0, .latitude = 0}, .operatorNames = {.alphaLong = , .alphaShort = }}], .cellIdentityLte = [], .cellIdentityTdscdma = []}} [SUB0]
04-18 14:56:03.782  2320  2414 D RILJ    : [3676]< QUERY_NETWORK_SELECTION_MODE {0} [SUB0]

04-18 15:12:31.434  2320  2604 D NetworkRegistrationManager: onGetNetworkRegistrationStateComplete result 0 state NetworkRegistrationState{transportType=1 domain=CS regState=HOME accessNetworkTechnology=CDMA - 1xRTT reasonForDenial=0 emergencyEnabled=false supportedServices=[I@fbb1f80 cellIdentity=CellIdentityCdma:{ mNetworkId=54 mSystemId=13938 mBasestationId=4305 mLongitude=2147483647 mLatitude=2147483647 mAlphaLong= mAlphaShort=} voiceSpecificStates=VoiceSpecificRegistrationStates { mCssSupported=false mRoamingIndicator=1 mSystemIsInPrl=1 mDefaultRoamingIndicator=-1} dataSpecificStates=null}
04-18 15:12:31.435  2320  2320 D SST     : [0] handlPollStateResultMessage: CdmaLteSST dataServiceState=0 registrationState=1 dataRadioTechnology=14
04-18 15:12:31.436  2320  2320 D SST     : [0] handlPollVoiceRegResultMessage: regState=1 radioTechnology=6

//獲取完信息後,根據pollStat查詢的結果,完成對舊ServiceState對象的更新,併發出服務信息變化對應的通知
04-18 15:12:31.439  2320  2320 D SST     : [0] pollStateDone: hasRegistered=false hasDeregistered=false hasDataAttached=false hasDataDetached=false hasDataRegStateChanged=false hasRilVoiceRadioTechnologyChanged= false hasRilDataRadioTechnologyChanged=false hasChanged=true hasVoiceRoamingOn=false hasVoiceRoamingOff=false hasDataRoamingOn=false hasDataRoamingOff=false hasLocationChanged=true has4gHandoff = false hasMultiApnSupport=false hasLostMultiApnSupport=false hasCssIndicatorChanged=false
04-18 15:04:01.608  2320  2320 D SST     : [0] Broadcasting ServiceState : {mVoiceRegState=0(IN_SERVICE), mDataRegState=0(IN_SERVICE), mChannelNumber=-1, duplexMode()=0, mCellBandwidths=[], mVoiceRoamingType=home, mDataRoamingType=home, mVoiceOperatorAlphaLong=中國電信, mVoiceOperatorAlphaShort=CT, mDataOperatorAlphaLong=中國電信, mDataOperatorAlphaShort=CT, isManualNetworkSelection=false(automatic), mRilVoiceRadioTechnology=4(CDMA-IS95A), mRilDataRadioTechnology=14(LTE), mCssIndicator=unsupported, mNetworkId=54, mSystemId=13938, mCdmaRoamingIndicator=1, mCdmaDefaultRoamingIndicator=-1, mIsEmergencyOnly=false, mIsDataRoamingFromRegistration=false, mIsUsingCarrierAggregation=false, mLteEarfcnRsrpBoost=0, mNetworkRegistrationStates=[NetworkRegistrationState{transportType=1 domain=PS regState=HOME accessNetworkTechnology=LTE reasonForDenial=0 emergencyEnabled=false supportedServices=[I@b0c93ce cellIdentity=CellIdentityLte:{ mCi=39138610 mPci=173 mTac=9568 mEarfcn=1825 mBandwidth=2147483647 mMcc=460 m

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章