summaryrefslogtreecommitdiffstats
path: root/tests/VoiceInteraction
diff options
context:
space:
mode:
authorSandeep Siddhartha <sansid@google.com>2014-07-16 23:55:41 -0700
committerSandeep Siddhartha <sansid@google.com>2014-07-17 18:44:12 -0700
commit7444c906faef1f7a9a6e6f7a443ba156f1e856be (patch)
treed422b62cbc7a5aa67a6edeb1c3d1bc3505f1f9bb /tests/VoiceInteraction
parentca58ddf7c82dd0857de0c3d49d7eb87a842ee4ce (diff)
downloadframeworks_base-7444c906faef1f7a9a6e6f7a443ba156f1e856be.zip
frameworks_base-7444c906faef1f7a9a6e6f7a443ba156f1e856be.tar.gz
frameworks_base-7444c906faef1f7a9a6e6f7a443ba156f1e856be.tar.bz2
Test hotword flow
- Also fix a few StrictMode violations in DatabaseHelper Change-Id: I93f27407dae34cc0dca5e9f891d4ca718d6010a5
Diffstat (limited to 'tests/VoiceInteraction')
-rw-r--r--tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
index ab2e8ac..edb28ea 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/MainInteractionService.java
@@ -18,6 +18,8 @@ package com.android.test.voiceinteraction;
import android.content.Intent;
import android.os.Bundle;
+import android.service.voice.AlwaysOnHotwordDetector;
+import android.service.voice.AlwaysOnHotwordDetector.Callback;
import android.service.voice.VoiceInteractionService;
import android.util.Log;
@@ -26,6 +28,25 @@ import java.util.Arrays;
public class MainInteractionService extends VoiceInteractionService {
static final String TAG = "MainInteractionService";
+ private final Callback mHotwordCallback = new Callback() {
+ @Override
+ public void onDetected(byte[] data) {
+ Log.i(TAG, "onDetected");
+ }
+
+ @Override
+ public void onDetectionStarted() {
+ Log.i(TAG, "onDetectionStarted");
+ }
+
+ @Override
+ public void onDetectionStopped() {
+ Log.i(TAG, "onDetectionStopped");
+ }
+ };
+
+ private AlwaysOnHotwordDetector mHotwordDetector;
+
@Override
public void onReady() {
super.onReady();
@@ -33,6 +54,31 @@ public class MainInteractionService extends VoiceInteractionService {
Log.i(TAG, "Keyphrase enrollment error? " + getKeyphraseEnrollmentInfo().getParseError());
Log.i(TAG, "Keyphrase enrollment meta-data: "
+ Arrays.toString(getKeyphraseEnrollmentInfo().listKeyphraseMetadata()));
+
+ mHotwordDetector = getAlwaysOnHotwordDetector("Hello There", "en-US", mHotwordCallback);
+ int availability = mHotwordDetector.getAvailability();
+ Log.i(TAG, "Hotword availability = " + availability);
+
+ switch (availability) {
+ case AlwaysOnHotwordDetector.KEYPHRASE_HARDWARE_UNAVAILABLE:
+ Log.i(TAG, "KEYPHRASE_HARDWARE_UNAVAILABLE");
+ break;
+ case AlwaysOnHotwordDetector.KEYPHRASE_UNSUPPORTED:
+ Log.i(TAG, "KEYPHRASE_UNSUPPORTED");
+ break;
+ case AlwaysOnHotwordDetector.KEYPHRASE_UNENROLLED:
+ Log.i(TAG, "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");
+ int status = mHotwordDetector.startRecognition(
+ AlwaysOnHotwordDetector.RECOGNITION_FLAG_NONE);
+ Log.i(TAG, "startRecognition status = " + status);
+ break;
+ }
}
@Override