From 8c50cdc72a1216a4eed0fe4f432bd830222e3d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Hern=C3=A1ndez?= Date: Thu, 22 Aug 2024 19:31:22 +0200 Subject: [PATCH] Update Modes List if modes change in the background Fixes: 361518126 Test: manual Flag: android.app.modes_ui Change-Id: Ia00025adbb89ddc9163a9c50582cbcbd524231bb --- .../notification/modes/ZenModesListFragment.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/notification/modes/ZenModesListFragment.java b/src/com/android/settings/notification/modes/ZenModesListFragment.java index 2b58f8e1c3b..588b3202bb6 100644 --- a/src/com/android/settings/notification/modes/ZenModesListFragment.java +++ b/src/com/android/settings/notification/modes/ZenModesListFragment.java @@ -23,6 +23,7 @@ import android.content.Intent; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import androidx.lifecycle.Lifecycle; import com.android.settings.R; import com.android.settings.core.SubSettingLauncher; @@ -62,9 +63,12 @@ public class ZenModesListFragment extends ZenModesFragmentBase { @Override protected void onUpdatedZenModeState() { - // TODO: b/322373473 -- update any overall description of modes state here if necessary. - // Note the preferences linking to individual rules do not need to be updated, as - // updateState() is called on all preference controllers whenever the page is resumed. + // Preferences linking to individual rules do not need to be updated as part of onStart(), + // because DashboardFragment does that in onResume(). However, we force the update if we + // detect Modes changes in the background with the page open. + if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) { + forceUpdatePreferences(); + } } @Override