Don't turn on keyboard backlights when keyboard is closed in auto brightness mode.
For framework light sensor support (does not affect hardware based approach).
Change-Id: I6896a7c5b3fd3ed136c4f25c63a0e5813c349f68
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index be1e8a5..455ae46 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1922,7 +1922,12 @@
if ((mPowerState & BATTERY_LOW_BIT) == 0) {
int lcdValue = getAutoBrightnessValue(value, mLcdBacklightValues);
int buttonValue = getAutoBrightnessValue(value, mButtonBacklightValues);
- int keyboardValue = getAutoBrightnessValue(value, mKeyboardBacklightValues);
+ int keyboardValue;
+ if (mKeyboardVisible) {
+ keyboardValue = getAutoBrightnessValue(value, mKeyboardBacklightValues);
+ } else {
+ keyboardValue = 0;
+ }
mLightSensorBrightness = lcdValue;
if (mDebugLightSensor) {
@@ -2044,6 +2049,14 @@
// will take care of turning on due to a true change to the lid
// switch and synchronized with the lock screen.
if ((mPowerState & SCREEN_ON_BIT) != 0) {
+ if (mAutoBrightessEnabled && mUseSoftwareAutoBrightness) {
+ // force recompute of backlight values
+ if (mLightSensorValue >= 0) {
+ int value = (int)mLightSensorValue;
+ mLightSensorValue = -1;
+ lightSensorChangedLocked(value);
+ }
+ }
userActivity(SystemClock.uptimeMillis(), false, BUTTON_EVENT, true);
}
}
@@ -2273,7 +2286,8 @@
// Don't let applications turn the screen all the way off
brightness = Math.max(brightness, Power.BRIGHTNESS_DIM);
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BACKLIGHT, brightness);
- mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD, brightness);
+ mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_KEYBOARD,
+ (mKeyboardVisible ? brightness : 0));
mHardware.setLightBrightness_UNCHECKED(HardwareService.LIGHT_ID_BUTTONS, brightness);
long identity = Binder.clearCallingIdentity();
try {