summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Charles Chen <liangyuchen@google.com> 2023-01-31 13:30:20 +0000
committer Charles Chen <liangyuchen@google.com> 2023-03-02 00:02:28 +0000
commit0fc282f67503a32c65408171ae95e0da6bb3dfe7 (patch)
tree049bd6d62582ad104309b862512354bc7b16bb0c
parent00f7aaf5038be2d66b2f951df4de5563d56adbd1 (diff)
Binder passing for VisualQueryDetectionService
Enables ContentCaptureService and SpeechRecognitionService for VisualQueryDetectionService. Bug: 267134219 Test: manual & atest CtsVoiceInteractionTestCases Change-Id: Ideb5871497b65ea0046447b62ce2a85791554a8b
-rw-r--r--core/java/android/service/voice/VisualQueryDetectionService.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/core/java/android/service/voice/VisualQueryDetectionService.java b/core/java/android/service/voice/VisualQueryDetectionService.java
index 1783186cd045..7de7b2f86f1a 100644
--- a/core/java/android/service/voice/VisualQueryDetectionService.java
+++ b/core/java/android/service/voice/VisualQueryDetectionService.java
@@ -20,9 +20,11 @@ import android.annotation.DurationMillisLong;
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.hardware.soundtrigger.SoundTrigger;
import android.media.AudioFormat;
@@ -35,6 +37,7 @@ 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;
import java.util.Objects;
@@ -79,6 +82,10 @@ public abstract class VisualQueryDetectionService extends Service
public static final String KEY_INITIALIZATION_STATUS = "initialization_status";
private IDetectorSessionVisualQueryDetectionCallback mRemoteCallback = null;
+ @Nullable
+ private ContentCaptureManager mContentCaptureManager;
+ @Nullable
+ private IRecognitionServiceManager mIRecognitionServiceManager;
private final ISandboxedDetectionService mInterface = new ISandboxedDetectionService.Stub() {
@@ -139,15 +146,29 @@ public abstract class VisualQueryDetectionService extends Service
@Override
public void updateContentCaptureManager(IContentCaptureManager manager,
ContentCaptureOptions options) {
- Log.v(TAG, "Ignore #updateContentCaptureManager");
+ mContentCaptureManager = new ContentCaptureManager(
+ VisualQueryDetectionService.this, manager, options);
}
@Override
public void updateRecognitionServiceManager(IRecognitionServiceManager manager) {
- Log.v(TAG, "Ignore #updateRecognitionServiceManager");
+ mIRecognitionServiceManager = manager;
}
};
+ @Override
+ @SuppressLint("OnNameExpected")
+ 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);
+ }
+ }
+
/**
* {@inheritDoc}
* @hide