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

Commit a8981b87 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Improve A2DP autoreconnect policy"

parents cd0393f1 d5c557a8
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -387,7 +387,9 @@ class PhonePolicy {
                connectOtherProfile(device);
            }
            if (nextState == BluetoothProfile.STATE_DISCONNECTED) {
                if (profileId == BluetoothProfile.A2DP) {
                if (profileId == BluetoothProfile.A2DP
                        && (prevState == BluetoothProfile.STATE_CONNECTING
                        || prevState == BluetoothProfile.STATE_DISCONNECTING)) {
                    mDatabaseManager.setDisconnection(device);
                }
                handleAllProfilesDisconnected(device);
+13 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ public class PhonePolicyTest {
        verify(mDatabaseManager, never()).setConnection(eq(connectionOrder.get(2)), anyBoolean());
        verify(mDatabaseManager, never()).setConnection(eq(connectionOrder.get(3)), anyBoolean());

        // Disconnect a2dp for the device
        // Disconnect a2dp for the device from previous STATE_CONNECTED
        when(mHeadsetService.getConnectionState(connectionOrder.get(1))).thenReturn(
                BluetoothProfile.STATE_DISCONNECTED);
        intent = new Intent(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
@@ -244,6 +244,18 @@ public class PhonePolicyTest {
        mPhonePolicy.getBroadcastReceiver().onReceive(null /* context */, intent);
        waitForLooperToFinishScheduledTask(mHandlerThread.getLooper());

        // Verify that we do not call setConnection, nor setDisconnection on disconnect
        // from previous STATE_CONNECTED
        verify(mDatabaseManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).setConnection(
                connectionOrder.get(1), true);
        verify(mDatabaseManager, never()).setDisconnection(connectionOrder.get(1));

        // Disconnect a2dp for the device from previous STATE_DISCONNECTING
        intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE,
                BluetoothProfile.STATE_DISCONNECTING);
        mPhonePolicy.getBroadcastReceiver().onReceive(null /* context */, intent);
        waitForLooperToFinishScheduledTask(mHandlerThread.getLooper());

        // Verify that we do not call setConnection, but instead setDisconnection on disconnect
        verify(mDatabaseManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).setConnection(
                connectionOrder.get(1), true);