summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Charles Chen <liangyuchen@google.com> 2023-03-04 01:51:37 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-03-04 01:51:37 +0000
commitd6f5b6c2444ae9d64f2be3783c33f8ce1453eb0d (patch)
treee812bbe646d36ad815bdd7fca099394e8bcf01ce
parent0dcaf197b42b7e995f6b7bd9c3fb3a7b622b255e (diff)
parent0fc282f67503a32c65408171ae95e0da6bb3dfe7 (diff)
Merge "Binder passing for VisualQueryDetectionService" into udc-dev
-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 a80ee85e8c77..cbe7666ddf43 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