Use the safe getDisplayId() API when building the recents desktop task list.

This avoids using -1 as the task's display ID and use the default
display ID instead.

In `TaskbarRecentAppsController#reloadRecentTasksIfNeeded()`, it filters
the first DesktopTask instance from allRecentsTask. Previously, the list
is built as nested lists with the same deskId = -1. This causes the
taskbar to show the running/minimized desktop apps incorrectly.

Fixes: 399859320
Fixes: 397956083
Flag: EXEMPT minor bug fix
Test: manual testing
Change-Id: Ie0a8817fc44dab69523547c79a6dfbcaef25ec20
This commit is contained in:
Vania Desmonda
2025-03-05 03:28:34 -08:00
parent 5fcd02dff6
commit 0d3cc4e75a
@@ -41,6 +41,7 @@ import com.android.launcher3.statehandlers.DesktopVisibilityController;
import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.util.DesktopTask;
import com.android.quickstep.util.ExternalDisplaysKt;
import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.SingleTask;
import com.android.quickstep.util.SplitTask;
@@ -460,7 +461,8 @@ public class RecentTasksList {
Map<Integer, List<Task>> perDisplayTasks = new HashMap<>();
for (TaskInfo taskInfo : recentTaskInfo.getTaskInfoList()) {
Task task = createTask(taskInfo, minimizedTaskIds);
List<Task> tasks = perDisplayTasks.computeIfAbsent(taskInfo.displayId,
List<Task> tasks = perDisplayTasks.computeIfAbsent(
ExternalDisplaysKt.getDisplayId(task),
k -> new ArrayList<>());
tasks.add(task);
}