From b4f36ff73ced1a20b05635f6dda11e6db7c24c22 Mon Sep 17 00:00:00 2001 From: Chad Date: Mon, 24 Aug 2026 20:16:38 +0000 Subject: [PATCH] Don't force manual brightness mode just from opening the brightness UI buildBrightnessSection() and buildBrightnessSubPanel() each unconditionally wrote Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL at the top of the function, as a side effect of building that view -- not in response to any touch. That meant opening KompaktX's Quick Settings brightness row, or just tapping "Bright" to expand its sub-panel, silently disabled Adaptive Brightness even if the slider was never touched. buildBrightnessSection's slider drag and sun-icon tap already go through applyBrightness(), which forces manual mode on its own, so removing the top-of-function write there is a pure deletion with no behavior change for actual interaction. buildBrightnessSubPanel's slider drag writes Settings.System.SCREEN_BRIGHTNESS directly rather than through applyBrightness(), so its mode-forcing moved into the ACTION_DOWN/ACTION_MOVE branch instead of being deleted outright -- dragging that slider still disables Adaptive Brightness, matching stock Android's own slider-drag behavior; merely opening the sub-panel no longer does. Independent of and narrower in scope than the wake-loop fix on fix/preserve-adaptive-brightness (which this branch does not include, since it's based on unmodified upstream main) -- see PROJECT-STATUS.md for how the two relate. --- .../noti/restore/overlay/OverlayPanelManager.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/noti/restore/overlay/OverlayPanelManager.kt b/app/src/main/java/com/noti/restore/overlay/OverlayPanelManager.kt index 282c108..05ec8c5 100644 --- a/app/src/main/java/com/noti/restore/overlay/OverlayPanelManager.kt +++ b/app/src/main/java/com/noti/restore/overlay/OverlayPanelManager.kt @@ -1071,12 +1071,6 @@ object OverlayPanelManager { Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS) } catch (_: Exception) { 128 } - // Ensure manual brightness mode - try { - Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE, - Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) - } catch (_: Exception) {} - val trackH = (6 * dp).toInt() val thumbSize = (24 * dp).toInt() @@ -1154,6 +1148,10 @@ object OverlayPanelManager { val frac = ((event.x - thumbSize / 2) / (v.width - thumbSize)).coerceIn(0f, 1f) val brightness = (frac * 255).toInt().coerceIn(1, 255) try { + // Force manual mode here, on an actual drag, not just from opening this + // sub-panel — matches stock Android's own slider-drag behavior. + Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE, + Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS, brightness) } catch (_: Exception) {} updateSliderVisual(brightness, v.width) @@ -1508,10 +1506,9 @@ object OverlayPanelManager { val currentBrightness = try { Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS) } catch (_: Exception) { 128 } - try { - Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE, - Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) - } catch (_: Exception) {} + // Manual mode is forced from applyBrightness() below, on an actual slider drag or + // sun-icon tap — not here, just from building this section's view. Merely viewing the + // Quick Settings tab shouldn't disable Adaptive Brightness on its own. // Percentage label on right (declare early so sun icon click can update it) val valueText = TextView(context).apply {