diff options
| author | 2024-04-18 11:26:02 +0000 | |
|---|---|---|
| committer | 2024-04-18 11:26:02 +0000 | |
| commit | b43e44ee9a7a69abbe22d8568c6f702127b0a241 (patch) | |
| tree | 5e606a82b414db84670ec8e11a19506deccf695d | |
| parent | c2caf6ae13b9d31054873cd8ca347e23a64440d4 (diff) | |
| parent | 794d5dce9c3a52731252fc254a06edc39792c9a4 (diff) | |
Merge "Manual brightness working as expected with refactoring flag enabled" into main
| -rw-r--r-- | services/core/java/com/android/server/display/DisplayPowerController.java | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index cfdb75f418de..896670e449f1 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -1406,42 +1406,47 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } setBrightnessFromOffload(PowerManager.BRIGHTNESS_INVALID_FLOAT); } - // AutomaticBrightnessStrategy has higher priority than OffloadBrightnessStrategy - if (!mFlags.isRefactorDisplayPowerControllerEnabled() && (Float.isNaN(brightnessState) - || mBrightnessReasonTemp.getReason() == BrightnessReason.REASON_OFFLOAD)) { - if (mAutomaticBrightnessStrategy.isAutoBrightnessEnabled()) { - brightnessState = mAutomaticBrightnessStrategy.getAutomaticScreenBrightness( - mTempBrightnessEvent); - if (BrightnessUtils.isValidBrightnessValue(brightnessState) - || 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 - slowChange = mAutomaticBrightnessStrategy.hasAppliedAutoBrightness() - && !mAutomaticBrightnessStrategy.getAutoBrightnessAdjustmentChanged(); - brightnessAdjustmentFlags = - mAutomaticBrightnessStrategy.getAutoBrightnessAdjustmentReasonsFlags(); - updateScreenBrightnessSetting = currentBrightnessSetting != brightnessState; - mAutomaticBrightnessStrategy.setAutoBrightnessApplied(true); - mBrightnessReasonTemp.setReason(BrightnessReason.REASON_AUTOMATIC); - if (mScreenOffBrightnessSensorController != null) { - mScreenOffBrightnessSensorController.setLightSensorEnabled(false); + + if (!mFlags.isRefactorDisplayPowerControllerEnabled()) { + // AutomaticBrightnessStrategy has higher priority than OffloadBrightnessStrategy + if (Float.isNaN(brightnessState) + || mBrightnessReasonTemp.getReason() == BrightnessReason.REASON_OFFLOAD) { + if (mAutomaticBrightnessStrategy.isAutoBrightnessEnabled()) { + brightnessState = mAutomaticBrightnessStrategy.getAutomaticScreenBrightness( + mTempBrightnessEvent); + if (BrightnessUtils.isValidBrightnessValue(brightnessState) + || brightnessState == PowerManager.BRIGHTNESS_OFF_FLOAT) { + rawBrightnessState = mAutomaticBrightnessController + .getRawAutomaticScreenBrightness(); + // slowly adapt to auto-brightness + // TODO(b/253226419): slowChange should be decided by + // strategy.updateBrightness + slowChange = mAutomaticBrightnessStrategy.hasAppliedAutoBrightness() + && !mAutomaticBrightnessStrategy + .getAutoBrightnessAdjustmentChanged(); + brightnessAdjustmentFlags = + mAutomaticBrightnessStrategy + .getAutoBrightnessAdjustmentReasonsFlags(); + updateScreenBrightnessSetting = currentBrightnessSetting != brightnessState; + mAutomaticBrightnessStrategy.setAutoBrightnessApplied(true); + mBrightnessReasonTemp.setReason(BrightnessReason.REASON_AUTOMATIC); + if (mScreenOffBrightnessSensorController != null) { + mScreenOffBrightnessSensorController.setLightSensorEnabled(false); + } + setBrightnessFromOffload(PowerManager.BRIGHTNESS_INVALID_FLOAT); + } else { + mAutomaticBrightnessStrategy.setAutoBrightnessApplied(false); + // Restore the lower-priority brightness strategy + brightnessState = displayBrightnessState.getBrightness(); } - setBrightnessFromOffload(PowerManager.BRIGHTNESS_INVALID_FLOAT); - } else { - mAutomaticBrightnessStrategy.setAutoBrightnessApplied(false); - // Restore the lower-priority brightness strategy - brightnessState = displayBrightnessState.getBrightness(); } + } else { + mAutomaticBrightnessStrategy.setAutoBrightnessApplied(false); } - } 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. + } + + if (!Float.isNaN(brightnessState)) { brightnessState = clampScreenBrightness(brightnessState); - mAutomaticBrightnessStrategy.setAutoBrightnessApplied(false); } // If there's an offload session, we need to set the initial doze brightness before |