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

Commit 9e48e881 authored by Sal Savage's avatar Sal Savage Committed by Automerger Merge Worker
Browse files

Merge "Drop codec configuration changes for disconnected devices" into main am: 690e8157

parents 5b0d6bb6 690e8157
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -636,6 +636,13 @@ public class A2dpSinkService extends ProfileService {
            return;
            return;
        }
        }
        A2dpSinkStateMachine stateMachine = getStateMachineForDevice(device);
        A2dpSinkStateMachine stateMachine = getStateMachineForDevice(device);
        if (stateMachine == null) {
            Log.w(
                    TAG,
                    "Received audio config changed event for an unconnected device, device="
                            + device);
            return;
        }
        stateMachine.onStackEvent(event);
        stateMachine.onStackEvent(event);
    }
    }


+20 −0
Original line number Original line Diff line number Diff line
@@ -295,6 +295,26 @@ public class A2dpSinkServiceTest {
        assertThat(config).isEqualTo(expected);
        assertThat(config).isEqualTo(expected);
    }
    }


    /** Make sure we ignore audio configuration changes for disconnected/unknown devices */
    @Test
    public void testOnAudioConfigChanged_withNullDevice_eventDropped() {
        StackEvent audioConfigChanged =
                StackEvent.audioConfigChanged(null, TEST_SAMPLE_RATE, TEST_CHANNEL_COUNT);
        mService.messageFromNative(audioConfigChanged);
        assertThat(mService.getAudioConfig(null)).isNull();
    }

    /** Make sure we ignore audio configuration changes for disconnected/unknown devices */
    @Test
    public void testOnAudioConfigChanged_withUnknownDevice_eventDropped() {
        assertThat(mService.getConnectionState(mDevice1))
                .isEqualTo(BluetoothProfile.STATE_DISCONNECTED);
        StackEvent audioConfigChanged =
                StackEvent.audioConfigChanged(mDevice1, TEST_SAMPLE_RATE, TEST_CHANNEL_COUNT);
        mService.messageFromNative(audioConfigChanged);
        assertThat(mService.getAudioConfig(mDevice1)).isNull();
    }

    /**
    /**
     * Getting an audio config for a device that hasn't received one yet should return null
     * Getting an audio config for a device that hasn't received one yet should return null
     */
     */