Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18cd8ae2 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Remove InputMonitor.pilferPointers API from Shell

This API is deprecated and should be removed.
The proper API is InputManager::pilferPointers.

This will also eventually allow us to properly handle InputChannel
lifecycle, and also will reduce the work needed to switch away from
InputMonitor completely.

Bug: 323450804
Test: presubmit
Flag: EXEMPT refactor
Change-Id: I529b44fc509319487df0f6a24ee1b47d0ac46485
parent 56e0b4dd
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ class BubblesNavBarGestureTracker {
    private static final String GESTURE_MONITOR = "bubbles-gesture";
    private final Context mContext;
    private final BubblePositioner mPositioner;
    private final InputManager mInputManager;

    @Nullable
    private InputMonitor mInputMonitor;
@@ -50,6 +51,7 @@ class BubblesNavBarGestureTracker {

    BubblesNavBarGestureTracker(Context context, BubblePositioner positioner) {
        mContext = context;
        mInputManager = mContext.getSystemService(InputManager.class);
        mPositioner = positioner;
    }

@@ -63,8 +65,7 @@ class BubblesNavBarGestureTracker {

        stopInternal();

        mInputMonitor = mContext.getSystemService(InputManager.class)
                .monitorGestureInput(GESTURE_MONITOR, mContext.getDisplayId());
        mInputMonitor = mInputManager.monitorGestureInput(GESTURE_MONITOR, mContext.getDisplayId());
        InputChannel inputChannel = mInputMonitor.getInputChannel();

        BubblesNavBarMotionEventHandler motionEventHandler =
@@ -92,8 +93,8 @@ class BubblesNavBarGestureTracker {

    private void onInterceptTouch() {
        ProtoLog.d(WM_SHELL_BUBBLES, "intercept touch event");
        if (mInputMonitor != null) {
            mInputMonitor.pilferPointers();
        if (mInputEventReceiver != null) {
            mInputManager.pilferPointers(mInputEventReceiver.getToken());
        }
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ public class PipResizeGestureHandler {
    private static final float PINCH_RESIZE_AUTO_MAX_RATIO = 0.9f;

    private final Context mContext;
    private final InputManager mInputManager;
    private final PipBoundsAlgorithm mPipBoundsAlgorithm;
    private final PipMotionHelper mMotionHelper;
    private final PipBoundsState mPipBoundsState;
@@ -136,6 +137,7 @@ public class PipResizeGestureHandler {
            PipUiEventLogger pipUiEventLogger, PhonePipMenuController menuActivityController,
            ShellExecutor mainExecutor, @Nullable PipPerfHintController pipPerfHintController) {
        mContext = context;
        mInputManager = mContext.getSystemService(InputManager.class);
        mDisplayId = context.getDisplayId();
        mMainExecutor = mainExecutor;
        mPipPerfHintController = pipPerfHintController;
@@ -227,8 +229,7 @@ public class PipResizeGestureHandler {

        if (mIsEnabled) {
            // Register input event receiver
            mInputMonitor = mContext.getSystemService(InputManager.class).monitorGestureInput(
                    "pip-resize", mDisplayId);
            mInputMonitor = mInputManager.monitorGestureInput("pip-resize", mDisplayId);
            try {
                mMainExecutor.executeBlocking(() -> {
                    mInputEventReceiver = new PipResizeInputEventReceiver(
@@ -509,7 +510,7 @@ public class PipResizeGestureHandler {
                        mThresholdCrossed = true;
                        // Reset the down to begin resizing from this point
                        mDownPoint.set(x, y);
                        mInputMonitor.pilferPointers();
                        mInputManager.pilferPointers(mInputEventReceiver.getToken());
                    }
                    if (mThresholdCrossed) {
                        if (mPhonePipMenuController.isMenuVisible()) {
@@ -637,10 +638,9 @@ public class PipResizeGestureHandler {

    @VisibleForTesting
    void pilferPointers() {
        mInputMonitor.pilferPointers();
        mInputManager.pilferPointers(mInputEventReceiver.getToken());
    }


    @VisibleForTesting public void updateMaxSize(int maxX, int maxY) {
        mMaxSize.set(maxX, maxY);
    }
+4 −2
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ public class PipResizeGestureHandler implements
    private static final String RESIZE_BOUNDS_CHANGE = "resize_bounds_change";

    private Context mContext;
    private final InputManager mInputManager;
    private final PipBoundsAlgorithm mPipBoundsAlgorithm;
    private final PipBoundsState mPipBoundsState;
    private final PipTouchState mPipTouchState;
@@ -133,6 +134,7 @@ public class PipResizeGestureHandler implements
            ShellExecutor mainExecutor,
            @Nullable PipPerfHintController pipPerfHintController) {
        mContext = context;
        mInputManager = mContext.getSystemService(InputManager.class);
        mSurfaceTransactionHelper = pipSurfaceTransactionHelper;
        mMainExecutor = mainExecutor;
        mPipPerfHintController = pipPerfHintController;
@@ -213,7 +215,7 @@ public class PipResizeGestureHandler implements

        if (mIsEnabled) {
            // Register input event receiver
            mInputMonitor = mContext.getSystemService(InputManager.class).monitorGestureInput(
            mInputMonitor = mInputManager.monitorGestureInput(
                    "pip-resize", mPipDisplayLayoutState.getDisplayId());
            try {
                mMainExecutor.executeBlocking(() -> {
@@ -476,7 +478,7 @@ public class PipResizeGestureHandler implements

    @VisibleForTesting
    void pilferPointers() {
        mInputMonitor.pilferPointers();
        mInputManager.pilferPointers(mInputEventReceiver.getToken());
    }

    void setOhmOffset(int offset) {