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);
}
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);
}
Aggregations