Search in sources :

Example 26 with Keyphrase

use of android.hardware.soundtrigger.SoundTrigger.Keyphrase in project android_frameworks_base by ResurrectionRemix.

the class SoundTriggerTest method testKeyphraseParcelUnparcel_zeroUsers.

@SmallTest
public void testKeyphraseParcelUnparcel_zeroUsers() throws Exception {
    Keyphrase keyphrase = new Keyphrase(1, 0, "en-US", "hello", new int[0]);
    // Write to a parcel
    Parcel parcel = Parcel.obtain();
    keyphrase.writeToParcel(parcel, 0);
    // Read from it
    parcel.setDataPosition(0);
    Keyphrase unparceled = Keyphrase.CREATOR.createFromParcel(parcel);
    // Verify that they are the same
    assertEquals(keyphrase.id, unparceled.id);
    assertTrue(Arrays.equals(keyphrase.users, unparceled.users));
    assertEquals(keyphrase.locale, unparceled.locale);
    assertEquals(keyphrase.text, unparceled.text);
}
Also used : Parcel(android.os.Parcel) Keyphrase(android.hardware.soundtrigger.SoundTrigger.Keyphrase) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 27 with Keyphrase

use of android.hardware.soundtrigger.SoundTrigger.Keyphrase in project android_frameworks_base by ResurrectionRemix.

the class SoundTriggerTest method testKeyphraseSoundModelParcelUnparcel_noData.

@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 });
    KeyphraseSoundModel ksm = new KeyphraseSoundModel(UUID.randomUUID(), UUID.randomUUID(), null, keyphrases);
    // Write to a parcel
    Parcel parcel = Parcel.obtain();
    ksm.writeToParcel(parcel, 0);
    // Read from it
    parcel.setDataPosition(0);
    KeyphraseSoundModel unparceled = KeyphraseSoundModel.CREATOR.createFromParcel(parcel);
    // Verify that they are the same
    assertEquals(ksm.uuid, unparceled.uuid);
    assertNull(unparceled.data);
    assertEquals(ksm.type, unparceled.type);
    assertTrue(Arrays.equals(keyphrases, unparceled.keyphrases));
}
Also used : KeyphraseSoundModel(android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel) Parcel(android.os.Parcel) Keyphrase(android.hardware.soundtrigger.SoundTrigger.Keyphrase) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 28 with Keyphrase

use of android.hardware.soundtrigger.SoundTrigger.Keyphrase in project android_frameworks_base by ResurrectionRemix.

the class TestEnrollmentActivity method onEnrollButtonClicked.

/**
     * Called when the user clicks the enroll button.
     * Performs a fresh enrollment.
     */
public void onEnrollButtonClicked(View v) {
    Keyphrase kp = new Keyphrase(KEYPHRASE_ID, RECOGNITION_MODES, BCP47_LOCALE, TEXT, new int[] { UserManager.get(this).getUserHandle() });
    UUID modelUuid = UUID.randomUUID();
    // Generate a fake model to push.
    byte[] data = new byte[1024];
    mRandom.nextBytes(data);
    KeyphraseSoundModel soundModel = new KeyphraseSoundModel(modelUuid, null, data, new Keyphrase[] { kp });
    boolean status = mEnrollmentUtil.addOrUpdateSoundModel(soundModel);
    if (status) {
        Toast.makeText(this, "Successfully enrolled, model UUID=" + modelUuid, Toast.LENGTH_SHORT).show();
    } else {
        Toast.makeText(this, "Failed to enroll!!!" + modelUuid, Toast.LENGTH_SHORT).show();
    }
}
Also used : KeyphraseSoundModel(android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel) Keyphrase(android.hardware.soundtrigger.SoundTrigger.Keyphrase) UUID(java.util.UUID)

Example 29 with Keyphrase

use of android.hardware.soundtrigger.SoundTrigger.Keyphrase in project android_frameworks_base by crdroidandroid.

the class SoundTriggerTest method testKeyphraseParcelUnparcel_pos.

@SmallTest
public void testKeyphraseParcelUnparcel_pos() throws Exception {
    Keyphrase keyphrase = new Keyphrase(1, 0, "en-US", "hello", new int[] { 1, 2, 3, 4, 5 });
    // Write to a parcel
    Parcel parcel = Parcel.obtain();
    keyphrase.writeToParcel(parcel, 0);
    // Read from it
    parcel.setDataPosition(0);
    Keyphrase unparceled = Keyphrase.CREATOR.createFromParcel(parcel);
    // Verify that they are the same
    assertEquals(keyphrase.id, unparceled.id);
    assertTrue(Arrays.equals(keyphrase.users, unparceled.users));
    assertEquals(keyphrase.locale, unparceled.locale);
    assertEquals(keyphrase.text, unparceled.text);
}
Also used : Parcel(android.os.Parcel) Keyphrase(android.hardware.soundtrigger.SoundTrigger.Keyphrase) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 30 with Keyphrase

use of android.hardware.soundtrigger.SoundTrigger.Keyphrase in project android_frameworks_base by crdroidandroid.

the class SoundTriggerTest method testKeyphraseParcelUnparcel_zeroUsers.

@SmallTest
public void testKeyphraseParcelUnparcel_zeroUsers() throws Exception {
    Keyphrase keyphrase = new Keyphrase(1, 0, "en-US", "hello", new int[0]);
    // Write to a parcel
    Parcel parcel = Parcel.obtain();
    keyphrase.writeToParcel(parcel, 0);
    // Read from it
    parcel.setDataPosition(0);
    Keyphrase unparceled = Keyphrase.CREATOR.createFromParcel(parcel);
    // Verify that they are the same
    assertEquals(keyphrase.id, unparceled.id);
    assertTrue(Arrays.equals(keyphrase.users, unparceled.users));
    assertEquals(keyphrase.locale, unparceled.locale);
    assertEquals(keyphrase.text, unparceled.text);
}
Also used : Parcel(android.os.Parcel) Keyphrase(android.hardware.soundtrigger.SoundTrigger.Keyphrase) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

Keyphrase (android.hardware.soundtrigger.SoundTrigger.Keyphrase)32 Parcel (android.os.Parcel)24 KeyphraseSoundModel (android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel)20 SmallTest (android.test.suitebuilder.annotation.SmallTest)20 UUID (java.util.UUID)8 Cursor (android.database.Cursor)4 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 LargeTest (android.test.suitebuilder.annotation.LargeTest)4