From 8a1be9125beb41e22d59e55ce64627be1a2c2880 Mon Sep 17 00:00:00 2001 From: Daniel Norman Date: Thu, 6 Jul 2023 14:22:08 -0700 Subject: Tracks whether an injected MotionEvent came from an accessibility tool. This property can be checked by the View to allow sensitive views to ignore gestures injected by non-tool accessibility services. Sensitive views should continue responding to gestures injected by Accessibility Tools. Note: The files in this change do not reference the new flag, but this change is a no-op if the flag is not enabled. See other change in this topic. Bug: 284180538 Flag: android.view.accessibility.prevent_a11y_nontool_from_injecting_into_sensitive_views Test: atest InputDispatcher_test.cpp Test: See other change in topic for tests using this property Change-Id: I40ba79852045aaefe84f7ab87d5e08c42509f1e7 --- include/input/Input.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/input/Input.h b/include/input/Input.h index 2cabd56204..e84023e5e5 100644 --- a/include/input/Input.h +++ b/include/input/Input.h @@ -92,11 +92,23 @@ enum { static_cast(android::os::MotionEventFlag::NO_FOCUS_CHANGE), /** - * This event was generated or modified by accessibility service. + * This event was injected from some AccessibilityService, which may be either an + * Accessibility Tool OR a service using that API for purposes other than assisting users + * with disabilities. */ AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT = static_cast(android::os::MotionEventFlag::IS_ACCESSIBILITY_EVENT), + /** + * This event was injected from an AccessibilityService with the + * AccessibilityServiceInfo#isAccessibilityTool property set to true. These services (known as + * "Accessibility Tools") are used to assist users with disabilities, so events from these + * services should be able to reach all Views including Views which set + * View#isAccessibilityDataSensitive to true. + */ + AMOTION_EVENT_FLAG_INJECTED_FROM_ACCESSIBILITY_TOOL = + static_cast(android::os::MotionEventFlag::INJECTED_FROM_ACCESSIBILITY_TOOL), + AMOTION_EVENT_FLAG_TARGET_ACCESSIBILITY_FOCUS = static_cast(android::os::MotionEventFlag::TARGET_ACCESSIBILITY_FOCUS), @@ -347,6 +359,9 @@ enum { POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY = android::os::IInputConstants::POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY, + POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY_TOOL = + android::os::IInputConstants::POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY_TOOL, + /* These flags are set by the input dispatcher. */ // Indicates that the input event was injected. -- cgit v1.2.3-59-g8ed1b