More targeted version of "Correct animation glitch for pinned stack."

See the referenced CL "Correct animation glitch" for an explanation of
why an exception in this area is required. That CL based the exception
off the dummy animation state, however it seems we also enter this
state in various docked transitions but in that case the dummy animation
will have the incorrect transforms referenced by the original comment.
Now we target the fix on the bounds animating state instead.

Bug: 37448295
Bug: 36777039
Bug: 37511473
Test: Dock app from recents, no stretching. Auto-pip app, doesn't get stuck in top-left. Yay!
Change-Id: I5c9a7384622de9cedcc4be4dec7caacf58c683eb
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index e2f313a..b7a268c 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -666,8 +666,9 @@
                     }
                 }
             }
-            if ((!winAnimator.isAnimationStarting() && !winAnimator.isWaitingForOpening()) ||
-                    winAnimator.isDummyAnimation()) {
+            final TaskStack stack = w.getStack();
+            if ((!winAnimator.isAnimationStarting() && !winAnimator.isWaitingForOpening())
+                    || (stack != null && stack.isAnimatingBounds())) {
                 // Updates the shown frame before we set up the surface. This is needed
                 // because the resizing could change the top-left position (in addition to
                 // size) of the window. setSurfaceBoundariesLocked uses mShownPosition to
@@ -675,7 +676,10 @@
                 //
                 // If an animation is being started, we can't call this method because the
                 // animation hasn't processed its initial transformation yet, but in general
-                // we do want to update the position if the window is animating.
+                // we do want to update the position if the window is animating. We make an exception
+                // for the bounds animating state, where an application may have been waiting
+                // for an exit animation to start, but instead enters PiP. We need to ensure
+                // we always recompute the top-left in this case.
                 winAnimator.computeShownFrameLocked();
             }
             winAnimator.setSurfaceBoundariesLocked(mTmpRecoveringMemory /* recoveringMemory */);