[bluetooth.bluez] Fix NullPointerException (#18185)

Fixes #18180

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2025-01-26 15:53:39 +01:00 committed by GitHub
parent f479a38337
commit a23086f206
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -218,9 +218,9 @@ public class BlueZBluetoothDevice extends BaseBluetoothDevice implements BlueZEv
return null;
}
for (BluetoothGattService service : dev.getGattServices()) {
for (BluetoothGattCharacteristic c : service.getGattCharacteristics()) {
if (uuid.equalsIgnoreCase(c.getUuid())) {
return c;
for (BluetoothGattCharacteristic characteristic : service.getGattCharacteristics()) {
if (characteristic != null && uuid.equalsIgnoreCase(characteristic.getUuid())) {
return characteristic;
}
}
}
@ -235,7 +235,7 @@ public class BlueZBluetoothDevice extends BaseBluetoothDevice implements BlueZEv
for (BluetoothGattService service : dev.getGattServices()) {
if (dBusPath.startsWith(service.getDbusPath())) {
for (BluetoothGattCharacteristic characteristic : service.getGattCharacteristics()) {
if (dBusPath.startsWith(characteristic.getDbusPath())) {
if (characteristic != null && dBusPath.startsWith(characteristic.getDbusPath())) {
return characteristic;
}
}