From 9fb4f1adb91bef02f501115ddd182ddaa412d819 Mon Sep 17 00:00:00 2001 From: slhssb Date: Fri, 20 Nov 2026 20:02:11 +0800 Subject: [PATCH] fix: persist the lock screen music switches HookSettings.write() never wrote the four keys that toSettings() reads for the lock screen music switches, so those switches could not survive a settings-process restart. The switches looked like they worked: update() changed the in-memory copy and Compose redrew, and the features themselves ran because SystemUI is driven by applySettings() over the probe bridge rather than through this file. The saved value was simply never written to disk, so the next HookSettingsStore construction read the default (false) and the switch came back off. Reopening the settings app is enough to see it: turn on the music lockscreen and lock screen lyrics switches, dismiss the settings app from recents, open it again - both switches are off again. Verified against this fix on Xiaomi 17 Pro Max (HyperOS 4, Android 17): both stay on. The same omission affects two related switches, fixed alongside: - KEY_LOCKSCREEN_MUSIC_LYRICS_HDR_ENABLED - KEY_LOCKSCREEN_MUSIC_LYRICS_KEEP_SCREEN_ON One file, four putBoolean calls, no logic change. --- .../btm/m/os4/systemuihook/HookSettings.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/btm/m/os4/systemuihook/HookSettings.kt b/app/src/main/java/btm/m/os4/systemuihook/HookSettings.kt index 699612c1..a345961e 100644 --- a/app/src/main/java/btm/m/os4/systemuihook/HookSettings.kt +++ b/app/src/main/java/btm/m/os4/systemuihook/HookSettings.kt @@ -1327,6 +1327,26 @@ private fun SharedPreferences.write(value: HookSettings) { .putInt(KEY_SHORTCUT_SOFT_GLASS_BACKDROP_BLUR_RADIUS, value.shortcutSoftGlassBackdropBlurRadius) .putInt(KEY_SHORTCUT_SOFT_GLASS_BLUR_RADIUS, value.shortcutSoftGlassBlurRadius) .putFloat(KEY_SHORTCUT_SOFT_GLASS_LUMINANCE, value.shortcutSoftGlassLuminance) + // Read by toSettings() since these switches existed, and never written until now: the + // settings page updated the in-memory copy and the UI redrew, the features worked + // (SystemUI is driven over the probe bridge, not through this file), and the switch was + // back to its default the moment the settings process restarted. + .putBoolean( + KEY_LOCKSCREEN_MUSIC_LOCKSCREEN_ENABLED, + value.lockscreenMusicLockscreenEnabled, + ) + .putBoolean( + KEY_LOCKSCREEN_MUSIC_LYRICS_ENABLED, + value.lockscreenMusicLyricsEnabled, + ) + .putBoolean( + KEY_LOCKSCREEN_MUSIC_LYRICS_HDR_ENABLED, + value.lockscreenMusicLyricsHdrEnabled, + ) + .putBoolean( + KEY_LOCKSCREEN_MUSIC_LYRICS_KEEP_SCREEN_ON, + value.lockscreenMusicLyricsKeepScreenOn, + ) .putBoolean(KEY_LOCKSCREEN_WIDGET_ENABLED, value.lockscreenWidgetEnabled) .putBoolean(KEY_LOCKSCREEN_WIDGET_HIDE_ON_AOD, value.lockscreenWidgetHideOnAod) .putString(KEY_LOCKSCREEN_WIDGET_DEVICE_NAME, value.lockscreenWidgetDeviceName.take(64))