当前位置:   article > 正文

android 亮灭屏流程_setscreenstate

setscreenstate

1、

frameworks\base\core\java\android\hardware\display\DisplayManagerInternal.java

内部服务

 

frameworks\base\services\core\java\com\android\server\display\DisplayManagerService.java

private final class LocalService extends DisplayManagerInternal {
    @Override
    public void initPowerManagement(final DisplayPowerCallbacks callbacks, Handler handler,
            SensorManager sensorManager) {
        synchronized (mSyncRoot) {
            DisplayBlanker blanker = new DisplayBlanker() {
                @Override
                public void requestDisplayState(int state, int brightness) {
                    // The order of operations is important for legacy reasons.
                    if (state == Display.STATE_OFF) {
                        requestGlobalDisplayStateInternal(state, brightness);
                    }

                    callbacks.onDisplayStateChange(state);

                    if (state != Display.STATE_OFF) {
                        requestGlobalDisplayStateInternal(state, brightness);
                    }
                }
            };
            mDisplayPowerController = new DisplayPowerController(
                    mContext, callbacks, handler, sensorManager, blanker);
        }
    }

 

 

DispalyManagerService 会实现DisplayPowerCallbacks  ,并创建DisplayPowerController ,传递DisplayPowerCallbacks 参数,从而可以回调通知PM 

2、

frameworks\base\services\core\java\com\android\server\display\DisplayPowerController.java

final class DisplayPowerController implements AutomaticBrightnessController.Callbacks

实现回调接口updateBrightness

 

显示状态管理,与pms 独立,与传感器相关,异步回调通知PM状态改变

 

frameworks\base\services\core\java\com\android\server\display\DisplayPowerState.java

DisplayPowerController调用,与显示属性相关

内部类PhotonicModulator是一个异步更新屏幕与背光的状态的线程,通过DisplayBlanker

接口mBlanker.requestDisplayState(state, backlight)实现。

当亮度与屏膜状态没有变化,这个线程就进入等待状态。

 

setScreenState

setScreenBrightness

会发送 mScreenUpdateRunnable 

 

 

3、显示管理

frameworks\base\services\core\java\com\android\server\display\LocalDisplayAdapter.java

 

https://wenku.baidu.com/view/892c8115f02d2af90242a8956bec0975f465a4bf.html

https://blog.csdn.net/fu_kevin0606/article/details/54411816

 

 

frameworks\base\services\core\java\com\android\server\display\DisplayPowerController.java

这里如果setScreenState 为false,则会返回。

 

1、执行setScreenState  设置power state 为 ON

frameworks\base\services\core\java\com\android\server\display\DisplayPowerState.java

 

这里setState 将屏膜请求状态设置到DisplayPowerState 变量中,并唤醒

mPhotonicModulator 独立线程,由于当前有设置为ON ,与之前OFF 为不同状态,所以mPhotonicModulator进程执行,执行如下:

 

frameworks\base\services\core\java\com\android\server\display\DisplayManagerService.java

 

这里由于是亮屏所以会执行一下两个函数

           A:callbacks.onDisplayStateChange(state);

           B:requestGlobalDisplayStateInternal(state, brightness);

 

     A: 函数会影响wms 绘制

     B: 函数如下

 

frameworks\base\services\core\java\com\android\server\display\LocalDisplayAdapter.java

 

这里设置背光亮度与DisplayState 即ON,这里比较费时,是一个独立的进程,只要在窗口绘制完之前结束时不会影响亮屏的。

 

2、通知wms 准备亮屏

这里mPendingScreenOnUnblocker是blockScreenOn()中创建的回调函数,这个函数用于wms 绘制好回调回PMS

blockScreenOn();unblockScreenOn 中log

Blocking screen on until initial contents have been drawn.

Unblocked screen on after " + delay + " ms"

表示绘制开始与结束log

 

这里mWindowManagerPolicy.screenTurningOn(mPendingScreenOnUnblocker);如下

 

frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java

 

这里会设置一个keyguard 绘制超时消息MSG_KEYGUARD_DRAWN_TIMEOUT,时间为1s.mKeyguardDrawnCallback 是keyguard 绘制完回调的函数。

 

分别对应窗口绘制完成回调与keygurad 绘制完成回调函数。回调函数发送的消息。

Keygurad 绘制完消息回调,用于等待窗口绘制

窗口绘制完的消息处理函数

处理函数回到接通知PMS

 

Keyguard 绘制完成

窗口绘制完,及通知PMS

 

04-25 07:37:07.179   741   975 D WindowManager: All windows drawn!

检测到window 绘制完成,发送消息ALL_WINDOWS_DRAWN

收到消息ALL_WINDOWS_DRAWN

04-25 07:37:07.184   741   771 I WindowManager: All windows ready for display!

发送MSG_WINDOW_MANAGER_DRAWN_COMPLETE收到后调用

Finished screen turning on...

在进行回到会PMS打印

Unblocked screen on after 538 ms

 

亮屏绘制:

frameworks\base\services\core\java\com\android\server\display\DisplayManagerService.java

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/642962
推荐阅读
相关标签
  

闽ICP备14008679号