From 8efa1655d95d7bf7bcd0d951494a660ad924de04 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 6 Jun 2018 09:34:23 -0700 Subject: [PATCH] Only use the pre-animation bounds when an animation is running and is set - Fix issue with NaN being calculated as the saved fraction due to the wrong bounds being used Bug: 109841835 Test: atest CtsActivityManagerDeviceTestCases:ActivityManagerPinnedStackTests Test: Repeatedly launch pip into fullscreen landscape app, and ensure that the saved snapfraction is calculated correctly Change-Id: I9b442cda636121164af1f3e66050894d06518439 --- .../java/com/android/server/wm/AppWindowToken.java | 14 +++++++++++++- .../android/server/wm/PinnedStackController.java | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index e45de459b0a70..08d0ae9dcdd88 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -1334,8 +1334,20 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree // for the next re-entry into PiP (assuming the activity is not hidden or destroyed) final TaskStack pinnedStack = mDisplayContent.getPinnedStack(); if (pinnedStack != null) { + final Rect stackBounds; + if (pinnedStack.lastAnimatingBoundsWasToFullscreen()) { + // We are animating the bounds, use the pre-animation bounds to save the snap + // fraction + stackBounds = pinnedStack.mPreAnimationBounds; + } else { + // We skip the animation if the fullscreen configuration is not compatible, so + // use the current bounds to calculate the saved snap fraction instead + // (see PinnedActivityStack.skipResizeAnimation()) + stackBounds = mTmpRect; + pinnedStack.getBounds(stackBounds); + } mDisplayContent.mPinnedStackControllerLocked.saveReentrySnapFraction(this, - pinnedStack.mPreAnimationBounds); + stackBounds); } } } diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java index 5f1916d4e5235..278d2b81991e7 100644 --- a/services/core/java/com/android/server/wm/PinnedStackController.java +++ b/services/core/java/com/android/server/wm/PinnedStackController.java @@ -589,6 +589,7 @@ class PinnedStackController { pw.println(prefix + " mImeHeight=" + mImeHeight); pw.println(prefix + " mIsShelfShowing=" + mIsShelfShowing); pw.println(prefix + " mShelfHeight=" + mShelfHeight); + pw.println(prefix + " mReentrySnapFraction=" + mReentrySnapFraction); pw.println(prefix + " mIsMinimized=" + mIsMinimized); if (mActions.isEmpty()) { pw.println(prefix + " mActions=[]"); @@ -601,6 +602,7 @@ class PinnedStackController { } pw.println(prefix + " ]"); } + pw.println(prefix + " mDisplayInfo=" + mDisplayInfo); } void writeToProto(ProtoOutputStream proto, long fieldId) {