Loading core/java/android/service/voice/HotwordDetectionService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -200,6 +200,11 @@ public abstract class HotwordDetectionService extends Service { HotwordDetectionService.this, manager, options); HotwordDetectionService.this, manager, options); } } @Override public void ping(IRemoteCallback callback) throws RemoteException { callback.sendResult(null); } @Override @Override public void stopDetection() { public void stopDetection() { HotwordDetectionService.this.onStopDetection(); HotwordDetectionService.this.onStopDetection(); Loading core/java/android/service/voice/IHotwordDetectionService.aidl +6 −0 Original line number Original line Diff line number Diff line Loading @@ -57,5 +57,11 @@ oneway interface IHotwordDetectionService { in IContentCaptureManager contentCaptureManager, in IContentCaptureManager contentCaptureManager, in ContentCaptureOptions options); in ContentCaptureOptions options); /** * Simply requests the service to trigger the callback, so that the system can check its * identity. */ void ping(in IRemoteCallback callback); void stopDetection(); void stopDetection(); } } services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +20 −10 Original line number Original line Diff line number Diff line Loading @@ -164,15 +164,7 @@ final class HotwordDetectionConnection { public void sendResult(Bundle bundle) throws RemoteException { public void sendResult(Bundle bundle) throws RemoteException { if (DEBUG) { if (DEBUG) { Slog.d(TAG, "updateState finish"); Slog.d(TAG, "updateState finish"); Slog.d(TAG, "updating hotword UID " + Binder.getCallingUid()); } } // TODO: Do this earlier than this callback and have the provider point to the // current state stored in VoiceInteractionManagerServiceImpl. final int uid = Binder.getCallingUid(); LocalServices.getService(PermissionManagerServiceInternal.class) .setHotwordDetectionServiceProvider(() -> uid); mIdentity = new HotwordDetectionServiceIdentity(uid, mVoiceInteractionServiceUid); future.complete(null); future.complete(null); if (mUpdateStateAfterStartFinished.getAndSet(true)) { if (mUpdateStateAfterStartFinished.getAndSet(true)) { Slog.w(TAG, "call callback after timeout"); Slog.w(TAG, "call callback after timeout"); Loading Loading @@ -695,6 +687,7 @@ final class HotwordDetectionConnection { updateAudioFlinger(connection); updateAudioFlinger(connection); updateContentCaptureManager(connection); updateContentCaptureManager(connection); updateServiceIdentity(connection); return connection; return connection; } } } } Loading Loading @@ -808,18 +801,35 @@ final class HotwordDetectionConnection { if (audioFlinger == null) { if (audioFlinger == null) { throw new IllegalStateException("Service media.audio_flinger wasn't found."); throw new IllegalStateException("Service media.audio_flinger wasn't found."); } } connection.post(service -> service.updateAudioFlinger(audioFlinger)); connection.run(service -> service.updateAudioFlinger(audioFlinger)); } } private static void updateContentCaptureManager(ServiceConnection connection) { private static void updateContentCaptureManager(ServiceConnection connection) { IBinder b = ServiceManager IBinder b = ServiceManager .getService(Context.CONTENT_CAPTURE_MANAGER_SERVICE); .getService(Context.CONTENT_CAPTURE_MANAGER_SERVICE); IContentCaptureManager binderService = IContentCaptureManager.Stub.asInterface(b); IContentCaptureManager binderService = IContentCaptureManager.Stub.asInterface(b); connection.post( connection.run( service -> service.updateContentCaptureManager(binderService, service -> service.updateContentCaptureManager(binderService, new ContentCaptureOptions(null))); new ContentCaptureOptions(null))); } } private void updateServiceIdentity(ServiceConnection connection) { connection.run(service -> service.ping(new IRemoteCallback.Stub() { @Override public void sendResult(Bundle bundle) throws RemoteException { if (DEBUG) { Slog.d(TAG, "updating hotword UID " + Binder.getCallingUid()); } // TODO: Have the provider point to the current state stored in // VoiceInteractionManagerServiceImpl. final int uid = Binder.getCallingUid(); LocalServices.getService(PermissionManagerServiceInternal.class) .setHotwordDetectionServiceProvider(() -> uid); mIdentity = new HotwordDetectionServiceIdentity(uid, mVoiceInteractionServiceUid); } })); } private static void bestEffortClose(Closeable closeable) { private static void bestEffortClose(Closeable closeable) { try { try { closeable.close(); closeable.close(); Loading Loading
core/java/android/service/voice/HotwordDetectionService.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -200,6 +200,11 @@ public abstract class HotwordDetectionService extends Service { HotwordDetectionService.this, manager, options); HotwordDetectionService.this, manager, options); } } @Override public void ping(IRemoteCallback callback) throws RemoteException { callback.sendResult(null); } @Override @Override public void stopDetection() { public void stopDetection() { HotwordDetectionService.this.onStopDetection(); HotwordDetectionService.this.onStopDetection(); Loading
core/java/android/service/voice/IHotwordDetectionService.aidl +6 −0 Original line number Original line Diff line number Diff line Loading @@ -57,5 +57,11 @@ oneway interface IHotwordDetectionService { in IContentCaptureManager contentCaptureManager, in IContentCaptureManager contentCaptureManager, in ContentCaptureOptions options); in ContentCaptureOptions options); /** * Simply requests the service to trigger the callback, so that the system can check its * identity. */ void ping(in IRemoteCallback callback); void stopDetection(); void stopDetection(); } }
services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +20 −10 Original line number Original line Diff line number Diff line Loading @@ -164,15 +164,7 @@ final class HotwordDetectionConnection { public void sendResult(Bundle bundle) throws RemoteException { public void sendResult(Bundle bundle) throws RemoteException { if (DEBUG) { if (DEBUG) { Slog.d(TAG, "updateState finish"); Slog.d(TAG, "updateState finish"); Slog.d(TAG, "updating hotword UID " + Binder.getCallingUid()); } } // TODO: Do this earlier than this callback and have the provider point to the // current state stored in VoiceInteractionManagerServiceImpl. final int uid = Binder.getCallingUid(); LocalServices.getService(PermissionManagerServiceInternal.class) .setHotwordDetectionServiceProvider(() -> uid); mIdentity = new HotwordDetectionServiceIdentity(uid, mVoiceInteractionServiceUid); future.complete(null); future.complete(null); if (mUpdateStateAfterStartFinished.getAndSet(true)) { if (mUpdateStateAfterStartFinished.getAndSet(true)) { Slog.w(TAG, "call callback after timeout"); Slog.w(TAG, "call callback after timeout"); Loading Loading @@ -695,6 +687,7 @@ final class HotwordDetectionConnection { updateAudioFlinger(connection); updateAudioFlinger(connection); updateContentCaptureManager(connection); updateContentCaptureManager(connection); updateServiceIdentity(connection); return connection; return connection; } } } } Loading Loading @@ -808,18 +801,35 @@ final class HotwordDetectionConnection { if (audioFlinger == null) { if (audioFlinger == null) { throw new IllegalStateException("Service media.audio_flinger wasn't found."); throw new IllegalStateException("Service media.audio_flinger wasn't found."); } } connection.post(service -> service.updateAudioFlinger(audioFlinger)); connection.run(service -> service.updateAudioFlinger(audioFlinger)); } } private static void updateContentCaptureManager(ServiceConnection connection) { private static void updateContentCaptureManager(ServiceConnection connection) { IBinder b = ServiceManager IBinder b = ServiceManager .getService(Context.CONTENT_CAPTURE_MANAGER_SERVICE); .getService(Context.CONTENT_CAPTURE_MANAGER_SERVICE); IContentCaptureManager binderService = IContentCaptureManager.Stub.asInterface(b); IContentCaptureManager binderService = IContentCaptureManager.Stub.asInterface(b); connection.post( connection.run( service -> service.updateContentCaptureManager(binderService, service -> service.updateContentCaptureManager(binderService, new ContentCaptureOptions(null))); new ContentCaptureOptions(null))); } } private void updateServiceIdentity(ServiceConnection connection) { connection.run(service -> service.ping(new IRemoteCallback.Stub() { @Override public void sendResult(Bundle bundle) throws RemoteException { if (DEBUG) { Slog.d(TAG, "updating hotword UID " + Binder.getCallingUid()); } // TODO: Have the provider point to the current state stored in // VoiceInteractionManagerServiceImpl. final int uid = Binder.getCallingUid(); LocalServices.getService(PermissionManagerServiceInternal.class) .setHotwordDetectionServiceProvider(() -> uid); mIdentity = new HotwordDetectionServiceIdentity(uid, mVoiceInteractionServiceUid); } })); } private static void bestEffortClose(Closeable closeable) { private static void bestEffortClose(Closeable closeable) { try { try { closeable.close(); closeable.close(); Loading