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

Commit 95033503 authored by wescande's avatar wescande Committed by William Escande
Browse files

Fix setActiveDevice(null)

BluetoothAdapter does not allow to remove a device with a
`setActiveDevice(null)`, instead we should call `removeActiveDevice()`

```
*** FATAL EXCEPTION IN SYSTEM PROCESS: BluetoothRouteManager
java.lang.IllegalArgumentException: device cannot be null
  at android.bluetooth.BluetoothAdapter.setActiveDevice(BluetoothAdapter.java:1990)
  at com.android.server.telecom.bluetooth.BluetoothDeviceManager.disconnectAudio(BluetoothDeviceManager.java:250)
  at com.android.server.telecom.bluetooth.BluetoothRouteManager$AudioConnectedState.processMessage(BluetoothRouteManager.java:388
```

Bug: 204727408
Fix: 204727408
Test: N/A
Tag: #stability
Change-Id: I0f12297370a2f633f881518cdbdfcdb042d11b4f
parent e3c7578b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ public class BluetoothDeviceManager {
            for (BluetoothDevice device: mBluetoothAdapter.getActiveDevices(
                        BluetoothProfile.HEARING_AID)) {
                if (device != null) {
                    mBluetoothAdapter.setActiveDevice(null, BluetoothAdapter.ACTIVE_DEVICE_ALL);
                    mBluetoothAdapter.removeActiveDevice(BluetoothAdapter.ACTIVE_DEVICE_ALL);
                }
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
                .thenReturn(Arrays.asList(device2, null));

        mBluetoothDeviceManager.disconnectAudio();
        verify(mAdapter).setActiveDevice(null, BluetoothAdapter.ACTIVE_DEVICE_ALL);
        verify(mAdapter).removeActiveDevice(BluetoothAdapter.ACTIVE_DEVICE_ALL);
        verify(mBluetoothHeadset).disconnectAudio();
    }