Android 亮度调节
frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
更新屏幕亮度值Settings.System.SCREEN_BRIGHTNESS
BrightnessController.java中有个onChanged事件,这个是更新 setBrightness(val)
private void setBrightness(int brightness) {
try {
mPower.setTemporaryScreenBrightnessSettingOverride(brightness);
} catch (RemoteException ex) {
}
}
frameworks/base/services/java/com/android/server/power/PowerManagerService.java
setTemporaryScreenBrightnessSettingOverrideInternal
updatePowerStateLocked
updateDisplayPowerStateLocked
mDisplayPowerController.requestPowerState
frameworks/base/services/java/com/android/server/power/DisplayPowerController.java
requestPowerState
sendUpdatePowerStateLocked
updatePowerState
setScreenOn
mPowerState.setScreenOn
/frameworks/base/services/java/com/android/server/power/DisplayPowerState.java
setScreenOn
scheduleScreenUpdate
postScreenUpdateThreadSafe
mHandler.post(mScreenUpdateRunnable)
mPhotonicModulator.setState(mScreenOn, brightness)
AsyncTask.THREAD_POOL_EXECUTOR.execute(mTask)
mBacklight.setBrightness
(mBacklight类是LightsService.Light)LightsService.Light
DisplayPowerState是和LightService交互的,LightService是和HAL层的lights.c或lights.cpp和内核交互
frameworks/base/services/java/com/android/server/LightsService.java
setBrightness
setLightLocked
setLight_native
/frameworks/base/services/jni/com_android_server_LightsService.cpp
setLight_native
devices->lights[light]->set_light(devices->lights[light], &state);
接下来就HAL层的处理,每个产商有所差异,找到LIGHTS_HARDWARE_MODULE_ID的定义
/device/softwinner/t3-common/hardware/libhardware/lights/lights.c
open_lights
内核里面生成结点:/dev/disp,通过ioctl到内核中去设置PWM引脚的值
参考
https://blog.csdn.net/fightfightfight/article/details/83548710
https://blog.csdn.net/FightFightFight/article/details/81320519