Commit 8fa6f63e5d7c6054d8d45ca8b37525567872ae54

Authored by Cheng-Shiun Tsai
Committed by Adeel Kazmi
1 parent 9b6fc4d8

Add ERROR message in the case of serious error

output an error message through logcat
regardless release/debug build
also exit with an non-zero exit code
so that it won't fall into infinite loop

Change-Id: Ib078a7c26a0bfc855f284f3103878e0b94ea1dfa
build/android/app/src/main/cpp/main.cpp
@@ -29,8 +29,11 @@ @@ -29,8 +29,11 @@
29 #include <dlfcn.h> 29 #include <dlfcn.h>
30 30
31 // from android_native_app_glue.c 31 // from android_native_app_glue.c
  32 +
  33 +#define TAG "dalidemo"
  34 +#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, TAG, ##__VA_ARGS__))
32 #ifndef NDEBUG 35 #ifndef NDEBUG
33 -#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "dalidemo", __VA_ARGS__)) 36 +#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, TAG, ##__VA_ARGS__))
34 #else 37 #else
35 #define LOGV(...) ((void)0) 38 #define LOGV(...) ((void)0)
36 #endif 39 #endif
@@ -153,6 +156,7 @@ void android_main(struct android_app* state) @@ -153,6 +156,7 @@ void android_main(struct android_app* state)
153 LOGV("android_main() >>"); 156 LOGV("android_main() >>");
154 157
155 std::string filesDir = state->activity->internalDataPath; 158 std::string filesDir = state->activity->internalDataPath;
  159 + LOGV("filesDir=%s", filesDir.c_str() );
156 160
157 std::string fontconfigPath = filesDir + "/fonts"; 161 std::string fontconfigPath = filesDir + "/fonts";
158 setenv("FONTCONFIG_PATH", fontconfigPath.c_str(), 1); 162 setenv("FONTCONFIG_PATH", fontconfigPath.c_str(), 1);
@@ -198,6 +202,9 @@ void android_main(struct android_app* state) @@ -198,6 +202,9 @@ void android_main(struct android_app* state)
198 void* handle = dlopen(libpath.c_str(), RTLD_LAZY); 202 void* handle = dlopen(libpath.c_str(), RTLD_LAZY);
199 if(!handle) 203 if(!handle)
200 { 204 {
  205 + int err = errno;
  206 + LOGE("Err=%d Fail to open lib %s", err, libpath.c_str());
  207 + status = err;
201 std::exit(status); 208 std::exit(status);
202 } 209 }
203 210