Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ecc32d24 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents d51f4018 a9391ebe
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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
+7 −3
Original line number Diff line number Diff line
@@ -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());
    }