replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / android / android_api / base / jni / JniOcResource.cpp
index a90446a..9d30ba2 100644 (file)
@@ -297,7 +297,9 @@ OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType,
 
 OCStackResult JniOcResource::cancelObserve(JNIEnv* env, QualityOfService qos)
 {
-    if (QualityOfService::HighQos != qos)
+    // In Low case, after delete the callback and send empty message when client receive the notify.
+    // But TCP does not support EMPTY message.
+    if ((CT_ADAPTER_IP & connectivityType()) && QualityOfService::HighQos != qos)
     {
         this->m_onObserveManager.removeAllListeners(env);
     }
@@ -354,6 +356,11 @@ std::string JniOcResource::sid() const
     return m_sharedResource->sid();
 }
 
+std::string JniOcResource::deviceName() const
+{
+    return m_sharedResource->deviceName();
+}
+
 JniOnGetListener* JniOcResource::addOnGetListener(JNIEnv* env, jobject jListener)
 {
     return this->m_onGetManager.addListener(env, jListener, this);
@@ -1703,6 +1710,24 @@ JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId
 
 /*
 * Class:     org_iotivity_base_OcResource
+* Method:    getDeviceName
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getDeviceName
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getDeviceName");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource)
+    {
+        return nullptr;
+    }
+
+    return env->NewStringUTF(resource->deviceName().c_str());
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
 * Method:    dispose
 * Signature: ()V
 */