@@ -141,7 +141,7 @@ public BleMidiPeripheralProvider(final Context context) throws UnsupportedOperat
141
141
/**
142
142
* Starts advertising
143
143
*/
144
- public void startAdvertising () {
144
+ public void startAdvertising () throws SecurityException {
145
145
// register Gatt service to Gatt server
146
146
if (gattServer == null ) {
147
147
gattServer = bluetoothManager .openGattServer (context , gattServerCallback );
@@ -212,7 +212,7 @@ public void startAdvertising() {
212
212
/**
213
213
* Stops advertising
214
214
*/
215
- public void stopAdvertising () {
215
+ public void stopAdvertising () throws SecurityException {
216
216
try {
217
217
bluetoothLeAdvertiser .stopAdvertising (advertiseCallback );
218
218
} catch (IllegalStateException ignored ) {
@@ -257,7 +257,7 @@ public void disconnectDevice(@NonNull MidiOutputDevice midiOutputDevice) {
257
257
*/
258
258
private final BluetoothGattCallback disconnectCallback = new BluetoothGattCallback () {
259
259
@ Override
260
- public void onConnectionStateChange (BluetoothGatt gatt , int status , int newState ) {
260
+ public void onConnectionStateChange (BluetoothGatt gatt , int status , int newState ) throws SecurityException {
261
261
super .onConnectionStateChange (gatt , status , newState );
262
262
Log .d (Constants .TAG , "onConnectionStateChange status: " + status + ", newState: " + newState );
263
263
// disconnect the device
@@ -272,7 +272,7 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
272
272
*
273
273
* @param deviceAddress the device address from {@link android.bluetooth.BluetoothGatt}
274
274
*/
275
- private void disconnectByDeviceAddress (@ NonNull String deviceAddress ) {
275
+ private void disconnectByDeviceAddress (@ NonNull String deviceAddress ) throws SecurityException {
276
276
synchronized (bluetoothDevicesMap ) {
277
277
BluetoothDevice bluetoothDevice = bluetoothDevicesMap .get (deviceAddress );
278
278
if (bluetoothDevice != null ) {
@@ -285,7 +285,7 @@ private void disconnectByDeviceAddress(@NonNull String deviceAddress) {
285
285
/**
286
286
* Terminates provider
287
287
*/
288
- public void terminate () {
288
+ public void terminate () throws SecurityException {
289
289
stopAdvertising ();
290
290
291
291
synchronized (bluetoothDevicesMap ) {
@@ -373,7 +373,7 @@ public void onConnectionStateChange(BluetoothDevice device, int status, int newS
373
373
}
374
374
375
375
@ Override
376
- public void onCharacteristicReadRequest (BluetoothDevice device , int requestId , int offset , BluetoothGattCharacteristic characteristic ) {
376
+ public void onCharacteristicReadRequest (BluetoothDevice device , int requestId , int offset , BluetoothGattCharacteristic characteristic ) throws SecurityException {
377
377
super .onCharacteristicReadRequest (device , requestId , offset , characteristic );
378
378
379
379
UUID characteristicUuid = characteristic .getUuid ();
@@ -398,7 +398,7 @@ public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, i
398
398
}
399
399
400
400
@ Override
401
- public void onCharacteristicWriteRequest (BluetoothDevice device , int requestId , BluetoothGattCharacteristic characteristic , boolean preparedWrite , boolean responseNeeded , int offset , byte [] value ) {
401
+ public void onCharacteristicWriteRequest (BluetoothDevice device , int requestId , BluetoothGattCharacteristic characteristic , boolean preparedWrite , boolean responseNeeded , int offset , byte [] value ) throws SecurityException {
402
402
super .onCharacteristicWriteRequest (device , requestId , characteristic , preparedWrite , responseNeeded , offset , value );
403
403
404
404
if (BleUuidUtils .matches (characteristic .getUuid (), CHARACTERISTIC_BLE_MIDI )) {
@@ -416,7 +416,7 @@ public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,
416
416
}
417
417
418
418
@ Override
419
- public void onDescriptorWriteRequest (BluetoothDevice device , int requestId , BluetoothGattDescriptor descriptor , boolean preparedWrite , boolean responseNeeded , int offset , byte [] value ) {
419
+ public void onDescriptorWriteRequest (BluetoothDevice device , int requestId , BluetoothGattDescriptor descriptor , boolean preparedWrite , boolean responseNeeded , int offset , byte [] value ) throws SecurityException {
420
420
super .onDescriptorWriteRequest (device , requestId , descriptor , preparedWrite , responseNeeded , offset , value );
421
421
422
422
byte [] descriptorValue = descriptor .getValue ();
@@ -430,7 +430,7 @@ public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, Blue
430
430
}
431
431
432
432
@ Override
433
- public void onDescriptorReadRequest (BluetoothDevice device , int requestId , int offset , BluetoothGattDescriptor descriptor ) {
433
+ public void onDescriptorReadRequest (BluetoothDevice device , int requestId , int offset , BluetoothGattDescriptor descriptor ) throws SecurityException {
434
434
super .onDescriptorReadRequest (device , requestId , offset , descriptor );
435
435
436
436
if (offset == 0 ) {
@@ -587,7 +587,7 @@ public void setOnMidiInputEventListener(OnMidiInputEventListener midiInputEventL
587
587
588
588
@ NonNull
589
589
@ Override
590
- public String getDeviceName () {
590
+ public String getDeviceName () throws SecurityException {
591
591
if (TextUtils .isEmpty (bluetoothDevice .getName ())) {
592
592
return bluetoothDevice .getAddress ();
593
593
}
@@ -635,15 +635,15 @@ public InternalMidiOutputDevice(@NonNull final BluetoothDevice bluetoothDevice,
635
635
636
636
@ NonNull
637
637
@ Override
638
- public String getDeviceName () {
638
+ public String getDeviceName () throws SecurityException {
639
639
if (TextUtils .isEmpty (bluetoothDevice .getName ())) {
640
640
return bluetoothDevice .getAddress ();
641
641
}
642
642
return bluetoothDevice .getName ();
643
643
}
644
644
645
645
@ Override
646
- public void transferData (@ NonNull byte [] writeBuffer ) {
646
+ public void transferData (@ NonNull byte [] writeBuffer ) throws SecurityException {
647
647
midiOutputCharacteristic .setValue (writeBuffer );
648
648
649
649
try {
0 commit comments