Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +10 −9 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ public class PipResizeGestureHandler { private final PipBoundsAlgorithm mPipBoundsAlgorithm; private final PipMotionHelper mMotionHelper; private final PipBoundsState mPipBoundsState; private final PipTouchState mPipTouchState; private final PipTaskOrganizer mPipTaskOrganizer; private final PhonePipMenuController mPhonePipMenuController; private final PipDismissTargetHandler mPipDismissTargetHandler; Loading Loading @@ -104,7 +105,6 @@ public class PipResizeGestureHandler { private boolean mAllowGesture; private boolean mIsAttached; private boolean mIsEnabled; private boolean mEnableTouch; private boolean mEnablePinchResize; private boolean mEnableDragCornerResize; private boolean mIsSysUiStateValid; Loading @@ -122,7 +122,8 @@ public class PipResizeGestureHandler { public PipResizeGestureHandler(Context context, PipBoundsAlgorithm pipBoundsAlgorithm, PipBoundsState pipBoundsState, PipMotionHelper motionHelper, PipTaskOrganizer pipTaskOrganizer, PipDismissTargetHandler pipDismissTargetHandler, PipTouchState pipTouchState, PipTaskOrganizer pipTaskOrganizer, PipDismissTargetHandler pipDismissTargetHandler, Function<Rect, Rect> movementBoundsSupplier, Runnable updateMovementBoundsRunnable, PipUiEventLogger pipUiEventLogger, PhonePipMenuController menuActivityController, ShellExecutor mainExecutor) { Loading @@ -132,6 +133,7 @@ public class PipResizeGestureHandler { mPipBoundsAlgorithm = pipBoundsAlgorithm; mPipBoundsState = pipBoundsState; mMotionHelper = motionHelper; mPipTouchState = pipTouchState; mPipTaskOrganizer = pipTaskOrganizer; mPipDismissTargetHandler = pipDismissTargetHandler; mMovementBoundsSupplier = movementBoundsSupplier; Loading @@ -139,7 +141,6 @@ public class PipResizeGestureHandler { mPhonePipMenuController = menuActivityController; mPipUiEventLogger = pipUiEventLogger; mPinchResizingAlgorithm = new PipPinchResizingAlgorithm(); mEnableTouch = true; mUpdateResizeBoundsCallback = (rect) -> { mUserResizeBounds.set(rect); Loading Loading @@ -250,8 +251,8 @@ public class PipResizeGestureHandler { return; } if (!mEnableTouch) { // No need to handle anything if touches are not enabled for resizing. if (!mPipTouchState.getAllowInputEvents()) { // No need to handle anything if touches are not enabled return; } Loading Loading @@ -588,13 +589,13 @@ public class PipResizeGestureHandler { mLastResizeBounds, movementBounds); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); // disable the resizing until the final bounds are updated mEnableTouch = false; // disable any touch events beyond resizing too mPipTouchState.setAllowInputEvents(false); mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { // reset the pinch resizing to its default state mEnableTouch = true; // enable touch events mPipTouchState.setAllowInputEvents(true); }); } else { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +10 −5 Original line number Diff line number Diff line Loading @@ -199,11 +199,6 @@ public class PipTouchHandler { mMotionHelper = pipMotionHelper; mPipDismissTargetHandler = new PipDismissTargetHandler(context, pipUiEventLogger, mMotionHelper, mainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, pipTaskOrganizer, mPipDismissTargetHandler, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mTouchState = new PipTouchState(ViewConfiguration.get(context), () -> { if (mPipBoundsState.isStashed()) { Loading @@ -220,6 +215,11 @@ public class PipTouchHandler { }, menuController::hideMenu, mainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, mTouchState, pipTaskOrganizer, mPipDismissTargetHandler, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mConnection = new PipAccessibilityInteractionConnection(mContext, pipBoundsState, mMotionHelper, pipTaskOrganizer, mPipBoundsAlgorithm.getSnapAlgorithm(), this::onAccessibilityShowMenu, this::updateMovementBounds, Loading Loading @@ -556,6 +556,11 @@ public class PipTouchHandler { return true; } // do not process input event if not allowed if (!mTouchState.getAllowInputEvents()) { return true; } MotionEvent ev = (MotionEvent) inputEvent; if (!mPipBoundsState.isStashed() && mPipResizeGestureHandler.willStartResizeGesture(ev)) { // Initialize the touch state for the gesture, but immediately reset to invalidate the Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchState.java +17 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ public class PipTouchState { private final PointF mLastDelta = new PointF(); private final PointF mVelocity = new PointF(); private boolean mAllowTouches = true; // Set to false to block both PipTouchHandler and PipResizeGestureHandler's input processing private boolean mAllowInputEvents = true; private boolean mIsUserInteracting = false; // Set to true only if the multiple taps occur within the double tap timeout private boolean mIsDoubleTap = false; Loading @@ -76,6 +79,20 @@ public class PipTouchState { mMainExecutor = mainExecutor; } /** * @return true if input processing is enabled for PiP in general. */ public boolean getAllowInputEvents() { return mAllowInputEvents; } /** * @param allowInputEvents true to enable input processing for PiP in general. */ public void setAllowInputEvents(boolean allowInputEvents) { mAllowInputEvents = allowInputEvents; } /** * Resets this state. */ Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipResizeGestureHandlerTest.java +8 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.graphics.Rect; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.MotionEvent; import android.view.ViewConfiguration; import androidx.test.filters.SmallTest; Loading Loading @@ -90,6 +91,8 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { private PipDisplayLayoutState mPipDisplayLayoutState; private PipTouchState mPipTouchState; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); Loading @@ -104,8 +107,12 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { final PipMotionHelper motionHelper = new PipMotionHelper(mContext, mPipBoundsState, mPipTaskOrganizer, mPhonePipMenuController, pipSnapAlgorithm, mMockPipTransitionController, mFloatingContentCoordinator); mPipTouchState = new PipTouchState(ViewConfiguration.get(mContext), () -> {}, () -> {}, mMainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(mContext, pipBoundsAlgorithm, mPipBoundsState, motionHelper, mPipTaskOrganizer, mPipDismissTargetHandler, mPipBoundsState, motionHelper, mPipTouchState, mPipTaskOrganizer, mPipDismissTargetHandler, (Rect bounds) -> new Rect(), () -> {}, mPipUiEventLogger, mPhonePipMenuController, mMainExecutor) { @Override Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +10 −9 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ public class PipResizeGestureHandler { private final PipBoundsAlgorithm mPipBoundsAlgorithm; private final PipMotionHelper mMotionHelper; private final PipBoundsState mPipBoundsState; private final PipTouchState mPipTouchState; private final PipTaskOrganizer mPipTaskOrganizer; private final PhonePipMenuController mPhonePipMenuController; private final PipDismissTargetHandler mPipDismissTargetHandler; Loading Loading @@ -104,7 +105,6 @@ public class PipResizeGestureHandler { private boolean mAllowGesture; private boolean mIsAttached; private boolean mIsEnabled; private boolean mEnableTouch; private boolean mEnablePinchResize; private boolean mEnableDragCornerResize; private boolean mIsSysUiStateValid; Loading @@ -122,7 +122,8 @@ public class PipResizeGestureHandler { public PipResizeGestureHandler(Context context, PipBoundsAlgorithm pipBoundsAlgorithm, PipBoundsState pipBoundsState, PipMotionHelper motionHelper, PipTaskOrganizer pipTaskOrganizer, PipDismissTargetHandler pipDismissTargetHandler, PipTouchState pipTouchState, PipTaskOrganizer pipTaskOrganizer, PipDismissTargetHandler pipDismissTargetHandler, Function<Rect, Rect> movementBoundsSupplier, Runnable updateMovementBoundsRunnable, PipUiEventLogger pipUiEventLogger, PhonePipMenuController menuActivityController, ShellExecutor mainExecutor) { Loading @@ -132,6 +133,7 @@ public class PipResizeGestureHandler { mPipBoundsAlgorithm = pipBoundsAlgorithm; mPipBoundsState = pipBoundsState; mMotionHelper = motionHelper; mPipTouchState = pipTouchState; mPipTaskOrganizer = pipTaskOrganizer; mPipDismissTargetHandler = pipDismissTargetHandler; mMovementBoundsSupplier = movementBoundsSupplier; Loading @@ -139,7 +141,6 @@ public class PipResizeGestureHandler { mPhonePipMenuController = menuActivityController; mPipUiEventLogger = pipUiEventLogger; mPinchResizingAlgorithm = new PipPinchResizingAlgorithm(); mEnableTouch = true; mUpdateResizeBoundsCallback = (rect) -> { mUserResizeBounds.set(rect); Loading Loading @@ -250,8 +251,8 @@ public class PipResizeGestureHandler { return; } if (!mEnableTouch) { // No need to handle anything if touches are not enabled for resizing. if (!mPipTouchState.getAllowInputEvents()) { // No need to handle anything if touches are not enabled return; } Loading Loading @@ -588,13 +589,13 @@ public class PipResizeGestureHandler { mLastResizeBounds, movementBounds); mPipBoundsAlgorithm.applySnapFraction(mLastResizeBounds, snapFraction); // disable the resizing until the final bounds are updated mEnableTouch = false; // disable any touch events beyond resizing too mPipTouchState.setAllowInputEvents(false); mPipTaskOrganizer.scheduleAnimateResizePip(startBounds, mLastResizeBounds, PINCH_RESIZE_SNAP_DURATION, mAngle, mUpdateResizeBoundsCallback, () -> { // reset the pinch resizing to its default state mEnableTouch = true; // enable touch events mPipTouchState.setAllowInputEvents(true); }); } else { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +10 −5 Original line number Diff line number Diff line Loading @@ -199,11 +199,6 @@ public class PipTouchHandler { mMotionHelper = pipMotionHelper; mPipDismissTargetHandler = new PipDismissTargetHandler(context, pipUiEventLogger, mMotionHelper, mainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, pipTaskOrganizer, mPipDismissTargetHandler, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mTouchState = new PipTouchState(ViewConfiguration.get(context), () -> { if (mPipBoundsState.isStashed()) { Loading @@ -220,6 +215,11 @@ public class PipTouchHandler { }, menuController::hideMenu, mainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, mTouchState, pipTaskOrganizer, mPipDismissTargetHandler, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mConnection = new PipAccessibilityInteractionConnection(mContext, pipBoundsState, mMotionHelper, pipTaskOrganizer, mPipBoundsAlgorithm.getSnapAlgorithm(), this::onAccessibilityShowMenu, this::updateMovementBounds, Loading Loading @@ -556,6 +556,11 @@ public class PipTouchHandler { return true; } // do not process input event if not allowed if (!mTouchState.getAllowInputEvents()) { return true; } MotionEvent ev = (MotionEvent) inputEvent; if (!mPipBoundsState.isStashed() && mPipResizeGestureHandler.willStartResizeGesture(ev)) { // Initialize the touch state for the gesture, but immediately reset to invalidate the Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchState.java +17 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ public class PipTouchState { private final PointF mLastDelta = new PointF(); private final PointF mVelocity = new PointF(); private boolean mAllowTouches = true; // Set to false to block both PipTouchHandler and PipResizeGestureHandler's input processing private boolean mAllowInputEvents = true; private boolean mIsUserInteracting = false; // Set to true only if the multiple taps occur within the double tap timeout private boolean mIsDoubleTap = false; Loading @@ -76,6 +79,20 @@ public class PipTouchState { mMainExecutor = mainExecutor; } /** * @return true if input processing is enabled for PiP in general. */ public boolean getAllowInputEvents() { return mAllowInputEvents; } /** * @param allowInputEvents true to enable input processing for PiP in general. */ public void setAllowInputEvents(boolean allowInputEvents) { mAllowInputEvents = allowInputEvents; } /** * Resets this state. */ Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipResizeGestureHandlerTest.java +8 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.graphics.Rect; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.MotionEvent; import android.view.ViewConfiguration; import androidx.test.filters.SmallTest; Loading Loading @@ -90,6 +91,8 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { private PipDisplayLayoutState mPipDisplayLayoutState; private PipTouchState mPipTouchState; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); Loading @@ -104,8 +107,12 @@ public class PipResizeGestureHandlerTest extends ShellTestCase { final PipMotionHelper motionHelper = new PipMotionHelper(mContext, mPipBoundsState, mPipTaskOrganizer, mPhonePipMenuController, pipSnapAlgorithm, mMockPipTransitionController, mFloatingContentCoordinator); mPipTouchState = new PipTouchState(ViewConfiguration.get(mContext), () -> {}, () -> {}, mMainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(mContext, pipBoundsAlgorithm, mPipBoundsState, motionHelper, mPipTaskOrganizer, mPipDismissTargetHandler, mPipBoundsState, motionHelper, mPipTouchState, mPipTaskOrganizer, mPipDismissTargetHandler, (Rect bounds) -> new Rect(), () -> {}, mPipUiEventLogger, mPhonePipMenuController, mMainExecutor) { @Override Loading