AudioService: fix disconnect/connect of A2DP device
Due to the expected BECOMING_NOISY behavior associated with a device disconnection, the disconnection is handled asynchronously after a fixed delay. This delay caused an inversion of commands in the processing order of the disconnection of a device closely followed by connection of the same device. The fix consists in: - overriding the equals() operator for BtDeviceConnectionInfo so messages for a given device in the message queue can be checked / removed. - when AudioDeviceBroker receives a command for A2DP connection or disconnection, remove all upcoming connection and disconnection commands in the queue for this device (see postBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent) - remove AudioDeviceBroker.handleSetA2dpSinkConnectionState, which was only used in BtHelper.onA2dpProfileConnected() with a CONNECTED state, and have this method perform a regular device connection (just like when coming from AM->AS). - in AudioDeviceInventory.onSetA2dpSinkConnectionState(), support receiving a connection event for an already connected device, to support codec changes. This change also includes modifications to the classes involved in the device connection to make them support mocking/spying to reproduce the bug conditions (see AudioDeviceBrokerTest). Bug: 134932649 Test: atest AudioDeviceBrokerTest Change-Id: If2b3b41409c77467a181a2f9b42310db9b9de8c5
Loading
Please register or sign in to comment