diff options
| author | 2023-05-07 19:08:14 +0000 | |
|---|---|---|
| committer | 2023-05-07 19:16:53 +0000 | |
| commit | 07b4b87f47d5a6f1552a104b8468618481118903 (patch) | |
| tree | 44fad27406ca69f177fe493d0cf7a880e31b3178 | |
| parent | de6724e24f0c2d6e48e8717c78868cdcef969a11 (diff) | |
Skip VisualQueryDetectionService being destroyed for SDK bump
The service needs to be enabled even if multiple detector is disabled.
However the changeId makes VisualQueryDetectionService destoryed when
HotwordDetectionService is created afterwards.
Bug: 279544077
Test: atest CtsVoiceInteractionTestCases
Change-Id: I75c8495587ceb70002ef64f52d91a1a900b76072
| -rw-r--r-- | core/java/android/service/voice/VoiceInteractionService.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java index 90e8cedab622..aeec06be3788 100644 --- a/core/java/android/service/voice/VoiceInteractionService.java +++ b/core/java/android/service/voice/VoiceInteractionService.java @@ -389,7 +389,7 @@ public class VoiceInteractionService extends Service { // It's still guaranteed to have been stopped. // This helps with cases where the voice interaction implementation is changed // by the user. - safelyShutdownAllHotwordDetectors(); + safelyShutdownAllHotwordDetectors(true); } /** @@ -715,7 +715,7 @@ public class VoiceInteractionService extends Service { synchronized (mLock) { if (!CompatChanges.isChangeEnabled(MULTIPLE_ACTIVE_HOTWORD_DETECTORS)) { // Allow only one concurrent recognition via the APIs. - safelyShutdownAllHotwordDetectors(); + safelyShutdownAllHotwordDetectors(false); } else { for (HotwordDetector detector : mActiveDetectors) { if (detector.isUsingSandboxedDetectionService() @@ -878,7 +878,7 @@ public class VoiceInteractionService extends Service { synchronized (mLock) { if (!CompatChanges.isChangeEnabled(MULTIPLE_ACTIVE_HOTWORD_DETECTORS)) { // Allow only one concurrent recognition via the APIs. - safelyShutdownAllHotwordDetectors(); + safelyShutdownAllHotwordDetectors(false); } else { for (HotwordDetector detector : mActiveDetectors) { if (!detector.isUsingSandboxedDetectionService()) { @@ -1062,11 +1062,14 @@ public class VoiceInteractionService extends Service { return mKeyphraseEnrollmentInfo.getKeyphraseMetadata(keyphrase, locale) != null; } - private void safelyShutdownAllHotwordDetectors() { + private void safelyShutdownAllHotwordDetectors(boolean shouldShutDownVisualQueryDetector) { synchronized (mLock) { mActiveDetectors.forEach(detector -> { try { - detector.destroy(); + if (detector != mActiveVisualQueryDetector.getInitializationDelegate() + || shouldShutDownVisualQueryDetector) { + detector.destroy(); + } } catch (Exception ex) { Log.i(TAG, "exception destroying HotwordDetector", ex); } |