use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project android_frameworks_base by crdroidandroid.
the class GenericSoundModelTest method testStartStopGenericSoundModel.
@LargeTest
public void testStartStopGenericSoundModel() throws Exception {
GenericSoundModel model = new_sound_model();
boolean captureTriggerAudio = true;
boolean allowMultipleTriggers = true;
RecognitionConfig config = new RecognitionConfig(captureTriggerAudio, allowMultipleTriggers, null, null);
TestRecognitionStatusCallback spyCallback = spy(new TestRecognitionStatusCallback());
// Update and start sound model recognition
soundTriggerService.updateSoundModel(model);
loadedModelUuids.add(model.uuid);
int r = soundTriggerService.startRecognition(new ParcelUuid(model.uuid), spyCallback, config);
assertEquals("Could Not Start Recognition with code: " + r, android.hardware.soundtrigger.SoundTrigger.STATUS_OK, r);
// Stop recognition
r = soundTriggerService.stopRecognition(new ParcelUuid(model.uuid), spyCallback);
assertEquals("Could Not Stop Recognition with code: " + r, android.hardware.soundtrigger.SoundTrigger.STATUS_OK, r);
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project android_frameworks_base by crdroidandroid.
the class GenericSoundModelTest method testUpdateGenericSoundModel.
@SmallTest
public void testUpdateGenericSoundModel() throws Exception {
GenericSoundModel model = new_sound_model();
// Update sound model
soundTriggerService.updateSoundModel(model);
loadedModelUuids.add(model.uuid);
// Confirm it was updated
GenericSoundModel returnedModel = soundTriggerService.getSoundModel(new ParcelUuid(model.uuid));
assertEquals(model, returnedModel);
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project android_frameworks_base by crdroidandroid.
the class GenericSoundModelTest method testDeleteGenericSoundModel.
@SmallTest
public void testDeleteGenericSoundModel() throws Exception {
GenericSoundModel model = new_sound_model();
// Update sound model
soundTriggerService.updateSoundModel(model);
loadedModelUuids.add(model.uuid);
// Delete sound model
soundTriggerService.deleteSoundModel(new ParcelUuid(model.uuid));
loadedModelUuids.remove(model.uuid);
// Confirm it was deleted
GenericSoundModel returnedModel = soundTriggerService.getSoundModel(new ParcelUuid(model.uuid));
assertEquals(null, returnedModel);
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project android_frameworks_base by crdroidandroid.
the class SoundTriggerTestService method loadModel.
public synchronized void loadModel(UUID modelUuid) {
ModelInfo modelInfo = mModelInfoMap.get(modelUuid);
if (modelInfo == null) {
postError("Could not find model for: " + modelUuid.toString());
return;
}
postMessage("Loading model: " + modelInfo.name);
GenericSoundModel soundModel = createNewSoundModel(modelInfo);
boolean status = mSoundTriggerUtil.addOrUpdateSoundModel(soundModel);
if (status) {
postToast("Successfully loaded " + modelInfo.name + ", UUID=" + soundModel.uuid);
setModelState(modelInfo, "Loaded");
} else {
postErrorToast("Failed to load " + modelInfo.name + ", UUID=" + soundModel.uuid + "!");
setModelState(modelInfo, "Failed to load");
}
}
use of android.hardware.soundtrigger.SoundTrigger.GenericSoundModel in project platform_frameworks_base by android.
the class SoundTriggerTestService method reloadModel.
public synchronized void reloadModel(UUID modelUuid) {
ModelInfo modelInfo = mModelInfoMap.get(modelUuid);
if (modelInfo == null) {
postError("Could not find model for: " + modelUuid.toString());
return;
}
postMessage("Reloading model: " + modelInfo.name);
GenericSoundModel soundModel = mSoundTriggerUtil.getSoundModel(modelUuid);
if (soundModel == null) {
postErrorToast("Sound model not found for " + modelInfo.name + "!");
return;
}
GenericSoundModel updated = createNewSoundModel(modelInfo);
boolean status = mSoundTriggerUtil.addOrUpdateSoundModel(updated);
if (status) {
postToast("Successfully reloaded " + modelInfo.name + ", UUID=" + modelInfo.modelUuid);
setModelState(modelInfo, "Reloaded");
} else {
postErrorToast("Failed to reload " + modelInfo.name + ", UUID=" + modelInfo.modelUuid + "!");
setModelState(modelInfo, "Failed to reload");
}
}
Aggregations