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

Commit 73d957e3 authored by Harry Cutts's avatar Harry Cutts Committed by Android (Google) Code Review
Browse files

Merge "input: add method to request specific pointer capture mode" into main

parents 665f055b a712240b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -54894,6 +54894,7 @@ package android.view {
    method public final boolean requestFocusFromTouch();
    method @CallSuper public void requestLayout();
    method public void requestPointerCapture();
    method @FlaggedApi("com.android.hardware.input.pointer_capture_modes") public void requestPointerCapture(int);
    method public boolean requestRectangleOnScreen(android.graphics.Rect);
    method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
    method @FlaggedApi("android.view.accessibility.request_rectangle_with_source") public boolean requestRectangleOnScreen(@NonNull android.graphics.Rect, boolean, int);
@@ -55205,6 +55206,8 @@ package android.view {
    field public static final int OVER_SCROLL_ALWAYS = 0; // 0x0
    field public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1; // 0x1
    field public static final int OVER_SCROLL_NEVER = 2; // 0x2
    field @FlaggedApi("com.android.hardware.input.pointer_capture_modes") public static final int POINTER_CAPTURE_MODE_ABSOLUTE = 1; // 0x1
    field @FlaggedApi("com.android.hardware.input.pointer_capture_modes") public static final int POINTER_CAPTURE_MODE_UNCAPTURED = 0; // 0x0
    field protected static final int[] PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET;
    field protected static final int[] PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET;
    field protected static final int[] PRESSED_ENABLED_FOCUSED_STATE_SET;
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.hardware.lights.Light;
import android.hardware.lights.LightState;
import android.os.IBinder;
import android.os.IVibratorStateListener;
import android.os.PointerCaptureMode;
import android.os.VibrationEffect;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
@@ -168,7 +169,7 @@ interface IInputManager {
    boolean setPointerIcon(in PointerIcon icon, int displayId, int deviceId, int pointerId,
            in IBinder inputToken);

    oneway void requestPointerCapture(IBinder inputChannelToken, boolean enabled);
    oneway void requestPointerCapture(IBinder inputChannelToken, PointerCaptureMode mode);

    /** Create an input monitor for gestures. */
    InputMonitor monitorGestureInput(IBinder token, String name, int displayId);
+9 −6
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.PointerIcon;
import android.view.VerifiedInputEvent;
import android.view.View;
import android.view.View.PointerCaptureMode;
import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
@@ -1100,16 +1102,17 @@ public final class InputManager {
    /**
     * Request or release pointer capture.
     * <p>
     * When in capturing mode, the pointer icon disappears and all mouse events are dispatched to
     * the window which has requested the capture. Relative position changes are available through
     * {@link MotionEvent#getX} and {@link MotionEvent#getY}.
     * When in capturing mode, the pointer icon disappears and all mouse and touchpad events are
     * dispatched to the window which has requested the capture.
     *
     * @param enable true when requesting pointer capture, false when releasing.
     * @param mode the capture mode to request.
     *
     * @see View#requestPointerCapture()
     *
     * @hide
     */
    public void requestPointerCapture(IBinder windowToken, boolean enable) {
        mGlobal.requestPointerCapture(windowToken, enable);
    public void requestPointerCapture(@NonNull IBinder windowToken, @PointerCaptureMode int mode) {
        mGlobal.requestPointerCapture(windowToken, mode);
    }

    /**
+12 −2
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ import android.view.InputMonitor;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.PointerIcon;
import android.view.View;
import android.view.View.PointerCaptureMode;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;

@@ -1752,9 +1754,17 @@ public final class InputManagerGlobal {
    /**
     * @see android.view.View#requestPointerCapture()
     */
    public void requestPointerCapture(IBinder windowToken, boolean enable) {
    public void requestPointerCapture(@NonNull IBinder windowToken, @PointerCaptureMode int mode) {
        // We need to check the mode is valid here too, since the binder call is oneway, so the
        // check in InputManagerService#requestPointerCapture would not result in the exception
        // being propagated to the caller.
        if (mode != View.POINTER_CAPTURE_MODE_UNCAPTURED
                && mode != View.POINTER_CAPTURE_MODE_ABSOLUTE) {
            throw new IllegalArgumentException("Invalid pointer capture mode " + mode);
        }

        try {
            mIm.requestPointerCapture(windowToken, enable);
            mIm.requestPointerCapture(windowToken, mode);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
+8 −0
Original line number Diff line number Diff line
@@ -223,3 +223,11 @@ flag {
    description: "Disable settings pages for virtual devices created using VDM or InputManager"
    bug: "402596982"
}

flag {
    name: "pointer_capture_modes"
    namespace: "input"
    description: "Enable pointer capture modes with different touchpad behaviours, and default to relative events from captured touchpads"
    is_exported: true
    bug: "403531245"
}
Loading