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

Commit 4597d532 authored by Joseph Pirozzo's avatar Joseph Pirozzo
Browse files

Bluetooth A2DP Sink only connect from Disconnected state

While in the pending or Connected state ignore CONNECT calls since
the A2DP sink is already in the process of connecting or
disconnecting to a target device.

Bug: 76096462
Test: While connected to a device attempt to change connection to
another device.

Change-Id: I533bf526ccb1d65b3eebf3b04ea95882ce0cdb74
parent 8ec03d0c
Loading
Loading
Loading
Loading
+3 −23
Original line number Diff line number Diff line
@@ -304,7 +304,7 @@ public class A2dpSinkStateMachine extends StateMachine {
            boolean retValue = HANDLED;
            switch (message.what) {
                case CONNECT:
                    deferMessage(message);
                    logd("Disconnect before connecting to another target");
                    break;
                case CONNECT_TIMEOUT:
                    onConnectionStateChanged(getByteAddress(mTargetDevice),
@@ -320,8 +320,6 @@ public class A2dpSinkStateMachine extends StateMachine {
                        synchronized (A2dpSinkStateMachine.this) {
                            mTargetDevice = null;
                        }
                    } else {
                        deferMessage(message);
                    }
                    break;
                case STACK_EVENT:
@@ -516,26 +514,8 @@ public class A2dpSinkStateMachine extends StateMachine {
            }

            switch (message.what) {
                case CONNECT: {
                    BluetoothDevice device = (BluetoothDevice) message.obj;
                    if (mCurrentDevice.equals(device)) {
                        break;
                    }

                    broadcastConnectionState(device, BluetoothProfile.STATE_CONNECTING,
                            BluetoothProfile.STATE_DISCONNECTED);
                    if (!disconnectA2dpNative(getByteAddress(mCurrentDevice))) {
                        broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED,
                                BluetoothProfile.STATE_CONNECTING);
                        break;
                    }

                    synchronized (A2dpSinkStateMachine.this) {
                        mTargetDevice = device;
                        mStreaming.obtainMessage(A2dpSinkStreamHandler.DISCONNECT).sendToTarget();
                        transitionTo(mPending);
                    }
                }
                case CONNECT:
                    logd("Disconnect before connecting to another target");
                break;

                case DISCONNECT: {