From 1a705fb85a0ec8f4cac0cccc023447fa44bf1707 Mon Sep 17 00:00:00 2001 From: lpeter Date: Sat, 14 Jan 2023 17:34:57 +0800 Subject: [PATCH] Log previous #onRejected result when unexpected #onDetected is called. Test: atest CtsVoiceInteractionTestCases Bug: 231458765 Change-Id: I3f32f681de8c1eaab480f11e6f47762930eb6425 --- .../voiceinteraction/DspTrustedHotwordDetectorSession.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java index ad84f004e9663..cb5b9300c1972 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/DspTrustedHotwordDetectorSession.java @@ -71,6 +71,8 @@ final class DspTrustedHotwordDetectorSession extends DetectorSession { @GuardedBy("mLock") private boolean mValidatingDspTrigger = false; + @GuardedBy("mLock") + private HotwordRejectedResult mLastHotwordRejectedResult = null; DspTrustedHotwordDetectorSession( @NonNull HotwordDetectionConnection.ServiceConnection remoteHotwordDetectionService, @@ -110,7 +112,8 @@ final class DspTrustedHotwordDetectorSession extends DetectorSession { HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__DETECTED, mVoiceInteractionServiceUid); if (!mValidatingDspTrigger) { - Slog.i(TAG, "Ignoring #onDetected due to a process restart"); + Slog.i(TAG, "Ignoring #onDetected due to a process restart or previous" + + " #onRejected result = " + mLastHotwordRejectedResult); HotwordMetricsLogger.writeKeyphraseTriggerEvent( HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP, METRICS_KEYPHRASE_TRIGGERED_DETECT_UNEXPECTED_CALLBACK, @@ -173,6 +176,7 @@ final class DspTrustedHotwordDetectorSession extends DetectorSession { } mValidatingDspTrigger = false; externalCallback.onRejected(result); + mLastHotwordRejectedResult = result; if (mDebugHotwordLogging && result != null) { Slog.i(TAG, "Egressed rejected result: " + result); } @@ -181,6 +185,7 @@ final class DspTrustedHotwordDetectorSession extends DetectorSession { }; mValidatingDspTrigger = true; + mLastHotwordRejectedResult = null; mRemoteDetectionService.run(service -> { // We use the VALIDATION_TIMEOUT_MILLIS to inform that the client needs to invoke // the callback before timeout value. In order to reduce the latency impact between