码迷,mamicode.com
首页 > 其他好文 > 详细

DisplayPowerState

时间:2018-01-17 15:53:46      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:dsa   actual   static   service   _id   htc   core   thread   mod   

源码:

  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

标签:dsa   actual   static   service   _id   htc   core   thread   mod   

原文地址:https://www.cnblogs.com/zzss-feature/p/8302629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!