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
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
index b4066ab..c485501 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 @@
}
}
- 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 @@
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 @@
.printLog(ALOGW, TAG));
forceStopAndUnloadModelLocked(modelData, e);
}
- updateRecognitionLocked(modelData, true);
}
}
@@ -936,7 +935,7 @@
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 @@
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 @@
}
}
} else {
- modelData.setStopPending();
+ modelData.setStopped();
MetricsLogger.count(mContext, "sth_stop_recognition_success", 1);
// Notify of pause if needed.
if (notify) {
@@ -1303,9 +1299,6 @@
// 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 @@
return mModelState == MODEL_NOTLOADED;
}
- synchronized boolean isStopPending() {
- return mModelState == MODEL_STOP_PENDING;
- }
-
synchronized void setStarted() {
mModelState = MODEL_STARTED;
}
@@ -1395,10 +1384,6 @@
mModelState = MODEL_LOADED;
}
- synchronized void setStopPending() {
- mModelState = MODEL_STOP_PENDING;
- }
-
synchronized void setLoaded() {
mModelState = MODEL_LOADED;
}