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

Commit cf3257a6 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge "Return early in removeTask if there is no task token" into udc-dev am:...

Merge "Return early in removeTask if there is no task token" into udc-dev am: 0ea18527 am: be9ccf4c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23087090



Change-Id: I7421e02cf50431d48a4a598d61f99f79d60d64c4
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5bda05e6 be9ccf4c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.pm.ShortcutInfo;
import android.graphics.Rect;
import android.os.Binder;
import android.util.CloseGuard;
import android.util.Slog;
import android.view.SurfaceControl;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
@@ -49,6 +50,8 @@ import java.util.concurrent.Executor;
 */
public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {

    private static final String TAG = TaskViewTaskController.class.getSimpleName();

    private final CloseGuard mGuard = new CloseGuard();

    private final ShellTaskOrganizer mTaskOrganizer;
@@ -405,6 +408,11 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
     * Call to remove the task from window manager. This task will not appear in recents.
     */
    void removeTask() {
        if (mTaskToken == null) {
            // Call to remove task before we have one, do nothing
            Slog.w(TAG, "Trying to remove a task that was never added? (no taskToken)");
            return;
        }
        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.removeTask(mTaskToken);
        mTaskViewTransitions.closeTaskView(wct, this);
+24 −0
Original line number Diff line number Diff line
@@ -520,4 +520,28 @@ public class TaskViewTest extends ShellTestCase {
        verify(mTaskViewTransitions).updateVisibilityState(eq(mTaskViewTaskController), eq(false));
        verify(mTaskViewTransitions, never()).updateBoundsState(eq(mTaskViewTaskController), any());
    }

    @Test
    public void testRemoveTaskView_noTask() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);

        mTaskView.removeTask();
        verify(mTaskViewTransitions, never()).closeTaskView(any(), any());
    }

    @Test
    public void testRemoveTaskView() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);

        mTaskView.surfaceCreated(mock(SurfaceHolder.class));
        WindowContainerTransaction wct = new WindowContainerTransaction();
        mTaskViewTaskController.prepareOpenAnimation(true /* newTask */,
                new SurfaceControl.Transaction(), new SurfaceControl.Transaction(), mTaskInfo,
                mLeash, wct);

        verify(mViewListener).onTaskCreated(eq(mTaskInfo.taskId), any());

        mTaskView.removeTask();
        verify(mTaskViewTransitions).closeTaskView(any(), eq(mTaskViewTaskController));
    }
}