Check for error messages and code formatting for resource container Android extension
authorMarkus Jung <markus.jung@samsung.com>
Thu, 14 Jan 2016 01:40:38 +0000 (10:40 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 15 Jan 2016 04:54:46 +0000 (04:54 +0000)
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Change-Id: I7209209155b85b39d0c87b01da284c56d4d0c47d
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4801
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-container/android/resource-container/src/main/jni/JniRcsResourceContainer.cpp
service/resource-container/android/resource-container/src/main/jni/JniRcsResourceContainer.h

index cf84553..09ef002 100644 (file)
@@ -25,6 +25,7 @@
 #include "JNIEnvWrapper.h"
 #include "Log.h"
 #include "Verify.h"
+#include <dlfcn.h>
 
 #include "ResourceContainerBundleAPI.h"
 #include "JniBundleResource.h"
@@ -116,6 +117,15 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStartCont
 {
     LOGD("nativeStartContainer");
 
+    // A strange error message happens if the container is used as native library on Android
+    // and further native libraries are loaded at runtime.
+    const char *error;
+    if ((error = dlerror()) != NULL)
+    {
+        __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer",
+                "dlerror: %s.", error);
+    }
+
     EXPECT(configFileObj, "ConfigFile is null.");
 
     auto configFile = toStdString(env, configFileObj);
@@ -126,11 +136,19 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStartCont
 }
 
 JNIEXPORT void JNICALL
-Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStopContainer
-(JNIEnv *env, jobject)
+Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStopContainer(JNIEnv *env, jobject)
 {
     LOGD("nativeStopContainers");
 
+    // A strange error message happens if the container is used as native library on Android
+    // and further native libraries are loaded at runtime.
+    const char *error;
+    if ((error = dlerror()) != NULL)
+    {
+        __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer",
+                "dlerror: %s.", error);
+    }
+
     RCSResourceContainer::getInstance()->stopContainer();
 }
 
@@ -141,6 +159,15 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeAddBundle
 {
     LOGD("nativeAddBundle");
 
+    // A strange error message happens if the container is used as native library on Android
+    // and further native libraries are loaded at runtime.
+    const char *error;
+    if ((error = dlerror()) != NULL)
+    {
+        __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer",
+                "dlerror: %s.", error);
+    }
+
     EXPECT(idObj, "BundleId is null.");
     EXPECT(pathObj, "BundlePath is null.");
     EXPECT(activatorObj, "Activator is null.");
@@ -169,6 +196,15 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeRemoveBun
 {
     LOGD("nativeRemoveBundle");
 
+    // A strange error message happens if the container is used as native library on Android
+    // and further native libraries are loaded at runtime.
+    const char *error;
+    if ((error = dlerror()) != NULL)
+    {
+        __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer",
+                "dlerror: %s.", error);
+    }
+
     EXPECT(idObj, "BundleId is null.");
 
     auto id = toStdString(env, idObj);
@@ -184,6 +220,15 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeListBundl
 {
     LOGD("nativeListBundles");
 
+    // A strange error message happens if the container is used as native library on Android
+    // and further native libraries are loaded at runtime.
+    const char *error;
+    if ((error = dlerror()) != NULL)
+    {
+        __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer",
+                "dlerror: %s.", error);
+    }
+
     JNIEnvWrapper envWrapper(env);
 
     try
@@ -208,7 +253,16 @@ JNIEXPORT void JNICALL
 Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStartBundle
 (JNIEnv *env, jobject, jstring idObj)
 {
-    LOGD("nativeStartBundle2");
+    LOGD("nativeStartBundle");
+
+    // A strange error message happens if the container is used as native library on Android
+    // and further native libraries are loaded at runtime.
+    const char *error;
+    if ((error = dlerror()) != NULL)
+    {
+        __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer",
+                "dlerror: %s.", error);
+    }
 
     EXPECT(idObj, "BundleId is null.");
 
@@ -224,6 +278,15 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStopBundl
 {
     LOGD("nativeStopBundle");
 
+    // A strange error message happens if the container is used as native library on Android
+    // and further native libraries are loaded at runtime.
+    const char *error;
+    if ((error = dlerror()) != NULL)
+    {
+        __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer",
+                "dlerror: %s.", error);
+    }
+
     EXPECT(idObj, "BundleId is null.");
 
     auto id = env->GetStringUTFChars(idObj, NULL);
@@ -314,11 +377,14 @@ Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeRegisterB
     JNIEnvWrapper envWrapper(env);
     LOGD("nativeRegisterJniBundleResource");
     auto str_bundle_id = toStdString(&envWrapper, bundleId);
-    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved bundle id: %s.", str_bundle_id.c_str());
+    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved bundle id: %s.",
+            str_bundle_id.c_str());
     auto str_uri = toStdString(&envWrapper, uri);
-    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved uri: %s.", str_uri.c_str());
+    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved uri: %s.",
+            str_uri.c_str());
     auto str_resourceType = toStdString(&envWrapper, resourceType);
-    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved resource type: %s.", str_resourceType.c_str());
+    __android_log_print(ANDROID_LOG_DEBUG, "JNI-RCSResourceContainer", "retrieved resource type: %s.",
+            str_resourceType.c_str());
     auto str_res_name = toStdString(&envWrapper, res_name);
     LOGD("retrieved res name.");
     JniBundleResource res;
index 825d276..db2fc07 100644 (file)
@@ -40,7 +40,7 @@ extern "C" {
 
 JNIEXPORT void JNICALL
 Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStartContainer
-(JNIEnv *, jobject, jstring configFile);
+(JNIEnv *, jobject, jstring);
 
 JNIEXPORT void JNICALL
 Java_org_iotivity_service_resourcecontainer_RcsResourceContainer_nativeStopContainer