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

Commit 6cc4627d authored by Svetoslav's avatar Svetoslav
Browse files

Fix finding views by accessibility id.

1. If a view has a node provider, then the latter takes over
   representation of the view tree. Hence, find by accessibility
   id should not return children of a view with a provider.

2. Views can change their importantce for accessibility, so an
   accessibility service may get a node and try to act on it
   but the node became not important in the meantime. Hence,
   find by accessibility id should respect importance.

Change-Id: Ib4d738c00f46c91300605a2928550f40705ea47b
parent 3546c61b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -18291,7 +18291,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (accessibilityId < 0) {
            return null;
        }
        return findViewByAccessibilityIdTraversal(accessibilityId);
        View view = findViewByAccessibilityIdTraversal(accessibilityId);
        if (view != null) {
            return view.includeForAccessibility() ? view : null;
        }
        return null;
    }
    /**
+6 −0
Original line number Diff line number Diff line
@@ -1173,6 +1173,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        if (foundView != null) {
            return foundView;
        }

        if (getAccessibilityNodeProvider() != null) {
            return null;
        }

        final int childrenCount = mChildrenCount;
        final View[] children = mChildren;
        for (int i = 0; i < childrenCount; i++) {
@@ -1182,6 +1187,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                return foundView;
            }
        }

        return null;
    }