diff options
author | Svetoslav <svetoslavganov@google.com> | 2014-09-19 18:18:04 -0700 |
---|---|---|
committer | Svet Ganov <svetoslavganov@google.com> | 2014-09-19 19:21:55 -0700 |
commit | 13bd771c993f96a06add4057c5f5d5be7ac4b42a (patch) | |
tree | 25aaed61778a5cd604e1757f703765f7789e313d | |
parent | 688a994f4d156db6a9310c438545f014accba5ed (diff) | |
download | frameworks_base-13bd771c993f96a06add4057c5f5d5be7ac4b42a.zip frameworks_base-13bd771c993f96a06add4057c5f5d5be7ac4b42a.tar.gz frameworks_base-13bd771c993f96a06add4057c5f5d5be7ac4b42a.tar.bz2 |
Fix memory leak in accessibility cache.
We were not clearing the cache if window state change event
is fired which was the behavior before adding the window
inspection APIs. As a result if no accessibility service
cares about windows we get a leek. Also when the accessibiilty
service cares about windows we were not clearing all windows
nodes from the cache. Now if a windows change or a window
state change event is recived we clear the cache.
bug:17589257
Change-Id: I8c416fbcab623160c6f505128b9fca713fcc6623
-rw-r--r-- | core/java/android/view/accessibility/AccessibilityCache.java | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java index ead757e..a218e4d 100644 --- a/core/java/android/view/accessibility/AccessibilityCache.java +++ b/core/java/android/view/accessibility/AccessibilityCache.java @@ -63,22 +63,6 @@ final class AccessibilityCache { } } - public void clearWindows() { - synchronized (mLock) { - final int windowCount = mWindowCache.size(); - for (int i = windowCount - 1; i >= 0; i--) { - AccessibilityWindowInfo window = mWindowCache.valueAt(i); - if (window != null) { - if (DEBUG) { - Log.i(LOG_TAG, "Removing window: " + window.getId()); - } - window.recycle(); - mWindowCache.removeAt(i); - } - } - } - } - /** * Notifies the cache that the something in the UI changed. As a result * the cache will either refresh some nodes or evict some nodes. @@ -115,8 +99,9 @@ final class AccessibilityCache { clearSubTreeLocked(event.getWindowId(), event.getSourceNodeId()); } break; - case AccessibilityEvent.TYPE_WINDOWS_CHANGED: { - clearWindows(); + case AccessibilityEvent.TYPE_WINDOWS_CHANGED: + case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: { + clear(); } break; } } @@ -287,7 +272,7 @@ final class AccessibilityCache { private void clearNodesForWindowLocked(int windowId) { if (DEBUG) { - Log.i(LOG_TAG, "clearWindowLocked(" + windowId + ")"); + Log.i(LOG_TAG, "clearNodesForWindowLocked(" + windowId + ")"); } LongSparseArray<AccessibilityNodeInfo> nodes = mNodeCache.get(windowId); if (nodes == null) { @@ -440,7 +425,7 @@ final class AccessibilityCache { } } if (!childOfItsParent) { - Log.e(LOG_TAG, "Invalid parent-child ralation between parent: " + Log.e(LOG_TAG, "Invalid parent-child relation between parent: " + nodeParent + " and child: " + node); } } @@ -452,7 +437,7 @@ final class AccessibilityCache { if (child != null) { AccessibilityNodeInfo parent = nodes.get(child.getParentNodeId()); if (parent != node) { - Log.e(LOG_TAG, "Invalid child-parent ralation between child: " + Log.e(LOG_TAG, "Invalid child-parent relation between child: " + node + " and parent: " + nodeParent); } } |