diff options
author | Eric Laurent <elaurent@google.com> | 2014-09-09 15:52:25 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-09-09 17:26:00 -0700 |
commit | 2475e38c10a02973665752e0b829153a5c493b28 (patch) | |
tree | 7d1ff82f2b4542862834886942b786753aa9f707 /services/voiceinteraction/java | |
parent | 9ed0292a650eb52becc0c17e4001767065d325ca (diff) | |
download | frameworks_base-2475e38c10a02973665752e0b829153a5c493b28.zip frameworks_base-2475e38c10a02973665752e0b829153a5c493b28.tar.gz frameworks_base-2475e38c10a02973665752e0b829153a5c493b28.tar.bz2 |
SoundTriggerHelper: handle media server death
Retry to attach sound trigger module when startRecognition() is called.
Bug: 17373746.
Change-Id: I5b2f806b6cab47741d345be1cde73a84f5a62590
Diffstat (limited to 'services/voiceinteraction/java')
-rw-r--r-- | services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java | 16 |
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 376230b..ad38b22 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; + } } } |