From 64d448a8db63537311dfe29b68af865bc28e89dc Mon Sep 17 00:00:00 2001 From: Jagrut Desai Date: Tue, 25 Mar 2025 09:53:50 -0700 Subject: [PATCH] Fix Taskbar Flicker with Recents or Running Apps Present Test: Manual, Presubmit Bug: 404772481 Flag: EXEMPT bugfix Change-Id: If3b87474e6e85fabf24a42ac2a3e4ac6a19a4358 --- .../launcher3/taskbar/TaskbarControllers.java | 4 ++-- .../taskbar/TaskbarRecentAppsController.kt | 16 ++++++++++++++-- .../launcher3/taskbar/TaskbarSharedState.java | 4 ++++ .../launcher3/taskbar/TaskbarOverflowTest.kt | 5 ++++- .../taskbar/TaskbarRecentAppsControllerTest.kt | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java index 9e15a60ed1..bd6bf68f0d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java @@ -177,7 +177,7 @@ public class TaskbarControllers { bubbleControllers.ifPresent(controllers -> controllers.init(sharedState, this)); taskbarInsetsController.init(this); voiceInteractionWindowController.init(this); - taskbarRecentAppsController.init(this); + taskbarRecentAppsController.init(this, sharedState.recentTasksBeforeTaskbarRecreate); taskbarTranslationController.init(this); taskbarEduTooltipController.init(this); keyboardQuickSwitchController.init(this); @@ -264,7 +264,6 @@ public class TaskbarControllers { */ public void onDestroy() { mAreAllControllersInitialized = false; - mSharedState = null; taskbarDragController.onDestroy(); navbarButtonsViewController.onDestroy(); @@ -289,6 +288,7 @@ public class TaskbarControllers { taskbarDesktopModeController.onDestroy(); mControllersToLog = null; mBackgroundRendererControllers = null; + mSharedState = null; } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt index 417ef7edef..b362b0c1a7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt @@ -171,7 +171,12 @@ class TaskbarRecentAppsController(context: Context, private val recentsModel: Re // tasks again if we have already requested it and the task list has not changed private var taskListChangeId = -1 - fun init(taskbarControllers: TaskbarControllers) { + private var recentTasksLoaded = false + + fun init(taskbarControllers: TaskbarControllers, previousShownTasks: List) { + if (previousShownTasks.isNotEmpty()) { + shownTasks = previousShownTasks + } controllers = taskbarControllers if (canShowRunningApps || canShowRecentApps) { recentsModel.registerRecentTasksChangedListener(recentTasksChangedListener) @@ -180,6 +185,10 @@ class TaskbarRecentAppsController(context: Context, private val recentsModel: Re } fun onDestroy() { + controllers.sharedState?.recentTasksBeforeTaskbarRecreate?.clear() + if (shownTasks.isNotEmpty()) { + controllers.sharedState?.recentTasksBeforeTaskbarRecreate?.addAll(shownTasks) + } recentsModel.unregisterRecentTasksChangedListener() iconLoadRequests.forEach { it.cancel() } iconLoadRequests.clear() @@ -211,7 +220,9 @@ class TaskbarRecentAppsController(context: Context, private val recentsModel: Re ) } - onRecentsOrHotseatChanged() + if (recentTasksLoaded) { + onRecentsOrHotseatChanged() + } return shownHotseatItems.toTypedArray() } @@ -229,6 +240,7 @@ class TaskbarRecentAppsController(context: Context, private val recentsModel: Re taskListChangeId = recentsModel.getTasks( { tasks -> + recentTasksLoaded = true allRecentTasks = tasks val oldRunningTaskdIds = runningTaskIds val oldMinimizedTaskIds = minimizedTaskIds diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java index f4a7d686c0..fb172e0eae 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java @@ -29,10 +29,12 @@ import android.os.Binder; import android.os.IBinder; import android.view.InsetsFrameProvider; +import com.android.quickstep.util.GroupTask; import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags; import com.android.wm.shell.shared.bubbles.BubbleBarLocation; import com.android.wm.shell.shared.bubbles.BubbleInfo; +import java.util.ArrayList; import java.util.List; /** @@ -121,4 +123,6 @@ public class TaskbarSharedState { // should show corner radius on persistent taskbar when in desktop mode. public boolean showCornerRadiusInDesktopMode = false; + + public List recentTasksBeforeTaskbarRecreate = new ArrayList<>(); } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt index c589415196..dd8d73118e 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt @@ -129,7 +129,10 @@ class TaskbarOverflowTest { if (!recentAppsController.canShowRunningApps) { recentAppsController.onDestroy() recentAppsController.canShowRunningApps = true - recentAppsController.init(taskbarUnitTestRule.activityContext.controllers) + recentAppsController.init( + taskbarUnitTestRule.activityContext.controllers, + emptyList(), + ) } currentControllerInitCallback.invoke() diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt index 334d8ab061..f452af3bf2 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt @@ -118,7 +118,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { recentAppsController = TaskbarRecentAppsController(mockContext, mockRecentsModel) recentAppsController.canShowRunningApps = canShowRunningAndRecentAppsAtInit recentAppsController.canShowRecentApps = canShowRunningAndRecentAppsAtInit - recentAppsController.init(taskbarControllers) + recentAppsController.init(taskbarControllers, emptyList()) taskbarControllers.onPostInit() recentTasksChangedListener =