summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/textservice
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-11-02 11:20:33 +0900
committersatok <satok@google.com>2011-11-03 01:22:20 +0900
commit74061ff90453c79ddbde468f630a41425da07710 (patch)
tree64d58b86ae60bd771e36478df4b00a9f4a0a58d2 /core/java/android/view/textservice
parent07b4b3145333bc8ece9fdbb68ade726b3d6485cd (diff)
downloadframeworks_base-74061ff90453c79ddbde468f630a41425da07710.zip
frameworks_base-74061ff90453c79ddbde468f630a41425da07710.tar.gz
frameworks_base-74061ff90453c79ddbde468f630a41425da07710.tar.bz2
Fix a memory leak of a Binder in SpellCheckerService
Bug: 5499490 Change-Id: I167a3e9dfdd6edd06c6ad993fbff3a535c81b09c
Diffstat (limited to 'core/java/android/view/textservice')
-rw-r--r--core/java/android/view/textservice/SpellCheckerSession.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/view/textservice/SpellCheckerSession.java b/core/java/android/view/textservice/SpellCheckerSession.java
index 5c3f089..01b114c 100644
--- a/core/java/android/view/textservice/SpellCheckerSession.java
+++ b/core/java/android/view/textservice/SpellCheckerSession.java
@@ -152,6 +152,7 @@ public class SpellCheckerSession {
public void close() {
mIsUsed = false;
try {
+ mSpellCheckerSessionListenerImpl.close();
mTextServicesManager.finishSpellCheckerService(mSpellCheckerSessionListenerImpl);
} catch (RemoteException e) {
// do nothing
@@ -190,6 +191,7 @@ public class SpellCheckerSession {
private static class SpellCheckerSessionListenerImpl extends ISpellCheckerSessionListener.Stub {
private static final int TASK_CANCEL = 1;
private static final int TASK_GET_SUGGESTIONS_MULTIPLE = 2;
+ private static final int TASK_CLOSE = 3;
private final Queue<SpellCheckerParams> mPendingTasks =
new LinkedList<SpellCheckerParams>();
private final Handler mHandler;
@@ -224,6 +226,9 @@ public class SpellCheckerSession {
case TASK_GET_SUGGESTIONS_MULTIPLE:
processGetSuggestionsMultiple(scp);
break;
+ case TASK_CLOSE:
+ processClose();
+ break;
}
}
@@ -247,6 +252,13 @@ public class SpellCheckerSession {
suggestionsLimit, sequentialWords));
}
+ public void close() {
+ if (DBG) {
+ Log.w(TAG, "close");
+ }
+ processOrEnqueueTask(new SpellCheckerParams(TASK_CLOSE, null, 0, false));
+ }
+
public boolean isDisconnected() {
return mOpened && mISpellCheckerSession == null;
}
@@ -284,6 +296,21 @@ public class SpellCheckerSession {
}
}
+ private void processClose() {
+ if (!checkOpenConnection()) {
+ return;
+ }
+ if (DBG) {
+ Log.w(TAG, "Close spell checker tasks.");
+ }
+ try {
+ mISpellCheckerSession.onClose();
+ mISpellCheckerSession = null;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to close " + e);
+ }
+ }
+
private void processGetSuggestionsMultiple(SpellCheckerParams scp) {
if (!checkOpenConnection()) {
return;