diff options
author | Sven Gothel <[email protected]> | 2020-06-24 13:55:54 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-24 13:55:54 +0200 |
commit | 548fa6e1bcf2518c3650e0149653826209117c44 (patch) | |
tree | d55fd8ea92dd7dd853f5675b72d365d78341b23b | |
parent | 9e64daadd7cdd5bcb7bd8bdc1400b3836125a2e9 (diff) |
DBTDevice::getServices() shall not throw an exception but return null on error (TinyB API)
-rw-r--r-- | java/direct_bt/tinyb/DBTDevice.java | 13 | ||||
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java index f0ab41ea..e2390a51 100644 --- a/java/direct_bt/tinyb/DBTDevice.java +++ b/java/direct_bt/tinyb/DBTDevice.java @@ -508,7 +508,18 @@ public class DBTDevice extends DBTObject implements BluetoothDevice public native boolean remove() throws BluetoothException; @Override - public native List<BluetoothGattService> getServices(); + public List<BluetoothGattService> getServices() { + try { + return getServicesImpl(); + } catch (final Throwable t) { + if(DEBUG) { + System.err.println("Caught "+t.getMessage()+" on thread "+Thread.currentThread().toString()); + t.printStackTrace(); + } + } + return null; + } + private native List<BluetoothGattService> getServicesImpl(); /* property accessors: */ diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index 306e4156..465aa87d 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -329,7 +329,7 @@ jboolean Java_direct_1bt_tinyb_DBTDevice_connectImpl__SSSSSS(JNIEnv *env, jobjec static const std::string _serviceClazzCtorArgs("(JLdirect_bt/tinyb/DBTDevice;ZLjava/lang/String;SS)V"); -jobject Java_direct_1bt_tinyb_DBTDevice_getServices(JNIEnv *env, jobject obj) { +jobject Java_direct_1bt_tinyb_DBTDevice_getServicesImpl(JNIEnv *env, jobject obj) { try { DBTDevice *device = getInstance<DBTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); |