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

Commit 95487eb9 authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Some view not shown on the screen are reported for accessibility."

parents 108c0b99 aa6f3de2
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -4483,10 +4483,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        getDrawingRect(bounds);
        info.setBoundsInParent(bounds);
        int[] locationOnScreen = mAttachInfo.mInvalidateChildLocation;
        getLocationOnScreen(locationOnScreen);
        bounds.offsetTo(0, 0);
        bounds.offset(locationOnScreen[0], locationOnScreen[1]);
        getGlobalVisibleRect(bounds);
        bounds.offset(mAttachInfo.mWindowLeft, mAttachInfo.mWindowTop);
        info.setBoundsInScreen(bounds);
        if ((mPrivateFlags & IS_ROOT_NAMESPACE) == 0) {
+20 −7
Original line number Diff line number Diff line
@@ -5064,6 +5064,19 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    /**
     * Computes whether a view is visible on the screen.
     *
     * @param view The view to check.
     * @return Whether the view is visible on the screen.
     */
    private boolean isDisplayedOnScreen(View view) {
        return (view.mAttachInfo != null
                && view.mAttachInfo.mWindowVisibility == View.VISIBLE
                && view.getVisibility() == View.VISIBLE
                && view.getGlobalVisibleRect(mTempRect));
    }

    /**
     * Class for managing accessibility interactions initiated from the system
     * and targeting the view hierarchy. A *ClientThread method is to be
@@ -5175,7 +5188,7 @@ public final class ViewRootImpl implements ViewParent,
                } else {
                    target = findViewByAccessibilityId(accessibilityViewId);
                }
                if (target != null && target.getVisibility() == View.VISIBLE) {
                if (target != null && isDisplayedOnScreen(target)) {
                    getAccessibilityNodePrefetcher().prefetchAccessibilityNodeInfos(target,
                            virtualDescendantId, prefetchFlags, infos);
                }
@@ -5231,7 +5244,7 @@ public final class ViewRootImpl implements ViewParent,
                }
                if (root != null) {
                    View target = root.findViewById(viewId);
                    if (target != null && target.getVisibility() == View.VISIBLE) {
                    if (target != null && isDisplayedOnScreen(target)) {
                        info = target.createAccessibilityNodeInfo();
                    }
                }
@@ -5287,7 +5300,7 @@ public final class ViewRootImpl implements ViewParent,
                } else {
                    target = ViewRootImpl.this.mView;
                }
                if (target != null && target.getVisibility() == View.VISIBLE) {
                if (target != null && isDisplayedOnScreen(target)) {
                    AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
                    if (provider != null) {
                        infos = provider.findAccessibilityNodeInfosByText(text,
@@ -5304,7 +5317,7 @@ public final class ViewRootImpl implements ViewParent,
                            final int viewCount = foundViews.size();
                            for (int i = 0; i < viewCount; i++) {
                                View foundView = foundViews.get(i);
                                if (foundView.getVisibility() == View.VISIBLE) {
                                if (isDisplayedOnScreen(foundView)) {
                                    provider = foundView.getAccessibilityNodeProvider();
                                    if (provider != null) {
                                        List<AccessibilityNodeInfo> infosFromProvider =
@@ -5367,7 +5380,7 @@ public final class ViewRootImpl implements ViewParent,
            boolean succeeded = false;
            try {
                View target = findViewByAccessibilityId(accessibilityViewId);
                if (target != null && target.getVisibility() == View.VISIBLE) {
                if (target != null && isDisplayedOnScreen(target)) {
                    AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
                    if (provider != null) {
                        succeeded = provider.performAccessibilityAction(action,
@@ -5505,7 +5518,7 @@ public final class ViewRootImpl implements ViewParent,
                    View child = parentGroup.getChildAt(i);
                    if (outInfos.size() < MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE
                            && child.getAccessibilityViewId() != current.getAccessibilityViewId()
                            && child.getVisibility() == View.VISIBLE) {
                            && isDisplayedOnScreen(child)) {
                        final long childNodeId = AccessibilityNodeInfo.makeNodeId(
                                child.getAccessibilityViewId(), AccessibilityNodeInfo.UNDEFINED);
                        AccessibilityNodeInfo info = null;
@@ -5533,7 +5546,7 @@ public final class ViewRootImpl implements ViewParent,
                final int childCount = rootGroup.getChildCount();
                for (int i = 0; i < childCount; i++) {
                    View child = rootGroup.getChildAt(i);
                    if (child.getVisibility() == View.VISIBLE
                    if (isDisplayedOnScreen(child)
                            && outInfos.size() < MAX_ACCESSIBILITY_NODE_INFO_BATCH_SIZE) {
                        final long childNodeId = AccessibilityNodeInfo.makeNodeId(
                                child.getAccessibilityViewId(), AccessibilityNodeInfo.UNDEFINED);