From ef2c62e79c192e124857ac30332e31e4880f376c Mon Sep 17 00:00:00 2001 From: Atneya Nair Date: Thu, 4 May 2023 19:31:55 -0700 Subject: [PATCH] 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 --- .../com/android/server/soundtrigger/SoundTriggerHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java index f1e1a5adc2c36..dc5f6e960a2b8 100644 --- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java +++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java @@ -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;