Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea1da3d2 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

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
parent 13774d2e
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -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,8 +4501,10 @@ 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);
                    if (foundView.isShown()) {
                        infos.add(foundView.createAccessibilityNodeInfo());
                    }
                 }
            } finally {
                try {
                    callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
@@ -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> {
+3 −2
Original line number Diff line number Diff line
@@ -2023,12 +2023,13 @@ 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];
            if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
                info.addChild(child);
            }
        }
    }

    /**
     * {@inheritDoc}