From 50fc90652126bd6840ff8b133a1c1bee67b9fe54 Mon Sep 17 00:00:00 2001 From: Sergey Volnov Date: Tue, 20 Apr 2021 10:51:28 +0100 Subject: [PATCH] Create a callback method to invoke when the hotword detector is restarted. Bug: 168305377 CTS-Coverage-Bug: 183425641 Test: atest CtsVoiceInteractionTestCases Change-Id: I73076562d822b95b39132cada8bfce904cc231cb --- core/api/system-current.txt | 2 ++ .../android/service/voice/AlwaysOnHotwordDetector.java | 9 +++++++++ core/java/android/service/voice/HotwordDetector.java | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 6307e2b0925b2..8f8939a2bec67 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -10493,6 +10493,7 @@ package android.service.voice { ctor public AlwaysOnHotwordDetector.Callback(); method public abstract void onAvailabilityChanged(int); method public void onHotwordDetectionServiceInitialized(int); + method public void onHotwordDetectionServiceRestarted(); method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult); } @@ -10569,6 +10570,7 @@ package android.service.voice { method public void onDetected(@NonNull android.service.voice.AlwaysOnHotwordDetector.EventPayload); method public void onError(); method public void onHotwordDetectionServiceInitialized(int); + method public void onHotwordDetectionServiceRestarted(); method public void onRecognitionPaused(); method public void onRecognitionResumed(); method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult); diff --git a/core/java/android/service/voice/AlwaysOnHotwordDetector.java b/core/java/android/service/voice/AlwaysOnHotwordDetector.java index a3e00fb8fdc09..3c53e8f305ae7 100644 --- a/core/java/android/service/voice/AlwaysOnHotwordDetector.java +++ b/core/java/android/service/voice/AlwaysOnHotwordDetector.java @@ -535,6 +535,15 @@ public class AlwaysOnHotwordDetector extends AbstractHotwordDetector { */ public void onHotwordDetectionServiceInitialized(@InitializationStatus int status) { } + + /** + * Called with the {@link HotwordDetectionService} is restarted. + * + * Clients are expected to call {@link HotwordDetector#updateState} to share the state with + * the newly created service. + */ + public void onHotwordDetectionServiceRestarted() { + } } /** diff --git a/core/java/android/service/voice/HotwordDetector.java b/core/java/android/service/voice/HotwordDetector.java index ab7d9cd5ae5c3..2fb4dbc835edf 100644 --- a/core/java/android/service/voice/HotwordDetector.java +++ b/core/java/android/service/voice/HotwordDetector.java @@ -169,5 +169,13 @@ public interface HotwordDetector { * @param status Info about initialization state of {@link HotwordDetectionService}. */ void onHotwordDetectionServiceInitialized(@InitializationStatus int status); + + /** + * Called with the {@link HotwordDetectionService} is restarted. + * + * Clients are expected to call {@link HotwordDetector#updateState} to share the state with + * the newly created service. + */ + void onHotwordDetectionServiceRestarted(); } }