summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-07-03 04:41:08 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-07-03 04:41:08 +0000
commitaa2c737e51b8c04a8e1485fb99b8db67c7a75735 (patch)
tree64eab4dd1364f5224d6b7d0fe930367084d3d773
parentb4c73cbe4a8d321ae6176ca5aa30f443fe06e67e (diff)
parentcb8ebd1151cb280e68b00dbcff88fc9be0b563d0 (diff)
Merge "Init HotwordDetectionSrvc identity earlier" into sc-dev
-rw-r--r--core/java/android/service/voice/HotwordDetectionService.java5
-rw-r--r--core/java/android/service/voice/IHotwordDetectionService.aidl6
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java30
3 files changed, 31 insertions, 10 deletions
diff --git a/core/java/android/service/voice/HotwordDetectionService.java b/core/java/android/service/voice/HotwordDetectionService.java
index 567ee2f65565..a43523974480 100644
--- a/core/java/android/service/voice/HotwordDetectionService.java
+++ b/core/java/android/service/voice/HotwordDetectionService.java
@@ -201,6 +201,11 @@ public abstract class HotwordDetectionService extends Service {
}
@Override
+ public void ping(IRemoteCallback callback) throws RemoteException {
+ callback.sendResult(null);
+ }
+
+ @Override
public void stopDetection() {
HotwordDetectionService.this.onStopDetection();
}
diff --git a/core/java/android/service/voice/IHotwordDetectionService.aidl b/core/java/android/service/voice/IHotwordDetectionService.aidl
index d7ed67812e87..f2a93f100986 100644
--- a/core/java/android/service/voice/IHotwordDetectionService.aidl
+++ b/core/java/android/service/voice/IHotwordDetectionService.aidl
@@ -57,5 +57,11 @@ oneway interface IHotwordDetectionService {
in IContentCaptureManager contentCaptureManager,
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();
}
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
index 8ba41f35648e..f2506870c370 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
@@ -164,15 +164,7 @@ final class HotwordDetectionConnection {
public void sendResult(Bundle bundle) throws RemoteException {
if (DEBUG) {
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);
if (mUpdateStateAfterStartFinished.getAndSet(true)) {
Slog.w(TAG, "call callback after timeout");
@@ -695,6 +687,7 @@ final class HotwordDetectionConnection {
updateAudioFlinger(connection);
updateContentCaptureManager(connection);
+ updateServiceIdentity(connection);
return connection;
}
}
@@ -808,18 +801,35 @@ final class HotwordDetectionConnection {
if (audioFlinger == null) {
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) {
IBinder b = ServiceManager
.getService(Context.CONTENT_CAPTURE_MANAGER_SERVICE);
IContentCaptureManager binderService = IContentCaptureManager.Stub.asInterface(b);
- connection.post(
+ connection.run(
service -> service.updateContentCaptureManager(binderService,
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) {
try {
closeable.close();