From bf4e414cf0d0f512a0929ecd4e662a925d7684f0 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 2 Oct 2014 13:08:05 -0700 Subject: [PATCH] Fix a bug with screen brightness during screen off animation. Due to a recent change there was a regression that caused the screen brightness to be animated down to 0 while the screen off animation was running. When the brightness was low this would cause the screen off animation to be cut short. This change ensures that we take into account the actual screen state instead of the desired screen state when making screen brightness decisions in case we are in the middle of a transition. The darkness came early. The pixel fairies trembled. Bug: 17718416 Change-Id: Ib4b55d61b359abbc70920e324f08a5db07bdd035 --- .../server/display/DisplayPowerController.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index e3a25c066d9fd..2d5b99eb6c263 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -563,6 +563,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call state = Display.STATE_OFF; } + // Animate the screen state change unless already animating. + // The transition may be deferred, so after this point we will use the + // actual state instead of the desired one. + animateScreenStateChange(state, performScreenOffTransition); + state = mPowerState.getScreenState(); + // Use zero brightness when screen is off. if (state == Display.STATE_OFF) { brightness = PowerManager.BRIGHTNESS_OFF; @@ -636,13 +642,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mAppliedLowPower = true; } - // Animate the screen state change unless already animating. - animateScreenStateChange(state, performScreenOffTransition); - // Animate the screen brightness when the screen is on or dozing. // Skip the animation when the screen is off or suspended. - final int actualState = mPowerState.getScreenState(); - if (actualState == Display.STATE_ON || actualState == Display.STATE_DOZE) { + if (state == Display.STATE_ON || state == Display.STATE_DOZE) { animateScreenBrightness(brightness, slowChange ? BRIGHTNESS_RAMP_RATE_SLOW : BRIGHTNESS_RAMP_RATE_FAST); } else {