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

Commit 4d4cf721 authored by Sanket Agarwal's avatar Sanket Agarwal
Browse files

Fix connection state broadcasts

- HFP was flipping states in case of timeout
- A2DP was not sending a disconnect when the native changed its mind
  about which device was actually connected

Change-Id: Ic89292fe0d6730b8bbbc4746f8e5afabcd59a943
(cherry picked from commit e5d025a4e7b40379f576be3f8d73d98bce1c89c5)
parent d0805f2e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -437,9 +437,12 @@ final class A2dpSinkStateMachine extends StateMachine {
                    }
                } else {
                    loge("Unknown device Connected: " + device);
                    // something is wrong here, but sync our state with stack
                    // something is wrong here, but sync our state with stack by connecting to
                    // the new device and disconnect from previous device.
                    broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTED,
                                             BluetoothProfile.STATE_DISCONNECTED);
                    broadcastConnectionState(mCurrentDevice, BluetoothProfile.STATE_DISCONNECTED,
                        BluetoothProfile.STATE_CONNECTING);
                    synchronized (A2dpSinkStateMachine.this) {
                        mCurrentDevice = device;
                        mTargetDevice = null;
+3 −3
Original line number Diff line number Diff line
@@ -1092,8 +1092,8 @@ final class HeadsetClientStateMachine extends StateMachine {
                      transitionTo(mDisconnected);
                      broadcastConnectionState(
                          mCurrentDevice,
                          BluetoothProfile.STATE_CONNECTING,
                          BluetoothProfile.STATE_DISCONNECTED);
                          BluetoothProfile.STATE_DISCONNECTED,
                          BluetoothProfile.STATE_CONNECTING);
                      break;

                default:
@@ -1240,7 +1240,7 @@ final class HeadsetClientStateMachine extends StateMachine {
                    if (!disconnectNative(getByteAddress(dev))) {
                        // disconnecting failed
                        broadcastConnectionState(dev, BluetoothProfile.STATE_CONNECTED,
                                BluetoothProfile.STATE_DISCONNECTED);
                                BluetoothProfile.STATE_DISCONNECTING);
                        break;
                    }
                    break;