aboutsummaryrefslogtreecommitdiffstats
path: root/java/jni
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-11-29 16:16:34 +0100
committerSven Gothel <[email protected]>2021-11-29 16:16:34 +0100
commite725e4f0b382d948cdfae5c5aaab8a5881e34034 (patch)
tree389e30eec30c7c2f5062fcf2d285b6da4a3f7175 /java/jni
parent4a1456402ecbf07cf16e02aa31788f1f66567890 (diff)
BTAdapter::pausing_discovery_devices: Use std::weak_ptr<BTDevice> list; Add BTAdapter::removeDevicePausingDiscovery() and getCurrentDiscoveryPolicy()
Using a weak_ptr<BTDevice> list avoid stopping BTDevice destruction. BTAdapter::removeDevicePausingDiscovery() allows manual DiscoveryPolicy intervention point, allowing user to remove the ready device from the queue of pausing-discovery devices. Manual intervention might be desired, if using DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED, but allowing discovery at an earlier processing step from AdapterStatusListener::deviceReady(). +++ Further added removeDevicePausingDiscovery() call in BTAdapter::removeDevice() as a last resort.
Diffstat (limited to 'java/jni')
-rw-r--r--java/jni/direct_bt/DBTAdapter.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx
index fc9c39c2..d675b4b4 100644
--- a/java/jni/direct_bt/DBTAdapter.cxx
+++ b/java/jni/direct_bt/DBTAdapter.cxx
@@ -710,6 +710,31 @@ jbyte Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE);
}
+jbyte Java_jau_direct_1bt_DBTAdapter_getCurrentDiscoveryPolicyImpl(JNIEnv *env, jobject obj) {
+ DiscoveryPolicy current = DiscoveryPolicy::AUTO_OFF;
+ try {
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
+ current = adapter->getCurrentDiscoveryPolicy();
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+ return (jbyte)number(current);
+}
+
+jboolean Java_jau_direct_1bt_DBTAdapter_removeDevicePausingDiscovery(JNIEnv *env, jobject obj, jobject jdevice) {
+ try {
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
+
+ BTDevice *device = jau::getJavaUplinkObject<BTDevice>(env, jdevice);
+ jau::JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
+
+ return adapter->removeDevicePausingDiscovery(*device) ? JNI_TRUE : JNI_FALSE;
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+ return JNI_FALSE;
+}
+
jbyte Java_jau_direct_1bt_DBTAdapter_getRoleImpl(JNIEnv *env, jobject obj)
{
try {