OSDN Git Service

Accessibility: ignore children of a view with node provider.
authorSvet Ganov <svetoslavganov@google.com>
Fri, 6 Feb 2015 20:41:17 +0000 (12:41 -0800)
committerSvet Ganov <svetoslavganov@google.com>
Fri, 6 Feb 2015 20:41:21 +0000 (12:41 -0800)
A view that has an accessibility node provider should not have real children
since the provider is responsible to generate the node infos for the subtree
rooted at its hosting view. This is how the APIs are designed to work. However,
it is a common mistake and if this occurs the accessibility services
introspecting the screen get into an infinite loop.

The framework now does not add the real children of a view with a node provider
to the list of accessibility children. If the developer wants them exposed they
have to do that via the provider APIs as per contract.

bug:19297093

Change-Id: I1b01b1e4a85e1c397886fcd2506b434beb063687

core/java/android/view/ViewGroup.java

index fd50c4d..1be2940 100644 (file)
@@ -2681,6 +2681,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
     @Override
     void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
         super.onInitializeAccessibilityNodeInfoInternal(info);
+        if (getAccessibilityNodeProvider() != null) {
+            return;
+        }
         if (mAttachInfo != null) {
             final ArrayList<View> childrenForAccessibility = mAttachInfo.mTempArrayList;
             childrenForAccessibility.clear();