diff options
| author | 2014-08-01 18:09:07 -0700 | |
|---|---|---|
| committer | 2014-08-01 18:18:08 -0700 | |
| commit | 5e33fb057c20b84418d96574abe861e9d05956eb (patch) | |
| tree | 1b5d8bebf88eee7888939c47f1019af8ec500e39 | |
| parent | 2c0273e50a3162595e9a54030166f2369b039a5a (diff) | |
Stop recognition when shutting down VIS
Bug: 16629417
Change-Id: I9c98d7e6d487d3eaff604df401c320f8554589f9
3 files changed, 26 insertions, 3 deletions
diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java index 82e23c448d19..51894049661b 100644 --- a/core/java/android/service/voice/VoiceInteractionService.java +++ b/core/java/android/service/voice/VoiceInteractionService.java @@ -182,6 +182,7 @@ public class VoiceInteractionService extends Service { /** * Called during service de-initialization to tell you when the system is shutting the * service down. + * At this point this service may no longer be the active {@link VoiceInteractionService}. */ public void onShutdown() { } diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java index 938efaa56c52..f3ede880faf4 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerHelper.java @@ -240,6 +240,30 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { } } + synchronized void stopAllRecognitions() { + if (moduleProperties == null || mModule == null) { + return; + } + + if (mCurrentSoundModelHandle == INVALID_SOUND_MODEL_HANDLE) { + return; + } + + int status = mModule.stopRecognition(mCurrentSoundModelHandle); + if (status != SoundTrigger.STATUS_OK) { + Slog.w(TAG, "stopRecognition call failed with " + status); + } + status = mModule.unloadSoundModel(mCurrentSoundModelHandle); + if (status != SoundTrigger.STATUS_OK) { + Slog.w(TAG, "unloadSoundModel call failed with " + status); + } + + mCurrentSoundModelHandle = INVALID_SOUND_MODEL_HANDLE; + mCurrentSoundModelUuid = null; + + mActiveListeners.clear(); + } + //---- SoundTrigger.StatusListener methods @Override public void onRecognition(RecognitionEvent event) { diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index a3d578a5dbb9..75d41aa13f58 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -49,9 +49,6 @@ import com.android.server.UiThread; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.util.List; -import java.util.UUID; - /** * SystemService that publishes an IVoiceInteractionManagerService. @@ -151,6 +148,7 @@ public class VoiceInteractionManagerService extends SystemService { } if (force || mImpl == null || mImpl.mUser != mCurUser || !mImpl.mComponent.equals(serviceComponent)) { + mSoundTriggerHelper.stopAllRecognitions(); if (mImpl != null) { mImpl.shutdownLocked(); } |