Ensure ST does not remain requested after error

After an error, since the service notifies the client, the service
should not attempt to restart recognition again when a state update
occurs, otherwise a state mismatch will occur.

Also, null out the recog token when the model state is cleared.

Bug: 272147641
Fixes: 280911900
Test: AlwaysOnHotwordDetectorTest#
    testRecognitionNotRequested_afterResumeFailed
Change-Id: I3f7c441a87292d767b6296d6075218a29850da2c
This commit is contained in:
Atneya Nair
2023-05-04 19:31:55 -07:00
parent d2c2751bff
commit ef2c62e79c

View File

@@ -1252,6 +1252,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
mEventLogger.enqueue(new SessionEvent(Type.RESUME_FAILED,
modelData.getModelId(), String.valueOf(status))
.printLog(ALOGW, TAG));
modelData.setRequested(false);
callback.onResumeFailed(status);
} catch (RemoteException e) {
mEventLogger.enqueue(new SessionEvent(Type.RESUME_FAILED,
@@ -1300,6 +1301,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
mEventLogger.enqueue(new SessionEvent(Type.PAUSE_FAILED,
modelData.getModelId(), String.valueOf(status))
.printLog(ALOGW, TAG));
modelData.setRequested(false);
callback.onPauseFailed(status);
} catch (RemoteException e) {
mEventLogger.enqueue(new SessionEvent(Type.PAUSE_FAILED,
@@ -1453,6 +1455,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
}
synchronized void setNotLoaded() {
mRecognitionToken = null;
mModelState = MODEL_NOTLOADED;
}
@@ -1462,6 +1465,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
synchronized void clearState() {
mModelState = MODEL_NOTLOADED;
mRecognitionToken = null;
mRecognitionConfig = null;
mRequested = false;
mCallback = null;