Invisible views should not be visible to accessibility services (interrogation)

1. Infisible children of a ViewGroup are reported by View group
   while constructing an AccessibilityNodeInfo.

2. AncestorView does not check whether a found view is shown before
   returining it or perform action on it.

bug:4672230
Change-Id: Ic620ea71b7755c598407bdd813a2beeee400c89c
This commit is contained in:
Svetoslav Ganov
2011-06-15 17:16:02 -07:00
parent 13774d2e38
commit ea1da3d2e6
2 changed files with 11 additions and 7 deletions

View File

@@ -4407,7 +4407,7 @@ public final class ViewAncestor extends Handler implements ViewParent,
predicate.init(accessibilityId);
View root = ViewAncestor.this.mView;
View target = root.findViewByPredicate(predicate);
if (target != null) {
if (target != null && target.isShown()) {
info = target.createAccessibilityNodeInfo();
}
} finally {
@@ -4439,7 +4439,7 @@ public final class ViewAncestor extends Handler implements ViewParent,
try {
View root = ViewAncestor.this.mView;
View target = root.findViewById(viewId);
if (target != null) {
if (target != null && target.isShown()) {
info = target.createAccessibilityNodeInfo();
}
} finally {
@@ -4486,7 +4486,7 @@ public final class ViewAncestor extends Handler implements ViewParent,
root = ViewAncestor.this.mView;
}
if (root == null) {
if (root == null || !root.isShown()) {
return;
}
@@ -4501,7 +4501,9 @@ public final class ViewAncestor extends Handler implements ViewParent,
final int viewCount = foundViews.size();
for (int i = 0; i < viewCount; i++) {
View foundView = foundViews.get(i);
infos.add(foundView.createAccessibilityNodeInfo());
if (foundView.isShown()) {
infos.add(foundView.createAccessibilityNodeInfo());
}
}
} finally {
try {
@@ -4611,7 +4613,8 @@ public final class ViewAncestor extends Handler implements ViewParent,
return null;
}
mFindByAccessibilityIdPredicate.init(accessibilityId);
return root.findViewByPredicate(mFindByAccessibilityIdPredicate);
View foundView = root.findViewByPredicate(mFindByAccessibilityIdPredicate);
return (foundView != null && foundView.isShown()) ? foundView : null;
}
private final class FindByAccessibilitytIdPredicate implements Predicate<View> {

View File

@@ -2023,10 +2023,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
for (int i = 0, count = mChildrenCount; i < count; i++) {
View child = mChildren[i];
info.addChild(child);
if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
info.addChild(child);
}
}
}