[bluetooth.bluez] Fix `NullPointerException` (#18185)

Fixes #18180

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
pull/18192/head
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
1 changed files with 4 additions and 4 deletions

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;
}
}