Loading android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java +111 −25 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.bluetooth.csip; import static android.Manifest.permission.BLUETOOTH_CONNECT; import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -880,11 +882,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void connect(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); boolean defaultValue = false; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.connect(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.connect(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -895,11 +905,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void disconnect(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); boolean defaultValue = false; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.disconnect(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.disconnect(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -910,11 +928,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void getConnectedDevices(AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); List<BluetoothDevice> defaultValue = new ArrayList<>(); CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getConnectedDevices(); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getConnectedDevices(); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -925,11 +950,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void getDevicesMatchingConnectionStates(int[] states, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); List<BluetoothDevice> defaultValue = new ArrayList<>(); CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getDevicesMatchingConnectionStates(states); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getDevicesMatchingConnectionStates(states); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -940,11 +972,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void getConnectionState(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); int defaultValue = BluetoothProfile.STATE_DISCONNECTED; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getConnectionState(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getConnectionState(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -955,11 +994,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void setConnectionPolicy(BluetoothDevice device, int connectionPolicy, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); boolean defaultValue = false; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.setConnectionPolicy(device, connectionPolicy); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.setConnectionPolicy(device, connectionPolicy); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -970,11 +1017,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void getConnectionPolicy(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); int defaultValue = BluetoothProfile.CONNECTION_POLICY_UNKNOWN; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getConnectionPolicy(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getConnectionPolicy(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -986,12 +1041,21 @@ public class CsipSetCoordinatorService extends ProfileService { int groupId, @NonNull IBluetoothCsipSetCoordinatorLockCallback callback, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(callback, "callback cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); ParcelUuid defaultValue = null; CsipSetCoordinatorService service = getService(source); if (service != null) { if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); UUID lockUuid = service.lockGroup(groupId, callback); defaultValue = lockUuid == null ? null : new ParcelUuid(lockUuid); } receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1002,10 +1066,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void unlockGroup(@NonNull ParcelUuid lockUuid, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(lockUuid, "lockUuid cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); CsipSetCoordinatorService service = getService(source); if (service != null) { service.unlockGroup(lockUuid.getUuid()); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); service.unlockGroup(lockUuid.getUuid()); receiver.send(null); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1016,11 +1088,17 @@ public class CsipSetCoordinatorService extends ProfileService { public void getAllGroupIds(ParcelUuid uuid, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(uuid, "uuid cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); List<Integer> defaultValue = new ArrayList<Integer>(); CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getAllGroupIds(uuid); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getAllGroupIds(uuid); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1033,9 +1111,13 @@ public class CsipSetCoordinatorService extends ProfileService { try { Map<Integer, ParcelUuid> defaultValue = null; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getGroupUuidMapByDevice(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getGroupUuidMapByDevice(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1048,9 +1130,13 @@ public class CsipSetCoordinatorService extends ProfileService { try { int defaultValue = IBluetoothCsipSetCoordinator.CSIS_GROUP_SIZE_UNKNOWN; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getDesiredGroupSize(groupId); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getDesiredGroupSize(groupId); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading framework/java/android/bluetooth/BluetoothCsipSetCoordinator.java +31 −18 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.UUID; import java.util.concurrent.Executor; import java.util.concurrent.TimeoutException; Loading Loading @@ -266,18 +267,14 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto @Nullable UUID lockGroup(int groupId, @NonNull @CallbackExecutor Executor executor, @NonNull ClientLockCallback callback) { if (VDBG) log("lockGroup()"); Objects.requireNonNull(executor, "executor cannot be null"); Objects.requireNonNull(callback, "callback cannot be null"); final IBluetoothCsipSetCoordinator service = getService(); final UUID defaultValue = null; if (service == null) { Log.w(TAG, "Proxy not attached to service"); if (DBG) log(Log.getStackTraceString(new Throwable())); } else if (isEnabled()) { if (executor == null) { throw new IllegalArgumentException("executor cannot be null"); } if (callback == null) { throw new IllegalArgumentException("callback cannot be null"); } IBluetoothCsipSetCoordinatorLockCallback delegate = new BluetoothCsipSetCoordinatorLockCallbackDelegate(executor, callback); try { Loading @@ -285,8 +282,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto service.lockGroup(groupId, delegate, mAttributionSource, recv); final ParcelUuid ret = recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); return ret == null ? defaultValue : ret.getUuid(); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -304,9 +303,7 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean unlockGroup(@NonNull UUID lockUuid) { if (VDBG) log("unlockGroup()"); if (lockUuid == null) { throw new IllegalArgumentException("lockUuid cannot be null"); } Objects.requireNonNull(lockUuid, "lockUuid cannot be null"); final IBluetoothCsipSetCoordinator service = getService(); final boolean defaultValue = false; if (service == null) { Loading @@ -318,8 +315,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto service.unlockGroup(new ParcelUuid(lockUuid), mAttributionSource, recv); recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); return true; } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -347,8 +346,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Map> recv = new SynchronousResultReceiver(); service.getGroupUuidMapByDevice(device, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -376,8 +377,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto new SynchronousResultReceiver(); service.getAllGroupIds(uuid, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -400,8 +403,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto new SynchronousResultReceiver(); service.getConnectedDevices(mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -425,8 +430,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto new SynchronousResultReceiver(); service.getDevicesMatchingConnectionStates(states, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -449,8 +456,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver(); service.getConnectionState(device, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -486,8 +495,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Boolean> recv = new SynchronousResultReceiver(); service.setConnectionPolicy(device, connectionPolicy, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -519,8 +530,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver(); service.getConnectionPolicy(device, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading
android/app/src/com/android/bluetooth/csip/CsipSetCoordinatorService.java +111 −25 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.bluetooth.csip; import static android.Manifest.permission.BLUETOOTH_CONNECT; import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -880,11 +882,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void connect(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); boolean defaultValue = false; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.connect(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.connect(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -895,11 +905,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void disconnect(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); boolean defaultValue = false; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.disconnect(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.disconnect(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -910,11 +928,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void getConnectedDevices(AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); List<BluetoothDevice> defaultValue = new ArrayList<>(); CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getConnectedDevices(); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getConnectedDevices(); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -925,11 +950,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void getDevicesMatchingConnectionStates(int[] states, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); List<BluetoothDevice> defaultValue = new ArrayList<>(); CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getDevicesMatchingConnectionStates(states); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getDevicesMatchingConnectionStates(states); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -940,11 +972,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void getConnectionState(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); int defaultValue = BluetoothProfile.STATE_DISCONNECTED; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getConnectionState(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getConnectionState(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -955,11 +994,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void setConnectionPolicy(BluetoothDevice device, int connectionPolicy, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); boolean defaultValue = false; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.setConnectionPolicy(device, connectionPolicy); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.setConnectionPolicy(device, connectionPolicy); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -970,11 +1017,19 @@ public class CsipSetCoordinatorService extends ProfileService { public void getConnectionPolicy(BluetoothDevice device, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(device, "device cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); int defaultValue = BluetoothProfile.CONNECTION_POLICY_UNKNOWN; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getConnectionPolicy(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getConnectionPolicy(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -986,12 +1041,21 @@ public class CsipSetCoordinatorService extends ProfileService { int groupId, @NonNull IBluetoothCsipSetCoordinatorLockCallback callback, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(callback, "callback cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); ParcelUuid defaultValue = null; CsipSetCoordinatorService service = getService(source); if (service != null) { if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); UUID lockUuid = service.lockGroup(groupId, callback); defaultValue = lockUuid == null ? null : new ParcelUuid(lockUuid); } receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1002,10 +1066,18 @@ public class CsipSetCoordinatorService extends ProfileService { public void unlockGroup(@NonNull ParcelUuid lockUuid, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(lockUuid, "lockUuid cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); CsipSetCoordinatorService service = getService(source); if (service != null) { service.unlockGroup(lockUuid.getUuid()); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); service.unlockGroup(lockUuid.getUuid()); receiver.send(null); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1016,11 +1088,17 @@ public class CsipSetCoordinatorService extends ProfileService { public void getAllGroupIds(ParcelUuid uuid, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(uuid, "uuid cannot be null"); Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); List<Integer> defaultValue = new ArrayList<Integer>(); CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getAllGroupIds(uuid); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getAllGroupIds(uuid); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1033,9 +1111,13 @@ public class CsipSetCoordinatorService extends ProfileService { try { Map<Integer, ParcelUuid> defaultValue = null; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getGroupUuidMapByDevice(device); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getGroupUuidMapByDevice(device); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading @@ -1048,9 +1130,13 @@ public class CsipSetCoordinatorService extends ProfileService { try { int defaultValue = IBluetoothCsipSetCoordinator.CSIS_GROUP_SIZE_UNKNOWN; CsipSetCoordinatorService service = getService(source); if (service != null) { defaultValue = service.getDesiredGroupSize(groupId); if (service == null) { throw new IllegalStateException("service is null"); } enforceBluetoothPrivilegedPermission(service); defaultValue = service.getDesiredGroupSize(groupId); receiver.send(defaultValue); } catch (RuntimeException e) { receiver.propagateException(e); Loading
framework/java/android/bluetooth/BluetoothCsipSetCoordinator.java +31 −18 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.UUID; import java.util.concurrent.Executor; import java.util.concurrent.TimeoutException; Loading Loading @@ -266,18 +267,14 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto @Nullable UUID lockGroup(int groupId, @NonNull @CallbackExecutor Executor executor, @NonNull ClientLockCallback callback) { if (VDBG) log("lockGroup()"); Objects.requireNonNull(executor, "executor cannot be null"); Objects.requireNonNull(callback, "callback cannot be null"); final IBluetoothCsipSetCoordinator service = getService(); final UUID defaultValue = null; if (service == null) { Log.w(TAG, "Proxy not attached to service"); if (DBG) log(Log.getStackTraceString(new Throwable())); } else if (isEnabled()) { if (executor == null) { throw new IllegalArgumentException("executor cannot be null"); } if (callback == null) { throw new IllegalArgumentException("callback cannot be null"); } IBluetoothCsipSetCoordinatorLockCallback delegate = new BluetoothCsipSetCoordinatorLockCallbackDelegate(executor, callback); try { Loading @@ -285,8 +282,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto service.lockGroup(groupId, delegate, mAttributionSource, recv); final ParcelUuid ret = recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); return ret == null ? defaultValue : ret.getUuid(); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -304,9 +303,7 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean unlockGroup(@NonNull UUID lockUuid) { if (VDBG) log("unlockGroup()"); if (lockUuid == null) { throw new IllegalArgumentException("lockUuid cannot be null"); } Objects.requireNonNull(lockUuid, "lockUuid cannot be null"); final IBluetoothCsipSetCoordinator service = getService(); final boolean defaultValue = false; if (service == null) { Loading @@ -318,8 +315,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto service.unlockGroup(new ParcelUuid(lockUuid), mAttributionSource, recv); recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); return true; } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -347,8 +346,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Map> recv = new SynchronousResultReceiver(); service.getGroupUuidMapByDevice(device, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -376,8 +377,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto new SynchronousResultReceiver(); service.getAllGroupIds(uuid, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -400,8 +403,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto new SynchronousResultReceiver(); service.getConnectedDevices(mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -425,8 +430,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto new SynchronousResultReceiver(); service.getDevicesMatchingConnectionStates(states, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading @@ -449,8 +456,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver(); service.getConnectionState(device, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -486,8 +495,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Boolean> recv = new SynchronousResultReceiver(); service.setConnectionPolicy(device, connectionPolicy, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading Loading @@ -519,8 +530,10 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver(); service.getConnectionPolicy(device, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } return defaultValue; Loading