From 603ea83bd71937fa599975dc03a3e4fd6ef30099 Mon Sep 17 00:00:00 2001 From: Ahaan Ugale Date: Tue, 4 May 2021 14:09:52 -0700 Subject: [PATCH] Hotword: Propagate the DSP DetectedResult. Fix: 190572818 Test: atest CtsVoiceInteractionTestCases Change-Id: I8a109f6540cf8c342b827464ccc2beabd99d1b9c --- .../service/voice/AlwaysOnHotwordDetector.java | 12 ++++++++++-- .../service/voice/SoftwareHotwordDetector.java | 5 +++-- .../app/IHotwordRecognitionStatusCallback.aidl | 6 +++++- .../voiceinteraction/HotwordDetectionConnection.java | 7 +++---- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/core/java/android/service/voice/AlwaysOnHotwordDetector.java b/core/java/android/service/voice/AlwaysOnHotwordDetector.java index fed28df964d66..67b97cee1b514 100644 --- a/core/java/android/service/voice/AlwaysOnHotwordDetector.java +++ b/core/java/android/service/voice/AlwaysOnHotwordDetector.java @@ -354,6 +354,13 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { null); } + EventPayload(boolean triggerAvailable, boolean captureAvailable, + AudioFormat audioFormat, int captureSession, byte[] data, + HotwordDetectedResult hotwordDetectedResult) { + this(triggerAvailable, captureAvailable, audioFormat, captureSession, data, + hotwordDetectedResult, null); + } + EventPayload(AudioFormat audioFormat, HotwordDetectedResult hotwordDetectedResult) { this(false, false, audioFormat, -1, null, hotwordDetectedResult, null); } @@ -1149,7 +1156,8 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { } @Override - public void onKeyphraseDetected(KeyphraseRecognitionEvent event) { + public void onKeyphraseDetected( + KeyphraseRecognitionEvent event, HotwordDetectedResult result) { if (DBG) { Slog.d(TAG, "onDetected(" + event + ")"); } else { @@ -1157,7 +1165,7 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { } Message.obtain(mHandler, MSG_HOTWORD_DETECTED, new EventPayload(event.triggerInData, event.captureAvailable, - event.captureFormat, event.captureSession, event.data)) + event.captureFormat, event.captureSession, event.data, result)) .sendToTarget(); } @Override diff --git a/core/java/android/service/voice/SoftwareHotwordDetector.java b/core/java/android/service/voice/SoftwareHotwordDetector.java index 47f2c6403757a..204e7df89706a 100644 --- a/core/java/android/service/voice/SoftwareHotwordDetector.java +++ b/core/java/android/service/voice/SoftwareHotwordDetector.java @@ -147,8 +147,9 @@ class SoftwareHotwordDetector extends AbstractHotwordDetector { } @Override - public void onKeyphraseDetected(SoundTrigger.KeyphraseRecognitionEvent recognitionEvent) - throws RemoteException { + public void onKeyphraseDetected( + SoundTrigger.KeyphraseRecognitionEvent recognitionEvent, + HotwordDetectedResult result) { } diff --git a/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl b/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl index 9bec505c801db..ec99c95a737c5 100644 --- a/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl +++ b/core/java/com/android/internal/app/IHotwordRecognitionStatusCallback.aidl @@ -17,6 +17,7 @@ package com.android.internal.app; import android.hardware.soundtrigger.SoundTrigger; +import android.service.voice.HotwordDetectedResult; import android.service.voice.HotwordRejectedResult; /** @@ -29,8 +30,11 @@ oneway interface IHotwordRecognitionStatusCallback { * @param recognitionEvent Object containing data relating to the * keyphrase recognition event such as keyphrase * extras. + * @param result Successful detection result payload. */ - void onKeyphraseDetected(in SoundTrigger.KeyphraseRecognitionEvent recognitionEvent); + void onKeyphraseDetected( + in SoundTrigger.KeyphraseRecognitionEvent recognitionEvent, + in HotwordDetectedResult result); /** * Called when a generic sound trigger event is witnessed. diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java index 0bb09a9de07f8..4d47f92f1d7e8 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java @@ -318,7 +318,7 @@ final class HotwordDetectionConnection { if (DEBUG) { Slog.d(TAG, "onDetected"); } - externalCallback.onKeyphraseDetected(recognitionEvent); + externalCallback.onKeyphraseDetected(recognitionEvent, result); } @Override @@ -351,8 +351,7 @@ final class HotwordDetectionConnection { if (DEBUG) { Slog.d(TAG, "onDetected"); } - // TODO: Propagate the HotwordDetectedResult. - externalCallback.onKeyphraseDetected(recognitionEvent); + externalCallback.onKeyphraseDetected(recognitionEvent, result); } @Override @@ -396,7 +395,7 @@ final class HotwordDetectionConnection { mHotwordDetectionConnection.detectFromDspSource( recognitionEvent, mExternalCallback); } else { - mExternalCallback.onKeyphraseDetected(recognitionEvent); + mExternalCallback.onKeyphraseDetected(recognitionEvent, null); } }