Loading core/java/android/service/voice/HotwordDetectionService.java +11 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.os.ParcelFileDescriptor; import android.os.PersistableBundle; import android.os.RemoteException; import android.os.SharedMemory; import android.speech.IRecognitionServiceManager; import android.util.Log; import android.view.contentcapture.ContentCaptureManager; import android.view.contentcapture.IContentCaptureManager; Loading Loading @@ -127,6 +128,8 @@ public abstract class HotwordDetectionService extends Service { @Nullable private ContentCaptureManager mContentCaptureManager; @Nullable private IRecognitionServiceManager mIRecognitionServiceManager; private final IHotwordDetectionService mInterface = new IHotwordDetectionService.Stub() { @Override Loading Loading @@ -195,6 +198,11 @@ public abstract class HotwordDetectionService extends Service { HotwordDetectionService.this, manager, options); } @Override public void updateRecognitionServiceManager(IRecognitionServiceManager manager) { mIRecognitionServiceManager = manager; } @Override public void ping(IRemoteCallback callback) throws RemoteException { callback.sendResult(null); Loading Loading @@ -222,6 +230,9 @@ public abstract class HotwordDetectionService extends Service { public @Nullable Object getSystemService(@ServiceName @NonNull String name) { if (Context.CONTENT_CAPTURE_MANAGER_SERVICE.equals(name)) { return mContentCaptureManager; } else if (Context.SPEECH_RECOGNITION_SERVICE.equals(name) && mIRecognitionServiceManager != null) { return mIRecognitionServiceManager.asBinder(); } else { return super.getSystemService(name); } Loading core/java/android/service/voice/IHotwordDetectionService.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.PersistableBundle; import android.os.SharedMemory; import android.service.voice.IDspHotwordDetectionCallback; import android.view.contentcapture.IContentCaptureManager; import android.speech.IRecognitionServiceManager; /** * Provide the interface to communicate with hotword detection service. Loading Loading @@ -57,6 +58,9 @@ oneway interface IHotwordDetectionService { in IContentCaptureManager contentCaptureManager, in ContentCaptureOptions options); void updateRecognitionServiceManager( in IRecognitionServiceManager recognitionServiceManager); /** * Simply requests the service to trigger the callback, so that the system can check its * identity. Loading core/java/android/speech/SpeechRecognizer.java +5 −5 Original line number Diff line number Diff line Loading @@ -735,12 +735,12 @@ public class SpeechRecognizer { return true; } mManagerService = IRecognitionServiceManager.Stub.asInterface( ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE)); if (DBG) { Log.i(TAG, "#maybeInitializeManagerService instantiated =" + mManagerService); IBinder service = ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE); if (service == null && mOnDevice) { service = (IBinder) mContext.getSystemService(Context.SPEECH_RECOGNITION_SERVICE); } mManagerService = IRecognitionServiceManager.Stub.asInterface(service); if (mManagerService == null) { if (mListener != null) { mListener.onError(ERROR_CLIENT); Loading services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java +7 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import android.permission.PermissionManager; import android.speech.IRecognitionListener; Loading Loading @@ -103,6 +104,12 @@ final class SpeechRecognitionManagerServiceImpl extends serviceComponent = getOnDeviceComponentNameLocked(); } if (!onDevice && Process.isIsolated(Binder.getCallingUid())) { Slog.w(TAG, "Isolated process can only start on device speech recognizer."); tryRespondWithError(callback, SpeechRecognizer.ERROR_CLIENT); return; } if (serviceComponent == null) { if (mMaster.debug) { Slog.i(TAG, "Service component is undefined, responding with error."); Loading services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +10 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import android.service.voice.IDspHotwordDetectionCallback; import android.service.voice.IHotwordDetectionService; import android.service.voice.IMicrophoneHotwordDetectionVoiceInteractionCallback; import android.service.voice.VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity; import android.speech.IRecognitionServiceManager; import android.text.TextUtils; import android.util.Pair; import android.util.Slog; Loading Loading @@ -923,6 +924,7 @@ final class HotwordDetectionConnection { updateAudioFlinger(connection, mAudioFlinger); updateContentCaptureManager(connection); updateSpeechService(connection); updateServiceIdentity(connection); return connection; } Loading Loading @@ -1060,6 +1062,14 @@ final class HotwordDetectionConnection { new ContentCaptureOptions(null))); } private static void updateSpeechService(ServiceConnection connection) { IBinder b = ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE); IRecognitionServiceManager binderService = IRecognitionServiceManager.Stub.asInterface(b); connection.run(service -> { service.updateRecognitionServiceManager(binderService); }); } private void updateServiceIdentity(ServiceConnection connection) { connection.run(service -> service.ping(new IRemoteCallback.Stub() { @Override Loading Loading
core/java/android/service/voice/HotwordDetectionService.java +11 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.os.ParcelFileDescriptor; import android.os.PersistableBundle; import android.os.RemoteException; import android.os.SharedMemory; import android.speech.IRecognitionServiceManager; import android.util.Log; import android.view.contentcapture.ContentCaptureManager; import android.view.contentcapture.IContentCaptureManager; Loading Loading @@ -127,6 +128,8 @@ public abstract class HotwordDetectionService extends Service { @Nullable private ContentCaptureManager mContentCaptureManager; @Nullable private IRecognitionServiceManager mIRecognitionServiceManager; private final IHotwordDetectionService mInterface = new IHotwordDetectionService.Stub() { @Override Loading Loading @@ -195,6 +198,11 @@ public abstract class HotwordDetectionService extends Service { HotwordDetectionService.this, manager, options); } @Override public void updateRecognitionServiceManager(IRecognitionServiceManager manager) { mIRecognitionServiceManager = manager; } @Override public void ping(IRemoteCallback callback) throws RemoteException { callback.sendResult(null); Loading Loading @@ -222,6 +230,9 @@ public abstract class HotwordDetectionService extends Service { public @Nullable Object getSystemService(@ServiceName @NonNull String name) { if (Context.CONTENT_CAPTURE_MANAGER_SERVICE.equals(name)) { return mContentCaptureManager; } else if (Context.SPEECH_RECOGNITION_SERVICE.equals(name) && mIRecognitionServiceManager != null) { return mIRecognitionServiceManager.asBinder(); } else { return super.getSystemService(name); } Loading
core/java/android/service/voice/IHotwordDetectionService.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.PersistableBundle; import android.os.SharedMemory; import android.service.voice.IDspHotwordDetectionCallback; import android.view.contentcapture.IContentCaptureManager; import android.speech.IRecognitionServiceManager; /** * Provide the interface to communicate with hotword detection service. Loading Loading @@ -57,6 +58,9 @@ oneway interface IHotwordDetectionService { in IContentCaptureManager contentCaptureManager, in ContentCaptureOptions options); void updateRecognitionServiceManager( in IRecognitionServiceManager recognitionServiceManager); /** * Simply requests the service to trigger the callback, so that the system can check its * identity. Loading
core/java/android/speech/SpeechRecognizer.java +5 −5 Original line number Diff line number Diff line Loading @@ -735,12 +735,12 @@ public class SpeechRecognizer { return true; } mManagerService = IRecognitionServiceManager.Stub.asInterface( ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE)); if (DBG) { Log.i(TAG, "#maybeInitializeManagerService instantiated =" + mManagerService); IBinder service = ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE); if (service == null && mOnDevice) { service = (IBinder) mContext.getSystemService(Context.SPEECH_RECOGNITION_SERVICE); } mManagerService = IRecognitionServiceManager.Stub.asInterface(service); if (mManagerService == null) { if (mListener != null) { mListener.onError(ERROR_CLIENT); Loading
services/core/java/com/android/server/speech/SpeechRecognitionManagerServiceImpl.java +7 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.IBinder; import android.os.Process; import android.os.RemoteException; import android.permission.PermissionManager; import android.speech.IRecognitionListener; Loading Loading @@ -103,6 +104,12 @@ final class SpeechRecognitionManagerServiceImpl extends serviceComponent = getOnDeviceComponentNameLocked(); } if (!onDevice && Process.isIsolated(Binder.getCallingUid())) { Slog.w(TAG, "Isolated process can only start on device speech recognizer."); tryRespondWithError(callback, SpeechRecognizer.ERROR_CLIENT); return; } if (serviceComponent == null) { if (mMaster.debug) { Slog.i(TAG, "Service component is undefined, responding with error."); Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +10 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import android.service.voice.IDspHotwordDetectionCallback; import android.service.voice.IHotwordDetectionService; import android.service.voice.IMicrophoneHotwordDetectionVoiceInteractionCallback; import android.service.voice.VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity; import android.speech.IRecognitionServiceManager; import android.text.TextUtils; import android.util.Pair; import android.util.Slog; Loading Loading @@ -923,6 +924,7 @@ final class HotwordDetectionConnection { updateAudioFlinger(connection, mAudioFlinger); updateContentCaptureManager(connection); updateSpeechService(connection); updateServiceIdentity(connection); return connection; } Loading Loading @@ -1060,6 +1062,14 @@ final class HotwordDetectionConnection { new ContentCaptureOptions(null))); } private static void updateSpeechService(ServiceConnection connection) { IBinder b = ServiceManager.getService(Context.SPEECH_RECOGNITION_SERVICE); IRecognitionServiceManager binderService = IRecognitionServiceManager.Stub.asInterface(b); connection.run(service -> { service.updateRecognitionServiceManager(binderService); }); } private void updateServiceIdentity(ServiceConnection connection) { connection.run(service -> service.ping(new IRemoteCallback.Stub() { @Override Loading