Add prepareToDisconnectExternalDevice.
When an external device is disconnected, some HALs rely on the early
disconnect indication to immediately abort any active read/write
operations on drivers to avoid problems with HW interfaces. In that
case, APM will broadcast the device disconnection before the streams are
closed. However, in AOSP AIDL HAL, the device may not be disconnected
when there are active configurations. In that case, a new way to notify
the HAL to prepare to disconnect external device is required.
Bug: 277955540
Test: atest audiopolicy_tests
Test: connect/disconnect USB device
Change-Id: Ie5868ac5efedb3dbdd8b4c2e3225c0c4085806a1
diff --git a/services/audiopolicy/tests/AudioPolicyManagerTestClient.h b/services/audiopolicy/tests/AudioPolicyManagerTestClient.h
index 6eca7cc..3629c16 100644
--- a/services/audiopolicy/tests/AudioPolicyManagerTestClient.h
+++ b/services/audiopolicy/tests/AudioPolicyManagerTestClient.h
@@ -103,10 +103,11 @@
++mAudioPortListUpdateCount;
}
- status_t setDeviceConnectedState(const struct audio_port_v7 *port, bool connected) override {
- if (connected) {
+ status_t setDeviceConnectedState(const struct audio_port_v7 *port,
+ media::DeviceConnectedState state) override {
+ if (state == media::DeviceConnectedState::CONNECTED) {
mConnectedDevicePorts.push_back(*port);
- } else {
+ } else if (state == media::DeviceConnectedState::DISCONNECTED){
mDisconnectedDevicePorts.push_back(*port);
}
return NO_ERROR;
diff --git a/services/audiopolicy/tests/AudioPolicyTestClient.h b/services/audiopolicy/tests/AudioPolicyTestClient.h
index 0c04e35..71e34e3 100644
--- a/services/audiopolicy/tests/AudioPolicyTestClient.h
+++ b/services/audiopolicy/tests/AudioPolicyTestClient.h
@@ -96,8 +96,8 @@
const TrackSecondaryOutputsMap& trackSecondaryOutputs __unused) override {
return NO_INIT;
}
- status_t setDeviceConnectedState(
- const struct audio_port_v7 *port __unused, bool connected __unused) override {
+ status_t setDeviceConnectedState(const struct audio_port_v7 *port __unused,
+ media::DeviceConnectedState state __unused) override {
return NO_INIT;
}
status_t invalidateTracks(const std::vector<audio_port_handle_t>& /*portIds*/) override {