diff options
author | Sven Gothel <[email protected]> | 2020-06-07 19:28:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-07 19:28:36 +0200 |
commit | 2e58b250a382e05f0f4cb8d9520097afe07b91cd (patch) | |
tree | 17c2ce6d1c385dc3d4f99de2ad840ca3ab5a21d6 /java/jni | |
parent | 66c34a6229c9d541f1ae8900b357f953edfa54cd (diff) |
Relax GATTHandler == nullptr for disable and listener-removal operations, it's OK to have a NOP here when GATTHandler has been shutdown.
Diffstat (limited to 'java/jni')
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index a392fadc..6349c180 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -213,7 +213,9 @@ jboolean Java_direct_1bt_tinyb_DBTDevice_removeCharacteristicListener(JNIEnv *en JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); std::shared_ptr<GATTHandler> gatt = device->getGATTHandler(); if( nullptr == gatt ) { - throw IllegalStateException("Characteristic's device GATTHandle not connected: "+ device->toString(), E_FILE_LINE); + // OK to have GATTHandler being shutdown @ disable + DBG_PRINT("Characteristic's device GATTHandle not connected: %s", device->toString().c_str()); + return false; } if( ! gatt->removeCharacteristicListener(pre) ) { @@ -233,9 +235,10 @@ jint Java_direct_1bt_tinyb_DBTDevice_removeAllCharacteristicListener(JNIEnv *env JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); std::shared_ptr<GATTHandler> gatt = device->getGATTHandler(); if( nullptr == gatt ) { - throw IllegalStateException("Characteristic's device GATTHandle not connected: "+ device->toString(), E_FILE_LINE); + // OK to have GATTHandler being shutdown @ disable + DBG_PRINT("Characteristic's device GATTHandle not connected: %s", device->toString().c_str()); + return 0; } - return gatt->removeAllCharacteristicListener(); } catch(...) { rethrow_and_raise_java_exception(env); |