aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorMisterioso <[email protected]>2017-09-27 10:30:22 +0200
committerpetreeftime <[email protected]>2017-10-03 08:27:19 +0300
commit898f6ac604d6266292f74ce95d28ae8b7a7a3a2a (patch)
tree424e3f99efdad09d4464ea83b2cc2aef5a4a0b10 /java
parentfe5fd110db1659853ffa2df32bcef38cd15e1acd (diff)
Added Java method BluetoothManager::getDiscovering()
Added a method to check if a discovery process is running directly from the BluetoothManager (completion to startDiscovery and stopDiscovery). Signed-off-by: Jorge Esteves <[email protected]>
Diffstat (limited to 'java')
-rw-r--r--java/BluetoothManager.java5
-rw-r--r--java/jni/BluetoothManager.cxx19
2 files changed, 24 insertions, 0 deletions
diff --git a/java/BluetoothManager.java b/java/BluetoothManager.java
index 222cf540..cc8f9d3a 100644
--- a/java/BluetoothManager.java
+++ b/java/BluetoothManager.java
@@ -205,6 +205,11 @@ public class BluetoothManager
*/
public native boolean stopDiscovery() throws BluetoothException;
+ /** Returns if the discovers is running or not.
+ * @return TRUE if discovery is running
+ */
+ public native boolean getDiscovering() throws BluetoothException;
+
/**
* When called, each new device found will fire an event to the passed
* listener<p>
diff --git a/java/jni/BluetoothManager.cxx b/java/jni/BluetoothManager.cxx
index d5c652eb..dac0432c 100644
--- a/java/jni/BluetoothManager.cxx
+++ b/java/jni/BluetoothManager.cxx
@@ -370,6 +370,25 @@ jboolean Java_tinyb_BluetoothManager_stopDiscovery(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
+jboolean Java_tinyb_BluetoothManager_getDiscovering(JNIEnv *env, jobject obj)
+{
+ try {
+ BluetoothManager *manager = getInstance<BluetoothManager>(env, obj);
+ return manager->get_discovering() ? 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;
+}
+
void Java_tinyb_BluetoothManager_init(JNIEnv *env, jobject obj)
{
try {