關於信號欄顯示問題

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]
相關文章
相關標籤/搜索