use of android.hardware.soundtrigger.SoundTrigger.RecognitionConfig in project android_frameworks_base by ResurrectionRemix.
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.RecognitionConfig in project android_frameworks_base by ResurrectionRemix.
the class GenericSoundModelTest method testTriggerGenericSoundModel.
@LargeTest
public void testTriggerGenericSoundModel() 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
soundTriggerService.updateSoundModel(model);
loadedModelUuids.add(model.uuid);
soundTriggerService.startRecognition(new ParcelUuid(model.uuid), spyCallback, config);
// Send trigger to stub HAL
Socket socket = new Socket(InetAddress.getLocalHost(), 14035);
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.writeBytes("trig " + model.uuid.toString() + "\r\n");
out.flush();
socket.close();
// Verify trigger was received
verify(spyCallback, timeout(100)).onGenericSoundTriggerDetected(any());
}
use of android.hardware.soundtrigger.SoundTrigger.RecognitionConfig in project android_frameworks_base by crdroidandroid.
the class GenericSoundModelTest method testTriggerGenericSoundModel.
@LargeTest
public void testTriggerGenericSoundModel() 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
soundTriggerService.updateSoundModel(model);
loadedModelUuids.add(model.uuid);
soundTriggerService.startRecognition(new ParcelUuid(model.uuid), spyCallback, config);
// Send trigger to stub HAL
Socket socket = new Socket(InetAddress.getLocalHost(), 14035);
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
out.writeBytes("trig " + model.uuid.toString() + "\r\n");
out.flush();
socket.close();
// Verify trigger was received
verify(spyCallback, timeout(100)).onGenericSoundTriggerDetected(any());
}
use of android.hardware.soundtrigger.SoundTrigger.RecognitionConfig in project android_frameworks_base by crdroidandroid.
the class SoundTriggerHelper method startRecognitionLocked.
// A single routine that implements the start recognition logic for both generic and keyphrase
// models.
private int startRecognitionLocked(ModelData modelData, boolean notify) {
IRecognitionStatusCallback callback = modelData.getCallback();
int handle = modelData.getHandle();
RecognitionConfig config = modelData.getRecognitionConfig();
if (callback == null || handle == INVALID_VALUE || config == null) {
// Nothing to do here.
Slog.w(TAG, "startRecognition: Bad data passed in.");
MetricsLogger.count(mContext, "sth_start_recognition_error", 1);
return STATUS_ERROR;
}
if (!isRecognitionAllowed()) {
// Nothing to do here.
Slog.w(TAG, "startRecognition requested but not allowed.");
MetricsLogger.count(mContext, "sth_start_recognition_not_allowed", 1);
return STATUS_OK;
}
int status = mModule.startRecognition(handle, config);
if (status != SoundTrigger.STATUS_OK) {
Slog.w(TAG, "startRecognition failed with " + status);
MetricsLogger.count(mContext, "sth_start_recognition_error", 1);
// Notify of error if needed.
if (notify) {
try {
callback.onError(status);
} catch (RemoteException e) {
Slog.w(TAG, "RemoteException in onError", e);
}
}
} else {
Slog.i(TAG, "startRecognition successful.");
MetricsLogger.count(mContext, "sth_start_recognition_success", 1);
modelData.setStarted();
// Notify of resume if needed.
if (notify) {
try {
callback.onRecognitionResumed();
} catch (RemoteException e) {
Slog.w(TAG, "RemoteException in onRecognitionResumed", e);
}
}
}
if (DBG) {
Slog.d(TAG, "Model being started :" + modelData.toString());
}
return status;
}
Aggregations