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

Commit b49aa608 authored by Eric Rowe's avatar Eric Rowe
Browse files

Remove asserts in bluetooth test utils

Certain checks were causing the test to fail due to a race condition.

Bug: b/3198566
Change-Id: I9389a1936f6032939851922c052ef8ed32e5283b
parent 23c06769
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -137,7 +137,6 @@ public class BluetoothTestUtils extends Assert {

        @Override
        public void onReceive(Context context, Intent intent) {
            Log.i("BT", intent.toString());
            if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(intent.getAction())) {
                setFiredFlag(DISCOVERY_STARTED_FLAG);
            } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(intent.getAction())) {
@@ -384,11 +383,14 @@ public class BluetoothTestUtils extends Assert {
                mask = 0; // Don't check for received intents since we might have missed them.
                break;
            case BluetoothAdapter.STATE_OFF:
            case BluetoothAdapter.STATE_TURNING_OFF:
                assertFalse(adapter.isEnabled());
                start = System.currentTimeMillis();
                assertTrue(adapter.enable());
                break;
            case BluetoothAdapter.STATE_TURNING_OFF:
                start = System.currentTimeMillis();
                assertTrue(adapter.enable());
                break;
            default:
                removeReceiver(receiver);
                fail(String.format("enable() invalid state: state=%d", state));
@@ -410,7 +412,6 @@ public class BluetoothTestUtils extends Assert {
                    return;
                }
            } else {
                assertFalse(adapter.isEnabled());
                assertEquals(BluetoothAdapter.STATE_TURNING_ON, state);
            }
            sleep(POLL_TIME);
@@ -437,7 +438,6 @@ public class BluetoothTestUtils extends Assert {
            case BluetoothAdapter.STATE_TURNING_ON:
                assertFalse(adapter.isEnabled());
                start = System.currentTimeMillis();
                assertTrue(adapter.disable());
                break;
            case BluetoothAdapter.STATE_ON:
                assertTrue(adapter.isEnabled());
@@ -470,7 +470,6 @@ public class BluetoothTestUtils extends Assert {
                    return;
                }
            } else {
                assertFalse(adapter.isEnabled());
                assertEquals(BluetoothAdapter.STATE_TURNING_OFF, state);
            }
            sleep(POLL_TIME);
@@ -665,7 +664,6 @@ public class BluetoothTestUtils extends Assert {
                assertTrue(adapter.getBondedDevices().contains(device));
                return;
            default:

                removeReceiver(receiver);
                fail(String.format("%s invalid state: device=%s, state=%d", methodName, device,
                        state));
@@ -949,14 +947,12 @@ public class BluetoothTestUtils extends Assert {
        long s = System.currentTimeMillis();
        switch (profile) {
            case BluetoothProfile.A2DP:
                while (mA2dp != null
                        && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
                while (mA2dp != null && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
                    sleep(POLL_TIME);
                }
                return mA2dp;
            case BluetoothProfile.HEADSET:
                while (mHeadset != null
                        && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
                while (mHeadset != null && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) {
                    sleep(POLL_TIME);
                }
                return mHeadset;