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

Commit 23c62567 authored by mike dooley's avatar mike dooley
Browse files

Fixing getModelState event processing

Test: manual testing with SoundTriggerTestApp

Bug: 119386757

Change-Id: I2c2960d169b119cb35345315638eeae28460896c
parent 407396e3
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);