From b0fa52f3ee947a4ffee029711f2fb932aeb765fb Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 28 Feb 2023 23:55:31 +0000 Subject: [PATCH] Only recreate taskbar for uiMode theme changes Test: simulate docking/undocking, ensure taskbar is not recreated; set dark/light theme and ensure taskbar is still recreated Fixes: 233459895 Change-Id: I583557039f4a7c02baaa5e62eb888f55d659adb0 --- .../android/launcher3/taskbar/TaskbarManager.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index 411082272e..8c918339f8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -130,10 +130,10 @@ public class TaskbarManager { ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null; int configDiff = mOldConfig.diff(newConfig); + int configDiffForRecreate = configDiff; int configsRequiringRecreate = ActivityInfo.CONFIG_ASSETS_PATHS | ActivityInfo.CONFIG_LAYOUT_DIRECTION | ActivityInfo.CONFIG_UI_MODE | ActivityInfo.CONFIG_SCREEN_SIZE; - boolean requiresRecreate = (configDiff & configsRequiringRecreate) != 0; if ((configDiff & ActivityInfo.CONFIG_SCREEN_SIZE) != 0 && mTaskbarActivityContext != null && dp != null && !isPhoneMode(dp)) { @@ -146,12 +146,19 @@ public class TaskbarManager { int oldWidth = isOrientationChange ? oldDp.heightPx : oldDp.widthPx; int oldHeight = isOrientationChange ? oldDp.widthPx : oldDp.heightPx; if (dp.widthPx == oldWidth && dp.heightPx == oldHeight) { - configDiff &= ~ActivityInfo.CONFIG_SCREEN_SIZE; - requiresRecreate = (configDiff & configsRequiringRecreate) != 0; + configDiffForRecreate &= ~ActivityInfo.CONFIG_SCREEN_SIZE; + } + } + if ((configDiff & ActivityInfo.CONFIG_UI_MODE) != 0) { + // Only recreate for theme changes, not other UI mode changes such as docking. + int oldUiNightMode = (mOldConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK); + int newUiNightMode = (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK); + if (oldUiNightMode == newUiNightMode) { + configDiffForRecreate &= ~ActivityInfo.CONFIG_UI_MODE; } } - if (requiresRecreate) { + if ((configDiffForRecreate & configsRequiringRecreate) != 0) { recreateTaskbar(); } else { // Config change might be handled without re-creating the taskbar