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

Commit d15475b9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Bluetooth: pause music player on A2dp service disconnect"

parents fbbe733d 3d23f625
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -2384,14 +2384,25 @@ public class AudioService extends IAudioService.Stub {
            }
        }
        public void onServiceDisconnected(int profile) {
            Log.d(TAG, "onServiceDisconnected: Bluetooth profile: " + profile);
            switch(profile) {
            case BluetoothProfile.A2DP:
                synchronized (mA2dpAvrcpLock) {
                    mA2dp = null;
                    synchronized (mConnectedDevices) {
                        if (mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)) {
                            makeA2dpDeviceUnavailableNow(
                                    mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP));
                            Log.d(TAG, "A2dp service disconnects, pause music player");
                            BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
                            BluetoothDevice btDevice = adapter.getRemoteDevice
                                    (mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP));
                            int delay = checkSendBecomingNoisyIntent(
                                                AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, 0);
                            queueMsgUnderWakeLock(mAudioHandler,
                                                MSG_SET_A2DP_CONNECTION_STATE,
                                                BluetoothA2dp.STATE_DISCONNECTED,
                                                0,
                                                btDevice,
                                                delay);
                        }
                    }
                }