summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Atneya Nair <atneya@google.com> 2023-04-21 18:48:20 -0700
committer Atneya Nair <atneya@google.com> 2023-05-03 15:40:58 -0700
commit70b1371bbc01e18b4a245b94ea998c95adc2237d (patch)
tree44369e6acebd5218a4e88e51d0fd07b6c1641d49
parentc4a891c6bcb9ab2b28c70bfd44c283cab1f43247 (diff)
Remove SoundTriggerService stopping state
Essentially reverts f3e7be00588ea67dfaeb8be3847802d238a9a974 The addition of this state caused several state mismatch issues, and spurious error callbacks. Removing, and solving the underlying race condition in a subsequent commit. Bug: 236826280 Bug: 268217943 Fixes: 275079746 Test: AlwaysOnHotwordDetectorTest# testAbortRecognitionAndOnResourceAvailable_recognitionPausedAndResumed Test: CtsSoundTriggerTestCases Test: CtsVoiceInteractionTestCases Test: Manual verification Change-Id: Icedc330c9fefbe6444dfec886672a97d603098e4
-rw-r--r--services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java25
1 files changed, 5 insertions, 20 deletions
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
index b4066ab1ff39..c485501e4509 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
@@ -468,7 +468,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
}
}
- if (unloadModel && (modelData.isModelLoaded() || modelData.isStopPending())) {
+ if (unloadModel && modelData.isModelLoaded()) {
Slog.d(TAG, "Unloading previously loaded stale model.");
if (mModule == null) {
return STATUS_ERROR;
@@ -851,7 +851,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
Slog.w(TAG, "Recognition aborted");
MetricsLogger.count(mContext, "sth_recognition_aborted", 1);
ModelData modelData = getModelDataForLocked(event.soundModelHandle);
- if (modelData != null && (modelData.isModelStarted() || modelData.isStopPending())) {
+ if (modelData != null && modelData.isModelStarted()) {
modelData.setStopped();
try {
IRecognitionStatusCallback callback = modelData.getCallback();
@@ -865,7 +865,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
.printLog(ALOGW, TAG));
forceStopAndUnloadModelLocked(modelData, e);
}
- updateRecognitionLocked(modelData, true);
}
}
@@ -936,7 +935,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
private int updateRecognitionLocked(ModelData model, boolean notifyClientOnError) {
boolean shouldStartModel = model.isRequested() && isRecognitionAllowedByDeviceState(model);
- if (shouldStartModel == model.isModelStarted() || model.isStopPending()) {
+ if (shouldStartModel == model.isModelStarted()) {
// No-op.
return STATUS_OK;
}
@@ -1041,10 +1040,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
if (mModule == null) {
return;
}
- if (modelData.isStopPending()) {
- // No need to wait for the stop to be confirmed.
- modelData.setStopped();
- } else if (modelData.isModelStarted()) {
+ if (modelData.isModelStarted()) {
Slog.d(TAG, "Stopping previously started dangling model " + modelData.getHandle());
if (mModule.stopRecognition(modelData.getHandle()) == STATUS_OK) {
modelData.setStopped();
@@ -1256,7 +1252,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
}
}
} else {
- modelData.setStopPending();
+ modelData.setStopped();
MetricsLogger.count(mContext, "sth_stop_recognition_success", 1);
// Notify of pause if needed.
if (notify) {
@@ -1303,9 +1299,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
// Started implies model was successfully loaded and start was called.
static final int MODEL_STARTED = 2;
- // Model stop request has been sent. Waiting for an event to signal model being stopped.
- static final int MODEL_STOP_PENDING = 3;
-
// One of MODEL_NOTLOADED, MODEL_LOADED, MODEL_STARTED (which implies loaded).
private int mModelState;
private UUID mModelId;
@@ -1383,10 +1376,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
return mModelState == MODEL_NOTLOADED;
}
- synchronized boolean isStopPending() {
- return mModelState == MODEL_STOP_PENDING;
- }
-
synchronized void setStarted() {
mModelState = MODEL_STARTED;
}
@@ -1395,10 +1384,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
mModelState = MODEL_LOADED;
}
- synchronized void setStopPending() {
- mModelState = MODEL_STOP_PENDING;
- }
-
synchronized void setLoaded() {
mModelState = MODEL_LOADED;
}