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

Commit b3320d87 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

LeAudioService: Expose getConnectedGroupLeadDevivces() API

This is going to be used by Telecom.
Each of the group is represented by the Lead devices (simply first
device connected in the group).
This lead devices is used later on when Active device is set in the
Audio System.

Other modules, should be able to know, which of the devices withing
group is a Lead, so they known which one they should make as Active if
needed.

Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
test: Test: atest BluetoothInstrumentationTests
Change-Id: I3ccf5a20bdd658a647cf1d6837675453224dc90b
parent 3ee89a29
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -363,6 +363,15 @@ public class LeAudioService extends ProfileService {
        }
    }

    public List<BluetoothDevice> getConnectedGroupLeadDevices() {
        List<BluetoothDevice> devices = new ArrayList<>();
        for (Map.Entry<Integer, LeAudioGroupDescriptor> entry : mGroupDescriptors.entrySet()) {
            Integer groupId = entry.getKey();
            devices.add(getFirstDeviceFromGroup(groupId));
        }
        return devices;
    }

    List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
        ArrayList<BluetoothDevice> devices = new ArrayList<>();
        if (states == null) {
@@ -1310,6 +1319,21 @@ public class LeAudioService extends ProfileService {
            }
        }

        @Override
        public void getConnectedGroupLeadDevices(AttributionSource source,
                SynchronousResultReceiver receiver) {
            try {
                LeAudioService service = getService(source);
                List<BluetoothDevice> defaultValue = new ArrayList<>(0);
                if (service != null) {
                    defaultValue = service.getConnectedGroupLeadDevices();
                }
                receiver.send(defaultValue);
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
        }

        @Override
        public void getDevicesMatchingConnectionStates(int[] states,
                AttributionSource source, SynchronousResultReceiver receiver) {
+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ oneway interface IBluetoothLeAudio {
    void setConnectionPolicy(in BluetoothDevice device, int connectionPolicy, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    void getConnectionPolicy(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
    void getConnectedGroupLeadDevices(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")

    /* Same value as bluetooth::groups::kGroupUnknown */
    const int LE_AUDIO_GROUP_ID_INVALID = -1;