Make the task remove a wct

When dragging to dismiss bubbles while they're expanded there's a
bit of a hiccup when there's another bubble to select, removing the
task via a transition resolves this

Test: manual (with other CL):
    - have 5 bubbles, expand the stack, drag each bubble to the
      dismiss target
    => observe that the animation to select the next bubble when the
       current one is selected is smooth
Bug: 279074302
Change-Id: I9989112a4834c99ae4bfa5cee6f3bf60270197dd
This commit is contained in:
Mady Mellor
2023-04-21 12:01:58 -07:00
parent a346767333
commit f5824def39
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

@@ -98,7 +98,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();
}
@@ -397,6 +397,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).mVisible == visible) return;
if (taskView.getTaskInfo() == null) {
@@ -294,6 +302,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 "