From aa80b60b596e54dcfae55db73262440b0acba198 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 9 Oct 2009 17:38:26 -0700 Subject: [PATCH] Fix issue #2179931: Power key to wake up frequently ignored when in dock app The dock app is forcing the screen to a particular brightness level. This causes the window manager to often call into the power manager with the new brightness. This causes us to go in to updateLightsLocked() to figure out and apply the real brightness to use. When the screen is off the real brightness always remains 0, but even if it didn't change from the last one we would start an animation which would when done put the system to sleep and fight with the user trying to turn the device on. Now, if the new target brightness is the same as the last one, we leave the animation as-is -- either running or not as appropriate. Change-Id: I067d55ea2b39e294c5d5291587a4d8727c0b8083 --- .../java/com/android/server/PowerManagerService.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index b2e3a8ce22e07..e1bea37ba8397 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -1531,9 +1531,10 @@ class PowerManagerService extends IPowerManager.Stub } finally { Binder.restoreCallingIdentity(identity); } - mScreenBrightness.setTargetLocked(brightness, - steps, INITIAL_SCREEN_BRIGHTNESS, nominalCurrentValue); - startAnimation = true; + if (mScreenBrightness.setTargetLocked(brightness, + steps, INITIAL_SCREEN_BRIGHTNESS, nominalCurrentValue)) { + startAnimation = true; + } } else { if ((newState & SCREEN_BRIGHT_BIT) == 0) { // dim or turn off backlight, depending on if the screen is on @@ -1612,11 +1613,13 @@ class PowerManagerService extends IPowerManager.Stub + " delta=" + delta); } - void setTargetLocked(int target, int stepsToTarget, int initialValue, + boolean setTargetLocked(int target, int stepsToTarget, int initialValue, int nominalCurrentValue) { if (!initialized) { initialized = true; curValue = (float)initialValue; + } else if (targetValue == target) { + return false; } targetValue = target; delta = (targetValue - @@ -1630,6 +1633,7 @@ class PowerManagerService extends IPowerManager.Stub + noticeMe); } animating = true; + return true; } boolean stepLocked() {