summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Poichet <jpoichet@google.com>2014-10-01 22:02:16 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-01 22:02:16 +0000
commitc2ece4228d64a5621bdadc042d3182af89141f8c (patch)
treecb27a8596224028c0817441dc549001fa907096c
parent923b627a6c69dfa99061c4c2669570ffe3a248b8 (diff)
parent87ed04832c7562260c3a87506286d63b137daee1 (diff)
downloadframeworks_base-c2ece4228d64a5621bdadc042d3182af89141f8c.zip
frameworks_base-c2ece4228d64a5621bdadc042d3182af89141f8c.tar.gz
frameworks_base-c2ece4228d64a5621bdadc042d3182af89141f8c.tar.bz2
am 87ed0483: am 0d71155d: am a5fa02df: am 72079f7f: Merge "Make sure cancel is called on tear down." into lmp-dev
* commit '87ed04832c7562260c3a87506286d63b137daee1': Make sure cancel is called on tear down.
-rw-r--r--core/java/android/speech/RecognitionService.java13
-rw-r--r--core/java/android/speech/SpeechRecognizer.java8
2 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/speech/RecognitionService.java b/core/java/android/speech/RecognitionService.java
index 32b2d8f..45eb0bf 100644
--- a/core/java/android/speech/RecognitionService.java
+++ b/core/java/android/speech/RecognitionService.java
@@ -91,9 +91,20 @@ public abstract class RecognitionService extends Service {
}
};
- private void dispatchStartListening(Intent intent, IRecognitionListener listener) {
+ private void dispatchStartListening(Intent intent, final IRecognitionListener listener) {
if (mCurrentCallback == null) {
if (DBG) Log.d(TAG, "created new mCurrentCallback, listener = " + listener.asBinder());
+ try {
+ listener.asBinder().linkToDeath(new IBinder.DeathRecipient() {
+ @Override
+ public void binderDied() {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_CANCEL, listener));
+ }
+ }, 0);
+ } catch (RemoteException re) {
+ Log.e(TAG, "dead listener on startListening");
+ return;
+ }
mCurrentCallback = new Callback(listener);
RecognitionService.this.onStartListening(intent, mCurrentCallback);
} else {
diff --git a/core/java/android/speech/SpeechRecognizer.java b/core/java/android/speech/SpeechRecognizer.java
index 91c3799..88e2ede 100644
--- a/core/java/android/speech/SpeechRecognizer.java
+++ b/core/java/android/speech/SpeechRecognizer.java
@@ -396,6 +396,14 @@ public class SpeechRecognizer {
* Destroys the {@code SpeechRecognizer} object.
*/
public void destroy() {
+ if (mService != null) {
+ try {
+ mService.cancel(mListener);
+ } catch (final RemoteException e) {
+ // Not important
+ }
+ }
+
if (mConnection != null) {
mContext.unbindService(mConnection);
}