From 57b3fe5ad9adecb65bdb372d796f25b56e751db3 Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Wed, 25 Jan 2023 11:44:20 +0000 Subject: [PATCH] Perform checking for restarting SandboxedDetectionProcesses SandboxedDetectionServices should not be started unexpectedly if the service is not specified. This change adds a checking to fix this. Bug: 265535257 Test: atest CtsVoiceInteractionTestCases Change-Id: I6143079bbf3288039246ce5f9af27164a84b0958 --- .../voiceinteraction/HotwordDetectionConnection.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java index 665d5e7604253..dfa6f8637846a 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java @@ -432,9 +432,15 @@ final class HotwordDetectionConnection { mLastRestartInstant = Instant.now(); // Recreate connection to reset the cache. - mRemoteHotwordDetectionService = mHotwordDetectionServiceConnectionFactory.createLocked(); - mRemoteVisualQueryDetectionService = - mVisualQueryDetectionServiceConnectionFactory.createLocked(); + if (oldHotwordConnection != null) { + mRemoteHotwordDetectionService = + mHotwordDetectionServiceConnectionFactory.createLocked(); + } + + if (oldVisualQueryDetectionConnection != null) { + mRemoteVisualQueryDetectionService = + mVisualQueryDetectionServiceConnectionFactory.createLocked(); + } Slog.v(TAG, "Started the new process, dispatching processRestarted to detector"); runForEachDetectorSessionLocked((session) -> {