Search in sources :

Example 11 with KeyphraseRecognitionEvent

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

the class SoundTriggerTest method testKeyphraseRecognitionEventParcelUnparcel_largeData.

@LargeTest
public void testKeyphraseRecognitionEventParcelUnparcel_largeData() throws Exception {
    byte[] data = new byte[200 * 1024];
    mRandom.nextBytes(data);
    KeyphraseRecognitionExtra[] kpExtra = new KeyphraseRecognitionExtra[4];
    ConfidenceLevel cl1 = new ConfidenceLevel(1, 90);
    ConfidenceLevel cl2 = new ConfidenceLevel(2, 30);
    kpExtra[0] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_USER_IDENTIFICATION, 0, new ConfidenceLevel[] { cl1, cl2 });
    kpExtra[1] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, new ConfidenceLevel[] { cl2 });
    kpExtra[2] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, null);
    kpExtra[3] = new KeyphraseRecognitionExtra(1, SoundTrigger.RECOGNITION_MODE_VOICE_TRIGGER, 0, new ConfidenceLevel[0]);
    KeyphraseRecognitionEvent re = new KeyphraseRecognitionEvent(SoundTrigger.RECOGNITION_STATUS_FAILURE, 1, true, 2, 3, 4, false, null, data, kpExtra);
    // Write to a parcel
    Parcel parcel = Parcel.obtain();
    re.writeToParcel(parcel, 0);
    // Read from it
    parcel.setDataPosition(0);
    KeyphraseRecognitionEvent unparceled = KeyphraseRecognitionEvent.CREATOR.createFromParcel(parcel);
    // Verify that they are the same
    assertEquals(re, unparceled);
}
Also used : KeyphraseRecognitionExtra(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra) ConfidenceLevel(android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel) KeyphraseRecognitionEvent(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionEvent) Parcel(android.os.Parcel) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 12 with KeyphraseRecognitionEvent

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

the class SoundTriggerTest method testKeyphraseRecognitionEventParcelUnparcel_noKeyphrases.

@SmallTest
public void testKeyphraseRecognitionEventParcelUnparcel_noKeyphrases() throws Exception {
    KeyphraseRecognitionEvent re = new KeyphraseRecognitionEvent(SoundTrigger.RECOGNITION_STATUS_SUCCESS, 1, true, 2, 3, 4, false, null, null, null);
    // Write to a parcel
    Parcel parcel = Parcel.obtain();
    re.writeToParcel(parcel, 0);
    // Read from it
    parcel.setDataPosition(0);
    KeyphraseRecognitionEvent unparceled = KeyphraseRecognitionEvent.CREATOR.createFromParcel(parcel);
    // Verify that they are the same
    assertEquals(re, unparceled);
}
Also used : KeyphraseRecognitionEvent(android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionEvent) Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

KeyphraseRecognitionEvent (android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionEvent)12 Parcel (android.os.Parcel)12 KeyphraseRecognitionExtra (android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra)8 SmallTest (android.test.suitebuilder.annotation.SmallTest)8 ConfidenceLevel (android.hardware.soundtrigger.SoundTrigger.ConfidenceLevel)4 LargeTest (android.test.suitebuilder.annotation.LargeTest)4