Add window manager support for overriding button and keyboard backlight values.
The new backlightBrightness field works similarly as the existing WindowManager.LayoutParams.screenBrightness field
Needed for bugs:
b/2233655 (under low ambient light the touch keys remain illuminated during video playback and never timeout)
b/2221079 (Backlight for home/search/back/etc buttons should turn off when in dock in night mode)
Change-Id: I60dfecdc7bb653b0db38094464de651220b3d438
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index a013c75..0481340 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -9313,6 +9313,7 @@
boolean orientationChangeComplete = true;
Session holdScreen = null;
float screenBrightness = -1;
+ float buttonBrightness = -1;
boolean focusDisplayed = false;
boolean animating = false;
@@ -10072,6 +10073,10 @@
&& screenBrightness < 0) {
screenBrightness = w.mAttrs.screenBrightness;
}
+ if (!syswin && w.mAttrs.buttonBrightness >= 0
+ && buttonBrightness < 0) {
+ buttonBrightness = w.mAttrs.buttonBrightness;
+ }
if (attrs.type == WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG
|| attrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD
|| attrs.type == WindowManager.LayoutParams.TYPE_SYSTEM_ERROR) {
@@ -10318,6 +10323,12 @@
mPowerManager.setScreenBrightnessOverride((int)
(screenBrightness * Power.BRIGHTNESS_ON));
}
+ if (buttonBrightness < 0 || buttonBrightness > 1.0f) {
+ mPowerManager.setButtonBrightnessOverride(-1);
+ } else {
+ mPowerManager.setButtonBrightnessOverride((int)
+ (buttonBrightness * Power.BRIGHTNESS_ON));
+ }
if (holdScreen != mHoldingScreenOn) {
mHoldingScreenOn = holdScreen;
Message m = mH.obtainMessage(H.HOLD_SCREEN_CHANGED, holdScreen);