diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java index 5d451a5006e1e..7a6aec718006e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java @@ -173,7 +173,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, */ public void onLocationChanged() { getBoundsOnScreen(mTmpRect); - mTaskViewTaskController.onLocationChanged(mTmpRect); + mTaskViewTaskController.setWindowBounds(mTmpRect); } /** @@ -198,7 +198,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, public void surfaceChanged(@androidx.annotation.NonNull SurfaceHolder holder, int format, int width, int height) { getBoundsOnScreen(mTmpRect); - mTaskViewTaskController.surfaceChanged(mTmpRect); + mTaskViewTaskController.setWindowBounds(mTmpRect); } @Override diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java index 69ce35f434019..1f223a6ec5d06 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/TaskViewTaskController.java @@ -182,26 +182,6 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener { options.setRemoveWithTaskOrganizer(true); } - /** - * Call when view position or size has changed. Do not call when animating. - */ - public void onLocationChanged(Rect newBounds) { - if (mTaskToken == null) { - return; - } - // Sync Transactions can't operate simultaneously with shell transition collection. - // The transition animation (upon showing) will sync the location itself. - if (isUsingShellTransitions() && mTaskViewTransitions.hasPending()) return; - - WindowContainerTransaction wct = new WindowContainerTransaction(); - updateWindowBounds(wct); - mSyncQueue.queue(wct); - } - - private void updateWindowBounds(WindowContainerTransaction wct) { - wct.setBounds(mTaskToken, mTaskViewBase.getCurrentBoundsOnScreen()); - } - /** * Release this container if it is initialized. */ @@ -394,15 +374,24 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener { } /** - * Should be called when the client surface is changed. + * Sets the window bounds to {@code boundsOnScreen}. + * Call when view position or size has changed. Can also be called before the animation when + * the final bounds are known. + * Do not call during the animation. * * @param boundsOnScreen the on screen bounds of the surface view. */ - public void surfaceChanged(Rect boundsOnScreen) { + public void setWindowBounds(Rect boundsOnScreen) { if (mTaskToken == null) { return; } - onLocationChanged(boundsOnScreen); + // Sync Transactions can't operate simultaneously with shell transition collection. + // The transition animation (upon showing) will sync the location itself. + if (isUsingShellTransitions() && mTaskViewTransitions.hasPending()) return; + + WindowContainerTransaction wct = new WindowContainerTransaction(); + wct.setBounds(mTaskToken, boundsOnScreen); + mSyncQueue.queue(wct); } /** Should be called when the client surface is destroyed. */ @@ -493,7 +482,7 @@ public class TaskViewTaskController implements ShellTaskOrganizer.TaskListener { .setPosition(mTaskLeash, 0, 0) .apply(); - updateWindowBounds(wct); + wct.setBounds(mTaskToken, mTaskViewBase.getCurrentBoundsOnScreen()); } else { // The surface has already been destroyed before the task has appeared, // so go ahead and hide the task entirely