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

Commit 3658233f authored by yingleiw's avatar yingleiw
Browse files

Update a11y focused virtual node properly

I noticed for most recent talkback (google3 version), when we focus
on the progress indcator in compose, the new progress is not announced when
progress changes. Instead, talkback always announce the progress
when the focus is placed. I debugged into it and see talkback has
some recent change on focus mananagement and the focus management
calls into a11y framework to get the focused node. And unfortunately,
the a11y focused node for virtual tree is not updated properly. And
the focus update always fills a11y cache with the old a11y info,
even though the new a11y info in a11y cache was updated by state
change event, it quickly get overriden by the stale value from
talkback focus management.

compose radio button is affected too (announcing not selected when
it is selected).

Test: tested with compose progress indicator and radio button. problem
fixed on google3 head talkback.

Change-Id: I2db8cbcf1da6bbcde146107df6407f917d8c8b23
parent 3ec0a5a5
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -9161,15 +9161,26 @@ public final class ViewRootImpl implements ViewParent,
            return;
        }

        // We only care about change types that may affect the bounds of the
        // focused virtual view.
        final long eventSourceNodeId = event.getSourceNodeId();
        final long focusedSourceNodeId = mAccessibilityFocusedVirtualView.getSourceNodeId();

        // Only change types that may affect the bounds of the focused virtual view should run
        // the update bounds logic after this if block.
        final int changes = event.getContentChangeTypes();
        if ((changes & AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE) == 0
                && changes != AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED) {
            // Now the changes(text, content description, state description) are local to this node.
            // If the focused virtual view changed, we need to update the
            // mAccessibilityFocusedVirtualView, otherwise A11y services will get stale value.
            if (eventSourceNodeId == focusedSourceNodeId) {
                int focusedChildId =
                        AccessibilityNodeInfo.getVirtualDescendantId(focusedSourceNodeId);
                mAccessibilityFocusedVirtualView =
                        provider.createAccessibilityNodeInfo(focusedChildId);
            }
            return;
        }

        final long eventSourceNodeId = event.getSourceNodeId();
        final int changedViewId = AccessibilityNodeInfo.getAccessibilityViewId(eventSourceNodeId);

        // Search up the tree for subtree containment.
@@ -9193,7 +9204,6 @@ public final class ViewRootImpl implements ViewParent,
            return;
        }

        final long focusedSourceNodeId = mAccessibilityFocusedVirtualView.getSourceNodeId();
        int focusedChildId = AccessibilityNodeInfo.getVirtualDescendantId(focusedSourceNodeId);

        // Refresh the node for the focused virtual view.