Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java +7 −0 Original line number Diff line number Diff line Loading @@ -184,4 +184,11 @@ public interface Pip { default void stopSwipePipToHome(ComponentName componentName, Rect destinationBounds) { return; } /** * Called by NavigationBar in order to listen in for PiP bounds change. This is mostly used * for times where the PiP bounds could conflict with SystemUI elements, such as a stashed * PiP and the Back-from-Edge gesture. */ default void setPipExclusionBoundsChangeListener(Consumer<Rect> listener) { } } libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +10 −0 Original line number Diff line number Diff line Loading @@ -472,6 +472,16 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac mReentryBounds.set(reentryBounds); } /** * Set a listener to watch out for PiP bounds. This is mostly used by SystemUI's * Back-gesture handler, to avoid conflicting with PiP when it's stashed. */ @Override public void setPipExclusionBoundsChangeListener( Consumer<Rect> pipExclusionBoundsChangeListener) { mTouchHandler.setPipExclusionBoundsChangeListener(pipExclusionBoundsChangeListener); } @Override public void onPipTransitionFinished(ComponentName activity, int direction) { onPipTransitionFinishedOrCanceled(direction); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java +32 −19 Original line number Diff line number Diff line Loading @@ -262,8 +262,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .spring(FloatProperties.RECT_X, toBounds.left, mSpringConfig) .spring(FloatProperties.RECT_Y, toBounds.top, mSpringConfig); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */, false /* dismiss */); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */); } } Loading Loading @@ -292,7 +291,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .spring(FloatProperties.RECT_HEIGHT, desiredHeight, mSpringConfig) .withEndActions(after); startBoundsAnimator(destinationX, destinationY, false); startBoundsAnimator(destinationX, destinationY); } /** Set whether we're springing-to-touch to catch up after being stuck in the dismiss target. */ Loading Loading @@ -364,21 +363,24 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, * Flings the PiP to the closest snap target. */ void flingToSnapTarget( float velocityX, float velocityY, @Nullable Runnable endAction) { movetoTarget(velocityX, velocityY, endAction, false /* isStash */); float velocityX, float velocityY, @Nullable Runnable postBoundsUpdateCallback) { movetoTarget(velocityX, velocityY, postBoundsUpdateCallback, false /* isStash */); } /** * Stash PiP to the closest edge. */ void stashToEdge( float velocityX, float velocityY, @Nullable Runnable endAction) { float velocityX, float velocityY, @Nullable Runnable postBoundsUpdateCallback) { mPipBoundsState.setStashed(velocityX < 0 ? STASH_TYPE_LEFT : STASH_TYPE_RIGHT); movetoTarget(velocityX, velocityY, endAction, true /* isStash */); movetoTarget(velocityX, velocityY, postBoundsUpdateCallback, true /* isStash */); } private void movetoTarget( float velocityX, float velocityY, @Nullable Runnable endAction, boolean isStash) { float velocityX, float velocityY, @Nullable Runnable postBoundsUpdateCallback, boolean isStash) { // If we're flinging to a snap target now, we're not springing to catch up to the touch // location now. mSpringingToTouch = false; Loading @@ -390,8 +392,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, FloatProperties.RECT_X, velocityX, isStash ? mStashConfigX : mFlingConfigX, mSpringConfig, true /* flingMustReachMinOrMax */) .flingThenSpring( FloatProperties.RECT_Y, velocityY, mFlingConfigY, mSpringConfig) .withEndActions(endAction); FloatProperties.RECT_Y, velocityY, mFlingConfigY, mSpringConfig); final float leftEdge = isStash ? mPipBoundsState.getStashOffset() - mPipBoundsState.getBounds().width() Loading @@ -407,7 +408,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, PhysicsAnimator.estimateFlingEndValue(startValueY, velocityY, mFlingConfigY); startBoundsAnimator(xEndValue /* toX */, estimatedFlingYEndValue /* toY */, false /* dismiss */); postBoundsUpdateCallback); } /** Loading @@ -423,8 +424,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mTemporaryBoundsPhysicsAnimator .spring(FloatProperties.RECT_X, bounds.left, springConfig) .spring(FloatProperties.RECT_Y, bounds.top, springConfig); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */, false /* dismiss */); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */); } /** Loading @@ -440,8 +440,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .withEndActions(this::dismissPip); startBoundsAnimator( getBounds().left /* toX */, getBounds().bottom + getBounds().height() /* toY */, true /* dismiss */); getBounds().left /* toX */, getBounds().bottom + getBounds().height() /* toY */); mDismissalPending = false; } Loading Loading @@ -516,14 +515,21 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mPipBoundsState.getDisplayBounds().right - mPipBoundsState.getStashOffset()); } private void startBoundsAnimator(float toX, float toY) { startBoundsAnimator(toX, toY, null /* postBoundsUpdateCallback */); } /** * Starts the physics animator which will update the animated PIP bounds using physics * animations, as well as the TimeAnimator which will apply those bounds to PIP. * * This will also add end actions to the bounds animator that cancel the TimeAnimator and update * the 'real' bounds to equal the final animated bounds. * * If one wishes to supply a callback after all the 'real' bounds update has happened, * pass @param postBoundsUpdateCallback. */ private void startBoundsAnimator(float toX, float toY, boolean dismiss) { private void startBoundsAnimator(float toX, float toY, Runnable postBoundsUpdateCallback) { if (!mSpringingToTouch) { cancelPhysicsAnimation(); } Loading @@ -535,10 +541,17 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, (int) toY + getBounds().height())); if (!mTemporaryBoundsPhysicsAnimator.isRunning()) { if (postBoundsUpdateCallback != null) { mTemporaryBoundsPhysicsAnimator .addUpdateListener(mResizePipUpdateListener) .withEndActions(this::onBoundsPhysicsAnimationEnd, postBoundsUpdateCallback); } else { mTemporaryBoundsPhysicsAnimator .addUpdateListener(mResizePipUpdateListener) .withEndActions(this::onBoundsPhysicsAnimationEnd); } } mTemporaryBoundsPhysicsAnimator.start(); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +26 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipUiEventLogger; import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.function.Consumer; /** * Manages all the touch handling for PIP on the Phone, including moving, dismissing and expanding Loading @@ -78,6 +80,7 @@ public class PipTouchHandler { private PipResizeGestureHandler mPipResizeGestureHandler; private IPinnedStackController mPinnedStackController; private WeakReference<Consumer<Rect>> mPipExclusionBoundsChangeListener; private final PipMenuActivityController mMenuController; private final AccessibilityManager mAccessibilityManager; Loading Loading @@ -259,6 +262,11 @@ public class PipTouchHandler { mFloatingContentCoordinator.onContentRemoved(mMotionHelper); } // Reset exclusion to none. if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(new Rect()); } mPipResizeGestureHandler.onActivityUnpinned(); } Loading Loading @@ -788,7 +796,7 @@ public class PipTouchHandler { if (mEnableStash && (animatingBounds.right > mPipBoundsState.getDisplayBounds().right || animatingBounds.left < mPipBoundsState.getDisplayBounds().left)) { mMotionHelper.stashToEdge(vel.x, vel.y, this::flingEndAction /* endAction */); mMotionHelper.stashToEdge(vel.x, vel.y, this::stashEndAction /* endAction */); } else { mMotionHelper.flingToSnapTarget(vel.x, vel.y, this::flingEndAction /* endAction */); Loading Loading @@ -829,14 +837,31 @@ public class PipTouchHandler { return true; } private void stashEndAction() { if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(mPipBoundsState.getBounds()); } } private void flingEndAction() { if (mShouldHideMenuAfterFling) { // If the menu is not visible, then we can still be showing the activity for the // dismiss overlay, so just finish it after the animation completes mMenuController.hideMenu(); } // Reset exclusion to none. if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(new Rect()); } } } void setPipExclusionBoundsChangeListener(Consumer<Rect> pipExclusionBoundsChangeListener) { mPipExclusionBoundsChangeListener = new WeakReference<>(pipExclusionBoundsChangeListener); pipExclusionBoundsChangeListener.accept(mPipBoundsState.getBounds()); } /** * Updates the current movement bounds based on whether the menu is currently visible and Loading packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java +3 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.systemui.statusbar.policy.DataSaverController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.util.leak.LeakDetector; import com.android.wm.shell.pip.Pip; import com.android.wm.shell.splitscreen.SplitScreen; import java.util.Optional; Loading Loading @@ -208,6 +209,7 @@ public class DependencyProvider { SysUiState sysUiFlagsContainer, BroadcastDispatcher broadcastDispatcher, CommandQueue commandQueue, Optional<Pip> pipOptional, Optional<SplitScreen> splitScreenOptional, Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy, Loading @@ -230,6 +232,7 @@ public class DependencyProvider { sysUiFlagsContainer, broadcastDispatcher, commandQueue, pipOptional, splitScreenOptional, recentsOptional, statusBarLazy, Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java +7 −0 Original line number Diff line number Diff line Loading @@ -184,4 +184,11 @@ public interface Pip { default void stopSwipePipToHome(ComponentName componentName, Rect destinationBounds) { return; } /** * Called by NavigationBar in order to listen in for PiP bounds change. This is mostly used * for times where the PiP bounds could conflict with SystemUI elements, such as a stashed * PiP and the Back-from-Edge gesture. */ default void setPipExclusionBoundsChangeListener(Consumer<Rect> listener) { } }
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +10 −0 Original line number Diff line number Diff line Loading @@ -472,6 +472,16 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac mReentryBounds.set(reentryBounds); } /** * Set a listener to watch out for PiP bounds. This is mostly used by SystemUI's * Back-gesture handler, to avoid conflicting with PiP when it's stashed. */ @Override public void setPipExclusionBoundsChangeListener( Consumer<Rect> pipExclusionBoundsChangeListener) { mTouchHandler.setPipExclusionBoundsChangeListener(pipExclusionBoundsChangeListener); } @Override public void onPipTransitionFinished(ComponentName activity, int direction) { onPipTransitionFinishedOrCanceled(direction); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java +32 −19 Original line number Diff line number Diff line Loading @@ -262,8 +262,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .spring(FloatProperties.RECT_X, toBounds.left, mSpringConfig) .spring(FloatProperties.RECT_Y, toBounds.top, mSpringConfig); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */, false /* dismiss */); startBoundsAnimator(toBounds.left /* toX */, toBounds.top /* toY */); } } Loading Loading @@ -292,7 +291,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .spring(FloatProperties.RECT_HEIGHT, desiredHeight, mSpringConfig) .withEndActions(after); startBoundsAnimator(destinationX, destinationY, false); startBoundsAnimator(destinationX, destinationY); } /** Set whether we're springing-to-touch to catch up after being stuck in the dismiss target. */ Loading Loading @@ -364,21 +363,24 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, * Flings the PiP to the closest snap target. */ void flingToSnapTarget( float velocityX, float velocityY, @Nullable Runnable endAction) { movetoTarget(velocityX, velocityY, endAction, false /* isStash */); float velocityX, float velocityY, @Nullable Runnable postBoundsUpdateCallback) { movetoTarget(velocityX, velocityY, postBoundsUpdateCallback, false /* isStash */); } /** * Stash PiP to the closest edge. */ void stashToEdge( float velocityX, float velocityY, @Nullable Runnable endAction) { float velocityX, float velocityY, @Nullable Runnable postBoundsUpdateCallback) { mPipBoundsState.setStashed(velocityX < 0 ? STASH_TYPE_LEFT : STASH_TYPE_RIGHT); movetoTarget(velocityX, velocityY, endAction, true /* isStash */); movetoTarget(velocityX, velocityY, postBoundsUpdateCallback, true /* isStash */); } private void movetoTarget( float velocityX, float velocityY, @Nullable Runnable endAction, boolean isStash) { float velocityX, float velocityY, @Nullable Runnable postBoundsUpdateCallback, boolean isStash) { // If we're flinging to a snap target now, we're not springing to catch up to the touch // location now. mSpringingToTouch = false; Loading @@ -390,8 +392,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, FloatProperties.RECT_X, velocityX, isStash ? mStashConfigX : mFlingConfigX, mSpringConfig, true /* flingMustReachMinOrMax */) .flingThenSpring( FloatProperties.RECT_Y, velocityY, mFlingConfigY, mSpringConfig) .withEndActions(endAction); FloatProperties.RECT_Y, velocityY, mFlingConfigY, mSpringConfig); final float leftEdge = isStash ? mPipBoundsState.getStashOffset() - mPipBoundsState.getBounds().width() Loading @@ -407,7 +408,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, PhysicsAnimator.estimateFlingEndValue(startValueY, velocityY, mFlingConfigY); startBoundsAnimator(xEndValue /* toX */, estimatedFlingYEndValue /* toY */, false /* dismiss */); postBoundsUpdateCallback); } /** Loading @@ -423,8 +424,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mTemporaryBoundsPhysicsAnimator .spring(FloatProperties.RECT_X, bounds.left, springConfig) .spring(FloatProperties.RECT_Y, bounds.top, springConfig); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */, false /* dismiss */); startBoundsAnimator(bounds.left /* toX */, bounds.top /* toY */); } /** Loading @@ -440,8 +440,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, .withEndActions(this::dismissPip); startBoundsAnimator( getBounds().left /* toX */, getBounds().bottom + getBounds().height() /* toY */, true /* dismiss */); getBounds().left /* toX */, getBounds().bottom + getBounds().height() /* toY */); mDismissalPending = false; } Loading Loading @@ -516,14 +515,21 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, mPipBoundsState.getDisplayBounds().right - mPipBoundsState.getStashOffset()); } private void startBoundsAnimator(float toX, float toY) { startBoundsAnimator(toX, toY, null /* postBoundsUpdateCallback */); } /** * Starts the physics animator which will update the animated PIP bounds using physics * animations, as well as the TimeAnimator which will apply those bounds to PIP. * * This will also add end actions to the bounds animator that cancel the TimeAnimator and update * the 'real' bounds to equal the final animated bounds. * * If one wishes to supply a callback after all the 'real' bounds update has happened, * pass @param postBoundsUpdateCallback. */ private void startBoundsAnimator(float toX, float toY, boolean dismiss) { private void startBoundsAnimator(float toX, float toY, Runnable postBoundsUpdateCallback) { if (!mSpringingToTouch) { cancelPhysicsAnimation(); } Loading @@ -535,10 +541,17 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, (int) toY + getBounds().height())); if (!mTemporaryBoundsPhysicsAnimator.isRunning()) { if (postBoundsUpdateCallback != null) { mTemporaryBoundsPhysicsAnimator .addUpdateListener(mResizePipUpdateListener) .withEndActions(this::onBoundsPhysicsAnimationEnd, postBoundsUpdateCallback); } else { mTemporaryBoundsPhysicsAnimator .addUpdateListener(mResizePipUpdateListener) .withEndActions(this::onBoundsPhysicsAnimationEnd); } } mTemporaryBoundsPhysicsAnimator.start(); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +26 −1 Original line number Diff line number Diff line Loading @@ -54,6 +54,8 @@ import com.android.wm.shell.pip.PipTaskOrganizer; import com.android.wm.shell.pip.PipUiEventLogger; import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.function.Consumer; /** * Manages all the touch handling for PIP on the Phone, including moving, dismissing and expanding Loading @@ -78,6 +80,7 @@ public class PipTouchHandler { private PipResizeGestureHandler mPipResizeGestureHandler; private IPinnedStackController mPinnedStackController; private WeakReference<Consumer<Rect>> mPipExclusionBoundsChangeListener; private final PipMenuActivityController mMenuController; private final AccessibilityManager mAccessibilityManager; Loading Loading @@ -259,6 +262,11 @@ public class PipTouchHandler { mFloatingContentCoordinator.onContentRemoved(mMotionHelper); } // Reset exclusion to none. if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(new Rect()); } mPipResizeGestureHandler.onActivityUnpinned(); } Loading Loading @@ -788,7 +796,7 @@ public class PipTouchHandler { if (mEnableStash && (animatingBounds.right > mPipBoundsState.getDisplayBounds().right || animatingBounds.left < mPipBoundsState.getDisplayBounds().left)) { mMotionHelper.stashToEdge(vel.x, vel.y, this::flingEndAction /* endAction */); mMotionHelper.stashToEdge(vel.x, vel.y, this::stashEndAction /* endAction */); } else { mMotionHelper.flingToSnapTarget(vel.x, vel.y, this::flingEndAction /* endAction */); Loading Loading @@ -829,14 +837,31 @@ public class PipTouchHandler { return true; } private void stashEndAction() { if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(mPipBoundsState.getBounds()); } } private void flingEndAction() { if (mShouldHideMenuAfterFling) { // If the menu is not visible, then we can still be showing the activity for the // dismiss overlay, so just finish it after the animation completes mMenuController.hideMenu(); } // Reset exclusion to none. if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(new Rect()); } } } void setPipExclusionBoundsChangeListener(Consumer<Rect> pipExclusionBoundsChangeListener) { mPipExclusionBoundsChangeListener = new WeakReference<>(pipExclusionBoundsChangeListener); pipExclusionBoundsChangeListener.accept(mPipBoundsState.getBounds()); } /** * Updates the current movement bounds based on whether the menu is currently visible and Loading
packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java +3 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.systemui.statusbar.policy.DataSaverController; import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.NetworkController; import com.android.systemui.util.leak.LeakDetector; import com.android.wm.shell.pip.Pip; import com.android.wm.shell.splitscreen.SplitScreen; import java.util.Optional; Loading Loading @@ -208,6 +209,7 @@ public class DependencyProvider { SysUiState sysUiFlagsContainer, BroadcastDispatcher broadcastDispatcher, CommandQueue commandQueue, Optional<Pip> pipOptional, Optional<SplitScreen> splitScreenOptional, Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy, Loading @@ -230,6 +232,7 @@ public class DependencyProvider { sysUiFlagsContainer, broadcastDispatcher, commandQueue, pipOptional, splitScreenOptional, recentsOptional, statusBarLazy, Loading