Merge "Fix ST recognition requested after start error" into udc-dev

This commit is contained in:
Atneya Nair
2023-05-04 16:34:25 +00:00
committed by Android (Google) Code Review

View File

@@ -322,12 +322,31 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
modelData.setRunInBatterySaverMode(runInBatterySaverMode); modelData.setRunInBatterySaverMode(runInBatterySaverMode);
modelData.setSoundModel(soundModel); modelData.setSoundModel(soundModel);
if (!isRecognitionAllowedByDeviceState(modelData)) { if (isRecognitionAllowedByDeviceState(modelData)) {
return STATUS_OK; 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.
return updateRecognitionLocked(modelData, // Dispatch a pause.
false /* Don't notify for synchronous calls */); 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;
} }
} }