diff options
author | Sandeep Siddhartha <sansid@google.com> | 2014-08-23 01:08:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-23 01:08:18 +0000 |
commit | a434963fade86654c46ca3a3538ef0e0150f73d0 (patch) | |
tree | b8be38c859fb380a2a2d0966ee0e1b63a5ab4c7e /core/java/android/service | |
parent | 79dbce8661f0ab3c345858b0bc69e0eae147dcde (diff) | |
parent | dcf3068fcb55f101680e70a8a6f84f3b2c9cb1e3 (diff) | |
download | frameworks_base-a434963fade86654c46ca3a3538ef0e0150f73d0.zip frameworks_base-a434963fade86654c46ca3a3538ef0e0150f73d0.tar.gz frameworks_base-a434963fade86654c46ca3a3538ef0e0150f73d0.tar.bz2 |
Merge "Fix the Locale story in the hotword API" into lmp-dev
Diffstat (limited to 'core/java/android/service')
-rw-r--r-- | core/java/android/service/voice/AlwaysOnHotwordDetector.java | 15 | ||||
-rw-r--r-- | core/java/android/service/voice/VoiceInteractionService.java | 17 |
2 files changed, 24 insertions, 8 deletions
diff --git a/core/java/android/service/voice/AlwaysOnHotwordDetector.java b/core/java/android/service/voice/AlwaysOnHotwordDetector.java index 15e66a0..2095773 100644 --- a/core/java/android/service/voice/AlwaysOnHotwordDetector.java +++ b/core/java/android/service/voice/AlwaysOnHotwordDetector.java @@ -39,10 +39,10 @@ import android.util.Slog; import com.android.internal.app.IVoiceInteractionManagerService; -import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Locale; /** * A class that lets a VoiceInteractionService implementation interact with @@ -167,7 +167,7 @@ public class AlwaysOnHotwordDetector { private static final int MSG_DETECTION_RESUME = 5; private final String mText; - private final String mLocale; + private final Locale mLocale; /** * The metadata of the Keyphrase, derived from the enrollment application. * This may be null if this keyphrase isn't supported by the enrollment application. @@ -317,7 +317,7 @@ public class AlwaysOnHotwordDetector { * * @hide */ - public AlwaysOnHotwordDetector(String text, String locale, Callback callback, + public AlwaysOnHotwordDetector(String text, Locale locale, Callback callback, KeyphraseEnrollmentInfo keyphraseEnrollmentInfo, IVoiceInteractionService voiceInteractionService, IVoiceInteractionManagerService modelManagementService) { @@ -491,8 +491,6 @@ public class AlwaysOnHotwordDetector { */ void onSoundModelsChanged() { synchronized (mLock) { - // FIXME: This should stop the recognition if it was using an enrolled sound model - // that's no longer available. if (mAvailability == STATE_INVALID || mAvailability == STATE_HARDWARE_UNAVAILABLE || mAvailability == STATE_KEYPHRASE_UNSUPPORTED) { @@ -500,6 +498,13 @@ public class AlwaysOnHotwordDetector { return; } + // Stop the recognition before proceeding. + // This is done because we want to stop the recognition on an older model if it changed + // or was deleted. + // The availability change callback should ensure that the client starts recognition + // again if needed. + stopRecognitionLocked(); + // Execute a refresh availability task - which should then notify of a change. new RefreshAvailabiltyTask().execute(); } diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java index b200356..884fa9f 100644 --- a/core/java/android/service/voice/VoiceInteractionService.java +++ b/core/java/android/service/voice/VoiceInteractionService.java @@ -35,6 +35,7 @@ import com.android.internal.app.IVoiceInteractionManagerService; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.Locale; /** @@ -163,7 +164,7 @@ public class VoiceInteractionService extends Service { * Called during service initialization to tell you when the system is ready * to receive interaction from it. You should generally do initialization here * rather than in {@link #onCreate()}. Methods such as {@link #startSession(Bundle)} and - * {@link #createAlwaysOnHotwordDetector(String, String, android.service.voice.AlwaysOnHotwordDetector.Callback)} + * {@link #createAlwaysOnHotwordDetector(String, Locale, android.service.voice.AlwaysOnHotwordDetector.Callback)} * will not be operational until this point. */ public void onReady() { @@ -200,6 +201,17 @@ public class VoiceInteractionService extends Service { } /** + * FIXME: Remove once the prebuilts are updated. + * + * @hide + */ + @Deprecated + public final AlwaysOnHotwordDetector createAlwaysOnHotwordDetector( + String keyphrase, String locale, AlwaysOnHotwordDetector.Callback callback) { + return createAlwaysOnHotwordDetector(keyphrase, new Locale(locale), callback); + } + + /** * Creates an {@link AlwaysOnHotwordDetector} for the given keyphrase and locale. * This instance must be retained and used by the client. * Calling this a second time invalidates the previously created hotword detector @@ -207,12 +219,11 @@ public class VoiceInteractionService extends Service { * * @param keyphrase The keyphrase that's being used, for example "Hello Android". * @param locale The locale for which the enrollment needs to be performed. - * This is a Java locale, for example "en_US". * @param callback The callback to notify of detection events. * @return An always-on hotword detector for the given keyphrase and locale. */ public final AlwaysOnHotwordDetector createAlwaysOnHotwordDetector( - String keyphrase, String locale, AlwaysOnHotwordDetector.Callback callback) { + String keyphrase, Locale locale, AlwaysOnHotwordDetector.Callback callback) { if (mSystemService == null) { throw new IllegalStateException("Not available until onReady() is called"); } |