Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91a94d76 authored by Michael Dooley's avatar Michael Dooley Committed by Android (Google) Code Review
Browse files

Merge "Fixing getModelState event processing"

parents 7a01a914 23c62567
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -622,6 +622,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
                    onRecognitionFailureLocked();
                    break;
                case SoundTrigger.RECOGNITION_STATUS_SUCCESS:
                case SoundTrigger.RECOGNITION_STATUS_GET_STATE_RESPONSE:
                    if (isKeyphraseRecognitionEvent(event)) {
                        onKeyphraseRecognitionSuccessLocked((KeyphraseRecognitionEvent) event);
                    } else {
@@ -638,7 +639,8 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {

    private void onGenericRecognitionSuccessLocked(GenericRecognitionEvent event) {
        MetricsLogger.count(mContext, "sth_generic_recognition_event", 1);
        if (event.status != SoundTrigger.RECOGNITION_STATUS_SUCCESS) {
        if (event.status != SoundTrigger.RECOGNITION_STATUS_SUCCESS
                && event.status != SoundTrigger.RECOGNITION_STATUS_GET_STATE_RESPONSE) {
            return;
        }
        ModelData model = getModelDataForLocked(event.soundModelHandle);
@@ -655,7 +657,9 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
            return;
        }

        if (event.status != SoundTrigger.RECOGNITION_STATUS_GET_STATE_RESPONSE) {
            model.setStopped();
        }
        try {
            callback.onGenericSoundTriggerDetected((GenericRecognitionEvent) event);
        } catch (DeadObjectException e) {
@@ -797,7 +801,10 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
            Slog.w(TAG, "Received onRecognition event without callback for keyphrase model.");
            return;
        }

        if (event.status != SoundTrigger.RECOGNITION_STATUS_GET_STATE_RESPONSE) {
            modelData.setStopped();
        }

        try {
            modelData.getCallback().onKeyphraseDetected((KeyphraseRecognitionEvent) event);