Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java +21 −18 Original line number Original line Diff line number Diff line Loading @@ -104,8 +104,8 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { // This is an indirect indication of the microphone being open in some other application. // This is an indirect indication of the microphone being open in some other application. private boolean mServiceDisabled = false; private boolean mServiceDisabled = false; // Whether we have ANY recognition (keyphrase or generic) running. // Whether ANY recognition (keyphrase or generic) has been requested. private boolean mRecognitionRunning = false; private boolean mRecognitionRequested = false; private PowerSaveModeListener mPowerSaveModeListener; private PowerSaveModeListener mPowerSaveModeListener; Loading Loading @@ -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 // 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. // 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 // This works for both keyphrase and generic models. This logic also ensures that a Loading Loading @@ -326,8 +321,16 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { modelData.setRecognitionConfig(recognitionConfig); modelData.setRecognitionConfig(recognitionConfig); modelData.setSoundModel(soundModel); modelData.setSoundModel(soundModel); return startRecognitionLocked(modelData, int status = startRecognitionLocked(modelData, false /* Don't notify for synchronous calls */); 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; } } } } Loading Loading @@ -450,7 +453,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { modelData.clearCallback(); modelData.clearCallback(); modelData.setRecognitionConfig(null); modelData.setRecognitionConfig(null); if (!computeRecognitionRunningLocked()) { if (!computeRecognitionRequestedLocked()) { internalClearGlobalStateLocked(); internalClearGlobalStateLocked(); } } Loading Loading @@ -1196,20 +1199,20 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { } } // Computes whether we have any recognition running at all (voice or generic). Sets // Computes whether we have any recognition running at all (voice or generic). Sets // the mRecognitionRunning variable with the result. // the mRecognitionRequested variable with the result. private boolean computeRecognitionRunningLocked() { private boolean computeRecognitionRequestedLocked() { if (mModuleProperties == null || mModule == null) { if (mModuleProperties == null || mModule == null) { mRecognitionRunning = false; mRecognitionRequested = false; return mRecognitionRunning; return mRecognitionRequested; } } for (ModelData modelData : mModelDataMap.values()) { for (ModelData modelData : mModelDataMap.values()) { if (modelData.isModelStarted()) { if (modelData.isRequested()) { mRecognitionRunning = true; mRecognitionRequested = true; return mRecognitionRunning; return mRecognitionRequested; } } } } mRecognitionRunning = false; mRecognitionRequested = false; return mRecognitionRunning; return mRecognitionRequested; } } // This class encapsulates the callbacks, state, handles and any other information that // This class encapsulates the callbacks, state, handles and any other information that Loading Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java +21 −18 Original line number Original line Diff line number Diff line Loading @@ -104,8 +104,8 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { // This is an indirect indication of the microphone being open in some other application. // This is an indirect indication of the microphone being open in some other application. private boolean mServiceDisabled = false; private boolean mServiceDisabled = false; // Whether we have ANY recognition (keyphrase or generic) running. // Whether ANY recognition (keyphrase or generic) has been requested. private boolean mRecognitionRunning = false; private boolean mRecognitionRequested = false; private PowerSaveModeListener mPowerSaveModeListener; private PowerSaveModeListener mPowerSaveModeListener; Loading Loading @@ -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 // 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. // 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 // This works for both keyphrase and generic models. This logic also ensures that a Loading Loading @@ -326,8 +321,16 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { modelData.setRecognitionConfig(recognitionConfig); modelData.setRecognitionConfig(recognitionConfig); modelData.setSoundModel(soundModel); modelData.setSoundModel(soundModel); return startRecognitionLocked(modelData, int status = startRecognitionLocked(modelData, false /* Don't notify for synchronous calls */); 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; } } } } Loading Loading @@ -450,7 +453,7 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { modelData.clearCallback(); modelData.clearCallback(); modelData.setRecognitionConfig(null); modelData.setRecognitionConfig(null); if (!computeRecognitionRunningLocked()) { if (!computeRecognitionRequestedLocked()) { internalClearGlobalStateLocked(); internalClearGlobalStateLocked(); } } Loading Loading @@ -1196,20 +1199,20 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { } } // Computes whether we have any recognition running at all (voice or generic). Sets // Computes whether we have any recognition running at all (voice or generic). Sets // the mRecognitionRunning variable with the result. // the mRecognitionRequested variable with the result. private boolean computeRecognitionRunningLocked() { private boolean computeRecognitionRequestedLocked() { if (mModuleProperties == null || mModule == null) { if (mModuleProperties == null || mModule == null) { mRecognitionRunning = false; mRecognitionRequested = false; return mRecognitionRunning; return mRecognitionRequested; } } for (ModelData modelData : mModelDataMap.values()) { for (ModelData modelData : mModelDataMap.values()) { if (modelData.isModelStarted()) { if (modelData.isRequested()) { mRecognitionRunning = true; mRecognitionRequested = true; return mRecognitionRunning; return mRecognitionRequested; } } } } mRecognitionRunning = false; mRecognitionRequested = false; return mRecognitionRunning; return mRecognitionRequested; } } // This class encapsulates the callbacks, state, handles and any other information that // This class encapsulates the callbacks, state, handles and any other information that Loading