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

Commit f0c758be authored by Svetoslav's avatar Svetoslav
Browse files

Update accessibility focused virtual view bounds.

We keep track of the accessibility focused virtual view in order to
draw the accessibility focus highlight. We were not updating this
virtual view when the view tree changes in a way that may affect
the virtial view's bounds in the screen.

bug:17211255

Change-Id: I69dd949b91ed9c8242521332081d50d75cac6921
parent def58cbf
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -6111,6 +6111,33 @@ public final class ViewRootImpl implements ViewParent,
                    }
                }
            } break;


            case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: {
                if (mAccessibilityFocusedHost != null && mAccessibilityFocusedVirtualView != null) {
                    // We care only for changes rooted in the focused host.
                    final long eventSourceId = event.getSourceNodeId();
                    final int hostViewId = AccessibilityNodeInfo.getAccessibilityViewId(
                            eventSourceId);
                    if (hostViewId != mAccessibilityFocusedHost.getAccessibilityViewId()) {
                        break;
                    }

                    // We only care about changes that may change the virtual focused view bounds.
                    final int changes = event.getContentChangeTypes();
                    if ((changes & AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE) != 0
                            || changes == AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED) {
                        AccessibilityNodeProvider provider = mAccessibilityFocusedHost
                                .getAccessibilityNodeProvider();
                        if (provider != null) {
                            final int virtualChildId = AccessibilityNodeInfo.getVirtualDescendantId(
                                    mAccessibilityFocusedVirtualView.getSourceNodeId());
                            mAccessibilityFocusedVirtualView = provider.createAccessibilityNodeInfo(
                                    virtualChildId);
                        }
                    }
                }
            } break;
        }
        mAccessibilityManager.sendAccessibilityEvent(event);
        return true;