From 97640b600a91d2f7ade00954fad58190b8572122 Mon Sep 17 00:00:00 2001 From: Sally Date: Thu, 9 Jun 2022 19:54:33 +0000 Subject: [PATCH] Add API warnings in AccessibilityManager Recommend that developers don't change UI or behavior based on accessibility checks. Bug: 235506503 Test: na Change-Id: I8e8b712a484a2b6dabe0f6c657766a0c1e21c92d --- .../accessibility/AccessibilityManager.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java index e89f836aaac13..7528e2a669265 100644 --- a/core/java/android/view/accessibility/AccessibilityManager.java +++ b/core/java/android/view/accessibility/AccessibilityManager.java @@ -585,6 +585,18 @@ public final class AccessibilityManager { /** * Returns if the accessibility in the system is enabled. + *

+ * Note: This query is used for sending {@link AccessibilityEvent}s, since events are + * only needed if accessibility is on. Avoid changing UI or app behavior based on the state of + * accessibility. While well-intentioned, doing this creates brittle, less + * well-maintained code that works for some users but not others. Shared code leads to more + * equitable experiences and less technical debt. + * + *

+ * For example, if you want to expose a unique interaction with your app, use + * ViewCompat#addAccessibilityAction in AndroidX to make this interaction - ideally + * with the same code path used for non-accessibility users - available to accessibility + * services. Services can then expose this action in the way best fit for their users. * * @return True if accessibility is enabled, false otherwise. */ @@ -597,6 +609,13 @@ public final class AccessibilityManager { /** * Returns if the touch exploration in the system is enabled. + *

+ * Note: This query is used for dispatching hover events, such as + * {@link android.view.MotionEvent#ACTION_HOVER_ENTER}, to accessibility services to manage + * touch exploration. Avoid changing UI or app behavior based on the state of accessibility. + * While well-intentioned, doing this creates brittle, less well-maintained code that works for + * som users but not others. Shared code leads to more equitable experiences and less technical + * debt. * * @return True if touch exploration is enabled, false otherwise. */