From a5799f8a484788d4d1ee07226288784894a1b12b Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Mon, 1 Jul 2019 15:52:50 -0700 Subject: [PATCH] Ensure applying saved fraction when re-entering PiP 1. Resets PiP fraction once the app is stopped When in gesture navigation mode, setHidden can be called ahead of enterPictureInPictureMode, which results the fraction being reset before accessing the last saved value. 2. Do not set mBoundsAnimating* variables for FADE_IN animation Bug: 135224920 Test: Manually enter and exit PiP mode Change-Id: I93d77071d72a2695e510372dff3a48bf97209b8d --- .../java/com/android/server/wm/AppWindowToken.java | 7 ++----- .../core/java/com/android/server/wm/TaskStack.java | 10 +++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 8007c0f316e0d..ed32183512105 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -1015,6 +1015,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree void notifyAppStopped() { if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this); mAppStopped = true; + // Reset the last saved PiP snap fraction on app stop. + mDisplayContent.mPinnedStackControllerLocked.resetReentrySnapFraction(this); destroySurfaces(); // Remove any starting window that was added for this app if they are still around. removeStartingWindow(); @@ -3072,11 +3074,6 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree @Override void setHidden(boolean hidden) { super.setHidden(hidden); - - if (hidden) { - // Once the app window is hidden, reset the last saved PiP snap fraction - mDisplayContent.mPinnedStackControllerLocked.resetReentrySnapFraction(this); - } scheduleAnimation(); } diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index eb45e73d47a49..79367a050d464 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -321,7 +321,9 @@ public class TaskStack extends WindowContainer implements */ private void setAnimationFinalBounds(Rect sourceHintBounds, Rect destBounds, boolean toFullscreen) { - mBoundsAnimatingRequested = true; + if (mAnimationType == BoundsAnimationController.BOUNDS) { + mBoundsAnimatingRequested = true; + } mBoundsAnimatingToFullscreen = toFullscreen; if (destBounds != null) { mBoundsAnimationTarget.set(destBounds); @@ -1586,8 +1588,10 @@ public class TaskStack extends WindowContainer implements return false; } - mBoundsAnimatingRequested = false; - mBoundsAnimating = true; + if (animationType == BoundsAnimationController.BOUNDS) { + mBoundsAnimatingRequested = false; + mBoundsAnimating = true; + } mAnimationType = animationType; // If we are changing UI mode, as in the PiP to fullscreen