Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsState.java +17 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Objects; import java.util.function.Consumer; /** * Singleton source of truth for the current state of PIP bounds. Loading Loading @@ -84,6 +85,7 @@ public final class PipBoundsState { private @Nullable Runnable mOnMinimalSizeChangeCallback; private @Nullable TriConsumer<Boolean, Integer, Boolean> mOnShelfVisibilityChangeCallback; private @Nullable Consumer<Rect> mOnPipExclusionBoundsChangeCallback; public PipBoundsState(@NonNull Context context) { mContext = context; Loading @@ -102,6 +104,9 @@ public final class PipBoundsState { /** Set the current PIP bounds. */ public void setBounds(@NonNull Rect bounds) { mBounds.set(bounds); if (mOnPipExclusionBoundsChangeCallback != null) { mOnPipExclusionBoundsChangeCallback.accept(bounds); } } /** Get the current PIP bounds. */ Loading Loading @@ -386,6 +391,18 @@ public final class PipBoundsState { mOnShelfVisibilityChangeCallback = onShelfVisibilityChangeCallback; } /** * Set a callback 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. */ public void setPipExclusionBoundsChangeCallback( @Nullable Consumer<Rect> onPipExclusionBoundsChangeCallback) { mOnPipExclusionBoundsChangeCallback = onPipExclusionBoundsChangeCallback; if (mOnPipExclusionBoundsChangeCallback != null) { mOnPipExclusionBoundsChangeCallback.accept(getBounds()); } } /** Source of truth for the current bounds of PIP that may be in motion. */ public static class MotionBoundsState { /** The bounds used when PIP is in motion (e.g. during a drag or animation) */ Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +2 −0 Original line number Diff line number Diff line Loading @@ -566,6 +566,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mInSwipePipToHomeTransition = false; mPictureInPictureParams = null; mState = State.UNDEFINED; // Re-set the PIP bounds to none. mPipBoundsState.setBounds(new Rect()); mPipUiEventLoggerLogger.setTaskInfo(null); mPipMenuController.detach(); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +1 −10 Original line number Diff line number Diff line Loading @@ -494,15 +494,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb mPipTaskOrganizer.stopSwipePipToHome(componentName, destinationBounds); } /** * 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. */ private void setPipExclusionBoundsChangeListener( Consumer<Rect> pipExclusionBoundsChangeListener) { mTouchHandler.setPipExclusionBoundsChangeListener(pipExclusionBoundsChangeListener); } @Override public void onPipTransitionStarted(int direction, Rect pipBounds) { if (isOutPipDirection(direction)) { Loading Loading @@ -712,7 +703,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb @Override public void setPipExclusionBoundsChangeListener(Consumer<Rect> listener) { mMainExecutor.execute(() -> { PipController.this.setPipExclusionBoundsChangeListener(listener); mPipBoundsState.setPipExclusionBoundsChangeCallback(listener); }); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java +1 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.os.Looper; import android.util.Log; import android.view.Choreographer; import androidx.annotation.VisibleForTesting; import androidx.dynamicanimation.animation.AnimationHandler; import androidx.dynamicanimation.animation.AnimationHandler.FrameCallbackScheduler; import androidx.dynamicanimation.animation.SpringForce; Loading Loading @@ -489,8 +488,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, /** * Animates the PiP to offset it from the IME or shelf. */ @VisibleForTesting public void animateToOffset(Rect originalBounds, int offset) { void animateToOffset(Rect originalBounds, int offset) { if (DEBUG) { Log.d(TAG, "animateToOffset: originalBounds=" + originalBounds + " offset=" + offset + " callers=\n" + Debug.getCallers(5, " ")); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +0 −26 Original line number Diff line number Diff line Loading @@ -57,8 +57,6 @@ import com.android.wm.shell.pip.PipTransitionController; 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 @@ -73,7 +71,6 @@ public class PipTouchHandler { // Allow PIP to resize to a slightly bigger state upon touch private boolean mEnableResize; private final Context mContext; private final PipTaskOrganizer mPipTaskOrganizer; private final PipBoundsAlgorithm mPipBoundsAlgorithm; private final @NonNull PipBoundsState mPipBoundsState; private final PipUiEventLogger mPipUiEventLogger; Loading @@ -81,7 +78,6 @@ public class PipTouchHandler { private final ShellExecutor mMainExecutor; private PipResizeGestureHandler mPipResizeGestureHandler; private WeakReference<Consumer<Rect>> mPipExclusionBoundsChangeListener; private final PhonePipMenuController mMenuController; private final AccessibilityManager mAccessibilityManager; Loading Loading @@ -170,7 +166,6 @@ public class PipTouchHandler { mContext = context; mMainExecutor = mainExecutor; mAccessibilityManager = context.getSystemService(AccessibilityManager.class); mPipTaskOrganizer = pipTaskOrganizer; mPipBoundsAlgorithm = pipBoundsAlgorithm; mPipBoundsState = pipBoundsState; mMenuController = menuController; Loading Loading @@ -290,11 +285,6 @@ 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 @@ -931,10 +921,6 @@ public class PipTouchHandler { } private void stashEndAction() { if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(mPipBoundsState.getBounds()); } if (mPipBoundsState.getBounds().left < 0 && mPipBoundsState.getStashedState() != STASH_TYPE_LEFT) { mPipUiEventLogger.log( Loading @@ -954,11 +940,6 @@ public class PipTouchHandler { // 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()); } } private boolean shouldStash(PointF vel, Rect motionBounds) { Loading @@ -982,13 +963,6 @@ public class PipTouchHandler { } } void setPipExclusionBoundsChangeListener(Consumer<Rect> pipExclusionBoundsChangeListener) { mPipExclusionBoundsChangeListener = new WeakReference<>(pipExclusionBoundsChangeListener); pipExclusionBoundsChangeListener.accept(mPipTaskOrganizer.isInPip() ? mPipBoundsState.getBounds() : new Rect()); } /** * Updates the current movement bounds based on whether the menu is currently visible and * resized. Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsState.java +17 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Objects; import java.util.function.Consumer; /** * Singleton source of truth for the current state of PIP bounds. Loading Loading @@ -84,6 +85,7 @@ public final class PipBoundsState { private @Nullable Runnable mOnMinimalSizeChangeCallback; private @Nullable TriConsumer<Boolean, Integer, Boolean> mOnShelfVisibilityChangeCallback; private @Nullable Consumer<Rect> mOnPipExclusionBoundsChangeCallback; public PipBoundsState(@NonNull Context context) { mContext = context; Loading @@ -102,6 +104,9 @@ public final class PipBoundsState { /** Set the current PIP bounds. */ public void setBounds(@NonNull Rect bounds) { mBounds.set(bounds); if (mOnPipExclusionBoundsChangeCallback != null) { mOnPipExclusionBoundsChangeCallback.accept(bounds); } } /** Get the current PIP bounds. */ Loading Loading @@ -386,6 +391,18 @@ public final class PipBoundsState { mOnShelfVisibilityChangeCallback = onShelfVisibilityChangeCallback; } /** * Set a callback 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. */ public void setPipExclusionBoundsChangeCallback( @Nullable Consumer<Rect> onPipExclusionBoundsChangeCallback) { mOnPipExclusionBoundsChangeCallback = onPipExclusionBoundsChangeCallback; if (mOnPipExclusionBoundsChangeCallback != null) { mOnPipExclusionBoundsChangeCallback.accept(getBounds()); } } /** Source of truth for the current bounds of PIP that may be in motion. */ public static class MotionBoundsState { /** The bounds used when PIP is in motion (e.g. during a drag or animation) */ Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +2 −0 Original line number Diff line number Diff line Loading @@ -566,6 +566,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, mInSwipePipToHomeTransition = false; mPictureInPictureParams = null; mState = State.UNDEFINED; // Re-set the PIP bounds to none. mPipBoundsState.setBounds(new Rect()); mPipUiEventLoggerLogger.setTaskInfo(null); mPipMenuController.detach(); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +1 −10 Original line number Diff line number Diff line Loading @@ -494,15 +494,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb mPipTaskOrganizer.stopSwipePipToHome(componentName, destinationBounds); } /** * 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. */ private void setPipExclusionBoundsChangeListener( Consumer<Rect> pipExclusionBoundsChangeListener) { mTouchHandler.setPipExclusionBoundsChangeListener(pipExclusionBoundsChangeListener); } @Override public void onPipTransitionStarted(int direction, Rect pipBounds) { if (isOutPipDirection(direction)) { Loading Loading @@ -712,7 +703,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb @Override public void setPipExclusionBoundsChangeListener(Consumer<Rect> listener) { mMainExecutor.execute(() -> { PipController.this.setPipExclusionBoundsChangeListener(listener); mPipBoundsState.setPipExclusionBoundsChangeCallback(listener); }); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java +1 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.os.Looper; import android.util.Log; import android.view.Choreographer; import androidx.annotation.VisibleForTesting; import androidx.dynamicanimation.animation.AnimationHandler; import androidx.dynamicanimation.animation.AnimationHandler.FrameCallbackScheduler; import androidx.dynamicanimation.animation.SpringForce; Loading Loading @@ -489,8 +488,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, /** * Animates the PiP to offset it from the IME or shelf. */ @VisibleForTesting public void animateToOffset(Rect originalBounds, int offset) { void animateToOffset(Rect originalBounds, int offset) { if (DEBUG) { Log.d(TAG, "animateToOffset: originalBounds=" + originalBounds + " offset=" + offset + " callers=\n" + Debug.getCallers(5, " ")); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +0 −26 Original line number Diff line number Diff line Loading @@ -57,8 +57,6 @@ import com.android.wm.shell.pip.PipTransitionController; 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 @@ -73,7 +71,6 @@ public class PipTouchHandler { // Allow PIP to resize to a slightly bigger state upon touch private boolean mEnableResize; private final Context mContext; private final PipTaskOrganizer mPipTaskOrganizer; private final PipBoundsAlgorithm mPipBoundsAlgorithm; private final @NonNull PipBoundsState mPipBoundsState; private final PipUiEventLogger mPipUiEventLogger; Loading @@ -81,7 +78,6 @@ public class PipTouchHandler { private final ShellExecutor mMainExecutor; private PipResizeGestureHandler mPipResizeGestureHandler; private WeakReference<Consumer<Rect>> mPipExclusionBoundsChangeListener; private final PhonePipMenuController mMenuController; private final AccessibilityManager mAccessibilityManager; Loading Loading @@ -170,7 +166,6 @@ public class PipTouchHandler { mContext = context; mMainExecutor = mainExecutor; mAccessibilityManager = context.getSystemService(AccessibilityManager.class); mPipTaskOrganizer = pipTaskOrganizer; mPipBoundsAlgorithm = pipBoundsAlgorithm; mPipBoundsState = pipBoundsState; mMenuController = menuController; Loading Loading @@ -290,11 +285,6 @@ 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 @@ -931,10 +921,6 @@ public class PipTouchHandler { } private void stashEndAction() { if (mPipExclusionBoundsChangeListener != null && mPipExclusionBoundsChangeListener.get() != null) { mPipExclusionBoundsChangeListener.get().accept(mPipBoundsState.getBounds()); } if (mPipBoundsState.getBounds().left < 0 && mPipBoundsState.getStashedState() != STASH_TYPE_LEFT) { mPipUiEventLogger.log( Loading @@ -954,11 +940,6 @@ public class PipTouchHandler { // 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()); } } private boolean shouldStash(PointF vel, Rect motionBounds) { Loading @@ -982,13 +963,6 @@ public class PipTouchHandler { } } void setPipExclusionBoundsChangeListener(Consumer<Rect> pipExclusionBoundsChangeListener) { mPipExclusionBoundsChangeListener = new WeakReference<>(pipExclusionBoundsChangeListener); pipExclusionBoundsChangeListener.accept(mPipTaskOrganizer.isInPip() ? mPipBoundsState.getBounds() : new Rect()); } /** * Updates the current movement bounds based on whether the menu is currently visible and * resized. Loading