From 3847d7ed9a6fabe08722102b3dfb46ca1545332e Mon Sep 17 00:00:00 2001 From: Sameer Zalke Date: Tue, 20 Jul 2021 21:13:56 +0530 Subject: [PATCH] Dark Theme "TURN ON UNTIL SUNRISE" is not retained after reboot Dark theme "TURN ON UNTIL SUNRISE"/MODE_NIGHT_AUTO is not kept after reboot. The reason is that TwilightState will takes time to update so lastState will be null in updateConfigurationLocked(). This lead to a reset of mComputedNightMode and mOverrideNightModeOn. This is a special bug for "TURN ON UNTIL SUNRISE"/MODE_NIGHT_AUTO, the other ones work fine and should not be touched, if we do not treat this as a special case we break the other ones. Test: Select "TURN ON UNTIL SUNRISE" in Dark Theme and reboot. Bug: 229228293 Change-Id: Ie32a6ddbbf03fa43ee6dd5e35b3c35ec03e58e0e --- .../core/java/com/android/server/UiModeManagerService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index 81627a05c9a40..2ab477f7dd175 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -1803,7 +1803,10 @@ final class UiModeManagerService extends SystemService { mComputedNightMode = false; return; } - resetNightModeOverrideLocked(); + if (mNightMode != MODE_NIGHT_AUTO || (mTwilightManager != null + && mTwilightManager.getLastTwilightState() != null)) { + resetNightModeOverrideLocked(); + } } private boolean resetNightModeOverrideLocked() {