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

Commit 18db7da1 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Add missing A2dpStateMachine lookup when processing native events

Fixed a bug in the code after messageFromNative() was refactored
to create state machine entries only when connecting to a device.
Because of that bug, some events (Audio State and Codec Changed updates)
were not processed properly.

Also added unit test to capture similar issues in the future:

Test: Manual with switching codec configuration in Developer options
  Unit test:
 runtest bluetooth --test-class com.android.bluetooth.a2dp.A2dpServiceTest \
     --test-method testProcessAudioStateChangedCodecConfigChangedEvents
Bug: 73379307
Change-Id: I58f42acb4e7e0d312a04ede49d7538c42e210333
parent 1bfed909
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -687,8 +687,9 @@ public class A2dpService extends ProfileService {
        Objects.requireNonNull(stackEvent.device,
                               "Device should never be null, event: " + stackEvent);
        synchronized (mStateMachines) {
            A2dpStateMachine sm = null;
            BluetoothDevice device = stackEvent.device;
            A2dpStateMachine sm = mStateMachines.get(device);
            if (sm == null) {
                if (stackEvent.type == A2dpStackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED) {
                    switch (stackEvent.valueInt) {
                        case A2dpStackEvent.CONNECTION_STATE_CONNECTED:
@@ -702,10 +703,10 @@ public class A2dpService extends ProfileService {
                            sm = getOrCreateStateMachine(device);
                            break;
                        default:
                        sm = mStateMachines.get(device);
                            break;
                    }
                }
            }
            if (sm == null) {
                Log.e(TAG, "Cannot process stack event: no state machine: " + stackEvent);
                return;
+226 −42

File changed.

Preview size limit exceeded, changes collapsed.