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

Commit c395a29e authored by Fiona Campbell's avatar Fiona Campbell
Browse files

Fix screen-on speed during phone call

RampAnimator was being passed -1.0f (PowerManager.BRIGHTNESS_OFF) and animating from that. This change ensures only valid brightness values are passed to it. brightnessState includes values such as off and invalid, which shouldn't be animated to. brightnessValues represent a value from PowerManager.BRIGHTNESS_MIN to PowerManager.BRIGHTNESS_MAX (0.0f - 1.0f).

Bug: 152171816

Test: manual
Change-Id: I2e7a80d50e4b52817959c120e6ee96a4186c2f8b
parent 4a2288bf
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -1067,13 +1067,23 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    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.
            // If the brightnessState is off (-1.0f) we still want to animate to the minimum
            // brightness (0.0f) to accommodate for LED displays, which can appear bright to the
            // user even when the display is all black.
            float animateValue = brightnessState == PowerManager.BRIGHTNESS_OFF_FLOAT
                    ? PowerManager.BRIGHTNESS_MIN : brightnessState;
            if (isValidBrightnessValue(animateValue)) {
                if (initialRampSkip || hasBrightnessBuckets
                        || wasOrWillBeInVr || !isDisplayContentVisible || brightnessIsTemporary) {
                animateScreenBrightness(brightnessState, SCREEN_ANIMATION_RATE_MINIMUM);
                    animateScreenBrightness(animateValue, SCREEN_ANIMATION_RATE_MINIMUM);
                } else {
                animateScreenBrightness(brightnessState,
                    animateScreenBrightness(animateValue,
                            slowChange ? mBrightnessRampRateSlow : mBrightnessRampRateFast);
                }
            }

            if (!brightnessIsTemporary) {
                if (userInitiatedChange && (mAutomaticBrightnessController == null
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ final class DisplayPowerState {
    /**
     * Sets the display brightness.
     *
     * @param brightness The brightness, ranges from 0 (minimum / off) to 255 (brightest).
     * @param brightness The brightness, ranges from 0.0f (minimum / off) to 1.0f (brightest).
     */
    public void setScreenBrightness(float brightness) {
        if (mScreenBrightness != brightness) {