[bluetooth.bluez] Fix the unpairing of all devices on binding disposal (#9011)

Signed-off-by: Benjamin Lafois <benjamin.lafois@gmail.com>
This commit is contained in:
Benjamin Lafois 2020-11-28 15:59:39 +01:00 committed by GitHub
parent 821a84067a
commit 2730bc8a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,6 +120,10 @@ public class BlueZBluetoothDevice extends BaseBluetoothDevice implements BlueZEv
public void dispose() {
BluetoothDevice dev = device;
if (dev != null) {
if (Boolean.TRUE.equals(dev.isPaired())) {
return;
}
try {
dev.getAdapter().removeDevice(dev.getRawDevice());
} catch (DBusException ex) {
@ -359,8 +363,10 @@ public class BlueZBluetoothDevice extends BaseBluetoothDevice implements BlueZEv
}
BluetoothCharacteristic c = getCharacteristic(UUID.fromString(characteristic.getUuid()));
if (c != null) {
c.setValue(event.getData());
notifyListeners(BluetoothEventType.CHARACTERISTIC_UPDATED, c, BluetoothCompletionStatus.SUCCESS);
synchronized (c) {
c.setValue(event.getData());
notifyListeners(BluetoothEventType.CHARACTERISTIC_UPDATED, c, BluetoothCompletionStatus.SUCCESS);
}
}
}