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

Commit 25072469 authored by Rachit Jain's avatar Rachit Jain
Browse files

Prevent TaskView's task from getting trimmed by Recents

- When moveTaskToFront() is called with the flag MOVE_TASK_WITH_HOME,
  recents trims the embedded task.
- Send a WindowContainerTransaction to make taskview's task as non-trimmable.
- TaskView's should manage the embedded task.
- Remove setInterceptBackPressedOnTaskRoot() from
  handleAndNotifyTaskRemoval() since it results in a no-op when the task
is being removed. Removed corresponding tests.

Bug: 358682563
Flag: EXEMPT (bug fix)
Test: open app grid, adb shell input keyevent KEYCODE_BACK, verify if embedded task opens
Test: atest CtsWindowManagerDeviceMultiDisplay:android.server.wm.multidisplay.MultiDisplayClientTests TaskViewTest
Change-Id: Ie07eab84293e0694fa6d2c07f056932c08ddff08
parent cf3cd4f6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -604,7 +604,6 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
                });
            }
            mTaskViewBase.onTaskVanished(taskInfo);
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(taskInfo.token, false);
        }
    }

@@ -718,6 +717,9 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
            mTaskViewBase.setResizeBgColor(startTransaction, backgroundColor);
        }

        // After the embedded task has appeared, set it to non-trimmable. This is important
        // to prevent recents from trimming and removing the embedded task.
        wct.setTaskTrimmableFromRecents(taskInfo.token, false /* isTrimmableFromRecents */);
        mTaskViewBase.onTaskAppeared(mTaskInfo, mTaskLeash);
        if (mListener != null) {
            final int taskId = mTaskInfo.taskId;
+10 −23
Original line number Diff line number Diff line
@@ -293,16 +293,6 @@ public class TaskViewTest extends ShellTestCase {
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));
    }

    @Test
    public void testUnsetOnBackPressedOnTaskRoot_legacyTransitions() {
        assumeFalse(Transitions.ENABLE_SHELL_TRANSITIONS);
        mTaskViewTaskController.onTaskAppeared(mTaskInfo, mLeash);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));

        mTaskViewTaskController.onTaskVanished(mTaskInfo);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(false));
    }

    @Test
    public void testOnNewTask_noSurface() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);
@@ -442,19 +432,6 @@ public class TaskViewTest extends ShellTestCase {
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));
    }

    @Test
    public void testUnsetOnBackPressedOnTaskRoot() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);
        WindowContainerTransaction wct = new WindowContainerTransaction();
        mTaskViewTaskController.prepareOpenAnimation(true /* newTask */,
                new SurfaceControl.Transaction(), new SurfaceControl.Transaction(), mTaskInfo,
                mLeash, wct);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));

        mTaskViewTaskController.prepareCloseAnimation();
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(false));
    }

    @Test
    public void testSetObscuredTouchRect() {
        mTaskView.setObscuredTouchRect(
@@ -714,6 +691,16 @@ public class TaskViewTest extends ShellTestCase {
        verify(mTaskView).setResizeBackgroundColor(eq(Color.BLUE));
    }

    @Test
    public void testOnAppeared_setsTrimmableTask() {
        WindowContainerTransaction wct = new WindowContainerTransaction();
        mTaskViewTaskController.prepareOpenAnimation(true /* newTask */,
                new SurfaceControl.Transaction(), new SurfaceControl.Transaction(), mTaskInfo,
                mLeash, wct);

        assertThat(wct.getHierarchyOps().get(0).isTrimmableFromRecents()).isFalse();
    }

    @Test
    public void testMoveToFullscreen_callsTaskRemovalStarted() {
        WindowContainerTransaction wct = new WindowContainerTransaction();