From fd9056cab444a6a5c9d3ce29fb498bdf83328ebd Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Thu, 8 Aug 2024 00:35:52 -0700 Subject: [PATCH] Check for leftTopTask and rightBottomTask in KQS. KQS currently always take the GroupTask's taskId1 and taskId2 as leftTop/rightBottom, in that order. However, sometimes it is possible that the order is flipped; RecentTasksController#getRecentTasks return a list of tasks base on recency, and it is possible that when it initializes a new GroupTask, it put leftBottom as task2 and vice versa, completely dependent on how they are processed. This CL uses GroupTask#mSplitBounds as the source of truth to see 1) Which leftTop/rightBottom to draw for the thumbnail and 2) Which task is leftTop, which task is rightBottom, for re-launching Bug: 328691131 Test: Manually; using KQS, no longer see the app in the wrong places Flag: EXEMPT bugfix Change-Id: I14b3becb05359a917372ec2d7d80d32190f0f96b --- .../launcher3/taskbar/KeyboardQuickSwitchView.java | 12 ++++++++++-- .../launcher3/uioverrides/QuickstepLauncher.java | 12 +++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java index 0ba5de14dd..dbd9c73aad 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java @@ -54,6 +54,7 @@ import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; import com.android.quickstep.util.DesktopTask; import com.android.quickstep.util.GroupTask; +import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import java.util.HashMap; @@ -213,9 +214,16 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { resources.getString(R.string.quick_switch_desktop), Locale.getDefault()).format(args)); } else { + final boolean firstTaskIsLeftTopTask = + groupTask.mSplitBounds == null + || groupTask.mSplitBounds.leftTopTaskId == groupTask.task1.key.id; + final Task leftTopTask = firstTaskIsLeftTopTask + ? groupTask.task1 : groupTask.task2; + final Task rightBottomTask = firstTaskIsLeftTopTask + ? groupTask.task2 : groupTask.task1; currentTaskView.setThumbnails( - groupTask.task1, - groupTask.task2, + leftTopTask, + rightBottomTask, updateTasks ? mViewCallbacks::updateThumbnailInBackground : null, updateTasks ? mViewCallbacks::updateIconInBackground : null); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index b2cc369376..ef39d2167c 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -1382,10 +1382,11 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer */ public void launchSplitTasks( @NonNull GroupTask groupTask, @Nullable RemoteTransition remoteTransition) { - // Top/left and bottom/right tasks respectively. - Task task1 = groupTask.task1; + // SplitBounds can be null if coming from Taskbar launch. + final boolean firstTaskIsLeftTopTask = isFirstTaskLeftTopTask(groupTask); // task2 should never be null when calling this method. Allow a crash to catch invalid calls - Task task2 = groupTask.task2; + Task task1 = firstTaskIsLeftTopTask ? groupTask.task1 : groupTask.task2; + Task task2 = firstTaskIsLeftTopTask ? groupTask.task2 : groupTask.task1; mSplitSelectStateController.launchExistingSplitPair( null /* launchingTaskView */, task1.key.id, @@ -1399,6 +1400,11 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer remoteTransition); } + private static boolean isFirstTaskLeftTopTask(@NonNull GroupTask groupTask) { + return groupTask.mSplitBounds == null + || groupTask.mSplitBounds.leftTopTaskId == groupTask.task1.key.id; + } + /** * Launches two apps as an app pair. */