X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=android%2Fandroid_api%2Fbase%2Fjni%2FJniCaInterface.c;h=2a7861bc465a1f1e72095c9d71954b281d23c5c4;hb=refs%2Ftags%2Faccepted%2Ftizen%2Funified%2F20171010.063815;hp=1e20461307379e0b21626151d44e70134f34606e;hpb=e50d2e0691efe9f522307a612d4fef468d8ff840;p=platform%2Fupstream%2Fiotivity.git diff --git a/android/android_api/base/jni/JniCaInterface.c b/android/android_api/base/jni/JniCaInterface.c index 1e20461..2a7861b 100644 --- a/android/android_api/base/jni/JniCaInterface.c +++ b/android/android_api/base/jni/JniCaInterface.c @@ -247,12 +247,6 @@ Java_org_iotivity_ca_CaInterface_caManagerTerminate(JNIEnv *env, jclass clazz) (*env)->DeleteGlobalRef(env, g_jni_cls_enum); g_jni_cls_enum = NULL; } - - if (g_jni_mid_enum) - { - (*env)->DeleteGlobalRef(env, g_jni_mid_enum); - g_jni_mid_enum = NULL; - } } JNIEXPORT void JNICALL @@ -261,6 +255,11 @@ Java_org_iotivity_ca_CaInterface_caManagerSetAutoConnectionDeviceInfo(JNIEnv *en jstring jaddress) { LOGI("CaManager_setAutoConnectionDeviceInfo"); + if (!jaddress) + { + LOGE("jaddress is null"); + return; + } const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL); if (!address) @@ -280,6 +279,11 @@ Java_org_iotivity_ca_CaInterface_caManagerUnsetAutoConnectionDeviceInfo(JNIEnv * jstring jaddress) { LOGI("CaManager_unsetAutoConnectionDeviceInfo"); + if (!jaddress) + { + LOGE("jaddress is null"); + return; + } const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL); if (!address) @@ -352,3 +356,84 @@ Java_org_iotivity_ca_CaInterface_setLeScanIntervalTimeImpl(JNIEnv *env, jclass c CAUtilSetLEScanInterval(intervalTime, workignCount); } +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_stopLeScanImpl(JNIEnv *env, jclass clazz) +{ + LOGI("stopLeScan"); + (void)env; + (void)clazz; + CAUtilStopLEScan(); +} + +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_startLeAdvertisingImpl(JNIEnv *env, jclass clazz) +{ + LOGI("startLeAdvertising"); + (void)env; + (void)clazz; + CAUtilStartLEAdvertising(); +} + +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_stopLeAdvertisingImpl(JNIEnv *env, jclass clazz) +{ + LOGI("stopLeAdvertising"); + (void)env; + (void)clazz; + CAUtilStopLEAdvertising(); +} + +JNIEXPORT void JNICALL +Java_org_iotivity_ca_CaInterface_setBTConfigureImpl(JNIEnv *env, jclass clazz, jint flag) +{ + LOGI("setConfigureImpl"); + (void)env; + (void)clazz; + CAUtilConfig_t configs = {(CATransportBTFlags_t)flag}; + CAUtilSetBTConfigure(configs); +} + +JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl + (JNIEnv *env, jclass clazz, jint cipherSuite, jint adapter) +{ + LOGI("setCipherSuiteImpl"); + (void)env; + (void)clazz; + CAResult_t ret = CASelectCipherSuite(cipherSuite, (CATransportAdapter_t) adapter); + if (CA_STATUS_OK != ret) + { + LOGE("CASelectCipherSuite has failed"); + } + return ret; +} + +JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_disconnectTCPSessionImpl + (JNIEnv *env, jclass clazz, jstring address, jint port, jint transportFlags) +{ + LOGI("disconnectTCPSessionImpl"); + (void)env; + (void)clazz; + + if(!address) + { + LOGE("Java address is null"); + return CA_STATUS_INVALID_PARAM; + } + + //convert java string to native string + const char* nativeAddress = (*env)->GetStringUTFChars(env, address, NULL); + if (!nativeAddress) + { + LOGE("Native address is null"); + return CA_STATUS_INVALID_PARAM; + } + + CAResult_t result = CAUtilTCPDisconnectSession(nativeAddress, (int)port, + (CATransportFlags_t)transportFlags); + if (CA_STATUS_OK != result) + { + LOGE("disconnectTCPSessionImpl failed"); + } + return result; +} +