Set FLAG_IS_ACCESSIBILITY_EVENT for events injected from accessibility
If an input event was modified or injected by accessibility, set the
appropriate flag. This helps applications distinguish the real hardware
events from synthesized events.
This also allows a11y services more flexibility in modifying the event
streams coming from real hardware.
Bug: 152399927
Bug: 175069843
Test: atest inputflinger_tests libinput_tests
Change-Id: I805cba4c84582fa4cd4e0892ec00428d4b255ec6
diff --git a/include/input/Input.h b/include/input/Input.h
index e8678d2..f3369e8 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -43,6 +43,13 @@
* Additional private constants not defined in ndk/ui/input.h.
*/
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,
+#else
+ AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800;
+#endif
/* Signifies that the key is being predispatched */
AKEY_EVENT_FLAG_PREDISPATCH = 0x20000000,
@@ -81,6 +88,16 @@
*/
AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE = 0x40,
+#ifdef __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,
+#else
+ AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = 0x800;
+#endif
+
/* Motion event is inconsistent with previously sent motion events. */
AMOTION_EVENT_FLAG_TAINTED = 0x80000000,
};
@@ -89,14 +106,15 @@
* Allowed VerifiedKeyEvent flags. All other flags from KeyEvent do not get verified.
* These values must be kept in sync with VerifiedKeyEvent.java
*/
-constexpr int32_t VERIFIED_KEY_EVENT_FLAGS = AKEY_EVENT_FLAG_CANCELED;
+constexpr int32_t VERIFIED_KEY_EVENT_FLAGS =
+ AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT;
/**
* Allowed VerifiedMotionEventFlags. All other flags from MotionEvent do not get verified.
* These values must be kept in sync with VerifiedMotionEvent.java
*/
-constexpr int32_t VERIFIED_MOTION_EVENT_FLAGS =
- AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED | AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
+constexpr int32_t VERIFIED_MOTION_EVENT_FLAGS = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED |
+ AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED | AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT;
/**
* This flag indicates that the point up event has been canceled.
@@ -222,16 +240,14 @@
POLICY_FLAG_GESTURE = 0x00000008,
POLICY_FLAG_RAW_MASK = 0x0000ffff,
-#ifdef __linux__
- POLICY_FLAG_INPUTFILTER_TRUSTED = android::os::IInputConstants::POLICY_FLAG_INPUTFILTER_TRUSTED,
+#ifdef __linux__
POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY =
android::os::IInputConstants::POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY,
#else
- POLICY_FLAG_INPUTFILTER_TRUSTED = 0x10000,
-
POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = 0x20000,
#endif
+
/* These flags are set by the input dispatcher. */
// Indicates that the input event was injected.