diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java index d5cf1dd0387dc..5afa53f557ba2 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java @@ -132,9 +132,6 @@ public class PipMenuActivityController { } case MESSAGE_EXPAND_PIP: { mListeners.forEach(l -> l.onPipExpand()); - // Preemptively mark the menu as invisible once we expand the PiP, but don't - // resize as we will be animating the stack - onMenuStateChanged(MENU_STATE_NONE, false /* resize */); break; } case MESSAGE_MINIMIZE_PIP: { @@ -143,9 +140,6 @@ public class PipMenuActivityController { } case MESSAGE_DISMISS_PIP: { mListeners.forEach(l -> l.onPipDismiss()); - // Preemptively mark the menu as invisible once we dismiss the PiP, but don't - // resize as we'll be removing the stack in place - onMenuStateChanged(MENU_STATE_NONE, false /* resize */); break; } case MESSAGE_SHOW_MENU: { @@ -307,6 +301,15 @@ public class PipMenuActivityController { } } + /** + * Preemptively mark the menu as invisible, used when we are directly manipulating the pinned + * stack and don't want to trigger a resize which can animate the stack in a conflicting way + * (ie. when manually expanding or dismissing). + */ + public void hideMenuWithoutResize() { + onMenuStateChanged(MENU_STATE_NONE, false /* resize */); + } + /** * @return the current menu state. */ diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java index 5121c8d0a3759..590e3c62e82ac 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java @@ -77,6 +77,7 @@ public class PipMotionHelper { private SurfaceFlingerVsyncChoreographer mVsyncChoreographer; private Handler mHandler; + private PipMenuActivityController mMenuController; private PipSnapAlgorithm mSnapAlgorithm; private FlingAnimationUtils mFlingAnimationUtils; @@ -93,10 +94,12 @@ public class PipMotionHelper { }; public PipMotionHelper(Context context, IActivityManager activityManager, - PipSnapAlgorithm snapAlgorithm, FlingAnimationUtils flingAnimationUtils) { + PipMenuActivityController menuController, PipSnapAlgorithm snapAlgorithm, + FlingAnimationUtils flingAnimationUtils) { mContext = context; mHandler = BackgroundThread.getHandler(); mActivityManager = activityManager; + mMenuController = menuController; mSnapAlgorithm = snapAlgorithm; mFlingAnimationUtils = flingAnimationUtils; mVsyncChoreographer = new SurfaceFlingerVsyncChoreographer(mHandler, mContext.getDisplay(), @@ -148,6 +151,7 @@ public class PipMotionHelper { */ void expandPip(boolean skipAnimation) { cancelAnimations(); + mMenuController.hideMenuWithoutResize(); mHandler.post(() -> { try { if (skipAnimation) { @@ -168,6 +172,7 @@ public class PipMotionHelper { */ void dismissPip() { cancelAnimations(); + mMenuController.hideMenuWithoutResize(); mHandler.post(() -> { try { mActivityManager.removeStack(PINNED_STACK_ID); diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java index 9c7e3986f8773..71d3d35eb5165 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java @@ -191,8 +191,8 @@ public class PipTouchHandler implements TunerService.Tunable { mGestures = new PipTouchGesture[] { mDefaultMovementGesture }; - mMotionHelper = new PipMotionHelper(mContext, mActivityManager, mSnapAlgorithm, - mFlingAnimationUtils); + mMotionHelper = new PipMotionHelper(mContext, mActivityManager, mMenuController, + mSnapAlgorithm, mFlingAnimationUtils); mExpandedShortestEdgeSize = context.getResources().getDimensionPixelSize( R.dimen.pip_expanded_shortest_edge_size);