diff options
| author | 2019-02-22 15:55:50 -0800 | |
|---|---|---|
| committer | 2019-02-22 15:55:50 -0800 | |
| commit | 24f953a6c21c6cfde196cbb0a60cd3a191998cdf (patch) | |
| tree | 9b3aa0f63da851fa408eba45bf245eeea482805d | |
| parent | 684632498cac0932ae09ee4b42070448380ad24b (diff) | |
| parent | 987ec033abd594b6a10717f0af4bb39b38e881b7 (diff) | |
Merge "Revert "Fix a11y cache correctness bug"" into pi-dev
am: 987ec033ab
Change-Id: I00d421256cbda478bf413a2195f14787d09d133c
| -rw-r--r-- | core/java/android/view/accessibility/AccessibilityCache.java | 14 | ||||
| -rw-r--r-- | core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java | 20 |
2 files changed, 3 insertions, 31 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java index 0e1e379d610a..da5a1cd67922 100644 --- a/core/java/android/view/accessibility/AccessibilityCache.java +++ b/core/java/android/view/accessibility/AccessibilityCache.java @@ -418,28 +418,20 @@ public class AccessibilityCache { * * @param nodes The nodes in the hosting window. * @param rootNodeId The id of the root to evict. - * - * @return {@code true} if the cache was cleared */ - private boolean clearSubTreeRecursiveLocked(LongSparseArray<AccessibilityNodeInfo> nodes, + private void clearSubTreeRecursiveLocked(LongSparseArray<AccessibilityNodeInfo> nodes, long rootNodeId) { AccessibilityNodeInfo current = nodes.get(rootNodeId); if (current == null) { - // The node isn't in the cache, but its descendents might be. - clear(); - return true; + return; } nodes.remove(rootNodeId); final int childCount = current.getChildCount(); for (int i = 0; i < childCount; i++) { final long childNodeId = current.getChildId(i); - if (clearSubTreeRecursiveLocked(nodes, childNodeId)) { - current.recycle(); - return true; - } + clearSubTreeRecursiveLocked(nodes, childNodeId); } current.recycle(); - return false; } /** diff --git a/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java b/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java index 993378d8a4d0..4de8155663f5 100644 --- a/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java +++ b/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java @@ -300,26 +300,6 @@ public class AccessibilityCacheTest { } @Test - public void subTreeChangeEventFromUncachedNode_clearsNodeInCache() { - AccessibilityNodeInfo nodeInfo = getNodeWithA11yAndWindowId(CHILD_VIEW_ID, WINDOW_ID_1); - long id = nodeInfo.getSourceNodeId(); - mAccessibilityCache.add(nodeInfo); - nodeInfo.recycle(); - - AccessibilityEvent event = AccessibilityEvent - .obtain(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); - event.setContentChangeTypes(AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE); - event.setSource(getMockViewWithA11yAndWindowIds(PARENT_VIEW_ID, WINDOW_ID_1)); - - mAccessibilityCache.onAccessibilityEvent(event); - AccessibilityNodeInfo shouldBeNull = mAccessibilityCache.getNode(WINDOW_ID_1, id); - if (shouldBeNull != null) { - shouldBeNull.recycle(); - } - assertNull(shouldBeNull); - } - - @Test public void scrollEvent_clearsNodeAndChild() { AccessibilityEvent event = AccessibilityEvent .obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED); |