From 9c0392e08dc9f0eaa4f712cf7d95bc6e29c9b6ae Mon Sep 17 00:00:00 2001 From: Orhan Uysal Date: Thu, 25 Jul 2024 11:15:59 +0000 Subject: [PATCH] Fix filtering of DesktopTaskViews When finding last active tasks we didn't account for the fact that there could be more than 2 tasks in a GroupTask. This cl fixes that so it finds the correct last active tasks in desktop cases. Also make sure that if a DesktopTaskView is found, we don't launch it through TaskView#LaunchTasks to create a transition that we can handle in WM Shell. Fix: 327447672 Fix: 354171747 Flag: EXEMPT Bugfix Test: atest SplitSelectStateControllerTest Change-Id: I71cc630a79f23e5eaad10b3c2284496422ce6994 --- .../taskbar/TaskbarActivityContext.java | 5 +++-- .../util/SplitSelectStateController.java | 18 ++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 088c3cc20b..c55b194ee3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -140,6 +140,7 @@ import com.android.quickstep.RecentsModel; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.DesktopTask; import com.android.quickstep.util.GroupTask; +import com.android.quickstep.views.DesktopTaskView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.Task; @@ -1357,7 +1358,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { if (foundTask != null) { TaskView foundTaskView = recents.getTaskViewByTaskId(foundTask.key.id); if (foundTaskView != null - && foundTaskView.isVisibleToUser()) { + && foundTaskView.isVisibleToUser() + && !(foundTaskView instanceof DesktopTaskView)) { TestLogging.recordEvent( TestProtocol.SEQUENCE_MAIN, "start: taskbarAppIcon"); foundTaskView.launchTasks(); @@ -1408,7 +1410,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext { return; } } - startActivity(intent); } else { getSystemService(LauncherApps.class).startMainActivity( diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index d906bb3fd3..27fad6169b 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -276,17 +276,15 @@ public class SplitSelectStateController { // Loop through tasks in reverse, since they are ordered with recent tasks last for (int j = taskGroups.size() - 1; j >= 0; j--) { GroupTask groupTask = taskGroups.get(j); - Task task1 = groupTask.task1; - // Don't add duplicate Tasks - if (isInstanceOfComponent(task1, key) - && !Arrays.asList(lastActiveTasks).contains(task1)) { - lastActiveTask = task1; - break; + // Account for desktop cases where there can be N tasks in the group + for (Task task : groupTask.getTasks()) { + if (isInstanceOfComponent(task, key) + && !Arrays.asList(lastActiveTasks).contains(task)) { + lastActiveTask = task; + break; + } } - Task task2 = groupTask.task2; - if (isInstanceOfComponent(task2, key) - && !Arrays.asList(lastActiveTasks).contains(task2)) { - lastActiveTask = task2; + if (lastActiveTask != null) { break; } }