Merge changes from topic "hotword-unbind-on-destroy" into udc-dev

* changes:
  AOHD do not unbind HotwordDetectionService on destroy
  unbind from HotwordDetectionService when all sessions are destroyed
This commit is contained in:
Nicholas Ambur
2023-04-27 23:05:10 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 17 deletions

View File

@@ -1063,21 +1063,6 @@ public class VoiceInteractionService extends Service {
mActiveVisualQueryDetector = null;
}
mActiveDetectors.remove(detector);
shutdownHotwordDetectionServiceIfRequiredLocked();
}
}
private void shutdownHotwordDetectionServiceIfRequiredLocked() {
for (HotwordDetector detector : mActiveDetectors) {
if (detector.isUsingSandboxedDetectionService()) {
return;
}
}
try {
mSystemService.shutdownHotwordDetectionService();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}

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();
}
}