If the desktop task is visible, increase the count
When the desktop tasks are visible while constructing tasks, increase the number of visible tasks count by 1. Otherwise we might not exclude tasks that are marked as transparent and exludeFromRecents in the constructed list.
Fix: 397190111
Test: Enter desktop, trigger CtS and swipe up. Observe there is only one
desktop tile
Flag: EXEMPT Bug fix
Change-Id: Iabb382b20305a9a5b099bf8ee09a96ac13d0f36d
diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java
index bb72408..fec073c 100644
--- a/quickstep/src/com/android/quickstep/RecentTasksList.java
+++ b/quickstep/src/com/android/quickstep/RecentTasksList.java
@@ -351,7 +351,7 @@
TaskLoadResult allTasks = new TaskLoadResult(requestId, loadKeysOnly, rawTasks.size());
- int numVisibleTasks = 0;
+ boolean isFirstVisibleTaskFound = false;
for (GroupedTaskInfo rawTask : rawTasks) {
if (rawTask.isBaseType(TYPE_FREEFORM)) {
// TYPE_FREEFORM tasks is only created when desktop mode can be entered,
@@ -360,6 +360,14 @@
List<DesktopTask> desktopTasks = createDesktopTasks(
rawTask.getBaseGroupedTask());
allTasks.addAll(desktopTasks);
+
+ // If any task in desktop group task is visible, set isFirstVisibleTaskFound to
+ // true. This way if there is a transparent task in the list later on, it does
+ // not get its own tile in Overview.
+ if (rawTask.getBaseGroupedTask().getTaskInfoList().stream().anyMatch(
+ taskInfo -> taskInfo.isVisible)) {
+ isFirstVisibleTaskFound = true;
+ }
}
continue;
}
@@ -400,7 +408,7 @@
tmpLockedUsers.get(task2Key.userId) /* isLocked */);
} else {
// Is fullscreen task
- if (numVisibleTasks > 0) {
+ if (!isFirstVisibleTaskFound) {
boolean isExcluded = (taskInfo1.baseIntent.getFlags()
& FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
if (taskInfo1.isTopActivityTransparent && isExcluded) {
@@ -411,7 +419,7 @@
}
}
if (taskInfo1.isVisible) {
- numVisibleTasks++;
+ isFirstVisibleTaskFound = true;
}
if (task2 != null) {
Objects.requireNonNull(rawTask.getSplitBounds());