Merge "Revert "Prevent recents from closing while moving PiP to fullscreen."" into nyc-dev
am: fa255f6

* commit 'fa255f6ead7097acba8400998c47685cc3defc67':
  Revert "Prevent recents from closing while moving PiP to fullscreen."

Change-Id: Iaf4f67f1dfac20235c99066d236102acad5e35d0
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
index 9842634..74f0cd3 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
@@ -267,6 +267,9 @@
     void movePipToFullscreen() {
         mState = STATE_NO_PIP;
         mPipTaskId = TASK_ID_NO_PIP;
+        for (int i = mListeners.size() - 1; i >= 0; --i) {
+            mListeners.get(i).onMoveToFullscreen();
+        }
         resizePinnedStack(mState);
     }
 
@@ -627,11 +630,6 @@
         public void onPinnedStackAnimationEnded() {
             if (DEBUG) Log.d(TAG, "onPinnedStackAnimationEnded()");
             switch (mState) {
-                case STATE_NO_PIP:
-                    for (int i = mListeners.size() - 1; i >= 0; --i) {
-                        mListeners.get(i).onMoveToFullscreen();
-                    }
-                    break;
                 case STATE_PIP_OVERLAY:
                     if (!mPipRecentsOverlayManager.isRecentsShown()) {
                         showPipOverlay();
diff --git a/services/core/java/com/android/server/wm/BoundsAnimationController.java b/services/core/java/com/android/server/wm/BoundsAnimationController.java
index 1f44b29..debb382 100644
--- a/services/core/java/com/android/server/wm/BoundsAnimationController.java
+++ b/services/core/java/com/android/server/wm/BoundsAnimationController.java
@@ -149,15 +149,11 @@
         public void onAnimationEnd(Animator animation) {
             if (DEBUG) Slog.d(TAG, "onAnimationEnd: mTarget=" + mTarget
                     + " mMoveToFullScreen=" + mMoveToFullScreen + " mWillReplace=" + mWillReplace);
+
+            finishAnimation();
             if (mMoveToFullScreen && !mWillReplace) {
                 mTarget.moveToFullscreen();
             }
-
-            // If we finish the animation before we move the target to fullscreen,
-            // recents may close itself and we may try and resume the previous
-            // fullscreen app leading to churn and flicker after we then move
-            // our target to fullscreen.
-            finishAnimation();
         }
 
         @Override