Don't turn the button backlights on if the screen is off. Part 2.
These are the logs from when I just reproduced it here. This means that we got an event after the
screen turned off. So isScreenTurningOffLocked() is working, but we need to also check that we're
not off. This bug is happening because lightSensorChangedLocked is calling
mButtonLight.setBrightness() directly instead of going through updateLightsLocked, which is where
I added that check to not turn the buttons on of the screen is off.
D/PowerManagerService( 1243): onSensorChanged: light value: 1280
I/power ( 1243): *** set_screen_state 0
D/PowerManagerService( 1243): enableLightSensor false
D/PowerManagerService( 1243): onSensorChanged: light value: 320
D/PowerManagerService( 1243): lightSensorChangedLocked 320
D/PowerManagerService( 1243): lcdValue 55
D/PowerManagerService( 1243): buttonValue 255
D/PowerManagerService( 1243): keyboardValue 0
D/SurfaceFlinger( 1243): About to give-up screen, flinger = 0x8dcf! 0
Bug: 3117801
Change-Id: I722d66cafba71b183cc987b7383d4ad7e171ba82
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index fadbb34..b0e30f9 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -2354,6 +2354,14 @@
Slog.d(TAG, "lightSensorChangedLocked " + value);
}
+ // Don't do anything if the screen is off.
+ if ((mPowerState & SCREEN_ON_BIT) == 0) {
+ if (mDebugLightSensor) {
+ Slog.d(TAG, "dropping lightSensorChangedLocked because screen is off");
+ }
+ return;
+ }
+
// do not allow light sensor value to decrease
if (mHighestLightSensorValue < value) {
mHighestLightSensorValue = value;