summaryrefslogtreecommitdiffstats
path: root/tests/VoiceInteraction
diff options
context:
space:
mode:
authorSandeep Siddhartha <sansid@google.com>2014-07-22 09:49:49 -0700
committerSandeep Siddhartha <sansid@google.com>2014-07-22 17:11:52 -0700
commitf63bc523eadbe01ce0a5ad52868a5dccb3d5f6dd (patch)
treeb2b0ca650b4c3f34e6af4c43ca6a0dfd5c93ff94 /tests/VoiceInteraction
parent10e62cb2f22566741a544be7aef2157409bfc6d4 (diff)
downloadframeworks_base-f63bc523eadbe01ce0a5ad52868a5dccb3d5f6dd.zip
frameworks_base-f63bc523eadbe01ce0a5ad52868a5dccb3d5f6dd.tar.gz
frameworks_base-f63bc523eadbe01ce0a5ad52868a5dccb3d5f6dd.tar.bz2
Make hotword availability a callback
This helps us make the list sound models operation an async one, it also helps us with the case where a detector is invalidated, so the client doesn't have to keep checking the state. Synchronize DatabaseHelper methods on its instance so that other VoiceInteractionManagerService calls aren't blocked on db writes/reads. It's still possible for the list operation to be blocked on update and vice-versa Change-Id: Ib8ec4ac5056b62d443038560ce31d0641b4627b0
Diffstat (limited to 'tests/VoiceInteraction')
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java22
1 files changed, 9 insertions, 13 deletions
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
index e750bb6..cc710f9 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
@@ -30,6 +30,12 @@ public class MainInteractionService extends VoiceInteractionService {
private final Callback mHotwordCallback = new Callback() {
@Override
+ public void onAvailabilityChanged(int status) {
+ Log.i(TAG, "onAvailabilityChanged(" + status + ")");
+ hotwordAvailabilityChangeHelper(status);
+ }
+
+ @Override
public void onDetected(byte[] data) {
Log.i(TAG, "onDetected");
}
@@ -51,17 +57,6 @@ public class MainInteractionService extends VoiceInteractionService {
+ Arrays.toString(getKeyphraseEnrollmentInfo().listKeyphraseMetadata()));
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
@@ -73,12 +68,13 @@ public class MainInteractionService extends VoiceInteractionService {
return START_NOT_STICKY;
}
- private void testHotwordAvailabilityStates() {
- int availability = mHotwordDetector.getAvailability();
+ private void hotwordAvailabilityChangeHelper(int availability) {
Log.i(TAG, "Hotword availability = " + availability);
switch (availability) {
case AlwaysOnHotwordDetector.STATE_INVALID:
Log.i(TAG, "STATE_INVALID");
+ mHotwordDetector =
+ createAlwaysOnHotwordDetector("Hello There", "en-US", mHotwordCallback);
break;
case AlwaysOnHotwordDetector.STATE_HARDWARE_UNAVAILABLE:
Log.i(TAG, "STATE_HARDWARE_UNAVAILABLE");