From 331a12188ad5d7043e410c7306452006744cef2e Mon Sep 17 00:00:00 2001 From: Daniel Norman Date: Thu, 25 Aug 2022 13:25:07 -0700 Subject: [PATCH] Rename ANI#makeQueryableFromAppProcess to enableQueryFromAppProcess. Bug: 243584378 Test: renamed in CTS tests Change-Id: I4c1ab6b758a5d146ae9e24a8b1276829584710fe --- core/api/current.txt | 2 +- core/java/android/view/ViewRootImpl.java | 2 +- .../accessibility/AccessibilityNodeInfo.java | 48 +++++++++++-------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index e0433399f3745..69d294d96c98a 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -51912,6 +51912,7 @@ package android.view.accessibility { method public void addChild(android.view.View, int); method public boolean canOpenPopup(); method public int describeContents(); + method public void enableQueryFromAppProcess(@NonNull android.view.View); method public java.util.List findAccessibilityNodeInfosByText(String); method public java.util.List findAccessibilityNodeInfosByViewId(@NonNull String); method public android.view.accessibility.AccessibilityNodeInfo findFocus(int); @@ -51979,7 +51980,6 @@ package android.view.accessibility { method public boolean isTextEntryKey(); method public boolean isTextSelectable(); method public boolean isVisibleToUser(); - method public void makeQueryableFromAppProcess(@NonNull android.view.View); method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View); method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View, int); method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo obtain(); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 59bc061f54aa6..303179c14065a 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -9574,7 +9574,7 @@ public final class ViewRootImpl implements ViewParent, /** * Return the connection ID for the {@link AccessibilityInteractionController} of this instance. - * @see AccessibilityNodeInfo#makeQueryableFromAppProcess(View) + * @see AccessibilityNodeInfo#enableQueryFromAppProcess(View) */ public int getDirectAccessibilityConnectionId() { return mAccessibilityInteractionConnectionManager.ensureDirectConnection(); diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 5d527500ff7bd..2ec52d3089492 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -84,7 +84,7 @@ import java.util.Objects; *

* Once an accessibility node info is delivered to an accessibility service it is * made immutable and calling a state mutation method generates an error. See - * {@link #makeQueryableFromAppProcess(View)} if you would like to inspect the + * {@link #enableQueryFromAppProcess(View)} if you would like to inspect the * node tree from the app process for testing or debugging tools. *

*

@@ -1160,7 +1160,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return The child node. * * @throws IllegalStateException If called outside of an {@link AccessibilityService} and before - * calling {@link #makeQueryableFromAppProcess(View)}. + * calling {@link #enableQueryFromAppProcess(View)}. */ public AccessibilityNodeInfo getChild(int index) { return getChild(index, FLAG_PREFETCH_DESCENDANTS_HYBRID); @@ -1175,7 +1175,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return The child node. * * @throws IllegalStateException If called outside of an {@link AccessibilityService} and before - * calling {@link #makeQueryableFromAppProcess(View)}. + * calling {@link #enableQueryFromAppProcess(View)}. * * @see AccessibilityNodeInfo#getParent(int) for a description of prefetching. */ @@ -1899,7 +1899,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return The parent. * * @throws IllegalStateException If called outside of an {@link AccessibilityService} and before - * calling {@link #makeQueryableFromAppProcess(View)}. + * calling {@link #enableQueryFromAppProcess(View)}. */ public AccessibilityNodeInfo getParent() { enforceSealed(); @@ -1928,7 +1928,7 @@ public class AccessibilityNodeInfo implements Parcelable { * @return The parent. * * @throws IllegalStateException If called outside of an {@link AccessibilityService} and before - * calling {@link #makeQueryableFromAppProcess(View)}. + * calling {@link #enableQueryFromAppProcess(View)}. * * @see #FLAG_PREFETCH_ANCESTORS * @see #FLAG_PREFETCH_DESCENDANTS_BREADTH_FIRST @@ -3654,29 +3654,39 @@ public class AccessibilityNodeInfo implements Parcelable { * {@link AccessibilityNodeInfo} tree and perform accessibility actions on nodes. * *

- * This is intended for short-lived inspections from testing or debugging tools in the app - * process. After calling this method, all nodes linked to this node (children, ancestors, etc.) - * are also queryable. Operations on this node tree will only succeed as long as the associated - * view hierarchy remains attached to a window. - *

- * - *

- * Calling this method more than once on the same node is a no-op; if you wish to inspect a - * different view hierarchy then create a new node from any view in that hierarchy and call this - * method on that node. - *

- * - *

* Testing or debugging tools should create this {@link AccessibilityNodeInfo} node using * {@link View#createAccessibilityNodeInfo()} or {@link AccessibilityNodeProvider} and call this * method, then navigate and interact with the node tree by calling methods on the node. + * Calling this method more than once on the same node is a no-op. After calling this method, + * all nodes linked to this node (children, ancestors, etc.) are also queryable. + *

+ * + *

+ * Here "query" refers to the following node operations: + *

  • check properties of this node (example: {@link #isScrollable()})
  • + *
  • find and query children (example: {@link #getChild(int)})
  • + *
  • find and query the parent (example: {@link #getParent()})
  • + *
  • find focus (examples: {@link #findFocus(int)}, {@link #focusSearch(int)})
  • + *
  • find and query other nodes (example: {@link #findAccessibilityNodeInfosByText(String)}, + * {@link #findAccessibilityNodeInfosByViewId(String)})
  • + *
  • perform actions (example: {@link #performAction(int)})
  • + *

    + * + *

    + * This is intended for short-lived inspections from testing or debugging tools in the app + * process, as operations on this node tree will only succeed as long as the associated + * view hierarchy remains attached to a window. Since {@link AccessibilityNodeInfo} objects can + * quickly become out of sync with their corresponding {@link View} objects there is + * intentionally no "disable" method: if you wish to inspect a changed or different view + * hierarchy then create a new node from any view in that hierarchy and call this method on that + * node. *

    * * @param view The view that generated this node, or any view in the same view-root hierarchy. * @throws IllegalStateException If called from an {@link AccessibilityService}, or if provided * a {@link View} that is not attached to a window. */ - public void makeQueryableFromAppProcess(@NonNull View view) { + public void enableQueryFromAppProcess(@NonNull View view) { enforceNotSealed(); if (mConnectionId != UNDEFINED_CONNECTION_ID) { return;