summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSergey Volnov <volnov@google.com>2021-04-16 22:17:22 +0100
committerSergey Volnov <volnov@google.com>2021-04-19 14:23:40 +0100
commitf421bf17fcf4a755dab49517d486db6efbeb246d (patch)
tree19f350b5082a2f9850d72a3d506c5e018cdc6e8d /core/java/android
parent43dfe44a0f339bd5f2b536b5db054f148abfbf3e (diff)
Allow HotwordDetectionService to obtain ContentCaptureManager.
This would allow pushing data into sandboxed ContentCaptureService. Bug: 168305377 CTS-Coverage-Bug: 183425641 Test: atest CtsVoiceInteractionTestCases Change-Id: I798b4f525a5707d4c97ae525ed69bd3864cb261d
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/service/voice/HotwordDetectionService.java25
-rw-r--r--core/java/android/service/voice/IHotwordDetectionService.aidl12
2 files changed, 35 insertions, 2 deletions
diff --git a/core/java/android/service/voice/HotwordDetectionService.java b/core/java/android/service/voice/HotwordDetectionService.java
index 23b2103ce5fd..ea854e8c9283 100644
--- a/core/java/android/service/voice/HotwordDetectionService.java
+++ b/core/java/android/service/voice/HotwordDetectionService.java
@@ -24,8 +24,11 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.app.Service;
+import android.content.ContentCaptureOptions;
+import android.content.Context;
import android.content.Intent;
import android.media.AudioFormat;
import android.os.Bundle;
@@ -38,6 +41,8 @@ import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.SharedMemory;
import android.util.Log;
+import android.view.contentcapture.ContentCaptureManager;
+import android.view.contentcapture.IContentCaptureManager;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@@ -122,6 +127,9 @@ public abstract class HotwordDetectionService extends Service {
private Handler mHandler;
+ @Nullable
+ private ContentCaptureManager mContentCaptureManager;
+
private final IHotwordDetectionService mInterface = new IHotwordDetectionService.Stub() {
@Override
public void detectFromDspSource(
@@ -187,6 +195,13 @@ public abstract class HotwordDetectionService extends Service {
Log.i(TAG, "Unsupported audio source " + audioSource);
}
}
+
+ @Override
+ public void updateContentCaptureManager(IContentCaptureManager manager,
+ ContentCaptureOptions options) {
+ mContentCaptureManager = new ContentCaptureManager(
+ HotwordDetectionService.this, manager, options);
+ }
};
@CallSuper
@@ -207,6 +222,16 @@ public abstract class HotwordDetectionService extends Service {
return null;
}
+ @Override
+ @SuppressLint("OnNameExpected")
+ public @Nullable Object getSystemService(@ServiceName @NonNull String name) {
+ if (Context.CONTENT_CAPTURE_MANAGER_SERVICE.equals(name)) {
+ return mContentCaptureManager;
+ } else {
+ return super.getSystemService(name);
+ }
+ }
+
/**
* Called when the device hardware (such as a DSP) detected the hotword, to request second stage
* validation before handing over the audio to the {@link AlwaysOnHotwordDetector}.
diff --git a/core/java/android/service/voice/IHotwordDetectionService.aidl b/core/java/android/service/voice/IHotwordDetectionService.aidl
index d2421603e554..2ffe787e895a 100644
--- a/core/java/android/service/voice/IHotwordDetectionService.aidl
+++ b/core/java/android/service/voice/IHotwordDetectionService.aidl
@@ -22,6 +22,8 @@ import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.SharedMemory;
import android.service.voice.IDspHotwordDetectionCallback;
+import android.view.contentcapture.IContentCaptureManager;
+import android.content.ContentCaptureOptions;
/**
* Provide the interface to communicate with hotword detection service.
@@ -42,6 +44,12 @@ oneway interface IHotwordDetectionService {
in PersistableBundle options,
in IDspHotwordDetectionCallback callback);
- void updateState(in PersistableBundle options, in SharedMemory sharedMemory,
- in IRemoteCallback callback);
+ void updateState(
+ in PersistableBundle options,
+ in SharedMemory sharedMemory,
+ in IRemoteCallback callback);
+
+ void updateContentCaptureManager(
+ in IContentCaptureManager contentCaptureManager,
+ in ContentCaptureOptions options);
}