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

Commit 5746474a authored by Piotr Wilczyński's avatar Piotr Wilczyński Committed by Android (Google) Code Review
Browse files

Merge "Check fallback strategy when using default doze brightness" into main

parents 8b7e8ca8 a006159a
Loading
Loading
Loading
Loading
+10 −15
Original line number Diff line number Diff line
@@ -1480,29 +1480,24 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            brightnessState = clampScreenBrightness(brightnessState);
        }

        if (useDozeBrightness) {
            // TODO(b/329676661): Introduce a config property to choose between this brightness
            //  strategy and DOZE_DEFAULT
            // On some devices, when auto-brightness is disabled and the device is dozing, we use
            // the current brightness setting scaled by the doze scale factor
            if ((Float.isNaN(brightnessState)
        if (useDozeBrightness && (Float.isNaN(brightnessState)
                || displayBrightnessState.getDisplayBrightnessStrategyName()
                    .equals(DisplayBrightnessStrategyConstants.FALLBACK_BRIGHTNESS_STRATEGY_NAME))
                    && mFlags.isDisplayOffloadEnabled()
                    && mDisplayOffloadSession != null
                .equals(DisplayBrightnessStrategyConstants.FALLBACK_BRIGHTNESS_STRATEGY_NAME))) {
            if (mFlags.isDisplayOffloadEnabled() && mDisplayOffloadSession != null
                    && (mAutomaticBrightnessController == null
                    || !mAutomaticBrightnessStrategy.shouldUseAutoBrightness())) {
                // TODO(b/329676661): Introduce a config property to choose between this brightness
                //  strategy and DOZE_DEFAULT
                // On some devices, when auto-brightness is disabled and the device is dozing, we
                // use the current brightness setting scaled by the doze scale factor
                rawBrightnessState = getDozeBrightnessForOffload();
                brightnessState = clampScreenBrightness(rawBrightnessState);
                updateScreenBrightnessSetting = false;
                mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_MANUAL);
                mTempBrightnessEvent.setFlags(
                        mTempBrightnessEvent.getFlags() | BrightnessEvent.FLAG_DOZE_SCALE);
            }

            } else if (!mDisplayBrightnessController.isAllowAutoBrightnessWhileDozingConfig()) {
                // Use default brightness when dozing unless overridden.
            if (Float.isNaN(brightnessState)
                    && !mDisplayBrightnessController.isAllowAutoBrightnessWhileDozingConfig()) {
                rawBrightnessState = mScreenBrightnessDozeConfig;
                brightnessState = clampScreenBrightness(rawBrightnessState);
                mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_DEFAULT);