From 548fa6e1bcf2518c3650e0149653826209117c44 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 24 Jun 2020 13:55:54 +0200 Subject: DBTDevice::getServices() shall not throw an exception but return null on error (TinyB API) --- java/direct_bt/tinyb/DBTDevice.java | 13 ++++++++++++- 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 getServices(); + public List 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 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(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); -- cgit v1.2.3