diff options
author | Sven Gothel <[email protected]> | 2022-01-13 05:35:58 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-01-13 05:35:58 +0100 |
commit | 48ff06cd7a4ebe0e22f82ac949624130f66dcdd1 (patch) | |
tree | 42c316243edb90fbeb634caa43af0dfcb8aa4f65 /java/jni | |
parent | 3c73bd3a8c8bc3489d25a9eabd18ac2a08dc4501 (diff) |
BTDevice::setConnSecurity*(..): Consolidate write methods to setConnSecurity() and setConnSecurityAuto() only
Also revert change allowing BTDevice::setConnSecurity*(..) on connected devices, IF BTAdapter is server,
i.e. method must be called pre-connection notification (commit f4118b41672c17b2f0845ea9a23c87cfaa04cf39).
Diffstat (limited to 'java/jni')
-rw-r--r-- | java/jni/direct_bt/DBTDevice.cxx | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx index 4bcf6492..8457d024 100644 --- a/java/jni/direct_bt/DBTDevice.cxx +++ b/java/jni/direct_bt/DBTDevice.cxx @@ -704,65 +704,65 @@ jbyte Java_jau_direct_1bt_DBTDevice_unpairImpl(JNIEnv *env, jobject obj) { return (jbyte) number(HCIStatusCode::INTERNAL_FAILURE); } -jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityLevelImpl(JNIEnv *env, jobject obj, jbyte jsec_level) { +jbyte Java_jau_direct_1bt_DBTDevice_getConnSecurityLevelImpl(JNIEnv *env, jobject obj) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - return device->setConnSecurityLevel( to_BTSecurityLevel( static_cast<uint8_t>(jsec_level) )); + return number( device->getConnSecurityLevel() ); } catch(...) { rethrow_and_raise_java_exception(env); } - return JNI_FALSE; + return number( BTSecurityLevel::UNSET ); } -jbyte Java_jau_direct_1bt_DBTDevice_getConnSecurityLevelImpl(JNIEnv *env, jobject obj) { +jbyte Java_jau_direct_1bt_DBTDevice_getConnIOCapabilityImpl(JNIEnv *env, jobject obj) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - return number( device->getConnSecurityLevel() ); + return number( device->getConnIOCapability() ); } catch(...) { rethrow_and_raise_java_exception(env); } - return number( BTSecurityLevel::UNSET ); + return number( SMPIOCapability::UNSET ); } -jboolean Java_jau_direct_1bt_DBTDevice_setConnIOCapabilityImpl(JNIEnv *env, jobject obj, jbyte jio_cap) { +jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - return device->setConnIOCapability( to_SMPIOCapability( static_cast<uint8_t>(jio_cap) )); + return device->setConnSecurity( to_BTSecurityLevel( static_cast<uint8_t>(jsec_level) ), + to_SMPIOCapability( static_cast<uint8_t>(jio_cap) ) ); } catch(...) { rethrow_and_raise_java_exception(env); } return JNI_FALSE; } -jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap) { +jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityAutoImpl(JNIEnv *env, jobject obj, jbyte jio_cap) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - return device->setConnSecurity( to_BTSecurityLevel( static_cast<uint8_t>(jsec_level) ), - to_SMPIOCapability( static_cast<uint8_t>(jio_cap) ) ); + return device->setConnSecurityAuto( to_SMPIOCapability( static_cast<uint8_t>(jio_cap) ) ); } catch(...) { rethrow_and_raise_java_exception(env); } return JNI_FALSE; } -jbyte Java_jau_direct_1bt_DBTDevice_getConnIOCapabilityImpl(JNIEnv *env, jobject obj) { +jboolean Java_jau_direct_1bt_DBTDevice_isConnSecurityAutoEnabled(JNIEnv *env, jobject obj) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - return number( device->getConnIOCapability() ); + return device->isConnSecurityAutoEnabled(); } catch(...) { rethrow_and_raise_java_exception(env); } - return number( SMPIOCapability::UNSET ); + return JNI_FALSE; } jbyte Java_jau_direct_1bt_DBTDevice_getPairingModeImpl(JNIEnv *env, jobject obj) { @@ -789,30 +789,6 @@ jbyte Java_jau_direct_1bt_DBTDevice_getPairingStateImpl(JNIEnv *env, jobject obj return static_cast<uint8_t>( SMPPairingState::NONE ); } -jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityAutoImpl(JNIEnv *env, jobject obj, jbyte jio_cap) { - try { - BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); - JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - - return device->setConnSecurityAuto( to_SMPIOCapability( static_cast<uint8_t>(jio_cap) ) ); - } catch(...) { - rethrow_and_raise_java_exception(env); - } - return JNI_FALSE; -} - -jboolean Java_jau_direct_1bt_DBTDevice_isConnSecurityAutoEnabled(JNIEnv *env, jobject obj) { - try { - BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); - JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE); - - return device->isConnSecurityAutoEnabled(); - } catch(...) { - rethrow_and_raise_java_exception(env); - } - return JNI_FALSE; -} - jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyImpl(JNIEnv *env, jobject obj, jint jpasskey) { try { BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj); |