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

Commit 7f8eef19 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent TaskView's task from getting trimmed by Recents" into main

parents ab478e98 25072469
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -604,7 +604,6 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
                });
                });
            }
            }
            mTaskViewBase.onTaskVanished(taskInfo);
            mTaskViewBase.onTaskVanished(taskInfo);
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(taskInfo.token, false);
        }
        }
    }
    }


@@ -718,6 +717,9 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
            mTaskViewBase.setResizeBgColor(startTransaction, backgroundColor);
            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);
        mTaskViewBase.onTaskAppeared(mTaskInfo, mTaskLeash);
        if (mListener != null) {
        if (mListener != null) {
            final int taskId = mTaskInfo.taskId;
            final int taskId = mTaskInfo.taskId;
+10 −23
Original line number Original line Diff line number Diff line
@@ -293,16 +293,6 @@ public class TaskViewTest extends ShellTestCase {
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));
        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
    @Test
    public void testOnNewTask_noSurface() {
    public void testOnNewTask_noSurface() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);
@@ -442,19 +432,6 @@ public class TaskViewTest extends ShellTestCase {
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));
        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
    @Test
    public void testSetObscuredTouchRect() {
    public void testSetObscuredTouchRect() {
        mTaskView.setObscuredTouchRect(
        mTaskView.setObscuredTouchRect(
@@ -714,6 +691,16 @@ public class TaskViewTest extends ShellTestCase {
        verify(mTaskView).setResizeBackgroundColor(eq(Color.BLUE));
        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
    @Test
    public void testMoveToFullscreen_callsTaskRemovalStarted() {
    public void testMoveToFullscreen_callsTaskRemovalStarted() {
        WindowContainerTransaction wct = new WindowContainerTransaction();
        WindowContainerTransaction wct = new WindowContainerTransaction();