Remove the isBound() check for HotwordDetectionService.

There will be a race condition (Ex:Create AlwaysOnHotwordDetector
twice quickly) where it will miss unbinding HotwordDetectionService
and clearing HotwordDetectionServiceProvider when using the
isBound() check for HotwordDetectionService.

Because we use "ServiceConnector.Impl" to create the connection,
it is unnecessary to use isBound() function to check if the
HotwordDetectionService should be unbound.

Bug: 195457729
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Test: manual - DSP and non-DSP
Change-Id: Ib74e0dc9364af3713007b115f7d170bf6e833810
This commit is contained in:
lpeter
2021-09-07 10:38:20 +08:00
parent ad28fe0efb
commit 74b69a2516

View File

@@ -269,13 +269,11 @@ final class HotwordDetectionConnection {
Slog.v(TAG, "cancelLocked");
clearDebugHotwordLoggingTimeoutLocked();
mDebugHotwordLogging = false;
if (mRemoteHotwordDetectionService.isBound()) {
mRemoteHotwordDetectionService.unbind();
LocalServices.getService(PermissionManagerServiceInternal.class)
.setHotwordDetectionServiceProvider(null);
mIdentity = null;
updateServiceUidForAudioPolicy(Process.INVALID_UID);
}
mRemoteHotwordDetectionService.unbind();
LocalServices.getService(PermissionManagerServiceInternal.class)
.setHotwordDetectionServiceProvider(null);
mIdentity = null;
updateServiceUidForAudioPolicy(Process.INVALID_UID);
mCancellationTaskFuture.cancel(/* may interrupt */ true);
if (mAudioFlinger != null) {
mAudioFlinger.unlinkToDeath(mAudioServerDeathRecipient, /* flags= */ 0);