From 57f3b566db630233087b121d3d43ecd81a6dfd95 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Mon, 31 Oct 2011 17:59:14 -0700 Subject: [PATCH] Accessibility window query APIs should respect root name space. 1. The window query API used to not-respect the root name space while traversing the parent relation i.e. a client was able to fetch the parent of a root name space node. 2. Children that are root name space were reported but their descendants not. Actually such children should not be reported since they are the root of a separate logical sub-tree. Such a tree is exposed by its root allowing its traversal. The accessibility APIs should be able to explore a virtual tree, i.e. one with a descendant which is root name space, only if an accessibility event from there was received. bug:5480096 Change-Id: I4c4d805aa2f6d4edba86eda213b5239bea83eed2 --- core/java/android/view/View.java | 10 ++++++---- core/java/android/view/ViewGroup.java | 8 ++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index fea79d55f0bc8..f4a971e25c394 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4122,10 +4122,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal bounds.offset(locationOnScreen[0], locationOnScreen[1]); info.setBoundsInScreen(bounds); - ViewParent parent = getParent(); - if (parent instanceof View) { - View parentView = (View) parent; - info.setParent(parentView); + if ((mPrivateFlags & IS_ROOT_NAMESPACE) == 0) { + ViewParent parent = getParent(); + if (parent instanceof View) { + View parentView = (View) parent; + info.setParent(parentView); + } } info.setPackageName(mContext.getPackageName()); diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 62b20b3196ed8..3d40ad2ff2731 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2231,14 +2231,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager @Override void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfoInternal(info); - // If the view is not the topmost one in the view hierarchy and it is - // marked as the logical root of a view hierarchy, do not go any deeper. - if ((!(getParent() instanceof ViewRootImpl)) && (mPrivateFlags & IS_ROOT_NAMESPACE) != 0) { - return; - } for (int i = 0, count = mChildrenCount; i < count; i++) { View child = mChildren[i]; - if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) { + if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE + && (child.mPrivateFlags & IS_ROOT_NAMESPACE) == 0) { info.addChild(child); } }