Skip to content

Commit 57f3b56

Browse files
committed
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
1 parent 2333a02 commit 57f3b56

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

core/java/android/view/View.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4122,10 +4122,12 @@ void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
41224122
bounds.offset(locationOnScreen[0], locationOnScreen[1]);
41234123
info.setBoundsInScreen(bounds);
41244124

4125-
ViewParent parent = getParent();
4126-
if (parent instanceof View) {
4127-
View parentView = (View) parent;
4128-
info.setParent(parentView);
4125+
if ((mPrivateFlags & IS_ROOT_NAMESPACE) == 0) {
4126+
ViewParent parent = getParent();
4127+
if (parent instanceof View) {
4128+
View parentView = (View) parent;
4129+
info.setParent(parentView);
4130+
}
41294131
}
41304132

41314133
info.setPackageName(mContext.getPackageName());

core/java/android/view/ViewGroup.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,14 +2231,10 @@ boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) {
22312231
@Override
22322232
void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
22332233
super.onInitializeAccessibilityNodeInfoInternal(info);
2234-
// If the view is not the topmost one in the view hierarchy and it is
2235-
// marked as the logical root of a view hierarchy, do not go any deeper.
2236-
if ((!(getParent() instanceof ViewRootImpl)) && (mPrivateFlags & IS_ROOT_NAMESPACE) != 0) {
2237-
return;
2238-
}
22392234
for (int i = 0, count = mChildrenCount; i < count; i++) {
22402235
View child = mChildren[i];
2241-
if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
2236+
if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE
2237+
&& (child.mPrivateFlags & IS_ROOT_NAMESPACE) == 0) {
22422238
info.addChild(child);
22432239
}
22442240
}

0 commit comments

Comments
 (0)