Ignore empty tasks when unfreezing recents list after timeout

- The top task can sometimes be a root that doesn't have any
  children (ie. split root), which can lead to an empty
  task being in the recents list

Bug: 275425871
Test: atest SwitchBetweenSplitPairs
Change-Id: Ia0bd7a08870e8cbd4849f79506fd8db9a1d18d65
This commit is contained in:
Winson Chung
2023-04-05 23:03:46 +00:00
parent f9a77b961f
commit e91a468a59
2 changed files with 7 additions and 1 deletions

View File

@@ -338,7 +338,8 @@ class RecentTasks {
synchronized (mService.mGlobalLock) {
final Task focusedStack = mService.getTopDisplayFocusedRootTask();
final Task topTask = focusedStack != null ? focusedStack.getTopMostTask() : null;
resetFreezeTaskListReordering(topTask);
final Task reorderToEndTask = topTask != null && topTask.hasChild() ? topTask : null;
resetFreezeTaskListReordering(reorderToEndTask);
}
}

View File

@@ -924,6 +924,11 @@ public class RecentTasksTest extends WindowTestsBase {
@Test
public void testFreezeTaskListOrder_timeout() {
for (Task t : mTasks) {
// Make all the tasks non-empty
new ActivityBuilder(mAtm).setTask(t).build();
}
// Add some tasks
mRecentTasks.add(mTasks.get(0));
mRecentTasks.add(mTasks.get(1));