From 0cc9546ef8ceb72cb731d3ff86eb037d7add3450 Mon Sep 17 00:00:00 2001 From: Adithya R Date: Thu, 7 Sep 2023 14:43:18 +0530 Subject: [PATCH] display: Handle zero auto brightness adjustment Some apps (such as miui camera) resets the auto brightness adjustment to 0.0f instead of correctly using Float.NaN, causing auto brightness animation to be disabled afterwards. Prevent this scenario by overriding it to Float.NaN ourselves. Change-Id: Idc39d120db306403482c7011db7c556f4f902468 --- .../com/android/server/display/DisplayManagerService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java index ae33b83b49dc..6e5ddddcbe7f 100644 --- a/services/core/java/com/android/server/display/DisplayManagerService.java +++ b/services/core/java/com/android/server/display/DisplayManagerService.java @@ -4607,7 +4607,11 @@ public final class DisplayManagerService extends SystemService { @Override // Binder call public void setTemporaryAutoBrightnessAdjustment(float adjustment) { setTemporaryAutoBrightnessAdjustment_enforcePermission(); - final long token = Binder.clearCallingIdentity(); + if (adjustment == 0.0f) { + Slog.w(TAG, "Invalid auto brightness adjustment 0.0f, use Float.NaN instead!"); + adjustment = Float.NaN; + } + final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { mDisplayPowerControllers.get(Display.DEFAULT_DISPLAY)