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: I762d38f2c4db980539dd92c3f64456a1d3c2bb41
This commit is contained in:
TreeHugger Robot
2020-06-30 03:31:06 +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) {
for (int i = mHiddenTasks.size() - 1; i >= 0; i--) {
final Task hiddenTask = mHiddenTasks.get(i);
if (!hiddenTask.hasChild()) {
// The task was removed by other path.
if (!hiddenTask.hasChild() || hiddenTask.inRecents) {
// The task was removed by other path or it became reachable (added to recents).
mHiddenTasks.remove(i);
continue;
}
@@ -1449,6 +1449,9 @@ class RecentTasks {
* of task as the given one.
*/
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);
if (removeIndex == -1) {
// Nothing to trim
@@ -1460,8 +1463,6 @@ class RecentTasks {
// callbacks here.
final Task removedTask = mTasks.remove(removeIndex);
if (removedTask != task) {
// The added task is in recents so it is not hidden.
mHiddenTasks.remove(task);
if (removedTask.hasChild()) {
// 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

View File

@@ -464,15 +464,19 @@ public class RecentTasksTest extends ActivityTestsBase {
mRecentTasks.add(task1);
final Task task2 = taskBuilder.apply(true /* visible */);
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.
mRecentTasks.add(createTaskBuilder(className).build());
mRecentTasks.add(task1);
// Go home to trigger the removal of untracked tasks.
mRecentTasks.add(createTaskBuilder(".Home").setStack(mTaskContainer.getRootHomeTask())
.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.
assertNull(task1.getTopNonFinishingActivity());
assertNull(task3.getTopNonFinishingActivity());
// The visible task should not be affected.
assertNotNull(task2.getTopNonFinishingActivity());
}