From a6e524e127f960159aa631509c5b6d6b0baa2a86 Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Fri, 9 Oct 2020 15:18:10 -0700 Subject: [PATCH] Use out pipBounds to save reentry size Currently, when an out PIP transition happens we combine: (1) the last user resized bounds, plus (2) the out pipBounds fraction (mLastReportedBounds) Using both we create the reentry bounds used to restore on reentry. This is actually unnecessary since ag/12307605 and ag/12309037 both landed. They landed as separate efforts fixing different issues almost at the same time, so we didn't realize that getting the last user resized bounds was no longer necessary with the safe mLastReportedBounds (i.e. pipBounds) passed into onPipTransitionStarted. The pipBounds argument is equal to the last user resized size with the current fraction applied, so there's no need to re-calculate it, we can just use it directly. Bug: 169373982 Test: enter/exit pip and resize multiple times to verify the reentry size is correct. Change-Id: I2517d10bfbc8ca9c15b08b32089bdeeb1dd3aab6 --- .../android/wm/shell/pip/phone/PipController.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) 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 41c0a881c0399..ea9c9609f6f59 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,7 +61,6 @@ 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; @@ -396,8 +395,7 @@ 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. - updateReentryBounds(pipBounds); - mPipBoundsHandler.onSaveReentryBounds(activity, mReentryBounds); + mPipBoundsHandler.onSaveReentryBounds(activity, pipBounds); } // Disable touches while the animation is running mTouchHandler.setTouchEnabled(false); @@ -406,16 +404,6 @@ 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);