Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f093fd4a authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Continue playing audio if output to local device is selected by the user

Audio will continue playing if the user explicitly selected the
local device as output.
However, if the local device was selected implicitly because the
remote device has been disconnected, then the music will stop
before selecting the local device as output.

Bug: 77192195
Test: Manual - play music to Bluetooth Headset, then either
      (a) Select local device as output; (b) disconnect Headset
Change-Id: I9253b7983ac40951f17876db44919830984201d3
parent 4271cf8b
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -442,10 +442,17 @@ public class A2dpService extends ProfileService {
                // disconnected. Please see comment in broadcastActiveDevice() for why.
                broadcastActiveDevice(null);
                if (previousActiveDevice != null) {
                    // Make sure the Audio Manager knows the previous Active device is disconnected
                    mAudioManager.setBluetoothA2dpDeviceConnectionState(
                    // Make sure the Audio Manager knows the previous Active device is disconnected.
                    // However, if A2DP is still connected for that remote device, the user has
                    // explicitly switched the output to the local device and music should
                    // continue playing. Otherwise, the remote device has been indeed disconnected,
                    // and audio should be suspended before switching the output to the local
                    // device.
                    mAudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(
                            previousActiveDevice, BluetoothProfile.STATE_DISCONNECTED,
                            BluetoothProfile.A2DP);
                            BluetoothProfile.A2DP,
                            getConnectionState(previousActiveDevice)
                                == BluetoothProfile.STATE_CONNECTED);
                    // Make sure the Active device in native layer is set to null and audio is off
                    if (!mA2dpNativeInterface.setActiveDevice(null)) {
                        Log.w(TAG, "setActiveDevice(null): Cannot remove active device in native "