From f175c1a191e3dcb149a53eba31235f840abed61d Mon Sep 17 00:00:00 2001 From: Randeep Singh Date: Thu, 29 Sep 2016 14:06:44 +0530 Subject: [PATCH] Andorid(JNI) Implementation for Cloud Provisioning. Patch #1: Add JNI interface for getAclByDeviceID API. Patch #2: Fixes. Change-Id: I0e8b09f9f1be66d202834e56f3d535604f6a766b Signed-off-by: Sandeep Sharma Signed-off-by: Randeep Singh Reviewed-on: https://gerrit.iotivity.org/gerrit/11507 Tested-by: jenkins-iotivity Reviewed-by: Ashwini Kumar (cherry picked from commit 05969521d6bab5c3c5e148b418872d21ac4d8282) Reviewed-on: https://gerrit.iotivity.org/gerrit/12557 --- android/android_api/base/jni/Android.mk | 19 +- .../base/jni/JniGetAclIdByDeviceListener.cpp | 128 +++++ .../base/jni/JniGetAclIdByDeviceListener.h | 46 ++ .../base/jni/JniOcCloudProvisioning.cpp | 561 +++++++++++++++++++++ .../android_api/base/jni/JniOcCloudProvisioning.h | 110 ++++ .../base/jni/JniOcCloudResultListener.cpp | 155 ++++++ .../base/jni/JniOcCloudResultListener.h | 52 ++ android/android_api/base/jni/JniOcStack.cpp | 23 + android/android_api/base/jni/JniOcStack.h | 7 + .../org/iotivity/base/OcCloudProvisioning.java | 9 +- resource/include/OCCloudProvisioning.h | 1 - resource/provisioning/src/OCCloudProvisioning.cpp | 11 +- 12 files changed, 1104 insertions(+), 18 deletions(-) create mode 100644 android/android_api/base/jni/JniGetAclIdByDeviceListener.cpp create mode 100644 android/android_api/base/jni/JniGetAclIdByDeviceListener.h create mode 100644 android/android_api/base/jni/JniOcCloudProvisioning.cpp create mode 100644 android/android_api/base/jni/JniOcCloudProvisioning.h create mode 100644 android/android_api/base/jni/JniOcCloudResultListener.cpp create mode 100644 android/android_api/base/jni/JniOcCloudResultListener.h diff --git a/android/android_api/base/jni/Android.mk b/android/android_api/base/jni/Android.mk index 7039ac3..182513d 100644 --- a/android/android_api/base/jni/Android.mk +++ b/android/android_api/base/jni/Android.mk @@ -47,9 +47,6 @@ include $(PREBUILT_SHARED_LIBRARY) endif include $(CLEAR_VARS) -ifeq ($(SECURE), 1) - LOCAL_CFLAGS += -D__WITH_DTLS__ -endif OIC_SRC_PATH := ../../../resource LOCAL_MODULE := libca-interface LOCAL_SRC_FILES := JniCaInterface.c @@ -69,14 +66,9 @@ ifeq ($(WITH_CLOUD), 1) endif ifeq ($(WITH_TCP), 1) - LOCAL_CPPFLAGS += -DWITH_TCP LOCAL_CPPFLAGS += -D__WITH_TLS__ endif -ifeq ($(SECURED), 1) - LOCAL_CPPFLAGS += -D__WITH_DTLS__ -endif - MQ_FLAG = 0 ifeq ($(WITH_MQ_PUB), 1) LOCAL_CFLAGS += -DWITH_MQ -DMQ_PUBLISHER @@ -137,6 +129,13 @@ ifeq ($(WITH_CLOUD), 1) LOCAL_SRC_FILES += JniOcAccountManager.cpp endif +ifeq ($(WITH_TCP), 1) + LOCAL_SRC_FILES += JniOcCloudProvisioning.cpp \ + JniOcCloudResultListener.cpp \ + JniGetAclIdByDeviceListener.cpp +endif + + LOCAL_LDLIBS := -llog LOCAL_STATIC_LIBRARIES := android-oc LOCAL_STATIC_LIBRARIES += android-octbstack @@ -165,9 +164,9 @@ LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/boost/boost_1_58_0 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/cjson LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../build_common/android/compatibility LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/cloud -LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/oxm +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/oxm/ LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/internal +LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/cloud/ LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/include LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/include/internal LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/api diff --git a/android/android_api/base/jni/JniGetAclIdByDeviceListener.cpp b/android/android_api/base/jni/JniGetAclIdByDeviceListener.cpp new file mode 100644 index 0000000..c13682f --- /dev/null +++ b/android/android_api/base/jni/JniGetAclIdByDeviceListener.cpp @@ -0,0 +1,128 @@ +/* +* //****************************************************************** +* // +* // Copyright 2016 Samsung Electronics All Rights Reserved. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // Licensed under the Apache License, Version 2.0 (the "License"); +* // you may not use this file except in compliance with the License. +* // You may obtain a copy of the License at +* // +* // http://www.apache.org/licenses/LICENSE-2.0 +* // +* // Unless required by applicable law or agreed to in writing, software +* // distributed under the License is distributed on an "AS IS" BASIS, +* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* // See the License for the specific language governing permissions and +* // limitations under the License. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ +#include "JniGetAclIdByDeviceListener.h" + +JniGetAclIdByDeviceListener::JniGetAclIdByDeviceListener(JNIEnv *env, jobject jListener, + RemoveCallback removeListener) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); + m_removeGetAclbyIDListener = removeListener; +} + +JniGetAclIdByDeviceListener::~JniGetAclIdByDeviceListener() +{ + LOGI("~JniGetAclIdByDeviceListener()"); + if (m_jwListener) + { + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (nullptr == env) + { + return; + } + env->DeleteWeakGlobalRef(m_jwListener); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + } +} + +void JniGetAclIdByDeviceListener::GetAclIdByDeviceListenerCB(int result, std::string aclID) +{ + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (nullptr == env) + { + return; + } + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + + jclass clsL = env->GetObjectClass(jListener); + + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + + jmethodID midL = env->GetMethodID(clsL, "getAclIdByDeviceListener", "(ZLjava/lang/String;)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + jstring jStr = env-> NewStringUTF(aclID.c_str()); + if (!jStr) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + + } + env->CallVoidMethod(jListener, midL, (jboolean)result, jStr); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + } + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } +} + +void JniGetAclIdByDeviceListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_removeGetAclbyIDListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_removeGetAclbyIDListener(env, m_jwListener); + } +} diff --git a/android/android_api/base/jni/JniGetAclIdByDeviceListener.h b/android/android_api/base/jni/JniGetAclIdByDeviceListener.h new file mode 100644 index 0000000..8ad5b11 --- /dev/null +++ b/android/android_api/base/jni/JniGetAclIdByDeviceListener.h @@ -0,0 +1,46 @@ +/* +* //****************************************************************** +* // +* // Copyright 2016 Samsung Electronics All Rights Reserved. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // Licensed under the Apache License, Version 2.0 (the "License"); +* // you may not use this file except in compliance with the License. +* // You may obtain a copy of the License at +* // +* // http://www.apache.org/licenses/LICENSE-2.0 +* // +* // Unless required by applicable law or agreed to in writing, software +* // distributed under the License is distributed on an "AS IS" BASIS, +* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* // See the License for the specific language governing permissions and +* // limitations under the License. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ + +#include +#include "JniOcStack.h" + +/* Header for class org_iotivity_base_OcCloudProvisioning_GetAclIdByDeviceListener */ +#ifndef _Included_org_iotivity_base_OcCloudProvisioning_JniGetAclIdByDeviceListener +#define _Included_org_iotivity_base_OcCloudProvisioning_JniGetAclIdByDeviceListener + +typedef std::function RemoveCallback; + +class JniGetAclIdByDeviceListener +{ + public: + JniGetAclIdByDeviceListener(JNIEnv *env, jobject jListener, + RemoveCallback removeListener); + ~JniGetAclIdByDeviceListener(); + + void GetAclIdByDeviceListenerCB(int result, std::string aclID); + + private: + RemoveCallback m_removeGetAclbyIDListener; + jweak m_jwListener; + void checkExAndRemoveListener(JNIEnv* env); +}; +#endif diff --git a/android/android_api/base/jni/JniOcCloudProvisioning.cpp b/android/android_api/base/jni/JniOcCloudProvisioning.cpp new file mode 100644 index 0000000..72f94de --- /dev/null +++ b/android/android_api/base/jni/JniOcCloudProvisioning.cpp @@ -0,0 +1,561 @@ +/* +* //****************************************************************** +* // +* // Copyright 2016 Samsung Electronics All Rights Reserved. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // Licensed under the Apache License, Version 2.0 (the "License"); +* // you may not use this file except in compliance with the License. +* // You may obtain a copy of the License at +* // +* // http://www.apache.org/licenses/LICENSE-2.0 +* // +* // Unless required by applicable law or agreed to in writing, software +* // distributed under the License is distributed on an "AS IS" BASIS, +* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* // See the License for the specific language governing permissions and +* // limitations under the License. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ + +#include "JniOcCloudProvisioning.h" +#include "oic_malloc.h" + +namespace PH = std::placeholders; + +JniOcCloudProvisioning::JniOcCloudProvisioning(std::shared_ptr p) + : m_sharedCloudObject(p) +{} + +JniOcCloudProvisioning::~JniOcCloudProvisioning() +{ + LOGD("~JniOcCloudProvisioning"); + m_sharedCloudObject = nullptr; +} + +JniOcCloudResultListener* JniOcCloudProvisioning::AddCloudResultListener(JNIEnv* env, + jobject jListener) +{ + JniOcCloudResultListener *resultListener = NULL; + resultMapLock.lock(); + + for (auto it = resultMap.begin(); it != resultMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + resultListener = refPair.first; + refPair.second++; + it->second = refPair; + resultMap.insert(*it); + LOGD("Cloud Provision resultListener: ref. count incremented"); + break; + } + } + if (!resultListener) + { + resultListener = new JniOcCloudResultListener(env, jListener, + RemoveCallback(std::bind(&JniOcCloudProvisioning::RemoveCloudResultListener, + this, PH::_1, PH::_2))); + jobject jgListener = env->NewGlobalRef(jListener); + + resultMap.insert(std::pair < jobject, std::pair < JniOcCloudResultListener*, + int >> (jgListener, std::pair(resultListener, 1))); + LOGD("Cloud Provision resultListener: new listener"); + } + resultMapLock.unlock(); + return resultListener; +} + +void JniOcCloudProvisioning::RemoveCloudResultListener(JNIEnv* env, jobject jListener) +{ + resultMapLock.lock(); + + for (auto it = resultMap.begin(); it != resultMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + if (refPair.second > 1) + { + refPair.second--; + it->second = refPair; + resultMap.insert(*it); + LOGI("Cloud Provision resultListener: ref. count decremented"); + } + else + { + env->DeleteGlobalRef(it->first); + JniOcCloudResultListener* listener = refPair.first; + delete listener; + resultMap.erase(it); + LOGI("Cloud Provision resultListener removed"); + } + break; + } + } + resultMapLock.unlock(); +} + +JniGetAclIdByDeviceListener* JniOcCloudProvisioning::AddGetAclByDeviceListener(JNIEnv* env, + jobject jListener) +{ + JniGetAclIdByDeviceListener *resultListener = NULL; + aclresultMapLock.lock(); + + for (auto it = aclresultMap.begin(); it != aclresultMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + resultListener = refPair.first; + refPair.second++; + it->second = refPair; + aclresultMap.insert(*it); + LOGD("GetACLByDeviceID Listener: ref. count incremented"); + break; + } + } + if (!resultListener) + { + resultListener = new JniGetAclIdByDeviceListener(env, jListener, + RemoveCallback(std::bind(&JniOcCloudProvisioning::RemoveGetAclByDeviceIdListener, + this, PH::_1, PH::_2))); + jobject jgListener = env->NewGlobalRef(jListener); + + aclresultMap.insert(std::pair < jobject, std::pair < JniGetAclIdByDeviceListener*, + int >> (jgListener, std::pair(resultListener, 1))); + LOGD("GetACLByDeviceID Listener: new listener"); + } + aclresultMapLock.unlock(); + return resultListener; +} + +void JniOcCloudProvisioning::RemoveGetAclByDeviceIdListener(JNIEnv* env, jobject jListener) +{ + aclresultMapLock.lock(); + + for (auto it = aclresultMap.begin(); it != aclresultMap.end(); ++it) + { + if (env->IsSameObject(jListener, it->first)) + { + auto refPair = it->second; + if (refPair.second > 1) + { + refPair.second--; + it->second = refPair; + aclresultMap.insert(*it); + LOGI("GetACLByDeviceID Listener: ref. count decremented"); + } + else + { + env->DeleteGlobalRef(it->first); + JniGetAclIdByDeviceListener* listener = refPair.first; + delete listener; + aclresultMap.erase(it); + LOGI("GetACLByDeviceID Listener removed"); + } + break; + } + } + aclresultMapLock.unlock(); +} +JniOcCloudProvisioning * Create_native_object(JNIEnv *env, jobject thiz) +{ + jstring jip = (jstring)env->CallObjectMethod(thiz, g_mid_OcCloudProvisioning_getIP); + if (!jip || env->ExceptionCheck()) + { + return nullptr; + } + const char *str = env->GetStringUTFChars(jip, NULL); + std::string ipaddress(str); + env->ReleaseStringUTFChars(jip, str); + + jint port = env->CallIntMethod(thiz, g_mid_OcCloudProvisioning_getPort); + if (env->ExceptionCheck()) + { + return nullptr; + } + JniOcCloudProvisioning *cloud = new JniOcCloudProvisioning( + std::shared_ptr(new OCCloudProvisioning(ipaddress, (uint16_t)port))); + SetHandle(env, thiz, cloud); + return cloud; +} + +JniOcCloudProvisioning* JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(JNIEnv *env, jobject thiz) +{ + JniOcCloudProvisioning *cloud = GetHandle(env, thiz); + + if (env->ExceptionCheck()) + { + LOGE("Failed to get native handle from OcCloudProvisioning class"); + } + + return cloud; +} + +OCStackResult JniOcCloudProvisioning::requestCertificate(JNIEnv* env, jobject jListener) +{ + JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener); + + ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data) + { + resultListener->CloudResultListenerCB(result, data, ListenerFunc::REQUEST_CERTIFICATE); + }; + + return m_sharedCloudObject->requestCertificate(responseCallBack); +} + +OCStackResult JniOcCloudProvisioning::getIndividualAclInfo(JNIEnv* env, jobject jListener, std::string &aclID) +{ + JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener); + + ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data) + { + resultListener->CloudResultListenerCB(result, data, ListenerFunc::GET_ACLINFO); + }; + + return m_sharedCloudObject->getIndividualAclInfo(aclID, responseCallBack); +} + +OCStackResult JniOcCloudProvisioning::getCRL(JNIEnv* env, jobject jListener) +{ + JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener); + + ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data) + { + resultListener->CloudResultListenerCB(result, data, ListenerFunc::GET_CRL); + }; + + return m_sharedCloudObject->getCRL(responseCallBack); +} + +OCStackResult JniOcCloudProvisioning::postCRL(JNIEnv* env, const std::string& thisUpdate, + const std::string& nextUpdate, const OCByteString *crl, + const stringArray_t *serialNumbers, jobject jListener) +{ + JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener); + + ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data) + { + resultListener->CloudResultListenerCB(result, data, ListenerFunc::POST_CRL); + }; + + return m_sharedCloudObject->postCRL(thisUpdate, nextUpdate, crl, serialNumbers, + responseCallBack); +} + +OCStackResult JniOcCloudProvisioning::getAclIdByDevice(JNIEnv* env, std::string deviceId, + jobject jListener) +{ + JniGetAclIdByDeviceListener *resultListener = AddGetAclByDeviceListener(env, jListener); + + AclIdResponseCallBack aclIdResponseCallBack = [resultListener](OCStackResult result, + std::string aclId) + { + resultListener->GetAclIdByDeviceListenerCB(result, aclId); + }; + + return m_sharedCloudObject->getAclIdByDevice(deviceId, aclIdResponseCallBack); +} +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: requestCertificate + * Signature: (Lorg/iotivity/base/OcCloudProvisioning/RequestCertificateListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_requestCertificate + (JNIEnv* env, jobject thiz, jobject jListener) +{ + LOGD("OcCloudProvisioning_requestCertificate"); + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null"); + return; + } + + JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz); + if (!cloud) + { + LOGD("OcCloudProvisioning_requestCertificate, No native object, creating now"); + cloud = Create_native_object(env, thiz); + if (!cloud) + { + ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_requestCertificate," + "Can not Create Native object"); + return; + } + } + + try + { + OCStackResult result = cloud->requestCertificate(env, jListener); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcCloudProvisioning_requestCertificate"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } + return; +} + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: getAclIdByDevice + * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetAclIdByDeviceListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getAclIdByDevice + (JNIEnv *env, jobject thiz, jstring jdeviceId, jobject jListener) +{ + LOGD("OcCloudProvisioning_getAclIdByDevice"); + if (!jListener || !jdeviceId) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "Listener and deviceID cannot be null"); + return; + } + + JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz); + if (!cloud) + { + LOGD("OcCloudProvisioning_getAclIdByDevice, No native object, creating now"); + cloud = Create_native_object(env, thiz); + if (!cloud) + { + ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_getAclIdByDevice," + "Can not Create Native object"); + return; + } + } + + const char *str = env->GetStringUTFChars(jdeviceId, NULL); + if (!str || env->ExceptionCheck()) + { + ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_getAclIdByDevice"); + return; + } + std::string deviceId(str); + env->ReleaseStringUTFChars(jdeviceId, str); + + try + { + OCStackResult result = cloud->getAclIdByDevice(env, deviceId, jListener); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcCloudProvisioning_getAclIdByDevice"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } + return; +} + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: getIndividualAclInfo + * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetIndividualAclInfoListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getIndividualAclInfo + (JNIEnv *env, jobject thiz, jstring jaclID, jobject jListener) +{ + LOGD("OcCloudProvisioning_getIndividualAclInfo"); + if (!jListener || !jaclID) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "Listener/aclID cannot be null"); + return; + } + + JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz); + if (!cloud) + { + LOGD("OcCloudProvisioning_getIndividualAclInfo, No native object, creating now"); + cloud = Create_native_object(env, thiz); + if (!cloud) + { + ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_getIndividualAclInfo," + "Can not Create Native object"); + return; + } + } + + const char *str = env->GetStringUTFChars(jaclID, NULL); + std::string aclID(str); + env->ReleaseStringUTFChars(jaclID, str); + + try + { + OCStackResult result = cloud->getIndividualAclInfo(env, jListener, aclID); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcCloudProvisioning_getIndividualAclInf"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } + return; +} + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: getCRL + * Signature: (Lorg/iotivity/base/OcCloudProvisioning/GetCRLListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getCRL + (JNIEnv *env, jobject thiz, jobject jListener) +{ + LOGD("OcCloudProvisioning_getCRL"); + if (!jListener) + { + ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null"); + return; + } + + JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz); + if (!cloud) + { + LOGD("OcCloudProvisioning_getCRL, No native object, creating now"); + cloud = Create_native_object(env, thiz); + if (!cloud) + { + ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_getCRL," + "Can not Create Native object"); + return; + } + } + + try + { + OCStackResult result = cloud->getCRL(env, jListener); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcCloudProvisioning_requestCertificate"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } + return; +} + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: postCRL0 + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/ArrayList;Lorg/iotivity/base/OcCloudProvisioning/PostCRLListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_postCRL0 + (JNIEnv *env , jobject thiz, jstring jthisUpdate, jstring jnextUpdate, jstring jcrl, + jobjectArray jserialnumArray, jobject jListener) +{ + LOGD("OcCloudProvisioning_postCRL0"); + if (!jListener || !jthisUpdate || !jnextUpdate || !jserialnumArray) + { + ThrowOcException(OC_STACK_INVALID_PARAM, " Invalid parameter (NULL param)"); + return; + } + + JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz); + if (!cloud) + { + LOGD("OcCloudProvisioning_getCRL, No native object, creating now"); + cloud = Create_native_object(env, thiz); + if (!cloud) + { + ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_PostCRL0," + "Can not Create Native object"); + return; + } + } + + const char *str = env->GetStringUTFChars(jthisUpdate, NULL); + if (!str || env->ExceptionCheck()) + { + ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0"); + return; + } + std::string thisUpdate(str); + env->ReleaseStringUTFChars(jthisUpdate, str); + + str = env->GetStringUTFChars(jnextUpdate, NULL); + if (!str || env->ExceptionCheck()) + { + ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0"); + return; + } + std::string nextUpdate(str); + env->ReleaseStringUTFChars(jnextUpdate, str); + + OCByteString *crl = NULL; + if (jcrl) + { + str = env->GetStringUTFChars(jcrl, NULL); + if (!str || env->ExceptionCheck()) + { + ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0"); + return; + } + crl = (OCByteString*)OICCalloc(1, sizeof(OCByteString)); + crl->len = (size_t)(strlen(str)); + crl->bytes = (uint8_t*)OICCalloc(crl->len, sizeof(uint8_t)); + + for (size_t i = 0 ; i < crl->len; i++) + { + crl->bytes[i] = (uint8_t)str[i]; + } + } + + jsize len = env->GetArrayLength(jserialnumArray); + + stringArray_t *serialNumArray = (stringArray_t*)OICCalloc(1, sizeof(stringArray_t)); + serialNumArray->array = (char**)OICCalloc(len, sizeof(char*)); + serialNumArray->length = len; + + for (jsize i = 0; i < len; ++i) + { + jstring jStr = (jstring)env->GetObjectArrayElement(jserialnumArray, i); + if (!jStr) + { + ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0"); + return; + } + serialNumArray->array[i] = (char*)env->GetStringUTFChars(jStr, nullptr); + if (env->ExceptionCheck()) + { + ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0"); + return; + } + env->DeleteLocalRef(jStr); + } + + try + { + OCStackResult result = cloud->postCRL(env, thisUpdate, nextUpdate, crl, + serialNumArray, jListener); + if (OC_STACK_OK != result) + { + ThrowOcException(result, "OcCloudProvisioning_PostCRL0"); + return; + } + } + catch (OCException& e) + { + LOGE("%s", e.reason().c_str()); + ThrowOcException(e.code(), e.reason().c_str()); + } + return; +} diff --git a/android/android_api/base/jni/JniOcCloudProvisioning.h b/android/android_api/base/jni/JniOcCloudProvisioning.h new file mode 100644 index 0000000..58693c7 --- /dev/null +++ b/android/android_api/base/jni/JniOcCloudProvisioning.h @@ -0,0 +1,110 @@ +/* +* //****************************************************************** +* // +* // Copyright 2016 Samsung Electronics All Rights Reserved. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // Licensed under the Apache License, Version 2.0 (the "License"); +* // you may not use this file except in compliance with the License. +* // You may obtain a copy of the License at +* // +* // http://www.apache.org/licenses/LICENSE-2.0 +* // +* // Unless required by applicable law or agreed to in writing, software +* // distributed under the License is distributed on an "AS IS" BASIS, +* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* // See the License for the specific language governing permissions and +* // limitations under the License. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ + +#include "JniOcStack.h" +#include "OCCloudProvisioning.h" +#include "JniOcCloudResultListener.h" +#include "JniGetAclIdByDeviceListener.h" +#include + + +using namespace OC; + +#ifndef _Included_org_iotivity_base_OcCloudProvisioning +#define _Included_org_iotivity_base_OcCloudProvisioning +class JniOcCloudProvisioning +{ + public: + JniOcCloudProvisioning(std::shared_ptr cloudObject); + ~JniOcCloudProvisioning(); + + static JniOcCloudProvisioning* getJniOcCloudProvisioningPtr(JNIEnv *env, jobject thiz); + JniOcCloudResultListener* AddCloudResultListener(JNIEnv* env, jobject jListener); + JniGetAclIdByDeviceListener* AddGetAclByDeviceListener(JNIEnv* env, jobject jListener); + void RemoveCloudResultListener(JNIEnv* env, jobject jListener); + void RemoveGetAclByDeviceIdListener(JNIEnv*, jobject); + + OCStackResult requestCertificate(JNIEnv* env, jobject jListener); + OCStackResult getAclIdByDevice(JNIEnv*, std::string, jobject); + OCStackResult getIndividualAclInfo(JNIEnv*, jobject, std::string &); + OCStackResult getCRL(JNIEnv* env, jobject jListener); + OCStackResult postCRL(JNIEnv* env, const std::string& thisUpdate, + const std::string& nextUpdate, const OCByteString *crl, + const stringArray_t *serialNumbers, jobject jListener); + + private: + std::map> resultMap; + std::map> aclresultMap; + std::mutex resultMapLock; + std::mutex aclresultMapLock; + std::shared_ptrm_sharedCloudObject; +}; + + +/* DO NOT EDIT THIS FILE - it is machine generated */ +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: requestCertificate + * Signature: (Lorg/iotivity/base/OcCloudProvisioning/RequestCertificateListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_requestCertificate + (JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: getAclIdByDevice + * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetAclIdByDeviceListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getAclIdByDevice + (JNIEnv *, jobject, jstring, jobject); + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: getIndividualAclInfo + * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetIndividualAclInfoListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getIndividualAclInfo + (JNIEnv *, jobject, jstring, jobject); + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: getCRL + * Signature: (Lorg/iotivity/base/OcCloudProvisioning/GetCRLListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getCRL + (JNIEnv *, jobject, jobject); + +/* + * Class: org_iotivity_base_OcCloudProvisioning + * Method: postCRL0 + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/ArrayList;Lorg/iotivity/base/OcCloudProvisioning/PostCRLListener;)V + */ +JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_postCRL0 + (JNIEnv *, jobject, jstring, jstring, jstring, jobjectArray, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/android/android_api/base/jni/JniOcCloudResultListener.cpp b/android/android_api/base/jni/JniOcCloudResultListener.cpp new file mode 100644 index 0000000..9894fa2 --- /dev/null +++ b/android/android_api/base/jni/JniOcCloudResultListener.cpp @@ -0,0 +1,155 @@ +/* +* //****************************************************************** +* // +* // Copyright 2016 Samsung Electronics All Rights Reserved. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // Licensed under the Apache License, Version 2.0 (the "License"); +* // you may not use this file except in compliance with the License. +* // You may obtain a copy of the License at +* // +* // http://www.apache.org/licenses/LICENSE-2.0 +* // +* // Unless required by applicable law or agreed to in writing, software +* // distributed under the License is distributed on an "AS IS" BASIS, +* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* // See the License for the specific language governing permissions and +* // limitations under the License. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ +#include "JniOcCloudResultListener.h" + +JniOcCloudResultListener::JniOcCloudResultListener(JNIEnv *env, jobject jListener, + RemoveCallback removeCloudResultListener) +{ + m_jwListener = env->NewWeakGlobalRef(jListener); + m_removeCloudResultListener = removeCloudResultListener; +} + +JniOcCloudResultListener::~JniOcCloudResultListener() +{ + LOGI("~JniOcCloudResultListener()"); + if (m_jwListener) + { + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (nullptr == env) + { + return; + } + env->DeleteWeakGlobalRef(m_jwListener); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + } +} + +void JniOcCloudResultListener::CloudResultListenerCB(int result, void *data, + ListenerFunc func) +{ + jint ret = JNI_ERR; + JNIEnv *env = GetJNIEnv(ret); + if (nullptr == env) + { + return; + } + + jobject jListener = env->NewLocalRef(m_jwListener); + if (!jListener) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + + jclass clsL = env->GetObjectClass(jListener); + + if (!clsL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + + std::string calledFunc; + switch (func) + { + case ListenerFunc::REQUEST_CERTIFICATE: + { + calledFunc = "requestCertificateListener"; + } + break; + case ListenerFunc::GET_ACLINFO: + { + calledFunc = "getIndividualAclInfoListener"; + } + break; + case ListenerFunc::GET_CRL: + { + calledFunc = "getCRLListener"; + } + break; + case ListenerFunc::POST_CRL: + { + calledFunc = "postCRLListener"; + } + break; + default: + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + return; + } + + jmethodID midL = env->GetMethodID(clsL, calledFunc.c_str(), "(Z)V"); + if (!midL) + { + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } + return; + } + + env->CallVoidMethod(jListener, midL, (jboolean)result); + if (env->ExceptionCheck()) + { + LOGE("Java exception is thrown"); + } + + checkExAndRemoveListener(env); + if (JNI_EDETACHED == ret) + { + g_jvm->DetachCurrentThread(); + } +} + +void JniOcCloudResultListener::checkExAndRemoveListener(JNIEnv* env) +{ + if (env->ExceptionCheck()) + { + jthrowable ex = env->ExceptionOccurred(); + env->ExceptionClear(); + m_removeCloudResultListener(env, m_jwListener); + env->Throw((jthrowable)ex); + } + else + { + m_removeCloudResultListener(env, m_jwListener); + } +} diff --git a/android/android_api/base/jni/JniOcCloudResultListener.h b/android/android_api/base/jni/JniOcCloudResultListener.h new file mode 100644 index 0000000..3cb826a --- /dev/null +++ b/android/android_api/base/jni/JniOcCloudResultListener.h @@ -0,0 +1,52 @@ +/* +* //****************************************************************** +* // +* // Copyright 2015 Samsung Electronics All Rights Reserved. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +* // +* // Licensed under the Apache License, Version 2.0 (the "License"); +* // you may not use this file except in compliance with the License. +* // You may obtain a copy of the License at +* // +* // http://www.apache.org/licenses/LICENSE-2.0 +* // +* // Unless required by applicable law or agreed to in writing, software +* // distributed under the License is distributed on an "AS IS" BASIS, +* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* // See the License for the specific language governing permissions and +* // limitations under the License. +* // +* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +*/ +#include +#include "JniOcStack.h" + +#ifndef _Included_org_iotivity_base_OcCloudProvisioning_JniOcCloudResultListener +#define _Included_org_iotivity_base_OcCloudProvisioning_JniOcCloudResultListener + +typedef std::function RemoveCallback; + +enum class ListenerFunc +{ + REQUEST_CERTIFICATE = 1, + GET_ACLINFO, + GET_CRL, + POST_CRL +}; + +class JniOcCloudResultListener +{ + public: + JniOcCloudResultListener(JNIEnv *env, jobject jListener, + RemoveCallback removeCloudResultListener); + ~JniOcCloudResultListener(); + + void CloudResultListenerCB(int result, void *data, ListenerFunc func); + + private: + RemoveCallback m_removeCloudResultListener; + jweak m_jwListener; + void checkExAndRemoveListener(JNIEnv* env); +}; +#endif diff --git a/android/android_api/base/jni/JniOcStack.cpp b/android/android_api/base/jni/JniOcStack.cpp index 06de766..c140551 100644 --- a/android/android_api/base/jni/JniOcStack.cpp +++ b/android/android_api/base/jni/JniOcStack.cpp @@ -79,6 +79,9 @@ jclass g_cls_OcOicSecAcl_resr = nullptr; jclass g_cls_OcOicSecAcl_validity = nullptr; jclass g_cls_OcOicSecPdAcl = nullptr; jclass g_cls_OcDirectPairDevice = nullptr; +#ifdef __WITH_TLS__ +jclass g_cls_OcCloudProvisioning = nullptr; +#endif #ifdef WITH_CLOUD jclass g_cls_OcAccountManager = nullptr; #endif @@ -144,6 +147,11 @@ jmethodID g_mid_OcOicSecAcl_validity_get_recurrenceLen = nullptr; jmethodID g_mid_OcOicSecAcl_resr_get_interfaceLen = nullptr; jmethodID g_mid_OcOicSecAcl_get_rownerID = nullptr; +#ifdef __WITH_TLS__ +jmethodID g_mid_OcCloudProvisioning_getIP = nullptr; +jmethodID g_mid_OcCloudProvisioning_getPort = nullptr; +#endif + jobject getOcException(JNIEnv* env, const char* file, const char* functionName, const int line, const int code, const char* message) { @@ -586,7 +594,19 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) g_mid_OcOicSecPdAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecPdAcl, "getRecurrences", "(I)Ljava/lang/String;"); VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_recurrences); +#ifdef __WITH_TLS__ + //OcCloudProvisioning + clazz = env->FindClass("org/iotivity/base/OcCloudProvisioning"); + VERIFY_VARIABLE_NULL(clazz); + g_cls_OcCloudProvisioning = (jclass)env->NewGlobalRef(clazz); + env->DeleteLocalRef(clazz); + g_mid_OcCloudProvisioning_getIP = env->GetMethodID(g_cls_OcCloudProvisioning, "getIP", "()Ljava/lang/String;"); + VERIFY_VARIABLE_NULL(g_mid_OcCloudProvisioning_getIP); + + g_mid_OcCloudProvisioning_getPort = env->GetMethodID(g_cls_OcCloudProvisioning, "getPort", "()I"); + VERIFY_VARIABLE_NULL(g_mid_OcCloudProvisioning_getPort); +#endif return JNI_CURRENT_VERSION; } @@ -641,6 +661,9 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) #ifdef WITH_CLOUD env->DeleteGlobalRef(g_cls_OcAccountManager); #endif +#ifdef WITH_CLOUD + env->DeleteGlobalRef(g_cls_OcCloudProvisioning); +#endif env->DeleteGlobalRef(g_cls_OcOicSecAcl); env->DeleteGlobalRef(g_cls_OcOicSecAcl_ace); env->DeleteGlobalRef(g_cls_OcOicSecAcl_resr); diff --git a/android/android_api/base/jni/JniOcStack.h b/android/android_api/base/jni/JniOcStack.h index 600f0ab..51f856e 100644 --- a/android/android_api/base/jni/JniOcStack.h +++ b/android/android_api/base/jni/JniOcStack.h @@ -88,6 +88,9 @@ extern jclass g_cls_OcDirectPairDevice; #ifdef WITH_CLOUD extern jclass g_cls_OcAccountManager; #endif +#ifdef __WITH_TLS__ +extern jclass g_cls_OcCloudProvisioning; +#endif extern jclass g_cls_OcOicSecAcl_ace; extern jclass g_cls_OcOicSecAcl_resr; @@ -129,6 +132,10 @@ extern jmethodID g_mid_OcDirectPairDevice_dev_ctor; #ifdef WITH_CLOUD extern jmethodID g_mid_OcAccountManager_ctor; #endif +#ifdef __WITH_TLS__ +extern jmethodID g_mid_OcCloudProvisioning_getIP; +extern jmethodID g_mid_OcCloudProvisioning_getPort; +#endif extern jmethodID g_mid_OcOicSecAcl_get_rownerID; extern jmethodID g_mid_OcOicSecAcl_get_aces; diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcCloudProvisioning.java b/android/android_api/base/src/main/java/org/iotivity/base/OcCloudProvisioning.java index 9b73305..31a071c 100755 --- a/android/android_api/base/src/main/java/org/iotivity/base/OcCloudProvisioning.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcCloudProvisioning.java @@ -125,7 +125,14 @@ public class OcCloudProvisioning { * @param cloudPostCRLHandler function called by the stack on completion of request. * @throws OcException */ - public native void postCRL0(String thisUpdate, String nextUpdate, String crl, ArrayList serialNumbers, + public void postCRL(String thisUpdate, String nextUpdate, String crl, ArrayList serialNumbers, + PostCRLListener cloudPostCRLHandler) throws OcException + { + String[] serialNums = new String[serialNumbers.size()]; + serialNums = serialNumbers.toArray(serialNums); + this.postCRL0(thisUpdate, nextUpdate, crl, serialNums, cloudPostCRLHandler); + } + public native void postCRL0(String thisUpdate, String nextUpdate, String crl, String[] serialNumbers, PostCRLListener cloudPostCRLHandler) throws OcException; } diff --git a/resource/include/OCCloudProvisioning.h b/resource/include/OCCloudProvisioning.h index dbb9998..deb5250 100755 --- a/resource/include/OCCloudProvisioning.h +++ b/resource/include/OCCloudProvisioning.h @@ -53,7 +53,6 @@ namespace OC private: OCDevAddr m_devAddr; - std::weak_ptr m_csdkLock; public: /** diff --git a/resource/provisioning/src/OCCloudProvisioning.cpp b/resource/provisioning/src/OCCloudProvisioning.cpp index 1c422b9..2e6d4a8 100644 --- a/resource/provisioning/src/OCCloudProvisioning.cpp +++ b/resource/provisioning/src/OCCloudProvisioning.cpp @@ -57,7 +57,6 @@ namespace OC memset(&m_devAddr, 0, sizeof(m_devAddr)); memcpy(m_devAddr.addr, ipAddr.c_str(), MAX_ADDR_STR_SIZE); m_devAddr.port = port; - m_csdkLock = OCPlatform_impl::Instance().csdkLock(); } OCCloudProvisioning::~OCCloudProvisioning(void) @@ -73,7 +72,7 @@ namespace OC } OCStackResult result; - auto cLock = m_csdkLock.lock(); + auto cLock = OCPlatform_impl::Instance().csdkLock().lock(); if (cLock) { @@ -101,7 +100,7 @@ namespace OC } OCStackResult result; - auto cLock = m_csdkLock.lock(); + auto cLock = OCPlatform_impl::Instance().csdkLock().lock(); if (cLock) { @@ -130,7 +129,7 @@ namespace OC } OCStackResult result; - auto cLock = m_csdkLock.lock(); + auto cLock = OCPlatform_impl::Instance().csdkLock().lock(); if (cLock) { @@ -158,7 +157,7 @@ namespace OC } OCStackResult result; - auto cLock = m_csdkLock.lock(); + auto cLock = OCPlatform_impl::Instance().csdkLock().lock(); if (cLock) { @@ -189,7 +188,7 @@ namespace OC } OCStackResult result; - auto cLock = m_csdkLock.lock(); + auto cLock = OCPlatform_impl::Instance().csdkLock().lock(); if (cLock) { -- 2.7.4