summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNicholas Ambur <nambur@google.com>2020-01-14 20:28:37 -0800
committerNicholas Ambur <nambur@google.com>2020-01-22 16:40:13 -0800
commitef84fc48433d47ea9c91dcb3273ae3d74ca6d32a (patch)
tree7ae618ac7d63eb705ca913274d800c38cbc98b58 /tests
parent4ec0be1fafd70ff43f5c579c73627b147168b194 (diff)
add KeyphraseModelManager
Exposes a set of @SystemApi's allowing the active VoiceInteractionService to enroll voice models. Bug: 147159435 Test: manual tested enrollment and unenrollment via bundled hotwordenrollment application and test app. Change-Id: I94ef3550df236486401a0a6f9de9d874b9bf9b46
Diffstat (limited to 'tests')
-rw-r--r--tests/SoundTriggerTests/src/android/hardware/soundtrigger/SoundTriggerTest.java28
-rw-r--r--tests/VoiceEnrollment/src/com/android/test/voiceenrollment/TestEnrollmentActivity.java13
2 files changed, 28 insertions, 13 deletions
diff --git a/tests/SoundTriggerTests/src/android/hardware/soundtrigger/SoundTriggerTest.java b/tests/SoundTriggerTests/src/android/hardware/soundtrigger/SoundTriggerTest.java
index 65a3d8a337db..c900eaedbdae 100644
--- a/tests/SoundTriggerTests/src/android/hardware/soundtrigger/SoundTriggerTest.java
+++ b/tests/SoundTriggerTests/src/android/hardware/soundtrigger/SoundTriggerTest.java
@@ -30,6 +30,7 @@ import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.Arrays;
+import java.util.Locale;
import java.util.Random;
import java.util.UUID;
@@ -38,7 +39,8 @@ public class SoundTriggerTest extends InstrumentationTestCase {
@SmallTest
public void testKeyphraseParcelUnparcel_noUsers() throws Exception {
- Keyphrase keyphrase = new Keyphrase(1, 0, "en-US", "hello", null);
+ Keyphrase keyphrase = new Keyphrase(1, 0,
+ Locale.forLanguageTag("en-US"), "hello", null);
// Write to a parcel
Parcel parcel = Parcel.obtain();
@@ -57,7 +59,8 @@ public class SoundTriggerTest extends InstrumentationTestCase {
@SmallTest
public void testKeyphraseParcelUnparcel_zeroUsers() throws Exception {
- Keyphrase keyphrase = new Keyphrase(1, 0, "en-US", "hello", new int[0]);
+ Keyphrase keyphrase = new Keyphrase(1, 0,
+ Locale.forLanguageTag("en-US"), "hello", new int[0]);
// Write to a parcel
Parcel parcel = Parcel.obtain();
@@ -76,7 +79,8 @@ public class SoundTriggerTest extends InstrumentationTestCase {
@SmallTest
public void testKeyphraseParcelUnparcel_pos() throws Exception {
- Keyphrase keyphrase = new Keyphrase(1, 0, "en-US", "hello", new int[] {1, 2, 3, 4, 5});
+ Keyphrase keyphrase = new Keyphrase(1, 0,
+ Locale.forLanguageTag("en-US"), "hello", new int[] {1, 2, 3, 4, 5});
// Write to a parcel
Parcel parcel = Parcel.obtain();
@@ -96,8 +100,10 @@ public class SoundTriggerTest extends InstrumentationTestCase {
@SmallTest
public void testKeyphraseSoundModelParcelUnparcel_noData() throws Exception {
Keyphrase[] keyphrases = new Keyphrase[2];
- keyphrases[0] = new Keyphrase(1, 0, "en-US", "hello", new int[] {0});
- keyphrases[1] = new Keyphrase(2, 0, "fr-FR", "there", new int[] {1, 2});
+ keyphrases[0] = new Keyphrase(1, 0, Locale.forLanguageTag("en-US"),
+ "hello", new int[] {0});
+ keyphrases[1] = new Keyphrase(2, 0, Locale.forLanguageTag("fr-FR"),
+ "there", new int[] {1, 2});
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(),
null, keyphrases);
@@ -119,8 +125,10 @@ public class SoundTriggerTest extends InstrumentationTestCase {
@SmallTest
public void testKeyphraseSoundModelParcelUnparcel_zeroData() throws Exception {
Keyphrase[] keyphrases = new Keyphrase[2];
- keyphrases[0] = new Keyphrase(1, 0, "en-US", "hello", new int[] {0});
- keyphrases[1] = new Keyphrase(2, 0, "fr-FR", "there", new int[] {1, 2});
+ keyphrases[0] = new Keyphrase(1, 0, Locale.forLanguageTag("en-US"),
+ "hello", new int[] {0});
+ keyphrases[1] = new Keyphrase(2, 0, Locale.forLanguageTag("fr-FR"),
+ "there", new int[] {1, 2});
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(),
new byte[0], keyphrases);
@@ -186,8 +194,10 @@ public class SoundTriggerTest extends InstrumentationTestCase {
@LargeTest
public void testKeyphraseSoundModelParcelUnparcel_largeData() throws Exception {
Keyphrase[] keyphrases = new Keyphrase[2];
- keyphrases[0] = new Keyphrase(1, 0, "en-US", "hello", new int[] {0});
- keyphrases[1] = new Keyphrase(2, 0, "fr-FR", "there", new int[] {1, 2});
+ keyphrases[0] = new Keyphrase(1, 0, Locale.forLanguageTag("en-US"),
+ "hello", new int[] {0});
+ keyphrases[1] = new Keyphrase(2, 0, Locale.forLanguageTag("fr-FR"),
+ "there", new int[] {1, 2});
byte[] data = new byte[200 * 1024];
mRandom.nextBytes(data);
KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(),
diff --git a/tests/VoiceEnrollment/src/com/android/test/voiceenrollment/TestEnrollmentActivity.java b/tests/VoiceEnrollment/src/com/android/test/voiceenrollment/TestEnrollmentActivity.java
index 54c944f9588e..b357ad076c11 100644
--- a/tests/VoiceEnrollment/src/com/android/test/voiceenrollment/TestEnrollmentActivity.java
+++ b/tests/VoiceEnrollment/src/com/android/test/voiceenrollment/TestEnrollmentActivity.java
@@ -16,9 +16,6 @@
package com.android.test.voiceenrollment;
-import java.util.Random;
-import java.util.UUID;
-
import android.app.Activity;
import android.hardware.soundtrigger.SoundTrigger;
import android.hardware.soundtrigger.SoundTrigger.Keyphrase;
@@ -29,6 +26,13 @@ import android.util.Log;
import android.view.View;
import android.widget.Toast;
+import java.util.Locale;
+import java.util.Random;
+import java.util.UUID;
+
+/**
+ * TODO: must be transitioned to a service.
+ */
public class TestEnrollmentActivity extends Activity {
private static final String TAG = "TestEnrollmentActivity";
private static final boolean DBG = false;
@@ -56,7 +60,8 @@ public class TestEnrollmentActivity extends Activity {
* Performs a fresh enrollment.
*/
public void onEnrollButtonClicked(View v) {
- Keyphrase kp = new Keyphrase(KEYPHRASE_ID, RECOGNITION_MODES, BCP47_LOCALE, TEXT,
+ Keyphrase kp = new Keyphrase(KEYPHRASE_ID, RECOGNITION_MODES,
+ Locale.forLanguageTag(BCP47_LOCALE), TEXT,
new int[] { UserManager.get(this).getUserHandle() /* current user */});
UUID modelUuid = UUID.randomUUID();
// Generate a fake model to push.