diff options
author | Sven Gothel <[email protected]> | 2020-05-11 10:22:39 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-05-11 10:22:39 +0200 |
commit | b06528b908c43860ebd89f72d5f5675ac82badea (patch) | |
tree | cce1c7a079c9ef3e7f185afa23c0633113052808 /java/jni/direct_bt | |
parent | 2a264bce0f6e5fffdc9488c5e00babd22d711876 (diff) |
Resolving flushed discovered devices and shared device reference usage.
Commit 09cd1183b3599357b05c426e2b59e8df813304c5 describes existed issue
in a multi device and hence multi-device-discovery environment.
(The change has been reverted)
This changed resolves the shared device reference usage,
by having adapter maintaining a 'sharedDevices' list
in parallel to the 'discoveredDevices'.
Adapter will add a newly found and created device
to both lists, shared- and discovered devices.
Device may remove itself from the sharedDevices list
via remove() and its destructor.
Adapter will also look in sharedDevices in connected and found
callback to determine if a device is known and re-adds it
to the discovered devices list for consistency.
(Note: discoveredDevices may be flushed via a new startDiscovery)
Diffstat (limited to 'java/jni/direct_bt')
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index 1ea3e016..d192ba9a 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -70,6 +70,7 @@ void Java_direct_1bt_tinyb_DBTDevice_deleteImpl(JNIEnv *env, jobject obj) { try { DBTDevice *device = getInstance<DBTDevice>(env, obj); + device->remove(); delete device; } catch(...) { rethrow_and_raise_java_exception(env); @@ -88,6 +89,18 @@ jboolean Java_direct_1bt_tinyb_DBTDevice_disconnectImpl(JNIEnv *env, jobject obj return JNI_TRUE; } +jboolean Java_direct_1bt_tinyb_DBTDevice_remove(JNIEnv *env, jobject obj) +{ + try { + DBTDevice *device = getInstance<DBTDevice>(env, obj); + JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); + device->remove(); + } catch(...) { + rethrow_and_raise_java_exception(env); + } + return JNI_TRUE; +} + jboolean Java_direct_1bt_tinyb_DBTDevice_connectImpl(JNIEnv *env, jobject obj) { try { |