diff options
author | Sven Gothel <[email protected]> | 2020-05-28 06:10:55 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-05-28 06:10:55 +0200 |
commit | 941f1d84e6662984f38b3eaf3de0a5945824c990 (patch) | |
tree | e44b7d25c018f1b518b83b8188fc26b6d0e6ad2d /java/direct_bt | |
parent | ec8b75e18b2fabadd23f60539ee5fdfb76bd6c1f (diff) |
DBTDevice: Avoid NPE: Check user callback reference before using
Diffstat (limited to 'java/direct_bt')
-rw-r--r-- | java/direct_bt/tinyb/DBTDevice.java | 24 |
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; |