前言
最近在改平台的亮度设置,顺便整理一下亮度调节的过程,使他人能方便理解亮度流程。
Kernel: v4.4.179
Device: rk3328
Platform Version: Android 9.0
流程如下
frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
DisplayManager.java
public void setTemporaryBrightness(int brightness) { mGlobal.setTemporaryBrightness(brightness); }
DisplayManagerGlobal.java
public void setTemporaryBrightness(int brightness) { try { mDm.setTemporaryBrightness(brightness); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } }
DisplayManagerService.java
public void setTemporaryBrightness(int brightness) { ... mDisplayPowerController.setTemporaryBrightness(brightness); ... }
DisplayPowerController.java
public void setTemporaryBrightness(int brightness) { Message msg = mHandler.obtainMessage(MSG_SET_TEMPORARY_BRIGHTNESS, brightness, 0 /*unused*/); msg.sendToTarget(); } ... private void updatePowerState() { //此方法比较长,里面有大量的判断,下面只写关键语句 ... animateScreenBrightness(brightness, 0); ... } ... private void animateScreenBrightness(int target, int rate) { //这一句就是关键的设置语句 if (mScreenBrightnessRampAnimator.animateTo(target, rate)) { } }
下面的就不太好跟了,直接贴图 RampAnimator.java
DisplayPowerState.java
setScreenBrightness(int brightness){...} scheduleScreenUpdate() {...} postScreenUpdateThreadSafe(){...} Runnable mScreenUpdateRunnable = new Runnable() { ... mPhotonicModulator.setState(mScreenState, brightness) ... }
PhotonicModulator.java
又调回到了DisplayManagerService.java
LocalDisplayAdapter.java
LightsService.java
com_android_server_lights_LightsService.cpp
后记
在这个之后的就是调用hal层的.so库, 根据不同厂商、不同Anroid版本可能实现有所不同。
转载请注明出处:http://www.wolfnx.com/2020/03/16/Brightness-Set-Stream
作者 : wolfnx
邮箱 : wolfnx@outlook.com
邮箱2 : lostnx@gmail.com