diff options
author | Sandeep Siddhartha <sansid@google.com> | 2014-07-21 10:31:34 -0700 |
---|---|---|
committer | Sandeep Siddhartha <sansid@google.com> | 2014-07-22 09:16:18 -0700 |
commit | 6daae9622672e0b38fc2efed29f68061d749cacc (patch) | |
tree | 94943fab0e4ab27952fffb07141456cfec65fbed /tests | |
parent | 70441467f4dc232cd8e6142f0afc117787dc979b (diff) | |
download | frameworks_base-6daae9622672e0b38fc2efed29f68061d749cacc.zip frameworks_base-6daae9622672e0b38fc2efed29f68061d749cacc.tar.gz frameworks_base-6daae9622672e0b38fc2efed29f68061d749cacc.tar.bz2 |
AlwaysOnHotwordDetector needs to reflect enrollment changes
Add a callback for when any sound model change happens. This helps the VIS
to re-check the availability and either enroll the user, or start/stop recognition.
Also shut down any active recognition when VIS dies, or a different hotword detector instance is obtained from VIS.
Change-Id: I03f94e78c6ee307afe822a84aebc7e74c64de7b4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java index e74307f..e750bb6 100644 --- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java +++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java @@ -50,38 +50,54 @@ public class MainInteractionService extends VoiceInteractionService { Log.i(TAG, "Keyphrase enrollment meta-data: " + Arrays.toString(getKeyphraseEnrollmentInfo().listKeyphraseMetadata())); - mHotwordDetector = getAlwaysOnHotwordDetector("Hello There", "en-US", mHotwordCallback); + mHotwordDetector = createAlwaysOnHotwordDetector("Hello There", "en-US", mHotwordCallback); + testHotwordAvailabilityStates(); + } + + @Override + public void onSoundModelsChanged() { int availability = mHotwordDetector.getAvailability(); Log.i(TAG, "Hotword availability = " + availability); + if (availability == AlwaysOnHotwordDetector.STATE_INVALID) { + mHotwordDetector = createAlwaysOnHotwordDetector("Hello There", "en-US", mHotwordCallback); + } + testHotwordAvailabilityStates(); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + Bundle args = new Bundle(); + args.putParcelable("intent", new Intent(this, TestInteractionActivity.class)); + startSession(args); + stopSelf(startId); + return START_NOT_STICKY; + } + private void testHotwordAvailabilityStates() { + int availability = mHotwordDetector.getAvailability(); + Log.i(TAG, "Hotword availability = " + availability); switch (availability) { - case AlwaysOnHotwordDetector.KEYPHRASE_HARDWARE_UNAVAILABLE: - Log.i(TAG, "KEYPHRASE_HARDWARE_UNAVAILABLE"); + case AlwaysOnHotwordDetector.STATE_INVALID: + Log.i(TAG, "STATE_INVALID"); + break; + case AlwaysOnHotwordDetector.STATE_HARDWARE_UNAVAILABLE: + Log.i(TAG, "STATE_HARDWARE_UNAVAILABLE"); break; - case AlwaysOnHotwordDetector.KEYPHRASE_UNSUPPORTED: - Log.i(TAG, "KEYPHRASE_UNSUPPORTED"); + case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNSUPPORTED: + Log.i(TAG, "STATE_KEYPHRASE_UNSUPPORTED"); break; - case AlwaysOnHotwordDetector.KEYPHRASE_UNENROLLED: - Log.i(TAG, "KEYPHRASE_UNENROLLED"); + case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNENROLLED: + Log.i(TAG, "STATE_KEYPHRASE_UNENROLLED"); Intent enroll = mHotwordDetector.getManageIntent( AlwaysOnHotwordDetector.MANAGE_ACTION_ENROLL); Log.i(TAG, "Need to enroll with " + enroll); break; - case AlwaysOnHotwordDetector.KEYPHRASE_ENROLLED: - Log.i(TAG, "KEYPHRASE_ENROLLED"); + case AlwaysOnHotwordDetector.STATE_KEYPHRASE_ENROLLED: + Log.i(TAG, "STATE_KEYPHRASE_ENROLLED"); int status = mHotwordDetector.startRecognition( AlwaysOnHotwordDetector.RECOGNITION_FLAG_NONE); Log.i(TAG, "startRecognition status = " + status); break; } } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - Bundle args = new Bundle(); - args.putParcelable("intent", new Intent(this, TestInteractionActivity.class)); - startSession(args); - stopSelf(startId); - return START_NOT_STICKY; - } } |