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

Commit d79e129b authored by Hall Liu's avatar Hall Liu Committed by Gerrit Code Review
Browse files

Merge "Change bluetooth routing to be more responsive"

parents 03ec7ce2 9ac3e684
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class BluetoothRouteManager extends StateMachine {
            BluetoothDevice erroneouslyConnectedDevice = getBluetoothAudioConnectedDevice();
            if (erroneouslyConnectedDevice != null) {
                Log.w(LOG_TAG, "Entering AudioOff state but device %s appears to be connected. " +
                        "Switching to audio-on state for %s", erroneouslyConnectedDevice);
                        "Switching to audio-on state for that device.", erroneouslyConnectedDevice);
                // change this to just transition to the new audio on state
                transitionToActualState();
            }
@@ -264,7 +264,6 @@ public class BluetoothRouteManager extends StateMachine {
                        break;
                    case DISCONNECT_HFP:
                        disconnectAudio();
                        transitionTo(mAudioOffState);
                        break;
                    case RETRY_HFP_CONNECTION:
                        if (Objects.equals(address, mDeviceAddress)) {
@@ -377,7 +376,6 @@ public class BluetoothRouteManager extends StateMachine {
                        break;
                    case DISCONNECT_HFP:
                        disconnectAudio();
                        transitionTo(mAudioOffState);
                        break;
                    case RETRY_HFP_CONNECTION:
                        if (Objects.equals(address, mDeviceAddress)) {
+15 −0
Original line number Diff line number Diff line
@@ -19,8 +19,10 @@ package com.android.server.telecom.tests;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.content.ContentResolver;
import android.telecom.Log;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.internal.os.SomeArgs;
import com.android.server.telecom.BluetoothHeadsetProxy;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.Timeouts;
@@ -243,6 +245,17 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase {
        setupConnectedDevices(mParams.connectedDevices,
                mParams.audioOnDevice, mParams.activeDevice);
        sm.setActiveDeviceCacheForTesting(mParams.activeDevice);
        if (mParams.initialDevice != null) {
            doAnswer(invocation -> {
                SomeArgs args = SomeArgs.obtain();
                args.arg1 = Log.createSubsession();
                args.arg2 = mParams.initialDevice.getAddress();
                sm.sendMessage(BluetoothRouteManager.HFP_LOST, args);
                when(mHeadsetProxy.getAudioState(eq(mParams.initialDevice)))
                        .thenReturn(BluetoothHeadset.STATE_AUDIO_DISCONNECTED);
                return true;
            }).when(mHeadsetProxy).disconnectAudio();
        }

        // Go through the utility methods for these two messages
        if (mParams.messageType == BluetoothRouteManager.NEW_DEVICE_CONNECTED) {
@@ -256,6 +269,8 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase {
                    mParams.messageDevice == null ? null : mParams.messageDevice.getAddress());
        }

        waitForHandlerAction(sm.getHandler(), TEST_TIMEOUT);
        waitForHandlerAction(sm.getHandler(), TEST_TIMEOUT);
        waitForHandlerAction(sm.getHandler(), TEST_TIMEOUT);
        assertEquals(mParams.expectedFinalStateName, sm.getCurrentState().getName());