关于信号栏显示问题

1、ServiceStateTracker类java

一、入口android

PhoneFactory中:网络

for (int i = 0; i < numPhones; i++) {
                    Phone phone = null;
                    int phoneType = TelephonyManager.getPhoneType(networkModes[i]);
                    if (phoneType == PhoneConstants.PHONE_TYPE_GSM) {
                        phone = new GsmCdmaPhone(context,
                                sCommandsInterfaces[i], sPhoneNotifier, i,
                                PhoneConstants.PHONE_TYPE_GSM,
                                TelephonyComponentFactory.getInstance());
                    } else if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
                        phone = new GsmCdmaPhone(context,
                                sCommandsInterfaces[i], sPhoneNotifier, i,
                                PhoneConstants.PHONE_TYPE_CDMA_LTE,
                                TelephonyComponentFactory.getInstance());

GsmCdmaPhone中:this

mSST = mTelephonyComponentFactory.makeServiceStateTracker(this, this.mCi);

TelephonyComponentFactory中:spa

public ServiceStateTracker makeServiceStateTracker(GsmCdmaPhone phone, CommandsInterface ci) {
        return new ServiceStateTracker(phone, ci);
    }

二、构造方法code

主要是initOnce这个方法,很明显就是注册一些rilj中消息,网络状态变化,卡状态变化等server

private void initOnce(GsmCdmaPhone phone, CommandsInterface ci) {
        mPhone = phone;
        mCi = ci;
        mVoiceCapable = mPhone.getContext().getResources().getBoolean(
                com.android.internal.R.bool.config_voice_capable);
        // Common
        //[ALPS01803573] - for 4gds/3gds tablet project
        mSmsCapable = mPhone.getContext().getResources().getBoolean(
            com.android.internal.R.bool.config_sms_capable);
        mUiccController = UiccController.getInstance();

        mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
        mCi.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
        mCi.registerForCellInfoList(this, EVENT_UNSOL_CELL_INFO_LIST, null);

        mSubscriptionController = SubscriptionController.getInstance();
        mSubscriptionManager = SubscriptionManager.from(phone.getContext());
        mSubscriptionManager
                .addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);

        mCi.registerForImsNetworkStateChanged(this, EVENT_IMS_STATE_CHANGED, null);

        PowerManager powerManager =
                (PowerManager)phone.getContext().getSystemService(Context.POWER_SERVICE);
        mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG);

        if (!SystemProperties.get("ro.mtk_bsp_package").equals("1")) {
            try {
                mServiceStateExt = MPlugin.createInstance(
                        IServiceStateExt.class.getName(), phone.getContext());
            } catch (RuntimeException e) {
                e.printStackTrace();
            }
        }

        mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
        //注册cs网络状态的变化,这个注册方法在baseCommands.java中,通知方法的实如今rilj中为其继承类
        mCi.registerForVoiceNetworkStateChanged(this, EVENT_NETWORK_STATE_CHANGED, null);
        mCi.setOnNITZTime(this, EVENT_NITZ_TIME, null);

        mCr = phone.getContext().getContentResolver();
        // system setting property AIRPLANE_MODE_ON is set in Settings.
        int airplaneMode = Settings.Global.getInt(mCr, Settings.Global.AIRPLANE_MODE_ON, 0);
        int enableCellularOnBoot = Settings.Global.getInt(mCr,
                Settings.Global.ENABLE_CELLULAR_ON_BOOT, 1);
        mDesiredPowerState = (enableCellularOnBoot > 0) && ! (airplaneMode > 0);

        mCr.registerContentObserver(
                Settings.Global.getUriFor(Settings.Global.AUTO_TIME), true,
                mAutoTimeObserver);
        mCr.registerContentObserver(
                Settings.Global.getUriFor(Settings.Global.AUTO_TIME_ZONE), true,
                mAutoTimeZoneObserver);
        setSignalStrengthDefaultValues();

        // Monitor locale change
        Context context = mPhone.getContext();
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_LOCALE_CHANGED);
        context.registerReceiver(mIntentReceiver, filter);
        filter = new IntentFilter();
        filter.addAction(ACTION_RADIO_OFF);

        // M : MTK added
        filter.addAction(Intent.ACTION_SCREEN_ON);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        filter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED);
        filter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
        // M: MTK added end
        context.registerReceiver(mIntentReceiver, filter);

        mEventLog = new TelephonyEventLog(mPhone.getPhoneId());
        mPhone.notifyOtaspChanged(OTASP_UNINITIALIZED);

        /// M: Simulate IMS Registration @{
        final IntentFilter imsfilter = new IntentFilter();
        imsfilter.addAction("ACTION_IMS_SIMULATE");
        context.registerReceiver(mBroadcastReceiver, imsfilter);
        /// @}
    }

三、因为是基于MTK平台的源码查看,下面分析两个call flow,一个是creg上报掉网,一个是ecsq上报信号强度变化继承

首先modem侧经过AT命令通知rild进程(mtk n平台分rild和rilproxy两个进程,咱们先不关注这点,就认为是rild进程),rild解析后会转化成ril消息发给phone进程,对应的类入口就是ril.java,先看log分析再转代码逻辑进程

12623 06-15 17:11:26.693182 12340 12375 I AT      : AT< +CREG: 0,"FFFF","0FFFFFFF",0,0,0 (RIL_URC_READER, tid:0)
12647 06-15 17:11:26.696826  1364  1499 V RILJ    : [UNSL]< UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED {0, ffff, fffffff, 0, 0} [SUB0]

收到主动网络状态变化的主动上报以后AP会主动查询cs网络状态(和其余模块很像)ip

12655 06-15 17:11:26.698923  1364  1364 D RILJ    : [4597]> VOICE_REGISTRATION_STATE [SUB0]
12726 06-15 17:11:26.714191 12340 12361 I AT      : AT> AT+CREG? (RIL_CMD_READER_1, tid:532545545296)
12739 06-15 17:11:26.717370 12340 12376 I AT      : AT< +CREG: 3,0,"FFFF","0FFFFFFF",0,0,0 (RIL_CMD_READER_1, tid:532545545296)
12753 06-15 17:11:26.721390  1364  1499 D RILJ    : [4597]< VOICE_REGISTRATION_STATE {0, ffff, fffffff, 0, , , , , , , , , , 0} [SUB0]
相关文章
相关标签/搜索