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

Commit be503699 authored by yingleiw's avatar yingleiw
Browse files

recreate a11y focused virtual node when findFocus

Added documentation that ViewRootImpl#mAccessibilityFocusedVirtualView
may be stale except for bounds and sourceNodeId. And recreate
the node when a11y services calls findFocus.

Checked other usages of mAccessibilityFocusedVirtualView(including
getter method) and verified they are OK.

Fix: b/192706021

Test: tested with Jetpack Compose progress indicator and radio button.
Without Jetpack Compose side workaround, this fix works well with
talkback google3 head.

Change-Id: I40c42011512e3d1fccd1ae8a16a62cbf500cf2ad
parent 3ec0a5a5
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -616,9 +616,12 @@ public final class AccessibilityInteractionController {
                        // focus instead fetching all provider nodes to do the search here.
                        AccessibilityNodeProvider provider = host.getAccessibilityNodeProvider();
                        if (provider != null) {
                            if (mViewRootImpl.mAccessibilityFocusedVirtualView != null) {
                                focused = AccessibilityNodeInfo.obtain(
                                        mViewRootImpl.mAccessibilityFocusedVirtualView);
                            final AccessibilityNodeInfo focusNode =
                                    mViewRootImpl.mAccessibilityFocusedVirtualView;
                            if (focusNode != null) {
                                final int virtualNodeId = AccessibilityNodeInfo
                                        .getVirtualDescendantId(focusNode.getSourceNodeId());
                                focused = provider.createAccessibilityNodeInfo(virtualNodeId);
                            }
                        } else if (virtualDescendantId == AccessibilityNodeProvider.HOST_VIEW_ID) {
                            focused = host.createAccessibilityNodeInfo();
+5 −0
Original line number Diff line number Diff line
@@ -396,6 +396,8 @@ public final class ViewRootImpl implements ViewParent,
    View mView;

    View mAccessibilityFocusedHost;
    // Accessibility-focused virtual view. The bounds and sourceNodeId of
    // mAccessibilityFocusedVirtualView is up-to-date while other fields may be stale.
    AccessibilityNodeInfo mAccessibilityFocusedVirtualView;

    // True if the window currently has pointer capture enabled.
@@ -4810,6 +4812,9 @@ public final class ViewRootImpl implements ViewParent,
    }

    /**
     * Get accessibility-focused virtual view. The bounds and sourceNodeId of the returned node is
     * up-to-date while other fields may be stale.
     *
     * @hide
     */
    @UnsupportedAppUsage