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

Commit 8d820ecf authored by Svetoslav's avatar Svetoslav
Browse files

Fixing bugs discovered by the CTS tests.

1. Delayed accessibility events sent when a view subtree changes may be
   be delivered after accessibility is disabled leading to a crash. It is
   possible that accessibility was disabled while we were waiting for
   the timeout before sending the event. Added a check before dispatching.

2. When refreshing a cached node the accessibility node info cache was
   not using the correct bypass cache argument value and as result was
   not getting the latest node but its cached value. We really want to
   get the latest state to update the cache.

3. The debugging cache integrity verification logic was incorrectly
   removing nodes from the cache while doing its work.

4. Removed the comments for some debug logging.

bug:9857067

Change-Id: I20ee1a6ffa65ad35457b51d3f2dc0bc5d8d784e6
parent 326ef35f
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -6435,11 +6435,17 @@ public final class ViewRootImpl implements ViewParent,
        public long mLastEventTimeMillis;

        public void run() {
            // The accessibility may be turned off while we were waiting so check again.
            if (AccessibilityManager.getInstance(mContext).isEnabled()) {
                mLastEventTimeMillis = SystemClock.uptimeMillis();
                AccessibilityEvent event = AccessibilityEvent.obtain();
                event.setEventType(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
                event.setContentChangeType(AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE);
                mSource.sendAccessibilityEventUnchecked(event);
            } else {
                mLastEventTimeMillis = 0;
            }
            // In any case reset to initial state.
            mSource.resetSubtreeAccessibilityStateChanged();
            mSource = null;
        }
+5 −7
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public class AccessibilityNodeInfoCache {

    private static final boolean ENABLED = true;

    private static final boolean DEBUG = true;
    private static final boolean DEBUG = false;

    private static final boolean CHECK_INTEGRITY_IF_DEBUGGABLE_BUILD = true;

@@ -108,7 +108,7 @@ public class AccessibilityNodeInfoCache {

    private void refreshCachedNode(long sourceId) {
        if (DEBUG) {
            Log.i(LOG_TAG, "Refresing cached node.");
            Log.i(LOG_TAG, "Refreshing cached node.");
        }
        synchronized (mLock) {
            AccessibilityNodeInfo cachedInfo = mCacheImpl.get(sourceId);
@@ -117,7 +117,7 @@ public class AccessibilityNodeInfoCache {
                return;
            }
            // The node changed so we will just refresh it right now.
            if (cachedInfo.refresh(false)) {
            if (cachedInfo.refresh(true)) {
                return;
            }
            // Weird, we could not refresh. Just evict the entire sub-tree.
@@ -141,7 +141,7 @@ public class AccessibilityNodeInfoCache {
                    info = AccessibilityNodeInfo.obtain(info);
                }
                if (DEBUG) {
//                    Log.i(LOG_TAG, "get(" + accessibilityNodeId + ") = " + info);
                    Log.i(LOG_TAG, "get(" + accessibilityNodeId + ") = " + info);
                }
                return info;
            }
@@ -159,7 +159,7 @@ public class AccessibilityNodeInfoCache {
        if (ENABLED) {
            synchronized(mLock) {
                if (DEBUG) {
//                    Log.i(LOG_TAG, "add(" + info + ")");
                    Log.i(LOG_TAG, "add(" + info + ")");
                }

                final long sourceId = info.getSourceNodeId();
@@ -319,8 +319,6 @@ public class AccessibilityNodeInfoCache {
                        Log.e(LOG_TAG, "Node from: " + info.getWindowId() + " not from:"
                                + windowId + " " + info);
                    }
                    mCacheImpl.removeAt(i);
                    i--;
                }
            }
        }