Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java +0 −28 Original line number Original line Diff line number Diff line Loading @@ -482,34 +482,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { return status; return status; } } /** * Stops all recognitions active currently and clears the internal state. */ void stopAllRecognitions() { synchronized (mLock) { MetricsLogger.count(mContext, "sth_stop_all_recognitions", 1); if (mModuleProperties == null || mModule == null) { return; } // Stop all recognition models. for (ModelData model : mModelDataMap.values()) { if (model.isModelStarted()) { int status = stopRecognitionLocked(model, false /* do not notify for synchronous calls */); if (status != STATUS_OK) { Slog.w(TAG, "Error stopping model: " + model.getHandle()); } model.setStopped(); model.setRequested(false); model.clearCallback(); model.setRecognitionConfig(null); } } internalClearGlobalStateLocked(); } } public ModuleProperties getModuleProperties() { public ModuleProperties getModuleProperties() { return mModuleProperties; return mModuleProperties; } } Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerInternal.java +3 −5 Original line number Original line Diff line number Diff line Loading @@ -68,13 +68,11 @@ public abstract class SoundTriggerInternal { */ */ public abstract int stopRecognition(int keyphraseId, IRecognitionStatusCallback listener); public abstract int stopRecognition(int keyphraseId, IRecognitionStatusCallback listener); /** * Stops all recognitions active currently and clears the internal state. */ public abstract void stopAllRecognitions(); public abstract ModuleProperties getModuleProperties(); public abstract ModuleProperties getModuleProperties(); /** * Unloads (and stops if running) the given keyphraseId */ public abstract int unloadKeyphraseModel(int keyphaseId); public abstract int unloadKeyphraseModel(int keyphaseId); public abstract void dump(FileDescriptor fd, PrintWriter pw, String[] args); public abstract void dump(FileDescriptor fd, PrintWriter pw, String[] args); Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +0 −6 Original line number Original line Diff line number Diff line Loading @@ -205,12 +205,6 @@ public class SoundTriggerService extends SystemService { return mSoundTriggerHelper.stopKeyphraseRecognition(keyphraseId, listener); return mSoundTriggerHelper.stopKeyphraseRecognition(keyphraseId, listener); } } @Override public void stopAllRecognitions() { if (!isInitialized()) return; mSoundTriggerHelper.stopAllRecognitions(); } @Override @Override public ModuleProperties getModuleProperties() { public ModuleProperties getModuleProperties() { if (!isInitialized()) return null; if (!isInitialized()) return null; Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +26 −2 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ import com.android.server.UiThread; import java.io.FileDescriptor; import java.io.FileDescriptor; import java.io.PrintWriter; import java.io.PrintWriter; import java.util.List; import java.util.List; import java.util.TreeSet; /** /** * SystemService that publishes an IVoiceInteractionManagerService. * SystemService that publishes an IVoiceInteractionManagerService. Loading @@ -81,6 +82,7 @@ public class VoiceInteractionManagerService extends SystemService { final ContentResolver mResolver; final ContentResolver mResolver; final DatabaseHelper mDbHelper; final DatabaseHelper mDbHelper; final ActivityManagerInternal mAmInternal; final ActivityManagerInternal mAmInternal; final TreeSet<Integer> mLoadedKeyphraseIds; SoundTriggerInternal mSoundTriggerInternal; SoundTriggerInternal mSoundTriggerInternal; public VoiceInteractionManagerService(Context context) { public VoiceInteractionManagerService(Context context) { Loading @@ -90,6 +92,7 @@ public class VoiceInteractionManagerService extends SystemService { mDbHelper = new DatabaseHelper(context); mDbHelper = new DatabaseHelper(context); mServiceStub = new VoiceInteractionManagerServiceStub(); mServiceStub = new VoiceInteractionManagerServiceStub(); mAmInternal = LocalServices.getService(ActivityManagerInternal.class); mAmInternal = LocalServices.getService(ActivityManagerInternal.class); mLoadedKeyphraseIds = new TreeSet<Integer>(); PackageManagerInternal packageManagerInternal = LocalServices.getService( PackageManagerInternal packageManagerInternal = LocalServices.getService( PackageManagerInternal.class); PackageManagerInternal.class); Loading Loading @@ -394,7 +397,7 @@ public class VoiceInteractionManagerService extends SystemService { if (force || mImpl == null || mImpl.mUser != mCurUser if (force || mImpl == null || mImpl.mUser != mCurUser || !mImpl.mComponent.equals(serviceComponent)) { || !mImpl.mComponent.equals(serviceComponent)) { mSoundTriggerInternal.stopAllRecognitions(); unloadAllKeyphraseModels(); if (mImpl != null) { if (mImpl != null) { mImpl.shutdownLocked(); mImpl.shutdownLocked(); } } Loading Loading @@ -785,6 +788,7 @@ public class VoiceInteractionManagerService extends SystemService { if (mImpl != null && mImpl.mService != null) { if (mImpl != null && mImpl.mService != null) { mImpl.notifySoundModelsChangedLocked(); mImpl.notifySoundModelsChangedLocked(); } } mLoadedKeyphraseIds.remove(keyphraseId); } } } } Binder.restoreCallingIdentity(caller); Binder.restoreCallingIdentity(caller); Loading Loading @@ -865,6 +869,11 @@ public class VoiceInteractionManagerService extends SystemService { Slog.w(TAG, "No matching sound model found in startRecognition"); Slog.w(TAG, "No matching sound model found in startRecognition"); return SoundTriggerInternal.STATUS_ERROR; return SoundTriggerInternal.STATUS_ERROR; } else { } else { // Regardless of the status of the start recognition, we need to make sure // that we unload this model if needed later. synchronized (this) { mLoadedKeyphraseIds.add(keyphraseId); } return mSoundTriggerInternal.startRecognition( return mSoundTriggerInternal.startRecognition( keyphraseId, soundModel, callback, recognitionConfig); keyphraseId, soundModel, callback, recognitionConfig); } } Loading Loading @@ -893,6 +902,21 @@ public class VoiceInteractionManagerService extends SystemService { } } } } private synchronized void unloadAllKeyphraseModels() { for (int keyphraseId : mLoadedKeyphraseIds) { final long caller = Binder.clearCallingIdentity(); try { int status = mSoundTriggerInternal.unloadKeyphraseModel(keyphraseId); if (status != SoundTriggerInternal.STATUS_OK) { Slog.w(TAG, "Failed to unload keyphrase " + keyphraseId + ":" + status); } } finally { Binder.restoreCallingIdentity(caller); } } mLoadedKeyphraseIds.clear(); } @Override @Override public ComponentName getActiveServiceComponentName() { public ComponentName getActiveServiceComponentName() { enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); Loading Loading @@ -1078,7 +1102,7 @@ public class VoiceInteractionManagerService extends SystemService { // The user is force stopping our current interactor/recognizer. // The user is force stopping our current interactor/recognizer. // Clear the current settings and restore default state. // Clear the current settings and restore default state. synchronized (VoiceInteractionManagerService.this) { synchronized (VoiceInteractionManagerService.this) { mSoundTriggerInternal.stopAllRecognitions(); unloadAllKeyphraseModels(); if (mImpl != null) { if (mImpl != null) { mImpl.shutdownLocked(); mImpl.shutdownLocked(); mImpl = null; mImpl = null; Loading Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java +0 −28 Original line number Original line Diff line number Diff line Loading @@ -482,34 +482,6 @@ public class SoundTriggerHelper implements SoundTrigger.StatusListener { return status; return status; } } /** * Stops all recognitions active currently and clears the internal state. */ void stopAllRecognitions() { synchronized (mLock) { MetricsLogger.count(mContext, "sth_stop_all_recognitions", 1); if (mModuleProperties == null || mModule == null) { return; } // Stop all recognition models. for (ModelData model : mModelDataMap.values()) { if (model.isModelStarted()) { int status = stopRecognitionLocked(model, false /* do not notify for synchronous calls */); if (status != STATUS_OK) { Slog.w(TAG, "Error stopping model: " + model.getHandle()); } model.setStopped(); model.setRequested(false); model.clearCallback(); model.setRecognitionConfig(null); } } internalClearGlobalStateLocked(); } } public ModuleProperties getModuleProperties() { public ModuleProperties getModuleProperties() { return mModuleProperties; return mModuleProperties; } } Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerInternal.java +3 −5 Original line number Original line Diff line number Diff line Loading @@ -68,13 +68,11 @@ public abstract class SoundTriggerInternal { */ */ public abstract int stopRecognition(int keyphraseId, IRecognitionStatusCallback listener); public abstract int stopRecognition(int keyphraseId, IRecognitionStatusCallback listener); /** * Stops all recognitions active currently and clears the internal state. */ public abstract void stopAllRecognitions(); public abstract ModuleProperties getModuleProperties(); public abstract ModuleProperties getModuleProperties(); /** * Unloads (and stops if running) the given keyphraseId */ public abstract int unloadKeyphraseModel(int keyphaseId); public abstract int unloadKeyphraseModel(int keyphaseId); public abstract void dump(FileDescriptor fd, PrintWriter pw, String[] args); public abstract void dump(FileDescriptor fd, PrintWriter pw, String[] args); Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +0 −6 Original line number Original line Diff line number Diff line Loading @@ -205,12 +205,6 @@ public class SoundTriggerService extends SystemService { return mSoundTriggerHelper.stopKeyphraseRecognition(keyphraseId, listener); return mSoundTriggerHelper.stopKeyphraseRecognition(keyphraseId, listener); } } @Override public void stopAllRecognitions() { if (!isInitialized()) return; mSoundTriggerHelper.stopAllRecognitions(); } @Override @Override public ModuleProperties getModuleProperties() { public ModuleProperties getModuleProperties() { if (!isInitialized()) return null; if (!isInitialized()) return null; Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +26 −2 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ import com.android.server.UiThread; import java.io.FileDescriptor; import java.io.FileDescriptor; import java.io.PrintWriter; import java.io.PrintWriter; import java.util.List; import java.util.List; import java.util.TreeSet; /** /** * SystemService that publishes an IVoiceInteractionManagerService. * SystemService that publishes an IVoiceInteractionManagerService. Loading @@ -81,6 +82,7 @@ public class VoiceInteractionManagerService extends SystemService { final ContentResolver mResolver; final ContentResolver mResolver; final DatabaseHelper mDbHelper; final DatabaseHelper mDbHelper; final ActivityManagerInternal mAmInternal; final ActivityManagerInternal mAmInternal; final TreeSet<Integer> mLoadedKeyphraseIds; SoundTriggerInternal mSoundTriggerInternal; SoundTriggerInternal mSoundTriggerInternal; public VoiceInteractionManagerService(Context context) { public VoiceInteractionManagerService(Context context) { Loading @@ -90,6 +92,7 @@ public class VoiceInteractionManagerService extends SystemService { mDbHelper = new DatabaseHelper(context); mDbHelper = new DatabaseHelper(context); mServiceStub = new VoiceInteractionManagerServiceStub(); mServiceStub = new VoiceInteractionManagerServiceStub(); mAmInternal = LocalServices.getService(ActivityManagerInternal.class); mAmInternal = LocalServices.getService(ActivityManagerInternal.class); mLoadedKeyphraseIds = new TreeSet<Integer>(); PackageManagerInternal packageManagerInternal = LocalServices.getService( PackageManagerInternal packageManagerInternal = LocalServices.getService( PackageManagerInternal.class); PackageManagerInternal.class); Loading Loading @@ -394,7 +397,7 @@ public class VoiceInteractionManagerService extends SystemService { if (force || mImpl == null || mImpl.mUser != mCurUser if (force || mImpl == null || mImpl.mUser != mCurUser || !mImpl.mComponent.equals(serviceComponent)) { || !mImpl.mComponent.equals(serviceComponent)) { mSoundTriggerInternal.stopAllRecognitions(); unloadAllKeyphraseModels(); if (mImpl != null) { if (mImpl != null) { mImpl.shutdownLocked(); mImpl.shutdownLocked(); } } Loading Loading @@ -785,6 +788,7 @@ public class VoiceInteractionManagerService extends SystemService { if (mImpl != null && mImpl.mService != null) { if (mImpl != null && mImpl.mService != null) { mImpl.notifySoundModelsChangedLocked(); mImpl.notifySoundModelsChangedLocked(); } } mLoadedKeyphraseIds.remove(keyphraseId); } } } } Binder.restoreCallingIdentity(caller); Binder.restoreCallingIdentity(caller); Loading Loading @@ -865,6 +869,11 @@ public class VoiceInteractionManagerService extends SystemService { Slog.w(TAG, "No matching sound model found in startRecognition"); Slog.w(TAG, "No matching sound model found in startRecognition"); return SoundTriggerInternal.STATUS_ERROR; return SoundTriggerInternal.STATUS_ERROR; } else { } else { // Regardless of the status of the start recognition, we need to make sure // that we unload this model if needed later. synchronized (this) { mLoadedKeyphraseIds.add(keyphraseId); } return mSoundTriggerInternal.startRecognition( return mSoundTriggerInternal.startRecognition( keyphraseId, soundModel, callback, recognitionConfig); keyphraseId, soundModel, callback, recognitionConfig); } } Loading Loading @@ -893,6 +902,21 @@ public class VoiceInteractionManagerService extends SystemService { } } } } private synchronized void unloadAllKeyphraseModels() { for (int keyphraseId : mLoadedKeyphraseIds) { final long caller = Binder.clearCallingIdentity(); try { int status = mSoundTriggerInternal.unloadKeyphraseModel(keyphraseId); if (status != SoundTriggerInternal.STATUS_OK) { Slog.w(TAG, "Failed to unload keyphrase " + keyphraseId + ":" + status); } } finally { Binder.restoreCallingIdentity(caller); } } mLoadedKeyphraseIds.clear(); } @Override @Override public ComponentName getActiveServiceComponentName() { public ComponentName getActiveServiceComponentName() { enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); Loading Loading @@ -1078,7 +1102,7 @@ public class VoiceInteractionManagerService extends SystemService { // The user is force stopping our current interactor/recognizer. // The user is force stopping our current interactor/recognizer. // Clear the current settings and restore default state. // Clear the current settings and restore default state. synchronized (VoiceInteractionManagerService.this) { synchronized (VoiceInteractionManagerService.this) { mSoundTriggerInternal.stopAllRecognitions(); unloadAllKeyphraseModels(); if (mImpl != null) { if (mImpl != null) { mImpl.shutdownLocked(); mImpl.shutdownLocked(); mImpl = null; mImpl = null; Loading