Merge "Correctly initialize recognition events" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fe5ac369f9
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
|
|||||||
import android.media.permission.SafeCloseable;
|
import android.media.permission.SafeCloseable;
|
||||||
import android.media.soundtrigger.ModelParameterRange;
|
import android.media.soundtrigger.ModelParameterRange;
|
||||||
import android.media.soundtrigger.PhraseRecognitionEvent;
|
import android.media.soundtrigger.PhraseRecognitionEvent;
|
||||||
|
import android.media.soundtrigger.PhraseRecognitionExtra;
|
||||||
import android.media.soundtrigger.PhraseSoundModel;
|
import android.media.soundtrigger.PhraseSoundModel;
|
||||||
import android.media.soundtrigger.Properties;
|
import android.media.soundtrigger.Properties;
|
||||||
import android.media.soundtrigger.RecognitionConfig;
|
import android.media.soundtrigger.RecognitionConfig;
|
||||||
@@ -392,7 +393,7 @@ public class SoundTriggerHalConcurrentCaptureHandler implements ISoundTriggerHal
|
|||||||
private static void notifyAbort(int modelHandle, LoadedModel model) {
|
private static void notifyAbort(int modelHandle, LoadedModel model) {
|
||||||
switch (model.type) {
|
switch (model.type) {
|
||||||
case SoundModelType.GENERIC: {
|
case SoundModelType.GENERIC: {
|
||||||
RecognitionEvent event = new RecognitionEvent();
|
RecognitionEvent event = newEmptyRecognitionEvent();
|
||||||
event.status = RecognitionStatus.ABORTED;
|
event.status = RecognitionStatus.ABORTED;
|
||||||
event.type = SoundModelType.GENERIC;
|
event.type = SoundModelType.GENERIC;
|
||||||
model.callback.recognitionCallback(modelHandle, event);
|
model.callback.recognitionCallback(modelHandle, event);
|
||||||
@@ -400,7 +401,7 @@ public class SoundTriggerHalConcurrentCaptureHandler implements ISoundTriggerHal
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SoundModelType.KEYPHRASE: {
|
case SoundModelType.KEYPHRASE: {
|
||||||
PhraseRecognitionEvent event = new PhraseRecognitionEvent();
|
PhraseRecognitionEvent event = newEmptyPhraseRecognitionEvent();
|
||||||
event.common.status = RecognitionStatus.ABORTED;
|
event.common.status = RecognitionStatus.ABORTED;
|
||||||
event.common.type = SoundModelType.KEYPHRASE;
|
event.common.type = SoundModelType.KEYPHRASE;
|
||||||
model.callback.phraseRecognitionCallback(modelHandle, event);
|
model.callback.phraseRecognitionCallback(modelHandle, event);
|
||||||
@@ -415,6 +416,19 @@ public class SoundTriggerHalConcurrentCaptureHandler implements ISoundTriggerHal
|
|||||||
mNotifier.unregisterListener(this);
|
mNotifier.unregisterListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PhraseRecognitionEvent newEmptyPhraseRecognitionEvent() {
|
||||||
|
PhraseRecognitionEvent result = new PhraseRecognitionEvent();
|
||||||
|
result.common = newEmptyRecognitionEvent();
|
||||||
|
result.phraseExtras = new PhraseRecognitionExtra[0];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RecognitionEvent newEmptyRecognitionEvent() {
|
||||||
|
RecognitionEvent result = new RecognitionEvent();
|
||||||
|
result.data = new byte[0];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// All methods below do trivial delegation - no interesting logic.
|
// All methods below do trivial delegation - no interesting logic.
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user