Fixes two bugs with findLastActiveTasksAndRunCallback()

This CL changes findLastActiveTasksAndRunCallback to return a fixed array rather than an ArrayList.

1) This fixes a (minor) crash with app pairs, where we performed get(0) on an empty array when no running tasks were found.
2) This also fixes a live bug where app pairs would launch apps in the wrong order if app 1 was not found in running tasks, but app 2 was.

The function should be more robust now, preserving the indexing of the input keys.

Fixes: 316053131
Test: Clear all tasks from Overview, launch an app pair, launch succeeds
Flag: ACONFIG com.android.wm.shell.enable_app_pairs DEVELOPMENT
Change-Id: I51d8ba823a2ec57e9ecfeede956e0afce1d653f4
This commit is contained in:
Jeremy Sim
2023-12-15 17:59:47 +09:00
parent ea4c701579
commit 42a44d7984
6 changed files with 30 additions and 27 deletions
@@ -644,7 +644,7 @@ public class QuickstepLauncher extends Launcher {
Collections.singletonList(splitSelectSource.itemInfo.getComponentKey()),
false /* findExactPairMatch */,
foundTasks -> {
@Nullable Task foundTask = foundTasks.get(0);
@Nullable Task foundTask = foundTasks[0];
boolean taskWasFound = foundTask != null;
splitSelectSource.alreadyRunningTaskId = taskWasFound
? foundTask.key.id