summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Volnov <volnov@google.com>2021-05-25 21:41:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-05-25 21:41:58 +0000
commit76660ef7211a3517a710ec03a23412c0c81368a7 (patch)
treee0b89571ce0c2b4793f090350da6e7b07266a579
parent12d855bbb55d0d4d8bf027ba869a5d57155c42ee (diff)
parent31f241cc63c189bc42a89f8cce54c8024840a5a4 (diff)
Merge "Hotword: Add onStopDetection() for software detectors." into sc-dev
-rw-r--r--core/api/system-current.txt1
-rw-r--r--core/java/android/service/voice/HotwordDetectionService.java14
-rw-r--r--core/java/android/service/voice/IHotwordDetectionService.aidl2
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java2
4 files changed, 19 insertions, 0 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index d5f3d661db42..b6c90a42dc61 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -10565,6 +10565,7 @@ package android.service.voice {
method public void onDetect(@NonNull android.service.voice.AlwaysOnHotwordDetector.EventPayload, long, @NonNull android.service.voice.HotwordDetectionService.Callback);
method public void onDetect(@NonNull android.service.voice.HotwordDetectionService.Callback);
method public void onDetect(@NonNull android.os.ParcelFileDescriptor, @NonNull android.media.AudioFormat, @Nullable android.os.PersistableBundle, @NonNull android.service.voice.HotwordDetectionService.Callback);
+ method public void onStopDetection();
method public void onUpdateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory, long, @Nullable java.util.function.IntConsumer);
field public static final int INITIALIZATION_STATUS_SUCCESS = 0; // 0x0
field public static final int INITIALIZATION_STATUS_UNKNOWN = 100; // 0x64
diff --git a/core/java/android/service/voice/HotwordDetectionService.java b/core/java/android/service/voice/HotwordDetectionService.java
index 7dd3a1dd5ea7..deb6c01a3088 100644
--- a/core/java/android/service/voice/HotwordDetectionService.java
+++ b/core/java/android/service/voice/HotwordDetectionService.java
@@ -192,6 +192,11 @@ public abstract class HotwordDetectionService extends Service {
mContentCaptureManager = new ContentCaptureManager(
HotwordDetectionService.this, manager, options);
}
+
+ @Override
+ public void stopDetection() {
+ HotwordDetectionService.this.onStopDetection();
+ }
};
@Override
@@ -349,6 +354,15 @@ public abstract class HotwordDetectionService extends Service {
}
/**
+ * Called when the {@link VoiceInteractionService}
+ * {@link HotwordDetector#stopRecognition() requests} that hotword recognition be stopped.
+ * <p>
+ * Any open {@link android.media.AudioRecord} should be closed here.
+ */
+ public void onStopDetection() {
+ }
+
+ /**
* Callback for returning the detection result.
*
* @hide
diff --git a/core/java/android/service/voice/IHotwordDetectionService.aidl b/core/java/android/service/voice/IHotwordDetectionService.aidl
index 7ba00982e6a2..72dd45aeeb0f 100644
--- a/core/java/android/service/voice/IHotwordDetectionService.aidl
+++ b/core/java/android/service/voice/IHotwordDetectionService.aidl
@@ -53,4 +53,6 @@ oneway interface IHotwordDetectionService {
void updateContentCaptureManager(
in IContentCaptureManager contentCaptureManager,
in ContentCaptureOptions options);
+
+ 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 aec06431c5fb..0bb09a9de07f 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
@@ -287,6 +287,8 @@ final class HotwordDetectionConnection {
Slog.d(TAG, "stopListening");
}
+ mRemoteHotwordDetectionService.run(service -> service.stopDetection());
+
synchronized (mLock) {
if (mCurrentAudioSink != null) {
Slog.i(TAG, "Closing audio stream to hotword detector: stopping requested");