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

Commit 4aac28ff authored by Hall Liu's avatar Hall Liu
Browse files

Fix semantics of a null address with BT_AUDIO_LOST

Hearing aids will send BT_AUDIO_LOST to the bt route manager with a null
device when the active device goes away. Make a fix so that this
actually disconnects the device in BluetoothRouteManager.

Change-Id: Icbd6cb57af73de27ef438f34a037b0290dca771c
Fixes: 120144501
Test: unit
parent 5a2f6feb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -296,7 +296,7 @@ public class BluetoothRouteManager extends StateMachine {
                        }
                        break;
                    case BT_AUDIO_LOST:
                        if (Objects.equals(mDeviceAddress, address)) {
                        if (Objects.equals(mDeviceAddress, address) || address == null) {
                            Log.i(LOG_TAG, "Connection with device %s failed.",
                                    mDeviceAddress);
                            transitionToActualState();
@@ -406,7 +406,7 @@ public class BluetoothRouteManager extends StateMachine {
                        }
                        break;
                    case BT_AUDIO_LOST:
                        if (Objects.equals(mDeviceAddress, address)) {
                        if (Objects.equals(mDeviceAddress, address) || address == null) {
                            Log.i(LOG_TAG, "HFP connection with device %s lost.", mDeviceAddress);
                            transitionToActualState();
                        } else {
+12 −0
Original line number Diff line number Diff line
@@ -538,6 +538,18 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase {
                .setExpectedFinalStateName(BluetoothRouteManager.AUDIO_OFF_STATE_NAME)
                .build());

        result.add(new BluetoothRouteTestParametersBuilder()
                .setName("Audio disconnect comes with a null device")
                .setInitialBluetoothState(BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX)
                .setInitialDevice(DEVICE2)
                .setConnectedDevices(DEVICE2)
                .setMessageType(BluetoothRouteManager.BT_AUDIO_LOST)
                .setMessageDevice(null)
                .setExpectedListenerUpdates(ListenerUpdate.AUDIO_DISCONNECTED)
                .setExpectedBluetoothInteraction(NONE)
                .setExpectedFinalStateName(BluetoothRouteManager.AUDIO_OFF_STATE_NAME)
                .build());

        result.add(new BluetoothRouteTestParametersBuilder()
                .setName("Device gets disconnected while pending. No fallback.")
                .setInitialBluetoothState(BluetoothRouteManager.AUDIO_CONNECTING_STATE_NAME_PREFIX)