[IOT-1089] Change Android build system to accomodate both Android and Generic Java...
[contrib/iotivity.git] / java / jni / JniOcStack.h
similarity index 93%
rename from android/android_api/base/jni/JniOcStack.h
rename to java/jni/JniOcStack.h
index 79ede36..66bd234 100644 (file)
@@ -20,7 +20,7 @@
 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 */
 #include <jni.h>
-#include <android/log.h>
+#include "logger.h"
 #include "OCApi.h"
 
 #ifndef _Included_org_iotivity_base_ocstack
@@ -30,9 +30,9 @@
 
 #define JNI_CURRENT_VERSION JNI_VERSION_1_6
 
-#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
-#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
+#define LOGI(...) OIC_LOG_V(INFO, TAG, __VA_ARGS__)
+#define LOGD(...) OIC_LOG_V(DEBUG, TAG, __VA_ARGS__)
+#define LOGE(...) OIC_LOG_V(ERROR, TAG, __VA_ARGS__)
 
 #define JNI_EXCEPTION 1000
 #define JNI_NO_NATIVE_POINTER 1001
@@ -156,7 +156,11 @@ static JNIEnv* GetJNIEnv(jint& ret)
     case JNI_OK:
         return env;
     case JNI_EDETACHED:
+// AttachCurrentThread API changed in JNI 1.7 which is not a defined version
+#pragma GCC diagnostic push
+#pragma GCC diagnostic warning "-fpermissive"
         if (g_jvm->AttachCurrentThread(&env, nullptr) < 0)
+#pragma GCC diagnostic push
         {
             LOGE("Failed to get the environment");
             return nullptr;
@@ -180,4 +184,4 @@ static void DuplicateString(char ** targetString, std::string sourceString)
     strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
 }
 
-#endif // _Included_org_iotivity_base_ocstack
\ No newline at end of file
+#endif // _Included_org_iotivity_base_ocstack