summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2014-09-10 00:52:59 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2014-09-10 00:53:00 +0000
commit0fd9d8a2c8494be0a6e2c327beca385be00a7a86 (patch)
treed2766e204c71739ca15e65ebe78cce55965afc95
parent13e28bb9386a3eb579c457985f0324238f2bfe38 (diff)
parent2475e38c10a02973665752e0b829153a5c493b28 (diff)
Merge "SoundTriggerHelper: handle media server death" into lmp-dev
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java
index 376230b51264..ad38b22e7a97 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java
@@ -67,7 +67,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
final ModuleProperties moduleProperties;
/** The properties for the DSP module */
- private final SoundTriggerModule mModule;
+ private SoundTriggerModule mModule;
private final Object mLock = new Object();
private final Context mContext;
private final TelephonyManager mTelephonyManager;
@@ -105,7 +105,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
} else {
// TODO: Figure out how to determine which module corresponds to the DSP hardware.
moduleProperties = modules.get(0);
- mModule = SoundTrigger.attachModule(moduleProperties.id, this, null);
}
}
@@ -155,10 +154,17 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
mIsPowerSaveMode = mPowerManager.isPowerSaveMode();
}
- if (moduleProperties == null || mModule == null) {
+ if (moduleProperties == null) {
Slog.w(TAG, "Attempting startRecognition without the capability");
return STATUS_ERROR;
}
+ if (mModule == null) {
+ mModule = SoundTrigger.attachModule(moduleProperties.id, this, null);
+ if (mModule == null) {
+ Slog.w(TAG, "startRecognition cannot attach to sound trigger module");
+ return STATUS_ERROR;
+ }
+ }
if (mCurrentSoundModelHandle != INVALID_VALUE
&& !soundModel.uuid.equals(mCurrentSoundModelUuid)) {
@@ -446,6 +452,10 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
Slog.w(TAG, "RemoteException in onError", e);
} finally {
internalClearStateLocked();
+ if (mModule != null) {
+ mModule.detach();
+ mModule = null;
+ }
}
}