From 4384409dae023b4571842e19174c0d729767de6f Mon Sep 17 00:00:00 2001 From: Fiona Campbell Date: Thu, 3 Jun 2021 15:54:12 +0100 Subject: [PATCH] Fix slider being at 0 on unlock This was happening due to a change that sourced the brightness value from the brightnessInfo object, which includes brightness state (invalid and -1/off) as well. This change ensures the brightnessInfo object will only store valid brightness values (ie, when the display is ON, and therefore the brightness is between min & max). Bug: 187776200 Test: manual Change-Id: I6b7077da1354f0b21c570f4e2283aa6830dbdb93 --- .../android/server/display/DisplayPowerController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 52b05f2d112f8..c14acd7b60d7e 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -941,6 +941,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call final boolean mustNotify; final int previousPolicy; boolean mustInitialize = false; + boolean shouldSaveBrightnessInfo = true; int brightnessAdjustmentFlags = 0; mBrightnessReasonTemp.set(null); synchronized (mLock) { @@ -1071,6 +1072,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call if (state == Display.STATE_OFF) { brightnessState = PowerManager.BRIGHTNESS_OFF_FLOAT; mBrightnessReasonTemp.setReason(BrightnessReason.REASON_SCREEN_OFF); + shouldSaveBrightnessInfo = false; } // Always use the VR brightness when in the VR state. @@ -1197,6 +1199,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call && Display.isDozeState(state)) { brightnessState = mScreenBrightnessDozeConfig; mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_DEFAULT); + shouldSaveBrightnessInfo = false; } // Apply manual brightness. @@ -1213,7 +1216,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Save out the brightness info now that the brightness state for this iteration has been // finalized and before we send out notifications about the brightness changing. - saveBrightnessInfo(brightnessState); + if (shouldSaveBrightnessInfo) { + saveBrightnessInfo(brightnessState); + + } if (updateScreenBrightnessSetting) { // Tell the rest of the system about the new brightness in case we had to change it