DisplayPowerState

Posted zzss-feature

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DisplayPowerState相关的知识,希望对你有一定的参考价值。

源码:

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

功能:

  对上:提供mProperty.setValue方法调用,接收brightness

  对下:调用LightsService.setBrightness方法,设置brightness

源码分析:

  构建了mProperty.setValue这个方法供调用,传入brightness值

public static final IntProperty<DisplayPowerState> SCREEN_BRIGHTNESS =
        new IntProperty<DisplayPowerState>("screenBrightness") {
    public void setValue(DisplayPowerState object, int value)
        object.setScreenBrightness(value);    // DisplayPowerState.setScreenBrightness
            mScreenBrightness = brightness;
            scheduleScreenUpdate();
                postScreenUpdateThreadSafe();
                    mHandler.post(mScreenUpdateRunnable);    // 执行mScreenUpdateRunnable.run()
                        brightness = mScreenBrightness;
                        mPhotonicModulator.setState(mScreenState, brightness);
                            mPendingBacklight = backlight;    // brightness最终保存在PhotonicModulator.mPendingBacklight
                            mLock.notifyAll();    // 唤醒PhotonicModulator线程

notifyAll将唤醒PhotonicModulator线程,最终调用LightsService.setBrightness,该函数功能请查看LightsService篇

public void run() {
    for (;;) {
        backlight = mPendingBacklight;
        backlightChanged = (backlight != mActualBacklight);
        if (!stateChanged && !backlightChanged) {
               mLock.wait();    // 等待
            continue;
        }
        mActualBacklight = backlight;    // 更新数据

        if (backlightChanged)
            setBrightness(backlight);
                mBacklight.setBrightness(backlight);    // mLights[LIGHT_ID_BACKLIGHT].setBrightness(backlight)
    }
}

以上是关于DisplayPowerState的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数