From 5f6523cdf4b534835de727aa83ca4cccb2ea19a0 Mon Sep 17 00:00:00 2001 From: Jorge Gil Date: Tue, 13 Oct 2020 21:06:09 +0000 Subject: [PATCH] Revert "Use out pipBounds to save reentry size" This reverts commit a6e524e127f960159aa631509c5b6d6b0baa2a86. Reason for revert: should not use current pipBounds as reentry bounds when the bounds are temporarily expanded due to active menu Bug: 170748861 Change-Id: I26a2ce4d9fb70db051b941ff09cdb423513b9ffc --- .../android/wm/shell/pip/phone/PipController.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index ea9c9609f6f59..41c0a881c0399 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -61,6 +61,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac private final DisplayInfo mTmpDisplayInfo = new DisplayInfo(); private final Rect mTmpInsetBounds = new Rect(); private final Rect mTmpNormalBounds = new Rect(); + protected final Rect mReentryBounds = new Rect(); private DisplayController mDisplayController; private PipAppOpsListener mAppOpsListener; @@ -395,7 +396,8 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac public void onPipTransitionStarted(ComponentName activity, int direction, Rect pipBounds) { if (isOutPipDirection(direction)) { // Exiting PIP, save the reentry bounds to restore to when re-entering. - mPipBoundsHandler.onSaveReentryBounds(activity, pipBounds); + updateReentryBounds(pipBounds); + mPipBoundsHandler.onSaveReentryBounds(activity, mReentryBounds); } // Disable touches while the animation is running mTouchHandler.setTouchEnabled(false); @@ -404,6 +406,16 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac } } + /** + * Update the bounds used to save the re-entry size and snap fraction when exiting PIP. + */ + public void updateReentryBounds(Rect bounds) { + final Rect reentryBounds = mTouchHandler.getUserResizeBounds(); + float snapFraction = mPipBoundsHandler.getSnapFraction(bounds); + mPipBoundsHandler.applySnapFraction(reentryBounds, snapFraction); + mReentryBounds.set(reentryBounds); + } + @Override public void onPipTransitionFinished(ComponentName activity, int direction) { onPipTransitionFinishedOrCanceled(direction);