diff options
author | Misterioso <[email protected]> | 2017-09-19 23:31:08 +0200 |
---|---|---|
committer | petreeftime <[email protected]> | 2017-09-24 23:48:49 +0300 |
commit | daa37a0e09bc79c6f21a205b93a211e33042e48b (patch) | |
tree | b5a87f87973905d86a3fd2071f3bb15257d0bb03 /java | |
parent | 7f2a22fe24c71c222f13ed100a3772ef66ac2dc0 (diff) |
Added Java method BluetoothDevice::remove()
Now it's possible to remove a single device calling directly the method "remove" from Java.
Signed-off-by: Jorge Esteves <[email protected]>
Diffstat (limited to 'java')
-rw-r--r-- | java/BluetoothDevice.java | 6 | ||||
-rw-r--r-- | java/jni/BluetoothDevice.cxx | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/java/BluetoothDevice.java b/java/BluetoothDevice.java index 4a2fe0f7..fa7b1fe0 100644 --- a/java/BluetoothDevice.java +++ b/java/BluetoothDevice.java @@ -98,6 +98,12 @@ public class BluetoothDevice extends BluetoothObject * @return TRUE if the device connected and paired */ public native boolean pair() throws BluetoothException; + + /** Remove this device from the system (like an unpair). + * @return TRUE if the device has been removed + * @throws BluetoothException + */ + public native boolean remove() throws BluetoothException; /** Cancels an initiated pairing operation * @return TRUE if the paring is cancelled successfully diff --git a/java/jni/BluetoothDevice.cxx b/java/jni/BluetoothDevice.cxx index 587d682a..387c9559 100644 --- a/java/jni/BluetoothDevice.cxx +++ b/java/jni/BluetoothDevice.cxx @@ -176,6 +176,26 @@ jboolean Java_tinyb_BluetoothDevice_pair(JNIEnv *env, jobject obj) return JNI_FALSE; } +jboolean Java_tinyb_BluetoothDevice_remove(JNIEnv *env, jobject obj) +{ + try { + BluetoothDevice *obj_device = getInstance<BluetoothDevice>(env, obj); + + return obj_device->remove_device() ? JNI_TRUE : JNI_FALSE; + } catch (std::bad_alloc &e) { + raise_java_oom_exception(env, e); + } catch (BluetoothException &e) { + raise_java_bluetooth_exception(env, e); + } catch (std::runtime_error &e) { + raise_java_runtime_exception(env, e); + } catch (std::invalid_argument &e) { + raise_java_invalid_arg_exception(env, e); + } catch (std::exception &e) { + raise_java_exception(env, e); + } + return JNI_FALSE; +} + jboolean Java_tinyb_BluetoothDevice_cancelPairing(JNIEnv *env, jobject obj) { try { |