diff options
author | Ćukasz Rymanowski <rlukasz@google.com> | 2022-01-11 18:12:37 +0000 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2022-01-19 23:10:04 +0000 |
commit | 42f37e1c4b71f6622c1c28b7e9132bb977ae2b7b (patch) | |
tree | a9f9af6e2328903f5935daadf6c93ff6e8961dee /framework/java/android/bluetooth/BluetoothLeAudio.java | |
parent | d796637eca324871f2777e60d5b160006d9c1639 (diff) |
leaudio: Add method to get device group lead
When Le Audio group is active in the system, it is represented by one
group member which becames Active Device.
With this patch, we want to expose group lead device which will be used
as an Active Device for connected group.
This is needed e.g. by telecom so it knows, which devices should be
presented in the Dialer for each Le Audio group.
Bug: 150670922
Tag: #feature
Test: build
Sponsor: jpawlowski@
Change-Id: I401ef3ceaeb334b35697dd88e2c1a9b1d5d2eac9
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeAudio.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothLeAudio.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java index 15db686b3b..fa78244477 100644 --- a/framework/java/android/bluetooth/BluetoothLeAudio.java +++ b/framework/java/android/bluetooth/BluetoothLeAudio.java @@ -451,6 +451,45 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { } /** + * Get lead device for a group. + * + * Lead device is the device that can be used as an active device in the system. + * Active devices points to the Audio Device for the Le Audio group. + * This method returns a list of Lead devices for all the connected LE Audio + * groups and those devices should be used in the setActiveDevice() method by other parts + * of the system, which wants to setActive a particular Le Audio Group. + * + * Note: getActiveDevice() returns the Lead device for the currently active LE Audio group. + * Note: When lead device gets disconnected, there will be new lead device for the group. + * + * @param groupId The group id. + * @return group lead device. + */ + @RequiresBluetoothConnectPermission + @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) + public @Nullable BluetoothDevice getConnectedGroupLeadDevice(int groupId) { + if (VDBG) log("getConnectedGroupLeadDevice()"); + final IBluetoothLeAudio service = getService(); + final BluetoothDevice defaultValue = null; + if (service == null) { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) log(Log.getStackTraceString(new Throwable())); + } else if (mAdapter.isEnabled()) { + try { + final SynchronousResultReceiver<BluetoothDevice> recv = + new SynchronousResultReceiver(); + service.getConnectedGroupLeadDevice(groupId, mAttributionSource, recv); + return Attributable.setAttributionSource( + recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue), + mAttributionSource); + } catch (RemoteException | TimeoutException e) { + Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); + } + } + return defaultValue; + } + + /** * {@inheritDoc} */ @Override |