unbind from HotwordDetectionService when all sessions are destroyed

Test: atest AlwaysOnHotwordDetectorTest
Bug: 277392480
Change-Id: I15855ad174bebd97409e6baa7c0256d2b0440d1a
This commit is contained in:
Nicholas Ambur
2023-04-18 01:03:49 +00:00
parent b309650132
commit aef1724849

View File

@@ -913,8 +913,10 @@ final class HotwordDetectionConnection {
}
// Handle case where all hotword detector sessions are destroyed with only the visual
// detector session left
if (mDetectorSessions.size() == 1
&& mDetectorSessions.get(0) instanceof VisualQueryDetectorSession) {
boolean allHotwordDetectionServiceSessionsRemoved = mDetectorSessions.size() == 0
|| (mDetectorSessions.size() == 1 && mDetectorSessions.get(0)
instanceof VisualQueryDetectorSession);
if (allHotwordDetectionServiceSessionsRemoved) {
unbindHotwordDetectionService();
}
}