audio policy: Fix handling of external device connection failure
The cleanup code in 'APM::setDeviceConnectionStateInt' was detaching
the external device prior to sending an update to HALs. As a result,
HALs were receiving an empty device address.
Bug: 333196025
Test: atest audiopolicy_tests
Change-Id: I76e8303f81d1d27484a62c073128600fb7718bab
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index f767522..7da982e 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -129,8 +129,8 @@
device->toAudioPort(&devicePort);
if (status_t status = mpClientInterface->setDeviceConnectedState(&devicePort, state);
status != OK) {
- ALOGE("Error %d while setting connected state for device %s",
- static_cast<int>(state),
+ ALOGE("Error %d while setting connected state %d for device %s",
+ status, static_cast<int>(state),
device->getDeviceTypeAddr().toString(false).c_str());
}
}
@@ -218,9 +218,9 @@
if (checkOutputsForDevice(device, state, outputs) != NO_ERROR) {
mAvailableOutputDevices.remove(device);
- mHwModules.cleanUpForDevice(device);
-
broadcastDeviceConnectionState(device, media::DeviceConnectedState::DISCONNECTED);
+
+ mHwModules.cleanUpForDevice(device);
return INVALID_OPERATION;
}