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

Commit 324bade1 authored by Dmitry Vykochko's avatar Dmitry Vykochko
Browse files

Fix a11y focus rendering on non-dirty root view.

ViewRootImpl can receive TYPE_VIEW_ACCESSIBILITY_FOCUSED, which
means it should draw the a11y focus. But without any other
triggers (e.g. animation or scrolling) it is not being rendered.
This event invalidates the renderer, which makes the focus rectangle
dirty, but nothing make the draw() method of the view to be called.
Fixed by adding the whole view invalidation.

Fix: 264356970
Test: manual
Change-Id: I4073974551daf622a0c467bfb27df5f5a14ba82c
parent b3041c20
Loading
Loading
Loading
Loading
+23 −15
Original line number Diff line number Diff line
@@ -4856,20 +4856,12 @@ public final class ViewRootImpl implements ViewParent,
            dirty.offset(surfaceInsets.left, surfaceInsets.top);
        }

        boolean accessibilityFocusDirty = false;
        final Drawable drawable = mAttachInfo.mAccessibilityFocusDrawable;
        if (drawable != null) {
            final Rect bounds = mAttachInfo.mTmpInvalRect;
            final boolean hasFocus = getAccessibilityFocusedRect(bounds);
            if (!hasFocus) {
                bounds.setEmpty();
            }
            if (!bounds.equals(drawable.getBounds())) {
                accessibilityFocusDirty = true;
        boolean accessibilityFocusDirty = isAccessibilityFocusDirty();

        // Force recalculation of transparent regions
        if (accessibilityFocusDirty) {
            requestLayout();
        }
        }

        mAttachInfo.mDrawingTime =
                mChoreographer.getFrameTimeNanos() / TimeUtils.NANOS_PER_MS;
@@ -5415,8 +5407,9 @@ public final class ViewRootImpl implements ViewParent,
        mAccessibilityFocusedVirtualView = node;
        updateKeepClearForAccessibilityFocusRect();

        if (mAttachInfo.mThreadedRenderer != null) {
            mAttachInfo.mThreadedRenderer.invalidateRoot();
        requestInvalidateRootRenderNode();
        if (isAccessibilityFocusDirty()) {
            scheduleTraversals();
        }
    }

@@ -9781,6 +9774,21 @@ public final class ViewRootImpl implements ViewParent,
        return AccessibilityNodeIdManager.getInstance().findView(accessibilityViewId);
    }

    private boolean isAccessibilityFocusDirty() {
        final Drawable drawable = mAttachInfo.mAccessibilityFocusDrawable;
        if (drawable != null) {
            final Rect bounds = mAttachInfo.mTmpInvalRect;
            final boolean hasFocus = getAccessibilityFocusedRect(bounds);
            if (!hasFocus) {
                bounds.setEmpty();
            }
            if (!bounds.equals(drawable.getBounds())) {
                return true;
            }
        }
        return false;
    }

    /**
     * Updates the focused virtual view, when necessary, in response to a
     * content changed event.