Merge "Make the task remove a wct" into udc-dev

This commit is contained in:
Mady Mellor
2023-05-04 14:58:56 +00:00
committed by Android (Google) Code Review
4 changed files with 43 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ import static com.android.wm.shell.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_EXPAND
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_BUBBLES;
import static com.android.wm.shell.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.wm.shell.bubbles.BubblePositioner.MAX_HEIGHT;
import static com.android.wm.shell.transition.Transitions.ENABLE_SHELL_TRANSITIONS;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
@@ -1057,13 +1058,21 @@ public class BubbleExpandedView extends LinearLayout {
Log.d(TAG, "cleanUpExpandedState: bubble=" + getBubbleKey() + " task=" + mTaskId);
}
if (getTaskId() != INVALID_TASK_ID) {
try {
ActivityTaskManager.getService().removeTask(getTaskId());
} catch (RemoteException e) {
Log.w(TAG, e.getMessage());
// Ensure the task is removed from WM
if (ENABLE_SHELL_TRANSITIONS) {
if (mTaskView != null) {
mTaskView.removeTask();
}
} else {
try {
ActivityTaskManager.getService().removeTask(getTaskId());
} catch (RemoteException e) {
Log.w(TAG, e.getMessage());
}
}
}
if (mTaskView != null) {
// Release the surface & other task view related things
mTaskView.release();
removeView(mTaskView);
mTaskView = null;

View File

@@ -176,6 +176,13 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
mTaskViewTaskController.setWindowBounds(mTmpRect);
}
/**
* Call to remove the task from window manager. This task will not appear in recents.
*/
public void removeTask() {
mTaskViewTaskController.removeTask();
}
/**
* Release this container if it is initialized.
*/

View File

@@ -102,7 +102,7 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
}
/** Until all users are converted, we may have mixed-use (eg. Car). */
private boolean isUsingShellTransitions() {
public boolean isUsingShellTransitions() {
return mTaskViewTransitions != null && mTaskViewTransitions.isEnabled();
}
@@ -401,6 +401,15 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener {
mSyncQueue.queue(wct);
}
/**
* Call to remove the task from window manager. This task will not appear in recents.
*/
void removeTask() {
WindowContainerTransaction wct = new WindowContainerTransaction();
wct.removeTask(mTaskToken);
mTaskViewTransitions.closeTaskView(wct, this);
}
/** Should be called when the client surface is destroyed. */
public void surfaceDestroyed() {
mSurfaceCreated = false;

View File

@@ -17,6 +17,7 @@
package com.android.wm.shell.taskview;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
@@ -201,6 +202,13 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
startNextTransition();
}
void closeTaskView(@NonNull WindowContainerTransaction wct,
@NonNull TaskViewTaskController taskView) {
updateVisibilityState(taskView, false /* visible */);
mPending.add(new PendingTransition(TRANSIT_CLOSE, wct, taskView, null /* cookie */));
startNextTransition();
}
void setTaskViewVisible(TaskViewTaskController taskView, boolean visible) {
if (mTaskViews.get(taskView) == null) return;
if (mTaskViews.get(taskView).mVisible == visible) return;
@@ -297,6 +305,11 @@ public class TaskViewTransitions implements Transitions.TransitionHandler {
if (TransitionUtil.isClosingType(chg.getMode())) {
final boolean isHide = chg.getMode() == TRANSIT_TO_BACK;
TaskViewTaskController tv = findTaskView(chg.getTaskInfo());
if (tv == null && !isHide) {
// TaskView can be null when closing
changesHandled++;
continue;
}
if (tv == null) {
if (pending != null) {
Slog.w(TAG, "Found a non-TaskView task in a TaskView Transition. This "