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

Commit 695beedd authored by Hall Liu's avatar Hall Liu Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE Speculative fix for BT race condition" into pi-dev

parents 259fd1e0 3424bea3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -136,6 +136,11 @@ public class BluetoothDeviceManager {

    void onDeviceConnected(BluetoothDevice device) {
        synchronized (mLock) {
            if (mBluetoothHeadsetService == null) {
                Log.w(this, "Headset service null when receiving device added broadcast");
                return;
            }

            if (!mConnectedDevicesByAddress.containsKey(device.getAddress())) {
                mConnectedDevicesByAddress.put(device.getAddress(), device);
                mBluetoothRouteManager.onDeviceAdded(device.getAddress());
+11 −0
Original line number Diff line number Diff line
@@ -98,6 +98,17 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
        assertNull(mBluetoothDeviceManager.getMostRecentlyConnectedDevice(null));
    }

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

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

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