summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2011-10-28 12:41:38 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2011-10-28 12:41:42 -0700
commitaf5b4f471df108ffbe1c3861d18b2141710d7bf8 (patch)
tree7ce9d3c628fc167d9afc3530dae67cd8dc082be5
parent2333a02e152616c4b982c149ea2a5c9e9615e274 (diff)
downloadframeworks_base-af5b4f471df108ffbe1c3861d18b2141710d7bf8.zip
frameworks_base-af5b4f471df108ffbe1c3861d18b2141710d7bf8.tar.gz
frameworks_base-af5b4f471df108ffbe1c3861d18b2141710d7bf8.tar.bz2
Fixing a memory leak in accessibility enteraction APIs.
1. AccessibilityInteractionConnection was non-static inner class, hence keeping a handle to the enclosing ViewRootImpl resulting in leaking activities. bug:5525412 Change-Id: Ie438861663d623d503995844125d9e15d677fc32
-rw-r--r--core/java/android/view/ViewRootImpl.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index a36aecb..24423c3 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -4473,19 +4473,20 @@ public final class ViewRootImpl extends Handler implements ViewParent,
* AccessibilityManagerService to the latter can interact with
* the view hierarchy in this ViewAncestor.
*/
- final class AccessibilityInteractionConnection
+ static final class AccessibilityInteractionConnection
extends IAccessibilityInteractionConnection.Stub {
- private final WeakReference<ViewRootImpl> mViewAncestor;
+ private final WeakReference<ViewRootImpl> mRootImpl;
AccessibilityInteractionConnection(ViewRootImpl viewAncestor) {
- mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
+ mRootImpl = new WeakReference<ViewRootImpl>(viewAncestor);
}
public void findAccessibilityNodeInfoByAccessibilityId(int accessibilityId,
int interactionId, IAccessibilityInteractionConnectionCallback callback,
int interrogatingPid, long interrogatingTid) {
- if (mViewAncestor.get() != null) {
- getAccessibilityInteractionController()
+ ViewRootImpl viewRootImpl = mRootImpl.get();
+ if (viewRootImpl != null) {
+ viewRootImpl.getAccessibilityInteractionController()
.findAccessibilityNodeInfoByAccessibilityIdClientThread(accessibilityId,
interactionId, callback, interrogatingPid, interrogatingTid);
}
@@ -4494,8 +4495,9 @@ public final class ViewRootImpl extends Handler implements ViewParent,
public void performAccessibilityAction(int accessibilityId, int action,
int interactionId, IAccessibilityInteractionConnectionCallback callback,
int interogatingPid, long interrogatingTid) {
- if (mViewAncestor.get() != null) {
- getAccessibilityInteractionController()
+ ViewRootImpl viewRootImpl = mRootImpl.get();
+ if (viewRootImpl != null) {
+ viewRootImpl.getAccessibilityInteractionController()
.performAccessibilityActionClientThread(accessibilityId, action, interactionId,
callback, interogatingPid, interrogatingTid);
}
@@ -4504,8 +4506,9 @@ public final class ViewRootImpl extends Handler implements ViewParent,
public void findAccessibilityNodeInfoByViewId(int viewId,
int interactionId, IAccessibilityInteractionConnectionCallback callback,
int interrogatingPid, long interrogatingTid) {
- if (mViewAncestor.get() != null) {
- getAccessibilityInteractionController()
+ ViewRootImpl viewRootImpl = mRootImpl.get();
+ if (viewRootImpl != null) {
+ viewRootImpl.getAccessibilityInteractionController()
.findAccessibilityNodeInfoByViewIdClientThread(viewId, interactionId, callback,
interrogatingPid, interrogatingTid);
}
@@ -4514,8 +4517,9 @@ public final class ViewRootImpl extends Handler implements ViewParent,
public void findAccessibilityNodeInfosByViewText(String text, int accessibilityId,
int interactionId, IAccessibilityInteractionConnectionCallback callback,
int interrogatingPid, long interrogatingTid) {
- if (mViewAncestor.get() != null) {
- getAccessibilityInteractionController()
+ ViewRootImpl viewRootImpl = mRootImpl.get();
+ if (viewRootImpl != null) {
+ viewRootImpl.getAccessibilityInteractionController()
.findAccessibilityNodeInfosByViewTextClientThread(text, accessibilityId,
interactionId, callback, interrogatingPid, interrogatingTid);
}