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

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

Change-Id: I61cd9c14211aef59f13b9f5ba60ce9af185820cf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Mady Mellor
2023-05-10 00:32:26 +00:00
committed by Automerger Merge Worker
2 changed files with 32 additions and 0 deletions

View File

@@ -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);

View File

@@ -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));
}
}