summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorPhil Weaver <pweaver@google.com>2018-10-03 18:23:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-10-03 18:23:47 +0000
commit3fbe56647cab174d4d78ee5d81c36a0dcdd6ea20 (patch)
treee6622296a5a7d54a98017b61b27f75de9dc5cd88 /core/java
parent37a944e88334a8d179de5be0750bb716354d227a (diff)
parent2f69c16c3dd0ea9522deebd9141ccc189b4a118e (diff)
Merge "Fix a11y cache correctness bug" into pi-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/accessibility/AccessibilityCache.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java
index da5a1cd67922..0e1e379d610a 100644
--- a/core/java/android/view/accessibility/AccessibilityCache.java
+++ b/core/java/android/view/accessibility/AccessibilityCache.java
@@ -418,20 +418,28 @@ 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 void clearSubTreeRecursiveLocked(LongSparseArray<AccessibilityNodeInfo> nodes,
+ private boolean clearSubTreeRecursiveLocked(LongSparseArray<AccessibilityNodeInfo> nodes,
long rootNodeId) {
AccessibilityNodeInfo current = nodes.get(rootNodeId);
if (current == null) {
- return;
+ // The node isn't in the cache, but its descendents might be.
+ clear();
+ return true;
}
nodes.remove(rootNodeId);
final int childCount = current.getChildCount();
for (int i = 0; i < childCount; i++) {
final long childNodeId = current.getChildId(i);
- clearSubTreeRecursiveLocked(nodes, childNodeId);
+ if (clearSubTreeRecursiveLocked(nodes, childNodeId)) {
+ current.recycle();
+ return true;
+ }
}
current.recycle();
+ return false;
}
/**