aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-05-28 06:10:55 +0200
committerSven Gothel <[email protected]>2020-05-28 06:10:55 +0200
commit941f1d84e6662984f38b3eaf3de0a5945824c990 (patch)
treee44b7d25c018f1b518b83b8188fc26b6d0e6ad2d
parentec8b75e18b2fabadd23f60539ee5fdfb76bd6c1f (diff)
DBTDevice: Avoid NPE: Check user callback reference before using
-rw-r--r--java/direct_bt/tinyb/DBTDevice.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java
index 002e50e6..636723e5 100644
--- a/java/direct_bt/tinyb/DBTDevice.java
+++ b/java/direct_bt/tinyb/DBTDevice.java
@@ -215,10 +215,14 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
// FIXME: Split up - may offload to other thread
// Currently service resolution performed in connectImpl()!
servicesResolved = false;
- userServicesResolvedNotificationsCB.run(Boolean.FALSE);
+ if( null != userServicesResolvedNotificationsCB ) {
+ userServicesResolvedNotificationsCB.run(Boolean.FALSE);
+ }
connected = false;
- userConnectedNotificationsCB.run(Boolean.FALSE);
+ if( null != userConnectedNotificationsCB ) {
+ userConnectedNotificationsCB.run(Boolean.FALSE);
+ }
}
}
return res;
@@ -232,12 +236,16 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
res = connectImpl();
if( res ) {
connected = true;
- userConnectedNotificationsCB.run(Boolean.TRUE);
+ if( null != userConnectedNotificationsCB ) {
+ userConnectedNotificationsCB.run(Boolean.TRUE);
+ }
// FIXME: Split up - may offload to other thread
// Currently service resolution performed in connectImpl()!
servicesResolved = true;
- userServicesResolvedNotificationsCB.run(Boolean.TRUE);
+ if( null != userServicesResolvedNotificationsCB ) {
+ userServicesResolvedNotificationsCB.run(Boolean.TRUE);
+ }
}
}
return res;
@@ -253,12 +261,16 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
res = connectImpl(interval, window, min_interval, max_interval, latency, timeout);
if( res ) {
connected = true;
- userConnectedNotificationsCB.run(Boolean.TRUE);
+ if( null != userConnectedNotificationsCB ) {
+ userConnectedNotificationsCB.run(Boolean.TRUE);
+ }
// FIXME: Split up - may offload to other thread
// Currently service resolution performed in connectImpl()!
servicesResolved = true;
- userServicesResolvedNotificationsCB.run(Boolean.TRUE);
+ if( null != userServicesResolvedNotificationsCB ) {
+ userServicesResolvedNotificationsCB.run(Boolean.TRUE);
+ }
}
}
return res;