From 29defc3d68f88cb178c54eb755cd148585014672 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Fri, 22 Jul 2022 14:29:58 -0400 Subject: [PATCH] Do not post a change in brightness if temporary While the user is dragging the slider, temporary brightness is set. In this case, we should not post to the listener or it may trigger unwanted animations. Test: manual, drag slider and hold Fixes: 232891167 Change-Id: I723fc74cf0c305247563cc6f2afb2b74d671f83d --- .../com/android/server/display/DisplayPowerController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 95c8fef12976a..62b1cfeda9de2 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -1500,6 +1500,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Animate the screen brightness when the screen is on or dozing. // Skip the animation when the screen is off or suspended or transition to/from VR. boolean brightnessAdjusted = false; + final boolean brightnessIsTemporary = + mAppliedTemporaryBrightness || mAppliedTemporaryAutoBrightnessAdjustment; if (!mPendingScreenOff) { if (mSkipScreenOnBrightnessRamp) { if (state == Display.STATE_ON) { @@ -1532,8 +1534,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // level without it being a noticeable jump since any actual content isn't yet visible. final boolean isDisplayContentVisible = mColorFadeEnabled && mPowerState.getColorFadeLevel() == 1.0f; - final boolean brightnessIsTemporary = - mAppliedTemporaryBrightness || mAppliedTemporaryAutoBrightnessAdjustment; // We only want to animate the brightness if it is between 0.0f and 1.0f. // brightnessState can contain the values -1.0f and NaN, which we do not want to // animate to. To avoid this, we check the value first. @@ -1605,7 +1605,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call brightnessAdjusted = saveBrightnessInfo(getScreenBrightnessSetting()); } - if (brightnessAdjusted) { + // Only notify if the brightness adjustment is not temporary (i.e. slider has been released) + if (brightnessAdjusted && !brightnessIsTemporary) { postBrightnessChangeRunnable(); }