Telephony基础之DataCall业务(ServiceState.java)

                                                                                          开机注网流程图

Telephony基础之DataCall业务(ServiceState.java)

                                                                                            信号更新流程图

一,什么是ServiceState
   Servicestate(服务状态),手机插入SIM卡并且开机成功之后,Modem会读取SIM卡的IMSI完成信息验证和电信运营商移动网络的注册,手机才能使用电信运营商的服务,如电话、短信等功能。
   Telephony Framework中,使用ServiceState实体类来保存SIM卡注册(即我们通常所说的注网)成功后电信运营商的一些基本服务信息。如服务状态、无线通信采用的技术类型和状态、是否漫游、无线网络信号强度等。

二,ServiceState的结构 (4个int+6个String+ 4个int):
 
Int   mVoiceRegState      (value: 0,1,2,3)
Int   mDataRegState       (value: 0,1,2,3)
Int   mVoiceRoamingType   (value: 0,1,2,3)
Int   mDataRoamingType    (value: 0,1,2,3)

String   mVoiceOperatorAlphaLong
String   mVoiceOperatorAlphaShort
String   mVoiceOperatorNumeric
String   mDataOperatorAlphaLong
String   mDataOperatorAlphaShort
String   mDataOperatorNumeric

Int    mIsManualNetworkSelection
Int    mRilVoiceRadioTechnology
Int    mRilDataRadioTechnology
Int    mCssIndicator
Int    mNetworkId
Int    mSystemId
Int    mCdmaRoamingIndicator
Int    mCdmaDefaultRoamingIndicator
Int    mCdmaEriIconIndex
Int    mCdmaEriIconMode
Int    mIsEmergencyOnly
Int    mIsDataRoamingFromRegistration
Int    mIsUsingCarrierAggregation
Int    mRilImsRadioTechnology
 

三,ServiceState的创建与更新
1,创建:在初始化ServiceStateTracker时创建
ServiceStateTracker(){
    updatePhoneType();
}

public void updatePhoneType() {
        mSS = new ServiceState();
        mNewSS = new ServiceState();
}


2,更新:在ServiceStateTracker.handlePollStateResult()-->handlePollStateResultMessage(what, ar)中取出RIL传过来的值,进而调用mNewSS一系列set方法赋值,
     之后进一步调用pollStateDone()-->pollStateDoneXXX()方法对比mSS(原先)与mNewSS(当前)的状态后,把mNewSS的内容交给mSS,并clean自身.
        // swap mSS and mNewSS to put new state in mSS
        ServiceState tss = mSS;
        mSS = mNewSS;
        mNewSS = tss;
        // clean slate for next time
        mNewSS.setStateOutOfService();    



VOICE_REGISTRATION_STATE与DATA_REGISTRATION_STATE流程差不多:
02-09 11:51:09.027  4974  5059 D RILJ    : [3759]< VOICE_REGISTRATION_STATE {1, f11b, 0a1ba01c, 3, null, null, null, 0, null, null, null, null, null, 0, 87} [SUB0]
02-09 11:51:09.057  4974  5059 D RILJ    : [3754]< DATA_REGISTRATION_STATE {2, null, null, null, 0, 20, null, null, null, null, null} [SUB0]
其中,RIL传过来的RegState有10种,通过regCodeToServiceState()转换:
    /** code is registration state 0-5 from TS 27.007 7.2 */
    private int regCodeToServiceState(int code) {
        switch (code) {
            case 0:
            case 2: // 2 is "searching"
            case 3: // 3 is "registration denied"
            case 4: // 4 is "unknown" no vaild in current baseband
            case 10:// same as 0, but indicates that emergency call is possible.
            case 12:// same as 2, but indicates that emergency call is possible.
            case 13:// same as 3, but indicates that emergency call is possible.
            case 14:// same as 4, but indicates that emergency call is possible.
                return ServiceState.STATE_OUT_OF_SERVICE;

            case 1:
            case 5: // 5 is "registered, roaming"
                return ServiceState.STATE_IN_SERVICE;

            default:
                loge("regCodeToServiceState: unexpected service state " + code);
                return ServiceState.STATE_OUT_OF_SERVICE;
        }
    }


Operator相关的几个参数更新:
02-09 11:51:09.023  4974  5059 D RILJ    : [3753]< OPERATOR {CHN-UNICOM, UNICOM, 46001} [SUB0]
String opNames[] = (String[]) ar.result
mNewSS.setOperatorName(brandOverride, brandOverride, opNames[2]);

    public void setOperatorName(String longName, String shortName, String numeric) {
        mVoiceOperatorAlphaLong = longName;
        mVoiceOperatorAlphaShort = shortName;
        mVoiceOperatorNumeric = numeric;
        mDataOperatorAlphaLong = longName;
        mDataOperatorAlphaShort = shortName;
        mDataOperatorNumeric = numeric;
    }


NETWORK_SELECTION_MODE比较简单:(1为手动,0为自动)
                ints = (int[])ar.result;
                mNewSS.setIsManualSelection(ints[0] == 1);
                if ((ints[0] == 1) && (!mPhone.isManualNetSelAllowed())) {
                        /*
                         * modem is currently in manual selection but manual
                         * selection is not allowed in the current mode so
                         * switch to automatic registration
                         */
                    mPhone.setNetworkSelectionModeAutomatic (null);
                    log(" Forcing Automatic Network Selection, " +
                            "manual selection is not allowed");
                }


 

相关文章: