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

Commit c93e40c8 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Speculative fix for BT race condition"

am: 13a230eb

Change-Id: Id7241854254cca5195cb225ef7eac47a70f88642
parents 403a5b8a 13a230eb
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -194,6 +194,10 @@ public class BluetoothDeviceManager {
                mHearingAidDeviceSyncIds.put(device, hiSyncId);
                targetDeviceMap = mHearingAidDevicesByAddress;
            } else {
                if (mBluetoothHeadsetService == null) {
                    Log.w(this, "Headset service null when receiving device added broadcast");
                    return;
                }
                targetDeviceMap = mHfpDevicesByAddress;
            }
            if (!targetDeviceMap.containsKey(device.getAddress())) {
+14 −0
Original line number Diff line number Diff line
@@ -106,6 +106,20 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
        assertEquals(0, mBluetoothDeviceManager.getNumConnectedDevices());
    }

    @SmallTest
    @Test
    public void testAddDeviceFailsWhenServicesAreNull() {
        mBluetoothDeviceManager.setHeadsetServiceForTesting(null);
        mBluetoothDeviceManager.setHearingAidServiceForTesting(null);

        receiverUnderTest.onReceive(mContext,
                buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device1, false));
        receiverUnderTest.onReceive(mContext,
                buildConnectionActionIntent(BluetoothHeadset.STATE_CONNECTED, device2, true));

        assertEquals(0, mBluetoothDeviceManager.getNumConnectedDevices());
    }
    
    @SmallTest
    @Test
    public void testMultiDeviceConnectAndDisconnect() {