Search in sources :

Example 16 with GenericSoundModel

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);
}
Also used : ParcelUuid(android.os.ParcelUuid) GenericSoundModel(android.hardware.soundtrigger.SoundTrigger.GenericSoundModel) RecognitionConfig(android.hardware.soundtrigger.SoundTrigger.RecognitionConfig) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 17 with GenericSoundModel

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);
}
Also used : ParcelUuid(android.os.ParcelUuid) GenericSoundModel(android.hardware.soundtrigger.SoundTrigger.GenericSoundModel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 18 with GenericSoundModel

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);
}
Also used : ParcelUuid(android.os.ParcelUuid) GenericSoundModel(android.hardware.soundtrigger.SoundTrigger.GenericSoundModel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 19 with GenericSoundModel

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");
    }
}
Also used : GenericSoundModel(android.hardware.soundtrigger.SoundTrigger.GenericSoundModel)

Example 20 with GenericSoundModel

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");
    }
}
Also used : GenericSoundModel(android.hardware.soundtrigger.SoundTrigger.GenericSoundModel)

Aggregations

GenericSoundModel (android.hardware.soundtrigger.SoundTrigger.GenericSoundModel)44 ParcelUuid (android.os.ParcelUuid)20 RecognitionConfig (android.hardware.soundtrigger.SoundTrigger.RecognitionConfig)12 LargeTest (android.test.suitebuilder.annotation.LargeTest)12 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)8 SmallTest (android.test.suitebuilder.annotation.SmallTest)8 DataOutputStream (java.io.DataOutputStream)8 Socket (java.net.Socket)8 UUID (java.util.UUID)8 Cursor (android.database.Cursor)4 ArrayList (java.util.ArrayList)4 Random (java.util.Random)4