Loading android/app/src/com/android/bluetooth/le_audio/LeAudioService.java +5 −10 Original line number Diff line number Diff line Loading @@ -364,13 +364,8 @@ 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; public BluetoothDevice getConnectedGroupLeadDevice(int groupId) { return getFirstDeviceFromGroup(groupId); } List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { Loading Loading @@ -1321,13 +1316,13 @@ public class LeAudioService extends ProfileService { } @Override public void getConnectedGroupLeadDevices(AttributionSource source, public void getConnectedGroupLeadDevice(int groupId, AttributionSource source, SynchronousResultReceiver receiver) { try { LeAudioService service = getService(source); List<BluetoothDevice> defaultValue = new ArrayList<>(0); BluetoothDevice defaultValue = null; if (service != null) { defaultValue = service.getConnectedGroupLeadDevices(); defaultValue = service.getConnectedGroupLeadDevice(groupId); } receiver.send(defaultValue); } catch (RuntimeException e) { Loading framework/java/android/bluetooth/BluetoothLeAudio.java +39 −0 Original line number Diff line number Diff line Loading @@ -458,6 +458,45 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { return defaultValue; } /** * 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} */ Loading system/binder/android/bluetooth/IBluetoothLeAudio.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ oneway interface IBluetoothLeAudio { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)") void getConnectionPolicy(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)") void getConnectedGroupLeadDevices(in AttributionSource attributionSource, in SynchronousResultReceiver receiver); void getConnectedGroupLeadDevice(int groupId, in AttributionSource attributionSource, in SynchronousResultReceiver receiver); /* Same value as bluetooth::groups::kGroupUnknown */ const int LE_AUDIO_GROUP_ID_INVALID = -1; Loading Loading
android/app/src/com/android/bluetooth/le_audio/LeAudioService.java +5 −10 Original line number Diff line number Diff line Loading @@ -364,13 +364,8 @@ 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; public BluetoothDevice getConnectedGroupLeadDevice(int groupId) { return getFirstDeviceFromGroup(groupId); } List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { Loading Loading @@ -1321,13 +1316,13 @@ public class LeAudioService extends ProfileService { } @Override public void getConnectedGroupLeadDevices(AttributionSource source, public void getConnectedGroupLeadDevice(int groupId, AttributionSource source, SynchronousResultReceiver receiver) { try { LeAudioService service = getService(source); List<BluetoothDevice> defaultValue = new ArrayList<>(0); BluetoothDevice defaultValue = null; if (service != null) { defaultValue = service.getConnectedGroupLeadDevices(); defaultValue = service.getConnectedGroupLeadDevice(groupId); } receiver.send(defaultValue); } catch (RuntimeException e) { Loading
framework/java/android/bluetooth/BluetoothLeAudio.java +39 −0 Original line number Diff line number Diff line Loading @@ -458,6 +458,45 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { return defaultValue; } /** * 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} */ Loading
system/binder/android/bluetooth/IBluetoothLeAudio.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ oneway interface IBluetoothLeAudio { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)") void getConnectionPolicy(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)") void getConnectedGroupLeadDevices(in AttributionSource attributionSource, in SynchronousResultReceiver receiver); void getConnectedGroupLeadDevice(int groupId, in AttributionSource attributionSource, in SynchronousResultReceiver receiver); /* Same value as bluetooth::groups::kGroupUnknown */ const int LE_AUDIO_GROUP_ID_INVALID = -1; Loading