Modern Apps git

← Modern-Apps.git

screentime: always use monochromacy for wind-down grayscale

Commit
7aa34b06f18c0db3c3529e9e2b9102140f5fe5c7
Author
Vayun Mathur <[email protected]>
When
2026-11-08 02:20 UTC (28 days ago)
Parents
b138f20
Fix wind-down grayscale possibly applying the wrong color transform.

Root cause: daltonizerMode read accessibility_display_daltonizer_mode live and wrote that value back. If the key held a non-monochromacy transform, perhaps after color-simulation use, wind-down enabled that transform instead of guaranteeing full desaturation.

Always write the documented monochromacy constant when wind-down turns grayscale on. This matches the class contract that monochromacy desaturates fully.

User-visible effect: wind-down grayscale is consistently full grayscale, even if the device previously used another display transform.

Verified with: ~/code/ma-cov/gslot ./gradlew :screentime:testDevUnitTest; BUILD SUCCESSFUL.

Diff

screentime/src/main/java/com/vayunmathur/screentime/platform/WindDownApplier.kt
diff --git a/screentime/src/main/java/com/vayunmathur/screentime/platform/WindDownApplier.kt b/screentime/src/main/java/com/vayunmathur/screentime/platform/WindDownApplier.ktindex df31d105b6..1d3e085b79 100644--- a/screentime/src/main/java/com/vayunmathur/screentime/platform/WindDownApplier.kt+++ b/screentime/src/main/java/com/vayunmathur/screentime/platform/WindDownApplier.kt@@ -61,19 +61,12 @@ class WindDownApplier(private val context: Context) {     }      /**-     * The daltonizer mode value for full monochromacy, read live rather than hardcoded.+     * The daltonizer mode value for full monochromacy.      *-     * Hardcoding the integer bakes an AOSP constant into the APK; reading the current value-     * first and only overriding the enabled flag keeps us correct if the constant moves.-     * Falls back to the documented monochromacy value when unreadable.+     * This is always the documented monochromacy constant: wind-down grayscale must+     * desaturate fully, not reapply whatever transform the key currently holds.      */-    private fun daltonizerMode(): String =-        runCatching {-            Settings.Secure.getString(-                context.contentResolver,-                "accessibility_display_daltonizer_mode",-            )-        }.getOrNull() ?: MONOCHROMACY_MODE+    private fun daltonizerMode(): String = MONOCHROMACY_MODE      private fun setDnd(on: Boolean) {         val nm = notifications ?: return@@ -90,7 +83,7 @@ class WindDownApplier(private val context: Context) {     }      private companion object {-        /** `AccessibilityManager` monochromacy mode. Documented AOSP value, fallback only. */+        /** `AccessibilityManager` monochromacy mode. Documented AOSP value. */         const val MONOCHROMACY_MODE = "0"     } }