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

Commit bec28e5a authored by Atneya Nair's avatar Atneya Nair Committed by Automerger Merge Worker
Browse files

Merge "Fix ST recognition requested after start error" into udc-dev am: 7c33508e

parents b8035d4c 7c33508e
Loading
Loading
Loading
Loading
+24 −5
Original line number Diff line number Diff line
@@ -322,12 +322,31 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
            modelData.setRunInBatterySaverMode(runInBatterySaverMode);
            modelData.setSoundModel(soundModel);

            if (!isRecognitionAllowedByDeviceState(modelData)) {
                return STATUS_OK;
            }

            return updateRecognitionLocked(modelData,
            if (isRecognitionAllowedByDeviceState(modelData)) {
                int startRecoResult = updateRecognitionLocked(modelData,
                        false /* Don't notify for synchronous calls */);
                if (startRecoResult == SoundTrigger.STATUS_OK) {
                    return startRecoResult;
                } else if (startRecoResult != SoundTrigger.STATUS_BUSY) {
                    // If we are returning an unexpected error, don't mark the model as requested
                    modelData.setRequested(false);
                    return startRecoResult;
                }
            }
            // Either recognition isn't allowed by device state, or the module is busy.
            // Dispatch a pause.
            try {
                if (callback != null) {
                    mEventLogger.enqueue(new SessionEvent(Type.PAUSE, modelData.getModelId()));
                    callback.onRecognitionPaused();
                }
            } catch (RemoteException e) {
                mEventLogger.enqueue(new SessionEvent(
                            Type.PAUSE, modelData.getModelId(), "RemoteException")
                        .printLog(ALOGW, TAG));
                forceStopAndUnloadModelLocked(modelData, e);
            }
            return STATUS_OK;
        }
    }