Loading android/app/src/com/android/bluetooth/vc/VolumeControlService.java +59 −16 Original line number Diff line number Diff line Loading @@ -921,6 +921,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); boolean defaultValue = false; if (service != null) { Loading @@ -936,6 +940,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); boolean defaultValue = false; if (service != null) { Loading @@ -951,6 +959,9 @@ public class VolumeControlService extends ProfileService { public void getConnectedDevices(AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); VolumeControlService service = getService(source); List<BluetoothDevice> defaultValue = new ArrayList<>(); if (service != null) { Loading @@ -967,6 +978,9 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); List<BluetoothDevice> defaultValue = new ArrayList<>(); if (service != null) { Loading @@ -982,6 +996,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); int defaultValue = BluetoothProfile.STATE_DISCONNECTED; if (service != null) { Loading @@ -997,6 +1015,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); boolean defaultValue = false; if (service != null) { Loading @@ -1012,6 +1034,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); int defaultValue = BluetoothProfile.CONNECTION_POLICY_UNKNOWN; if (service != null) { Loading @@ -1027,6 +1053,10 @@ public class VolumeControlService extends ProfileService { public void isVolumeOffsetAvailable(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; VolumeControlService service = getService(source); if (service != null) { Loading @@ -1042,6 +1072,10 @@ public class VolumeControlService extends ProfileService { public void setVolumeOffset(BluetoothDevice device, int volumeOffset, 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"); VolumeControlService service = getService(source); if (service != null) { service.setVolumeOffset(device, volumeOffset); Loading @@ -1056,6 +1090,9 @@ public class VolumeControlService extends ProfileService { public void setVolumeGroup(int groupId, int volume, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); VolumeControlService service = getService(source); if (service != null) { service.setVolumeGroup(groupId, volume); Loading @@ -1069,6 +1106,11 @@ public class VolumeControlService extends ProfileService { @Override public void registerCallback(IBluetoothVolumeControlCallback 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"); VolumeControlService service = getService(source); if (service == null) { throw new IllegalStateException("Service is unavailable"); Loading @@ -1076,18 +1118,21 @@ public class VolumeControlService extends ProfileService { enforceBluetoothPrivilegedPermission(service); try { service.mCallbacks.register(callback); receiver.send(null); } catch (RuntimeException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); throw new IllegalArgumentException(" Invalid callback"); receiver.propagateException(e); } } @Override public void unregisterCallback(IBluetoothVolumeControlCallback 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"); VolumeControlService service = getService(source); if (service == null) { throw new IllegalStateException("Service is unavailable"); Loading @@ -1095,12 +1140,10 @@ public class VolumeControlService extends ProfileService { enforceBluetoothPrivilegedPermission(service); try { service.mCallbacks.unregister(callback); receiver.send(null); } catch (RuntimeException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); throw new IllegalArgumentException(" Invalid callback "); receiver.propagateException(e); } } } Loading Loading
android/app/src/com/android/bluetooth/vc/VolumeControlService.java +59 −16 Original line number Diff line number Diff line Loading @@ -921,6 +921,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); boolean defaultValue = false; if (service != null) { Loading @@ -936,6 +940,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); boolean defaultValue = false; if (service != null) { Loading @@ -951,6 +959,9 @@ public class VolumeControlService extends ProfileService { public void getConnectedDevices(AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); VolumeControlService service = getService(source); List<BluetoothDevice> defaultValue = new ArrayList<>(); if (service != null) { Loading @@ -967,6 +978,9 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); List<BluetoothDevice> defaultValue = new ArrayList<>(); if (service != null) { Loading @@ -982,6 +996,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); int defaultValue = BluetoothProfile.STATE_DISCONNECTED; if (service != null) { Loading @@ -997,6 +1015,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); boolean defaultValue = false; if (service != null) { Loading @@ -1012,6 +1034,10 @@ public class VolumeControlService 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"); VolumeControlService service = getService(source); int defaultValue = BluetoothProfile.CONNECTION_POLICY_UNKNOWN; if (service != null) { Loading @@ -1027,6 +1053,10 @@ public class VolumeControlService extends ProfileService { public void isVolumeOffsetAvailable(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; VolumeControlService service = getService(source); if (service != null) { Loading @@ -1042,6 +1072,10 @@ public class VolumeControlService extends ProfileService { public void setVolumeOffset(BluetoothDevice device, int volumeOffset, 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"); VolumeControlService service = getService(source); if (service != null) { service.setVolumeOffset(device, volumeOffset); Loading @@ -1056,6 +1090,9 @@ public class VolumeControlService extends ProfileService { public void setVolumeGroup(int groupId, int volume, AttributionSource source, SynchronousResultReceiver receiver) { try { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(receiver, "receiver cannot be null"); VolumeControlService service = getService(source); if (service != null) { service.setVolumeGroup(groupId, volume); Loading @@ -1069,6 +1106,11 @@ public class VolumeControlService extends ProfileService { @Override public void registerCallback(IBluetoothVolumeControlCallback 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"); VolumeControlService service = getService(source); if (service == null) { throw new IllegalStateException("Service is unavailable"); Loading @@ -1076,18 +1118,21 @@ public class VolumeControlService extends ProfileService { enforceBluetoothPrivilegedPermission(service); try { service.mCallbacks.register(callback); receiver.send(null); } catch (RuntimeException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); throw new IllegalArgumentException(" Invalid callback"); receiver.propagateException(e); } } @Override public void unregisterCallback(IBluetoothVolumeControlCallback 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"); VolumeControlService service = getService(source); if (service == null) { throw new IllegalStateException("Service is unavailable"); Loading @@ -1095,12 +1140,10 @@ public class VolumeControlService extends ProfileService { enforceBluetoothPrivilegedPermission(service); try { service.mCallbacks.unregister(callback); receiver.send(null); } catch (RuntimeException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); throw new IllegalArgumentException(" Invalid callback "); receiver.propagateException(e); } } } Loading