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

Commit b43e44ee authored by Rupesh Bansal's avatar Rupesh Bansal Committed by Android (Google) Code Review
Browse files

Merge "Manual brightness working as expected with refactoring flag enabled" into main

parents c2caf6ae 794d5dce
Loading
Loading
Loading
Loading
+37 −32
Original line number Diff line number Diff line
@@ -1406,9 +1406,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            }
            setBrightnessFromOffload(PowerManager.BRIGHTNESS_INVALID_FLOAT);
        }

        if (!mFlags.isRefactorDisplayPowerControllerEnabled()) {
            // AutomaticBrightnessStrategy has higher priority than OffloadBrightnessStrategy
        if (!mFlags.isRefactorDisplayPowerControllerEnabled() && (Float.isNaN(brightnessState)
                || mBrightnessReasonTemp.getReason() == BrightnessReason.REASON_OFFLOAD)) {
            if (Float.isNaN(brightnessState)
                    || mBrightnessReasonTemp.getReason() == BrightnessReason.REASON_OFFLOAD) {
                if (mAutomaticBrightnessStrategy.isAutoBrightnessEnabled()) {
                    brightnessState = mAutomaticBrightnessStrategy.getAutomaticScreenBrightness(
                            mTempBrightnessEvent);
@@ -1416,13 +1418,15 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                            || brightnessState == PowerManager.BRIGHTNESS_OFF_FLOAT) {
                        rawBrightnessState = mAutomaticBrightnessController
                                .getRawAutomaticScreenBrightness();
                    brightnessState = clampScreenBrightness(brightnessState);
                        // slowly adapt to auto-brightness
                    // TODO(b/253226419): slowChange should be decided by strategy.updateBrightness
                        // TODO(b/253226419): slowChange should be decided by
                        // strategy.updateBrightness
                        slowChange = mAutomaticBrightnessStrategy.hasAppliedAutoBrightness()
                            && !mAutomaticBrightnessStrategy.getAutoBrightnessAdjustmentChanged();
                                && !mAutomaticBrightnessStrategy
                                .getAutoBrightnessAdjustmentChanged();
                        brightnessAdjustmentFlags =
                            mAutomaticBrightnessStrategy.getAutoBrightnessAdjustmentReasonsFlags();
                                mAutomaticBrightnessStrategy
                                        .getAutoBrightnessAdjustmentReasonsFlags();
                        updateScreenBrightnessSetting = currentBrightnessSetting != brightnessState;
                        mAutomaticBrightnessStrategy.setAutoBrightnessApplied(true);
                        mBrightnessReasonTemp.setReason(BrightnessReason.REASON_AUTOMATIC);
@@ -1437,12 +1441,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    }
                }
            } else {
            // Any non-auto-brightness values such as override or temporary should still be subject
            // to clamping so that they don't go beyond the current max as specified by Brightness
            // Range Controller.
            brightnessState = clampScreenBrightness(brightnessState);
                mAutomaticBrightnessStrategy.setAutoBrightnessApplied(false);
            }
        }

        if (!Float.isNaN(brightnessState)) {
            brightnessState = clampScreenBrightness(brightnessState);
        }

        // If there's an offload session, we need to set the initial doze brightness before
        // the offload session starts controlling the brightness.