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

Commit 6e8c8891 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun Committed by Gerrit Code Review
Browse files

Merge "Remove timeout from CONNECTING"

parents ec4c8d9f 4fea36f8
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -333,7 +333,6 @@ public class BatteryStateMachine extends StateMachine {
        public void enter() {
            log(TAG, "Enter (" + mDevice + "): "
                    + messageWhatToString(getCurrentMessage().what));
            sendMessageDelayed(CONNECT_TIMEOUT, sConnectTimeoutMs);
            dispatchConnectionStateChanged(mLastConnectionState, BluetoothProfile.STATE_CONNECTING);
        }

@@ -342,7 +341,6 @@ public class BatteryStateMachine extends StateMachine {
            log(TAG, "Exit (" + mDevice + "): "
                    + messageWhatToString(getCurrentMessage().what));
            mLastConnectionState = BluetoothProfile.STATE_CONNECTING;
            removeMessages(CONNECT_TIMEOUT);
        }

        @Override
@@ -355,8 +353,8 @@ public class BatteryStateMachine extends StateMachine {
                    Log.w(TAG, "CONNECT ignored: " + mDevice);
                    break;
                case CONNECT_TIMEOUT:
                    Log.w(TAG, "Connection timeout: " + mDevice);
                    // fall through
                    Log.e(TAG, "Connection timeout unexpected: " + mDevice);
                    break;
                case DISCONNECT:
                    log(TAG, "Connection canceled to " + mDevice);
                    if (mBluetoothGatt != null) {
+0 −26
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;

@@ -278,31 +277,6 @@ public class BatteryStateMachineTest {
                .isInstanceOf(BatteryStateMachine.Connected.class);
    }

    @Test
    public void testConnectGattTimeout() {
        allowConnection(true);
        allowConnectGatt(true);

        // Inject an event for when incoming connection is requested
        mBatteryStateMachine.sendMessage(BatteryStateMachine.CONNECT);

        verify(mBatteryService, timeout(TIMEOUT_MS))
                .handleConnectionStateChanged(any(BatteryStateMachine.class),
                        eq(BluetoothProfile.STATE_DISCONNECTED),
                        eq(BluetoothProfile.STATE_CONNECTING));

        Assert.assertThat(mBatteryStateMachine.getCurrentState(),
                IsInstanceOf.instanceOf(BatteryStateMachine.Connecting.class));

        verify(mBatteryService, timeout(TIMEOUT_MS))
                .handleConnectionStateChanged(any(BatteryStateMachine.class),
                        eq(BluetoothProfile.STATE_CONNECTING),
                        eq(BluetoothProfile.STATE_DISCONNECTED));

        Assert.assertThat(mBatteryStateMachine.getCurrentState(),
                IsInstanceOf.instanceOf(BatteryStateMachine.Disconnected.class));
    }

    @Test
    public void testBatteryLevelChanged() {
        allowConnection(true);