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

Commit 81260f05 authored by Mady Mellor's avatar Mady Mellor
Browse files

Intercept back press for TaskView

This existed as part of MultiWindowTaskListener but got
lost at some point when that went away.
Adds a test to ensure TaskView sets to intercept.

Test: atest TaskViewTest
Fixes: 172362619
Change-Id: Ia84865b783966ded1257bd1cf3552a2255419234
parent c6eec7e5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
                // so go ahead and hide the task entirely
                updateTaskVisibility();
            }

            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(mTaskToken, true);
            // TODO: Synchronize show with the resize
            onLocationChanged();
            setResizeBackgroundColor(taskInfo.taskDescription.getBackgroundColor());
@@ -257,6 +257,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
            if (mListener != null) {
                mListener.onTaskRemovalStarted(taskInfo.taskId);
            }
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(mTaskToken, false);

            // Unparent the task when this surface is destroyed
            mTransaction.reparent(mTaskLeash, null).apply();
+15 −0
Original line number Diff line number Diff line
@@ -215,4 +215,19 @@ public class TaskViewTest extends ShellTestCase {

        verify(mViewListener).onBackPressedOnTaskRoot(eq(mTaskInfo.taskId));
    }

    @Test
    public void testSetOnBackPressedOnTaskRoot() {
        mTaskView.onTaskAppeared(mTaskInfo, mLeash);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));
    }

    @Test
    public void testUnsetOnBackPressedOnTaskRoot() {
        mTaskView.onTaskAppeared(mTaskInfo, mLeash);
        verify(mOrganizer).setInterceptBackPressedOnTaskRoot(eq(mTaskInfo.token), eq(true));

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