Loading core/java/android/service/voice/AbstractHotwordDetector.java +8 −4 Original line number Diff line number Diff line Loading @@ -44,14 +44,17 @@ abstract class AbstractHotwordDetector implements HotwordDetector { private final IVoiceInteractionManagerService mManagerService; private final Handler mHandler; private final HotwordDetector.Callback mCallback; private final int mDetectorType; AbstractHotwordDetector( IVoiceInteractionManagerService managerService, HotwordDetector.Callback callback) { HotwordDetector.Callback callback, int detectorType) { mManagerService = managerService; // TODO: this needs to be supplied from above mHandler = new Handler(Looper.getMainLooper()); mCallback = callback; mDetectorType = detectorType; } /** Loading Loading @@ -104,19 +107,20 @@ abstract class AbstractHotwordDetector implements HotwordDetector { Slog.d(TAG, "updateState()"); } synchronized (mLock) { updateStateLocked(options, sharedMemory, null /* callback */); updateStateLocked(options, sharedMemory, null /* callback */, mDetectorType); } } protected void updateStateLocked(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback) { @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback, int detectorType) { if (DEBUG) { Slog.d(TAG, "updateStateLocked()"); } Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); try { mManagerService.updateState(identity, options, sharedMemory, callback); mManagerService.updateState(identity, options, sharedMemory, callback, detectorType); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/android/service/voice/AlwaysOnHotwordDetector.java +5 −2 Original line number Diff line number Diff line Loading @@ -578,7 +578,9 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { IVoiceInteractionManagerService modelManagementService, int targetSdkVersion, boolean supportHotwordDetectionService, @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { super(modelManagementService, callback); super(modelManagementService, callback, supportHotwordDetectionService ? DETECTOR_TYPE_TRUSTED_HOTWORD_DSP : DETECTOR_TYPE_NORMAL); mHandler = new MyHandler(); mText = text; Loading @@ -590,7 +592,8 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { mTargetSdkVersion = targetSdkVersion; mSupportHotwordDetectionService = supportHotwordDetectionService; if (mSupportHotwordDetectionService) { updateStateLocked(options, sharedMemory, mInternalCallback); updateStateLocked(options, sharedMemory, mInternalCallback, DETECTOR_TYPE_TRUSTED_HOTWORD_DSP); } try { Identity identity = new Identity(); Loading core/java/android/service/voice/HotwordDetector.java +37 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,27 @@ import android.os.SharedMemory; @SystemApi public interface HotwordDetector { /** * Indicates that it is a non-trusted hotword detector. * * @hide */ int DETECTOR_TYPE_NORMAL = 0; /** * Indicates that it is a DSP trusted hotword detector. * * @hide */ int DETECTOR_TYPE_TRUSTED_HOTWORD_DSP = 1; /** * Indicates that it is a software trusted hotword detector. * * @hide */ int DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE = 2; /** * Starts hotword recognition. * <p> Loading Loading @@ -97,6 +118,22 @@ public interface HotwordDetector { */ void updateState(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory); /** * @hide */ static String detectorTypeToString(int detectorType) { switch (detectorType) { case DETECTOR_TYPE_NORMAL: return "normal"; case DETECTOR_TYPE_TRUSTED_HOTWORD_DSP: return "trusted_hotword_dsp"; case DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE: return "trusted_hotword_software"; default: return Integer.toString(detectorType); } } /** * The callback to notify of detection events. */ Loading core/java/android/service/voice/SoftwareHotwordDetector.java +3 −2 Original line number Diff line number Diff line Loading @@ -60,14 +60,15 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { PersistableBundle options, SharedMemory sharedMemory, HotwordDetector.Callback callback) { super(managerService, callback); super(managerService, callback, DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); mManagerService = managerService; mAudioFormat = audioFormat; mCallback = callback; mHandler = new Handler(Looper.getMainLooper()); updateStateLocked(options, sharedMemory, new InitializationStateListener(mHandler, mCallback)); new InitializationStateListener(mHandler, mCallback), DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); } @RequiresPermission(RECORD_AUDIO) Loading core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -242,12 +242,14 @@ interface IVoiceInteractionManagerService { * {@link HotwordDetectionService}. Use this to provide the hotword models data or other * such data to the trusted process. * @param callback Use this to report {@link HotwordDetectionService} status. * @param detectorType Indicate which detector is used. */ void updateState( in Identity originatorIdentity, in PersistableBundle options, in SharedMemory sharedMemory, in IHotwordRecognitionStatusCallback callback); in IHotwordRecognitionStatusCallback callback, int detectorType); /** * Requests to shutdown hotword detection service. Loading Loading
core/java/android/service/voice/AbstractHotwordDetector.java +8 −4 Original line number Diff line number Diff line Loading @@ -44,14 +44,17 @@ abstract class AbstractHotwordDetector implements HotwordDetector { private final IVoiceInteractionManagerService mManagerService; private final Handler mHandler; private final HotwordDetector.Callback mCallback; private final int mDetectorType; AbstractHotwordDetector( IVoiceInteractionManagerService managerService, HotwordDetector.Callback callback) { HotwordDetector.Callback callback, int detectorType) { mManagerService = managerService; // TODO: this needs to be supplied from above mHandler = new Handler(Looper.getMainLooper()); mCallback = callback; mDetectorType = detectorType; } /** Loading Loading @@ -104,19 +107,20 @@ abstract class AbstractHotwordDetector implements HotwordDetector { Slog.d(TAG, "updateState()"); } synchronized (mLock) { updateStateLocked(options, sharedMemory, null /* callback */); updateStateLocked(options, sharedMemory, null /* callback */, mDetectorType); } } protected void updateStateLocked(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback) { @Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback, int detectorType) { if (DEBUG) { Slog.d(TAG, "updateStateLocked()"); } Identity identity = new Identity(); identity.packageName = ActivityThread.currentOpPackageName(); try { mManagerService.updateState(identity, options, sharedMemory, callback); mManagerService.updateState(identity, options, sharedMemory, callback, detectorType); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/android/service/voice/AlwaysOnHotwordDetector.java +5 −2 Original line number Diff line number Diff line Loading @@ -578,7 +578,9 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { IVoiceInteractionManagerService modelManagementService, int targetSdkVersion, boolean supportHotwordDetectionService, @Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory) { super(modelManagementService, callback); super(modelManagementService, callback, supportHotwordDetectionService ? DETECTOR_TYPE_TRUSTED_HOTWORD_DSP : DETECTOR_TYPE_NORMAL); mHandler = new MyHandler(); mText = text; Loading @@ -590,7 +592,8 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { mTargetSdkVersion = targetSdkVersion; mSupportHotwordDetectionService = supportHotwordDetectionService; if (mSupportHotwordDetectionService) { updateStateLocked(options, sharedMemory, mInternalCallback); updateStateLocked(options, sharedMemory, mInternalCallback, DETECTOR_TYPE_TRUSTED_HOTWORD_DSP); } try { Identity identity = new Identity(); Loading
core/java/android/service/voice/HotwordDetector.java +37 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,27 @@ import android.os.SharedMemory; @SystemApi public interface HotwordDetector { /** * Indicates that it is a non-trusted hotword detector. * * @hide */ int DETECTOR_TYPE_NORMAL = 0; /** * Indicates that it is a DSP trusted hotword detector. * * @hide */ int DETECTOR_TYPE_TRUSTED_HOTWORD_DSP = 1; /** * Indicates that it is a software trusted hotword detector. * * @hide */ int DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE = 2; /** * Starts hotword recognition. * <p> Loading Loading @@ -97,6 +118,22 @@ public interface HotwordDetector { */ void updateState(@Nullable PersistableBundle options, @Nullable SharedMemory sharedMemory); /** * @hide */ static String detectorTypeToString(int detectorType) { switch (detectorType) { case DETECTOR_TYPE_NORMAL: return "normal"; case DETECTOR_TYPE_TRUSTED_HOTWORD_DSP: return "trusted_hotword_dsp"; case DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE: return "trusted_hotword_software"; default: return Integer.toString(detectorType); } } /** * The callback to notify of detection events. */ Loading
core/java/android/service/voice/SoftwareHotwordDetector.java +3 −2 Original line number Diff line number Diff line Loading @@ -60,14 +60,15 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { PersistableBundle options, SharedMemory sharedMemory, HotwordDetector.Callback callback) { super(managerService, callback); super(managerService, callback, DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); mManagerService = managerService; mAudioFormat = audioFormat; mCallback = callback; mHandler = new Handler(Looper.getMainLooper()); updateStateLocked(options, sharedMemory, new InitializationStateListener(mHandler, mCallback)); new InitializationStateListener(mHandler, mCallback), DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE); } @RequiresPermission(RECORD_AUDIO) Loading
core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -242,12 +242,14 @@ interface IVoiceInteractionManagerService { * {@link HotwordDetectionService}. Use this to provide the hotword models data or other * such data to the trusted process. * @param callback Use this to report {@link HotwordDetectionService} status. * @param detectorType Indicate which detector is used. */ void updateState( in Identity originatorIdentity, in PersistableBundle options, in SharedMemory sharedMemory, in IHotwordRecognitionStatusCallback callback); in IHotwordRecognitionStatusCallback callback, int detectorType); /** * Requests to shutdown hotword detection service. Loading