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

Commit f8bc9642 authored by Svetoslav's avatar Svetoslav
Browse files

Fixing some accessibility bugs.

1. Views not important for accessibility should not send events.

2. The base View implementation should not add it self to the
   list of children for accessibility.

3. Null pointer exception in AccessibilityNodeInfoCache.

Change-Id: Ie5b373362269200ead13ffe632679bd42ee40309
parent eb3a0fad
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -5022,7 +5022,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @param text The announcement text.
     */
    public void announceForAccessibility(CharSequence text) {
        if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) {
        if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null
                && isImportantForAccessibility()) {
            AccessibilityEvent event = AccessibilityEvent.obtain(
                    AccessibilityEvent.TYPE_ANNOUNCEMENT);
            onInitializeAccessibilityEvent(event);
@@ -5072,7 +5073,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Note: Called from the default {@link AccessibilityDelegate}.
     */
    void sendAccessibilityEventUncheckedInternal(AccessibilityEvent event) {
        if (!isShown()) {
        if (!isShown() || !isImportantForAccessibility()) {
            return;
        }
        onInitializeAccessibilityEvent(event);
@@ -7372,9 +7373,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @param children The list of children for accessibility.
     */
    public void addChildrenForAccessibility(ArrayList<View> children) {
        if (includeForAccessibility()) {
            children.add(this);
        }
    }
    /**
@@ -7388,7 +7387,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @hide
     */
    public boolean includeForAccessibility() {
        //noinspection SimplifiableIfStatement
        if (mAttachInfo != null) {
            return (mAttachInfo.mAccessibilityFetchFlags
                    & AccessibilityNodeInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0
+7 −5
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ public class AccessibilityNodeInfoCache {
                    // subtrees in the cache.
                    // TODO: Runs in O(n^2), could optimize to O(n + n log n)
                    final LongArray newChildrenIds = info.getChildNodeIds();
                    if (newChildrenIds != null) {
                        final int oldChildCount = oldInfo.getChildCount();
                        for (int i = 0; i < oldChildCount; i++) {
                            final long oldChildId = oldInfo.getChildId(i);
@@ -181,6 +182,7 @@ public class AccessibilityNodeInfoCache {
                                clearSubTreeLocked(oldChildId);
                            }
                        }
                    }

                    // Also be careful if the parent has changed since the new
                    // parent may be a predecessor of the old parent which will