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

Commit 597af5da authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Preserve task when clearing top activities" into tm-dev

parents 12af01de 56ce0fa5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1630,12 +1630,16 @@ class Task extends TaskFragment {
    }

    ActivityRecord performClearTop(ActivityRecord newR, int launchFlags) {
        // The task should be preserved for putting new activity in case the last activity is
        // finished if it is normal launch mode and not single top ("clear-task-top").
        mReuseTask = true;
        mTaskSupervisor.beginDeferResume();
        final ActivityRecord result;
        try {
            result = clearTopActivities(newR, launchFlags);
        } finally {
            mTaskSupervisor.endDeferResume();
            mReuseTask = false;
        }
        return result;
    }
+14 −0
Original line number Diff line number Diff line
@@ -258,6 +258,20 @@ public class TaskTests extends WindowTestsBase {
        assertNull(task1.isInTask(activity2));
    }

    @Test
    public void testPerformClearTop() {
        final Task task = createTask(mDisplayContent);
        final ActivityRecord activity1 = new ActivityBuilder(mAtm).setTask(task).build();
        final ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(task).build();
        // Detach from process so the activities can be removed from hierarchy when finishing.
        activity1.detachFromProcess();
        activity2.detachFromProcess();
        assertNull(task.performClearTop(activity1, 0 /* launchFlags */));
        assertFalse(task.hasChild());
        // In real case, the task should be preserved for adding new activity.
        assertTrue(task.isAttached());
    }

    @Test
    public void testRemoveChildForOverlayTask() {
        final Task task = createTask(mDisplayContent);