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

Commit 91ea16cb authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add missing input flags to aidl and add missing definitions" into main

parents f96cbe2d c40f6e00
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ enum {
#ifdef __linux__
    /* This event was generated or modified by accessibility service. */
    AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
            android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT, // 0x800,
            android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
#else
    AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800,
#endif
@@ -54,11 +54,11 @@ enum {
    AKEY_EVENT_FLAG_START_TRACKING = 0x40000000,

    /* Key event is inconsistent with previously sent key events. */
    AKEY_EVENT_FLAG_TAINTED = 0x80000000,
    AKEY_EVENT_FLAG_TAINTED = android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED,
};

enum {

    // AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED is defined in include/android/input.h
    /**
     * This flag indicates that the window that received this motion event is partly
     * or wholly obscured by another visible window above it.  This flag is set to true
@@ -69,13 +69,16 @@ enum {
     * to drop the suspect touches or to take additional precautions to confirm the user's
     * actual intent.
     */
    AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2,

    AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED =
            android::os::IInputConstants::MOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED,
    AMOTION_EVENT_FLAG_HOVER_EXIT_PENDING =
            android::os::IInputConstants::MOTION_EVENT_FLAG_HOVER_EXIT_PENDING,
    /**
     * This flag indicates that the event has been generated by a gesture generator. It
     * provides a hint to the GestureDetector to not apply any touch slop.
     */
    AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE = 0x8,
    AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE =
            android::os::IInputConstants::MOTION_EVENT_FLAG_IS_GENERATED_GESTURE,

    /**
     * This flag indicates that the event will not cause a focus change if it is directed to an
@@ -83,20 +86,24 @@ enum {
     * gestures to allow the user to direct gestures to an unfocused window without bringing it
     * into focus.
     */
    AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40,
    AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE =
            android::os::IInputConstants::MOTION_EVENT_FLAG_NO_FOCUS_CHANGE,

#if defined(__linux__)
    /**
     * This event was generated or modified by accessibility service.
     */
    AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT =
            android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT, // 0x800,
            android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT,
#else
    AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800,
#endif

    AMOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS =
            android::os::IInputConstants::MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS,

    /* Motion event is inconsistent with previously sent motion events. */
    AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
    AMOTION_EVENT_FLAG_TAINTED = android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED,
};

/**
@@ -116,9 +123,10 @@ constexpr int32_t VERIFIED_MOTION_EVENT_FLAGS = AMOTION_EVENT_FLAG_WINDOW_IS_OBS
/**
 * This flag indicates that the point up event has been canceled.
 * Typically this is used for palm event when the user has accidental touches.
 * TODO: Adjust flag to public api
 * TODO(b/338143308): Add this to NDK
 */
constexpr int32_t AMOTION_EVENT_FLAG_CANCELED = 0x20;
constexpr int32_t AMOTION_EVENT_FLAG_CANCELED =
        android::os::IInputConstants::INPUT_EVENT_FLAG_CANCELED;

enum {
    /*
+1 −5
Original line number Diff line number Diff line
@@ -89,11 +89,6 @@ rust_bindgen {

    bindgen_flags: [
        "--verbose",
        "--allowlist-var=AMOTION_EVENT_FLAG_CANCELED",
        "--allowlist-var=AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED",
        "--allowlist-var=AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED",
        "--allowlist-var=AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT",
        "--allowlist-var=AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE",
        "--allowlist-var=AMOTION_EVENT_ACTION_CANCEL",
        "--allowlist-var=AMOTION_EVENT_ACTION_UP",
        "--allowlist-var=AMOTION_EVENT_ACTION_POINTER_DOWN",
@@ -246,6 +241,7 @@ cc_library {
    shared_libs: [
        "libbase",
        "libbinder",
        "libbinder_ndk",
        "libcutils",
        "liblog",
        "libPlatformProperties",
+93 −0
Original line number Diff line number Diff line
@@ -48,6 +48,73 @@ interface IInputConstants
     */
    const int POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000;

    /**
     * This flag indicates that the window that received this motion event is partly
     * or wholly obscured by another visible window above it and the event directly passed through
     * the obscured area.
     *
     * A security sensitive application can check this flag to identify situations in which
     * a malicious application may have covered up part of its content for the purpose
     * of misleading the user or hijacking touches.  An appropriate response might be
     * to drop the suspect touches or to take additional precautions to confirm the user's
     * actual intent.
     */
    const int MOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1;

    /**
     * This flag indicates that the window that received this motion event is partly
     * or wholly obscured by another visible window above it and the event did not directly pass
     * through the obscured area.
     *
     * A security sensitive application can check this flag to identify situations in which
     * a malicious application may have covered up part of its content for the purpose
     * of misleading the user or hijacking touches.  An appropriate response might be
     * to drop the suspect touches or to take additional precautions to confirm the user's
     * actual intent.
     *
     * Unlike FLAG_WINDOW_IS_OBSCURED, this is only true if the window that received this event is
     * obstructed in areas other than the touched location.
     */
    const int MOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2;

    /**
     * This private flag is only set on {@link #ACTION_HOVER_MOVE} events and indicates that
     * this event will be immediately followed by a {@link #ACTION_HOVER_EXIT}. It is used to
     * prevent generating redundant {@link #ACTION_HOVER_ENTER} events.
     * @hide
     */
    const int MOTION_EVENT_FLAG_HOVER_EXIT_PENDING = 0x4;

    /**
     * This flag indicates that the event has been generated by a gesture generator. It
     * provides a hint to the GestureDetector to not apply any touch slop.
     *
     * @hide
     */
    const int MOTION_EVENT_FLAG_IS_GENERATED_GESTURE = 0x8;

    /**
     * This flag is only set for events with {@link #ACTION_POINTER_UP} and {@link #ACTION_CANCEL}.
     * It indicates that the pointer going up was an unintentional user touch. When FLAG_CANCELED
     * is set, the typical actions that occur in response for a pointer going up (such as click
     * handlers, end of drawing) should be aborted. This flag is typically set when the user was
     * accidentally touching the screen, such as by gripping the device, or placing the palm on the
     * screen.
     *
     * @see #ACTION_POINTER_UP
     * @see #ACTION_CANCEL
     */
    const int INPUT_EVENT_FLAG_CANCELED = 0x20;

    /**
     * This flag indicates that the event will not cause a focus change if it is directed to an
     * unfocused window, even if it an {@link #ACTION_DOWN}. This is typically used with pointer
     * gestures to allow the user to direct gestures to an unfocused window without bringing the
     * window into focus.
     * @hide
     */
    const int MOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40;

    /**
     * The input event was generated or modified by accessibility service.
     * Shared by both KeyEvent and MotionEvent flags, so this value should not overlap with either
@@ -55,6 +122,32 @@ interface IInputConstants
     */
    const int INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800;

    /**
     * Private flag that indicates when the system has detected that this motion event
     * may be inconsistent with respect to the sequence of previously delivered motion events,
     * such as when a pointer move event is sent but the pointer is not down.
     *
     * @hide
     * @see #isTainted
     * @see #setTainted
     */
    const int INPUT_EVENT_FLAG_TAINTED = 0x80000000;

    /**
     * Private flag indicating that this event was synthesized by the system and should be delivered
     * to the accessibility focused view first. When being dispatched such an event is not handled
     * by predecessors of the accessibility focused view and after the event reaches that view the
     * flag is cleared and normal event dispatch is performed. This ensures that the platform can
     * click on any view that has accessibility focus which is semantically equivalent to asking the
     * view to perform a click accessibility action but more generic as views not implementing click
     * action correctly can still be activated.
     *
     * @hide
     * @see #isTargetAccessibilityFocus()
     * @see #setTargetAccessibilityFocus(boolean)
     */
    const int MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS = 0x40000000;

    /* The default pointer acceleration value. */
    const int DEFAULT_POINTER_ACCELERATION = 3;

+23 −12
Original line number Diff line number Diff line
@@ -17,6 +17,15 @@
//! Common definitions of the Android Input Framework in rust.

use bitflags::bitflags;
use inputconstants::aidl::android::os::IInputConstants::INPUT_EVENT_FLAG_CANCELED;
use inputconstants::aidl::android::os::IInputConstants::INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT;
use inputconstants::aidl::android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED;
use inputconstants::aidl::android::os::IInputConstants::MOTION_EVENT_FLAG_HOVER_EXIT_PENDING;
use inputconstants::aidl::android::os::IInputConstants::MOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
use inputconstants::aidl::android::os::IInputConstants::MOTION_EVENT_FLAG_NO_FOCUS_CHANGE;
use inputconstants::aidl::android::os::IInputConstants::MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS;
use inputconstants::aidl::android::os::IInputConstants::MOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
use inputconstants::aidl::android::os::IInputConstants::MOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
use std::fmt;

/// The InputDevice ID.
@@ -182,22 +191,24 @@ bitflags! {
    /// MotionEvent flags.
    #[derive(Debug)]
    pub struct MotionFlags: u32 {
        /// FLAG_CANCELED
        const CANCELED = input_bindgen::AMOTION_EVENT_FLAG_CANCELED as u32;
        /// FLAG_WINDOW_IS_OBSCURED
        const WINDOW_IS_OBSCURED = input_bindgen::AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED;
        const WINDOW_IS_OBSCURED = MOTION_EVENT_FLAG_WINDOW_IS_OBSCURED as u32;
        /// FLAG_WINDOW_IS_PARTIALLY_OBSCURED
        const WINDOW_IS_PARTIALLY_OBSCURED =
                input_bindgen::AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
        /// FLAG_IS_ACCESSIBILITY_EVENT
        const IS_ACCESSIBILITY_EVENT =
                input_bindgen::AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT;
        /// FLAG_NO_FOCUS_CHANGE
        const NO_FOCUS_CHANGE = input_bindgen::AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE;
        const WINDOW_IS_PARTIALLY_OBSCURED = MOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED as u32;
        /// FLAG_HOVER_EXIT_PENDING
        const HOVER_EXIT_PENDING = MOTION_EVENT_FLAG_HOVER_EXIT_PENDING as u32;
        /// FLAG_IS_GENERATED_GESTURE
        const IS_GENERATED_GESTURE = input_bindgen::AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
        const IS_GENERATED_GESTURE = MOTION_EVENT_FLAG_IS_GENERATED_GESTURE as u32;
        /// FLAG_CANCELED
        const CANCELED = INPUT_EVENT_FLAG_CANCELED as u32;
        /// FLAG_NO_FOCUS_CHANGE
        const NO_FOCUS_CHANGE = MOTION_EVENT_FLAG_NO_FOCUS_CHANGE as u32;
        /// FLAG_IS_ACCESSIBILITY_EVENT
        const IS_ACCESSIBILITY_EVENT = INPUT_EVENT_FLAG_IS_ACCESSIBILITY_EVENT as u32;
        /// FLAG_TAINTED
        const TAINTED = input_bindgen::AMOTION_EVENT_FLAG_TAINTED;
        const TAINTED = INPUT_EVENT_FLAG_TAINTED as u32;
        /// FLAG_TARGET_ACCESSIBILITY_FOCUS
        const TARGET_ACCESSIBILITY_FOCUS = MOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS as u32;
    }
}