diff options
author | Svetoslav <svetoslavganov@google.com> | 2015-06-03 11:38:30 -0700 |
---|---|---|
committer | Svetoslav <svetoslavganov@google.com> | 2015-06-03 11:44:47 -0700 |
commit | 6cc4627d88932c93ce4c8821a5714b5382cd0425 (patch) | |
tree | 6600faf7089c2b4eac885d37cac9e2aa7de4b3c4 | |
parent | 3546c61b27eee218fc37581a3e0229b8646eb119 (diff) | |
download | frameworks_base-6cc4627d88932c93ce4c8821a5714b5382cd0425.zip frameworks_base-6cc4627d88932c93ce4c8821a5714b5382cd0425.tar.gz frameworks_base-6cc4627d88932c93ce4c8821a5714b5382cd0425.tar.bz2 |
Fix finding views by accessibility id.
1. If a view has a node provider, then the latter takes over
representation of the view tree. Hence, find by accessibility
id should not return children of a view with a provider.
2. Views can change their importantce for accessibility, so an
accessibility service may get a node and try to act on it
but the node became not important in the meantime. Hence,
find by accessibility id should respect importance.
Change-Id: Ib4d738c00f46c91300605a2928550f40705ea47b
-rw-r--r-- | core/java/android/view/View.java | 6 | ||||
-rw-r--r-- | core/java/android/view/ViewGroup.java | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index cfd504d..e3ad3cf 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -18291,7 +18291,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (accessibilityId < 0) { return null; } - return findViewByAccessibilityIdTraversal(accessibilityId); + View view = findViewByAccessibilityIdTraversal(accessibilityId); + if (view != null) { + return view.includeForAccessibility() ? view : null; + } + return null; } /** diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index e015c04..dd32f85 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -1173,6 +1173,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (foundView != null) { return foundView; } + + if (getAccessibilityNodeProvider() != null) { + return null; + } + final int childrenCount = mChildrenCount; final View[] children = mChildren; for (int i = 0; i < childrenCount; i++) { @@ -1182,6 +1187,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return foundView; } } + return null; } |