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

Commit 3639fc6d authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Automerger Merge Worker
Browse files

Merge "LeAudioServiceTest: Fix flaky test" into main am: 3175c2c5 am: 3dd11905

parents b63c5cba 3dd11905
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -2949,6 +2949,7 @@ public class LeAudioService extends ProfileService {
     * Process a change for disconnection of a device.
     */
    public synchronized void deviceDisconnected(BluetoothDevice device, boolean hasFallbackDevice) {
        synchronized (mGroupLock) {
            LeAudioDeviceDescriptor deviceDescriptor = getDeviceDescriptor(device);
            if (deviceDescriptor == null) {
                Log.e(TAG, "deviceDisconnected: No valid descriptor for device: " + device);
@@ -2968,7 +2969,6 @@ public class LeAudioService extends ProfileService {
                stopAudioServersBackgroundScan();
            }

        synchronized (mGroupLock) {
            LeAudioGroupDescriptor descriptor = getGroupDescriptor(deviceDescriptor.mGroupId);
            if (descriptor == null) {
                Log.e(TAG, "deviceDisconnected: no descriptors for group: "
+4 −5
Original line number Diff line number Diff line
@@ -839,7 +839,7 @@ public class LeAudioServiceTest {
                .when(mAdapterService)
                .getBondState(any(BluetoothDevice.class));
        mService.bondStateChanged(mLeftDevice, BluetoothDevice.BOND_NONE);
        assertThat(mService.getDevices().contains(mLeftDevice)).isTrue();

        verifyConnectionStateIntent(
                TIMEOUT_MS,
                mLeftDevice,
@@ -851,6 +851,8 @@ public class LeAudioServiceTest {
        reset(mTbsService);
        reset(mMcpService);

        assertThat(mService.getDevices().contains(mLeftDevice)).isFalse();

        // Unbond received in CONNECTION_STATE_CONNECTED
        // Create device descriptor with connect request. To connect service,
        // device needs to be bonded
@@ -920,8 +922,8 @@ public class LeAudioServiceTest {
        assertThat(mService.getConnectionState(mLeftDevice))
                .isEqualTo(BluetoothProfile.STATE_CONNECTED);

        assertThat(mService.getDevices().contains(mLeftDevice)).isTrue();
        injectAndVerifyDeviceDisconnected(mLeftDevice);
        assertThat(mService.getDevices().contains(mLeftDevice)).isTrue();

        verify(mTbsService, times(0)).removeDeviceAuthorizationInfo(mLeftDevice);
        verify(mMcpService, times(0)).removeDeviceAuthorizationInfo(mLeftDevice);
@@ -930,9 +932,6 @@ public class LeAudioServiceTest {
        reset(mMcpService);

        // Device unbond
        doReturn(BluetoothDevice.BOND_NONE)
                .when(mAdapterService)
                .getBondState(any(BluetoothDevice.class));
        mService.bondStateChanged(mLeftDevice, BluetoothDevice.BOND_NONE);

        verify(mTbsService, times(1)).removeDeviceAuthorizationInfo(mLeftDevice);