diff options
author | Łukasz Rymanowski <lukasz.rymanowski@codecoup.pl> | 2021-10-08 21:12:19 +0000 |
---|---|---|
committer | Łukasz Rymanowski <lukasz.rymanowski@codecoup.pl> | 2021-10-13 11:39:29 +0000 |
commit | 48c38333b177614688dea8090cc6eee24b047b3c (patch) | |
tree | 3aece55ee83a889e526cc72a5ed68816d20db383 | |
parent | 7e33f238b2fd191a74183b11bf6abf35e7668665 (diff) |
leaudio: Add API to add/remove group node
Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: Manual
Change-Id: Ib385b24d6b10754d9cadea2363e81c78b4382a44
-rw-r--r-- | framework/java/android/bluetooth/BluetoothLeAudio.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java index c30c933b6e..92fcb6633e 100644 --- a/framework/java/android/bluetooth/BluetoothLeAudio.java +++ b/framework/java/android/bluetooth/BluetoothLeAudio.java @@ -250,6 +250,17 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { */ public static final int GROUP_STATUS_INACTIVE = IBluetoothLeAudio.GROUP_STATUS_INACTIVE; + /** + * Indicating that node has been added to the group. + * @hide + */ + public static final int GROUP_NODE_ADDED = IBluetoothLeAudio.GROUP_NODE_ADDED; + + /** + * Indicating that node has been removed from the group. + * @hide + */ + public static final int GROUP_NODE_REMOVED = IBluetoothLeAudio.GROUP_NODE_REMOVED; private final BluetoothProfileConnector<IBluetoothLeAudio> mProfileConnector = new BluetoothProfileConnector(this, BluetoothProfile.LE_AUDIO, "BluetoothLeAudio", @@ -546,6 +557,61 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { } /** + * Add device to the given group. + * @param group_id group ID the device is being added to + * @param device the active device + * @return true on success, otherwise false + * @hide + */ + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED + }) + public boolean groupAddNode(int group_id, @NonNull BluetoothDevice device) { + if (VDBG) log("groupAddNode()"); + final IBluetoothLeAudio service = getService(); + try { + if (service != null && mAdapter.isEnabled()) { + return service.groupAddNode(group_id, device, mAttributionSource); + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return false; + } catch (RemoteException e) { + Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); + return false; + } + } + + /** + * Remove device from a given group. + * @param group_id group ID the device is being removed from + * @param device the active device + * @return true on success, otherwise false + * + * @hide + */ + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED + }) + public boolean groupRemoveNode(int group_id, @NonNull BluetoothDevice device) { + if (VDBG) log("groupRemoveNode()"); + final IBluetoothLeAudio service = getService(); + try { + if (service != null && mAdapter.isEnabled()) { + return service.groupRemoveNode(group_id, device, mAttributionSource); + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return false; + } catch (RemoteException e) { + Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); + return false; + } + } + + /** * Set connection policy of the profile * * <p> The device should already be paired. |