Merge "SoundTriggerHelper: fix power save mode listener" into qt-r1-dev

am: 8b3386567f

Change-Id: Ibadb71932d91e456c4bf6fbd40c24ae060664a8b
This commit is contained in:
Eric Laurent
2019-07-22 18:18:08 -07:00
committed by android-build-merger

View File

@@ -104,8 +104,8 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
// This is an indirect indication of the microphone being open in some other application.
private boolean mServiceDisabled = false;
// Whether we have ANY recognition (keyphrase or generic) running.
private boolean mRecognitionRunning = false;
// Whether ANY recognition (keyphrase or generic) has been requested.
private boolean mRecognitionRequested = false;
private PowerSaveModeListener mPowerSaveModeListener;
@@ -252,11 +252,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
}
}
// Initialize power save, call active state monitoring logic.
if (!mRecognitionRunning) {
initializeTelephonyAndPowerStateListeners();
}
// If the existing SoundModel is different (for the same UUID for Generic and same
// keyphrase ID for voice), ensure that it is unloaded and stopped before proceeding.
// This works for both keyphrase and generic models. This logic also ensures that a
@@ -326,8 +321,16 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
modelData.setRecognitionConfig(recognitionConfig);
modelData.setSoundModel(soundModel);
return startRecognitionLocked(modelData,
int status = startRecognitionLocked(modelData,
false /* Don't notify for synchronous calls */);
// Initialize power save, call active state monitoring logic.
if (status == STATUS_OK && !mRecognitionRequested) {
initializeTelephonyAndPowerStateListeners();
mRecognitionRequested = true;
}
return status;
}
}
@@ -450,7 +453,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
modelData.clearCallback();
modelData.setRecognitionConfig(null);
if (!computeRecognitionRunningLocked()) {
if (!computeRecognitionRequestedLocked()) {
internalClearGlobalStateLocked();
}
@@ -1196,20 +1199,20 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener {
}
// Computes whether we have any recognition running at all (voice or generic). Sets
// the mRecognitionRunning variable with the result.
private boolean computeRecognitionRunningLocked() {
// the mRecognitionRequested variable with the result.
private boolean computeRecognitionRequestedLocked() {
if (mModuleProperties == null || mModule == null) {
mRecognitionRunning = false;
return mRecognitionRunning;
mRecognitionRequested = false;
return mRecognitionRequested;
}
for (ModelData modelData : mModelDataMap.values()) {
if (modelData.isModelStarted()) {
mRecognitionRunning = true;
return mRecognitionRunning;
if (modelData.isRequested()) {
mRecognitionRequested = true;
return mRecognitionRequested;
}
}
mRecognitionRunning = false;
return mRecognitionRunning;
mRecognitionRequested = false;
return mRecognitionRequested;
}
// This class encapsulates the callbacks, state, handles and any other information that