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

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

Check fallback strategy when using default doze brightness

Bug: 343666198
Flag: EXEMPT bugfix
Test: atest DisplayPowerControllerTest
Change-Id: Iac87a0f147a53924d60ec4d639a0ee33b4756949
parent 435ec085
Loading
Loading
Loading
Loading
+10 −15
Original line number Original line Diff line number Diff line
@@ -1480,29 +1480,24 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            brightnessState = clampScreenBrightness(brightnessState);
            brightnessState = clampScreenBrightness(brightnessState);
        }
        }


        if (useDozeBrightness) {
        if (useDozeBrightness && (Float.isNaN(brightnessState)
            // 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)
                || displayBrightnessState.getDisplayBrightnessStrategyName()
                || displayBrightnessState.getDisplayBrightnessStrategyName()
                    .equals(DisplayBrightnessStrategyConstants.FALLBACK_BRIGHTNESS_STRATEGY_NAME))
                .equals(DisplayBrightnessStrategyConstants.FALLBACK_BRIGHTNESS_STRATEGY_NAME))) {
                    && mFlags.isDisplayOffloadEnabled()
            if (mFlags.isDisplayOffloadEnabled() && mDisplayOffloadSession != null
                    && mDisplayOffloadSession != null
                    && (mAutomaticBrightnessController == null
                    && (mAutomaticBrightnessController == null
                    || !mAutomaticBrightnessStrategy.shouldUseAutoBrightness())) {
                    || !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();
                rawBrightnessState = getDozeBrightnessForOffload();
                brightnessState = clampScreenBrightness(rawBrightnessState);
                brightnessState = clampScreenBrightness(rawBrightnessState);
                updateScreenBrightnessSetting = false;
                updateScreenBrightnessSetting = false;
                mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_MANUAL);
                mBrightnessReasonTemp.setReason(BrightnessReason.REASON_DOZE_MANUAL);
                mTempBrightnessEvent.setFlags(
                mTempBrightnessEvent.setFlags(
                        mTempBrightnessEvent.getFlags() | BrightnessEvent.FLAG_DOZE_SCALE);
                        mTempBrightnessEvent.getFlags() | BrightnessEvent.FLAG_DOZE_SCALE);
            }
            } else if (!mDisplayBrightnessController.isAllowAutoBrightnessWhileDozingConfig()) {

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