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

Commit 81c03370 authored by Etienne Ruffieux's avatar Etienne Ruffieux
Browse files

Replacing getActiveDevice by btAdapter.getActiveDevices()

BluetoothProfile.getActiveDevice() is hidden, packages
should call BluetoothAdapter.getActiveDevices(profile)
instead.

Tag: #feature
Bug: 200202780
Test: build
Change-Id: I9392dd7ff1d73a847321fdaa32e326799eeded10
parent 667eecfe
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -794,7 +794,8 @@ public class BluetoothRouteManager extends StateMachine {

        if (bluetoothLeAudio != null) {
            if (mDeviceManager.isLeAudioCommunicationDevice()) {
                for (BluetoothDevice device : bluetoothLeAudio.getActiveDevices()) {
                for (BluetoothDevice device : bluetoothAdapter.getActiveDevices(
                        BluetoothProfile.LE_AUDIO)) {
                    if (device != null) {
                        leAudioActiveDevice = device;
                        activeDevices++;
+2 −1
Original line number Diff line number Diff line
@@ -423,7 +423,8 @@ public class BluetoothDeviceManagerTest extends TelecomTestCase {
        verify(mAdapter, never()).setActiveDevice(nullable(BluetoothDevice.class),
                eq(BluetoothAdapter.ACTIVE_DEVICE_PHONE_CALL));

        when(mBluetoothLeAudio.getActiveDevices()).thenReturn(Arrays.asList(device5, device6));
        when(mAdapter.getActiveDevices(eq(BluetoothProfile.LE_AUDIO)))
                .thenReturn(Arrays.asList(device5, device6));

        receiverUnderTest.onReceive(mContext,
                buildConnectionActionIntent(BluetoothHeadset.STATE_DISCONNECTED, device5,
+1 −1
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ public class BluetoothRouteManagerTest extends TelecomTestCase {
                .thenReturn(Arrays.asList(hearingAidDevices));
        when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.HEARING_AID)))
                .thenReturn(Arrays.asList(hearingAidActiveDevice, null));
        when(mBluetoothLeAudio.getActiveDevices())
        when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.LE_AUDIO)))
                .thenReturn(Arrays.asList(leAudioDevice, null));
    }

+1 −1
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ public class BluetoothRouteTransitionTests extends TelecomTestCase {
            if (mParams.hearingAidBtDevices.contains(mParams.messageDevice)) {
                when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.HEARING_AID)))
                    .thenReturn(Arrays.asList(null, null));
                when(mBluetoothLeAudio.getActiveDevices())
                when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.LE_AUDIO)))
                    .thenReturn(mParams.leAudioDevices.stream()
                       .filter(device -> device != mParams.messageDevice)
                       .collect(Collectors.toList()));