SystemUI源码分析四(QSPanel显示的流程)

本文主要分析SystemUI中快速设置(QS)面板的加载显示流程。从PhoneStatusBar.java开始,详细探讨如何获取QSPanel,创建QSTileHost对象,并通过setHost()传递给QSPanel。接着,分析QSTileHost的构造方法,包括查询TILES_SETTING,加载默认tileSpecs,创建快捷设置tile对象,并通过回调更新显示。在PhoneStatusBar.java中,设置tiles并初始化QSPanel,最后注册回调以便在tiles变化时更新显示。整个流程解析了QSPanel如何加载和展示quick settings tile panel。
摘要由CSDN通过智能技术生成

quick settings是statusbar的一部分,随着statusbarview的创建而加载,上一篇SystemUI源码分析三中已经分析了statusbar的加载流程,那么这里将继续对其中的quick settings部分进行简单的分析,弄清楚它的加载显示流程。首先从PhoneStausBar.java中开始分析。

protected PhoneStatusBarView makeStatusBarView() {
        final Context context = mContext;

    // Set up the quick settings tile panel
        mQSPanel = (QSPanel) mStatusBarWindow.findViewById(R.id.quick_settings_panel);
        if (mQSPanel != null) {
            final QSTileHost qsh = new QSTileHost(mContext, this,
                    mBluetoothController, mLocationController, mRotationLockController,
                    mNetworkController, mZenModeController, mHotspotController,
                    mCastController, mFlashlightController,
                    mUserSwitcherController, mKeyguardMonitor,
                    mSecurityController);
            mQSPanel.setHost(qsh);
            mQSPanel.setTiles(qsh.getTiles());
            mBrightnessMirrorController = new BrightnessMirrorController(mStatusBarWindow);
            mQSPanel.setBrightnessMirror(mBrightnessMirrorController);
            mHeader.setQSPanel(mQSPanel);
            qsh.setCallback(new QSTileHost.Callback() {
                @Override
                public void onTilesChanged() {
                    mQSPanel.setTiles(qsh.getTiles());
                }
            });
        }
}

1、获得QSPanel这个viewgroup,然后创建QSTileHost对象,通过调用QSPanel的setHost()函数将QSTileHost对象传递给QSPanel.java.

QSTileHost的构造方法分析

protected static final String TILES_SETTING = "sysui_qs_tiles";

public QSTileHost(Context context, PhoneStatusBar statusBar,
        BluetoothController bluetooth, LocationController location,
        RotationLockController rotation, NetworkController network,
        ZenModeController zen, HotspotController hotspot,
        CastController cast, FlashlightController flashlight,
        UserSwitcherController userSwitcher, KeyguardMonitor keyguard,
        SecurityController security) {
    mContext = context;
    mStatusBar = statusBar;
    mBluetooth = bluetooth;
    mLocation = location;
    mRotation = rotation;
    mNetwork = network;
    mZen = zen;
    mHotspot = hotspot;
    mCast = cast;
    mFlashlight = flashlight;
    mUserSwitcherController = userSwitcher;
    mKeyguard = keyguard;
    mSecurity = security;

    final HandlerThread ht = new HandlerThread(QSTileHost.class.getSimpleName(),
            Process.THREAD_PRIORITY_BACKGROUND);
    ht.start();
    mLooper = ht.getLooper();

    TunerService.get(mContext).addTunable(this, TILES_SETTING);
}

调用TunerService.get(mContext).addTunable()函数查询TILES_SETTING

TunerService.java

private void addTunable(Tunable tunable, String key) {
    if (!mTunableLookup.containsKey(key)) {
        mTunableLookup.put(key, new ArrayList<Tunable>());
    }
    mTunableLookup.get(key).add(tunable);
    Uri uri = Settings.Secure.getUriFor(key);
    if (!mListeningUris.containsKey(uri)) {
        mListeningUris.put(uri, key);
        mContentResolver.registerContentObserver(uri, false, mObserver, mCurrentUser);
    }
    // Send
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值