Merge "Do not put in-recent task in hidden task list" into rvc-dev am: ecc32d24e8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12004940

Change-Id: I57f84a5fbacdf44c2e071381f6c0fe0151b60277
This commit is contained in:
TreeHugger Robot
2020-06-30 03:31:49 +00:00
committed by Automerger Merge Worker
2 changed files with 12 additions and 7 deletions

View File

@@ -1426,8 +1426,8 @@ class RecentTasks {
private void removeUnreachableHiddenTasks(int windowingMode) { private void removeUnreachableHiddenTasks(int windowingMode) {
for (int i = mHiddenTasks.size() - 1; i >= 0; i--) { for (int i = mHiddenTasks.size() - 1; i >= 0; i--) {
final Task hiddenTask = mHiddenTasks.get(i); final Task hiddenTask = mHiddenTasks.get(i);
if (!hiddenTask.hasChild()) { if (!hiddenTask.hasChild() || hiddenTask.inRecents) {
// The task was removed by other path. // The task was removed by other path or it became reachable (added to recents).
mHiddenTasks.remove(i); mHiddenTasks.remove(i);
continue; continue;
} }
@@ -1449,6 +1449,9 @@ class RecentTasks {
* of task as the given one. * of task as the given one.
*/ */
private void removeForAddTask(Task task) { private void removeForAddTask(Task task) {
// The adding task will be in recents so it is not hidden.
mHiddenTasks.remove(task);
final int removeIndex = findRemoveIndexForAddTask(task); final int removeIndex = findRemoveIndexForAddTask(task);
if (removeIndex == -1) { if (removeIndex == -1) {
// Nothing to trim // Nothing to trim
@@ -1460,8 +1463,6 @@ class RecentTasks {
// callbacks here. // callbacks here.
final Task removedTask = mTasks.remove(removeIndex); final Task removedTask = mTasks.remove(removeIndex);
if (removedTask != task) { if (removedTask != task) {
// The added task is in recents so it is not hidden.
mHiddenTasks.remove(task);
if (removedTask.hasChild()) { if (removedTask.hasChild()) {
// A non-empty task is replaced by a new task. Because the removed task is no longer // A non-empty task is replaced by a new task. Because the removed task is no longer
// managed by the recent tasks list, add it to the hidden list to prevent the task // managed by the recent tasks list, add it to the hidden list to prevent the task

View File

@@ -464,15 +464,19 @@ public class RecentTasksTest extends ActivityTestsBase {
mRecentTasks.add(task1); mRecentTasks.add(task1);
final Task task2 = taskBuilder.apply(true /* visible */); final Task task2 = taskBuilder.apply(true /* visible */);
mRecentTasks.add(task2); mRecentTasks.add(task2);
// Only the last task is kept in recents and the previous 2 tasks will becomes untracked final Task task3 = createTaskBuilder(className).build();
mRecentTasks.add(task3);
// Only the last added task is kept in recents and the previous 2 tasks will become hidden
// tasks because their intents are identical. // tasks because their intents are identical.
mRecentTasks.add(createTaskBuilder(className).build()); mRecentTasks.add(task1);
// Go home to trigger the removal of untracked tasks. // Go home to trigger the removal of untracked tasks.
mRecentTasks.add(createTaskBuilder(".Home").setStack(mTaskContainer.getRootHomeTask()) mRecentTasks.add(createTaskBuilder(".Home").setStack(mTaskContainer.getRootHomeTask())
.build()); .build());
// The task was added into recents again so it is not hidden and shouldn't be removed.
assertNotNull(task1.getTopNonFinishingActivity());
// All activities in the invisible task should be finishing or removed. // All activities in the invisible task should be finishing or removed.
assertNull(task1.getTopNonFinishingActivity()); assertNull(task3.getTopNonFinishingActivity());
// The visible task should not be affected. // The visible task should not be affected.
assertNotNull(task2.getTopNonFinishingActivity()); assertNotNull(task2.getTopNonFinishingActivity());
} }