Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eba8c934 authored by Piotr Wilczyński's avatar Piotr Wilczyński
Browse files

Keep DOZE_INITIAL brightness in setting

We don't want to fall back to the last interactive brightness when the screen turns on because it might be brighter than the brightness applied shortly after, when a lux sample is available.

Bug: 336000148
Test: See that there's no bright flash when going from AOD to ON
Test: atest DisplayPowerControllerTest
Change-Id: I5fed20f6b4d2de3821f52ac06dc21c0dbe287aac
parent 7bdcc594
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1446,6 +1446,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call

        // If there's an offload session, we need to set the initial doze brightness before
        // the offload session starts controlling the brightness.
        // During the transition DOZE_SUSPEND -> DOZE -> DOZE_SUSPEND, this brightness strategy
        // will be selected again, meaning that no new brightness will be sent to the hardware and
        // the display will stay at the brightness level set by the offload session.
        if (Float.isNaN(brightnessState) && mFlags.isDisplayOffloadEnabled()
                && Display.isDozeState(state) && mDisplayOffloadSession != null) {
            if (mAutomaticBrightnessController != null
@@ -1463,6 +1466,15 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            if (BrightnessUtils.isValidBrightnessValue(rawBrightnessState)) {
                brightnessState = clampScreenBrightness(rawBrightnessState);
                mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_INITIAL);

                if (mAutomaticBrightnessController != null
                        && mAutomaticBrightnessStrategy.shouldUseAutoBrightness()) {
                    // Keep the brightness in the setting so that we can use it after the screen
                    // turns on, until a lux sample becomes available. We don't do this when
                    // auto-brightness is disabled - in that situation we still want to use
                    // the last brightness from when the screen was on.
                    updateScreenBrightnessSetting = currentBrightnessSetting != brightnessState;
                }
            }
        }

+1 −0
Original line number Diff line number Diff line
@@ -1790,6 +1790,7 @@ public final class DisplayPowerControllerTest {
        verify(mHolder.animator).animateTo(eq(brightness),
                /* linearSecondTarget= */ anyFloat(), /* rate= */ anyFloat(),
                /* ignoreAnimationLimits= */ anyBoolean());
        verify(mHolder.brightnessSetting).setBrightness(brightness);
    }

    @Test