SystemUI锁屏流程

锁屏UI界面

SystemUI启动的时候启动各个SERVICE,这些Service不是四大组件的service,这个SERVICE继承SystemUI,实现了start()和onBootComplete方法.其中StatusBar加载了SystemUI几乎全部的界面,其中包括锁屏界面,
SystemUI锁屏流程_第1张图片
其中Bouncer是安全锁屏界面,实现类是KeyguardBouncer

锁屏加载

锁屏加载KeyguardBouncer过程:
(1)SystemUIApplication启动Statusbar,这里通过createAndAddWindows加载主要的界面,然后调用startKeyguard
(2)在startKeyguard中,调用KeyguardViewMediator的registerStatusbar方法,KeyguardViewMediator是整个待机解/锁屏业务的调度器,负责调度锁屏界面的相关动作及查询解锁屏状态,然后进入StatusBarKeyguardViewManager
(3)(4)StatusBarKeyguardViewManager管理KeyguardBouncer,KeyguardBouncer里面是安全锁界面,它把所有的锁封装起来,然后通过判断当前是什么锁,然后把对应的锁视图显示出来
(5)当滑动锁屏,如果用户设置了锁屏,那么就让安全锁屏界面显示出来
(6)(7)(8)显示锁屏界面
(9)是PhoeWindowmamanegr通过binder调用到KeyguardViewMediator的,这里不研究
第(1)步到第(9)步如图所示
SystemUI锁屏流程_第2张图片#### Step 1:
Statusbar.startKeyguard

    @Override
    public void start() {
       ....
        createAndAddWindows();
        ....
        startKeyguard();
    }

    protected void startKeyguard() {
        ....
        mStatusBarKeyguardViewManager = keyguardViewMediator.registerStatusBar(this,
                getBouncerContainer(), mNotificationPanel, mFingerprintUnlockController);
       ....
    }
    public StatusBarWindowView getStatusBarWindow() {
        return mStatusBarWindow;
    }

这里的getBouncerContainer()就是createAndAddWindows创建的View

Step 2:

KeyguardViewMediator.registerStatusbar

    public StatusBarKeyguardViewManager registerStatusBar(StatusBar statusBar,
            ViewGroup container, NotificationPanelView panelView,
            FingerprintUnlockController fingerprintUnlockController) {
        mStatusBarKeyguardViewManager.registerStatusBar(statusBar, container, panelView,
                fingerprintUnlockController, mDismissCallbackRegistry);//1
        return mStatusBarKeyguardViewManager;
    }
    private void setupLocked() {
        mStatusBarKeyguardViewManager =
                SystemUIFactory.getInstance().createStatusBarKeyguardViewManager(mContext,
                        mViewMediatorCallback, mLockPatternUtils);
    }

1处的mStatusBarKeyguardViewManager对象是在setupLocked中创建的,mStatusBarKeyguardViewManager实例化的时候传递了mViewMediatorCallback的回调,监听锁屏事件,如解锁成功

Step 3:

StatusBarKeyguardViewManager.registerStatusBar

    public void registerStatusBar(StatusBar statusBar,
            ViewGroup container,
            NotificationPanelView notificationPanelView,
            FingerprintUnlockController fingerprintUnlockController,
            DismissCallbackRegistry dismissCallbackRegistry) {
        mStatusBar = statusBar;
        mContainer = container;
        mFingerprintUnlockController = fingerprintUnlockController;
        mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext,
                mViewMediatorCallback, mLockPatternUtils, container, dismissCallbackRegistry,
                mExpansionCallback);//2
        mContainer.addOnLayoutChangeListener(this::onContainerLayout);
        mNotificationPanelView = notificationPanelView;
        notificationPanelView.setExpansionListener(this::onPanelExpansionChanged);//3
    }

2处这里把创建KeyguardBouncer,KeyguardBouncer管理所有锁屏类型,3处监听notificationPanelView的状态,当notificationPanelView滑动展开后,让KeyguardBouncer把具体view显示出来.

Step 6,7,8:

这里就是显示锁屏VIew,KeyguardBouncer会根据具体的锁屏类型把VIew加载出来.

SystemUI锁屏流程_第3张图片inflateView加载Keyguard_host_view.xml
SystemUI锁屏流程_第4张图片下面是KeyguardSecurityContainer的getSecurityView
SystemUI锁屏流程_第5张图片
SystemUI锁屏流程_第6张图片

4处根据当前的锁屏类型获取对应的视图的layoutid,如图7处,在5处判断视图是否已经过加载,没有就重新加载,然后放到SercurityViewFlipper里面,6处更新锁屏.后面的操作就是增加监听,然后KeyGuardMeditor对解锁的操作的了.

你可能感兴趣的:(应用)