From fa915cb52c2a8dea04928b2195f2d13c3deaabc9 Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Thu, 13 May 2021 12:00:27 -0700 Subject: [PATCH] Skip finishResize for non-exit animation if PIP is about to exit This handles the case were exitPip is called while there is a animateResize PIP ongoing, such the menu expand/unexpand animation. When that was the case, the first finishResize was applied at the same time as the exit WCT, resulting in bad frames at the end of the exit animation. This CL makes it so that the first finishResize is skipped if we know exitPip is handling the exit and will eventually call its own finishResize operation. Bug: 185306679 Test: enter PIP with YT, tap on menu to show it and immediately tap on the app launcher icon to expand PIP - verify the exit transtion runs smoothly Change-Id: I230a94b53d2a96331021c1ea49510caa92fa991e --- .../com/android/wm/shell/pip/PipTaskOrganizer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 4ce6c9e35e9ee..8d3c3e80913b3 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -184,8 +184,16 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mDeferredAnimEndTransaction = tx; return; } - finishResize(tx, destinationBounds, direction, animationType); - sendOnPipTransitionFinished(direction); + + if (mState != State.EXITING_PIP || direction == TRANSITION_DIRECTION_LEAVE_PIP) { + // Finish resize as long as we're not exiting PIP, or, if we are, only if this is + // the end of the leave PIP animation. + // This is necessary in case there was a resize animation ongoing when exit PIP + // started, in which case the first resize will be skipped to let the exit + // operation handle the final resize out of PIP mode. See b/185306679. + finishResize(tx, destinationBounds, direction, animationType); + sendOnPipTransitionFinished(direction); + } if (direction == TRANSITION_DIRECTION_TO_PIP) { // TODO (b//169221267): Add jank listener for transactions without buffer updates. //InteractionJankMonitor.getInstance().end(