From 8de5edde9599b6ca00c23e753c00676d7bc9b335 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 16:03:52 +0100 Subject: ANDROID: Protect port files with our define get rid of -DANDROID and -DANDROID_BACKEND --- backends/platform/android/android.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/platform/android/android.cpp') diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index efcee488a5..6502f94408 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -23,14 +23,14 @@ * */ +#if defined(__ANDROID__) + #include "backends/base-backend.h" #include "base/main.h" #include "graphics/surface.h" #include "backends/platform/android/video.h" -#if defined(ANDROID_BACKEND) - #include #include -- cgit v1.2.3 From bf237c8d2c270014a95c40b7567db80ed787a67a Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 6 Feb 2011 19:37:17 +0100 Subject: ANDROID: Unify log prefix adb logcat ScummVM:\* \*:S --- backends/platform/android/android.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'backends/platform/android/android.cpp') diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 6502f94408..d3b7697e7a 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -1276,17 +1276,15 @@ void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s, void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) { switch (type) { case LogMessageType::kDebug: - BaseBackend::logMessage(type, message); + __android_log_write(ANDROID_LOG_DEBUG, LOG_TAG, message); break; case LogMessageType::kWarning: - __android_log_write(ANDROID_LOG_WARN, "ScummVM", message); + __android_log_write(ANDROID_LOG_WARN, LOG_TAG, message); break; case LogMessageType::kError: - // FIXME: From the name it looks like this will also quit the program. - // This shouldn't do that though. - __android_log_assert("Fatal error", "ScummVM", "%s", message); + __android_log_write(ANDROID_LOG_ERROR, LOG_TAG, message); break; } } -- cgit v1.2.3 From ea2cfc44c0ce91267aa87173cfd02eb1c69d3147 Mon Sep 17 00:00:00 2001 From: dhewg Date: Mon, 14 Feb 2011 17:51:58 +0100 Subject: ANDROID: Fix assert() to log output add bionic replacement __assert2(), so we actually see what's happening --- backends/platform/android/android.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'backends/platform/android/android.cpp') diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index d3b7697e7a..b59fc76a59 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -73,12 +73,20 @@ #undef JNIEXPORT #define JNIEXPORT __attribute__ ((visibility("default"))) -// This replaces the bionic libc assert message with something that +// This replaces the bionic libc assert functions with something that // actually prints the assertion failure before aborting. -extern "C" -void __assert(const char *file, int line, const char *expr) { - __android_log_assert(expr, LOG_TAG, "%s:%d: Assertion failure: %s", - file, line, expr); +extern "C" { + void __assert(const char *file, int line, const char *expr) { + __android_log_assert(expr, LOG_TAG, + "Assertion failure: '%s' in %s:%d", + expr, file, line); + } + + void __assert2(const char *file, int line, const char *func, const char *expr) { + __android_log_assert(expr, LOG_TAG, + "Assertion failure: '%s' in %s:%d (%s)", + expr, file, line, func); + } } static JavaVM *cached_jvm; -- cgit v1.2.3 From 2586e15e4ea6a365eced1888759630907b6b5870 Mon Sep 17 00:00:00 2001 From: dhewg Date: Mon, 14 Feb 2011 18:48:33 +0100 Subject: ANDROID: Fix JNI calls for the timer thread JNI calls can happen through the timer mechanism (hence from another thread). Attach the timer thread to the VM to prevent assert()s --- backends/platform/android/android.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'backends/platform/android/android.cpp') diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index b59fc76a59..07fb1d5d98 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -102,10 +102,14 @@ static jfieldID FID_ScummVM_nativeScummVM; static jmethodID MID_Object_wait; JNIEnv* JNU_GetEnv() { - JNIEnv* env; - bool version_unsupported = - cached_jvm->GetEnv((void**)&env, JNI_VERSION_1_2); - assert(! version_unsupported); + JNIEnv* env = 0; + + jint res = cached_jvm->GetEnv((void**)&env, JNI_VERSION_1_2); + if (res != JNI_OK) { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "GetEnv() failed: %d", res); + abort(); + } + return env; } @@ -453,6 +457,14 @@ void* OSystem_Android::timerThreadFunc(void* arg) { OSystem_Android* system = (OSystem_Android*)arg; DefaultTimerManager* timer = (DefaultTimerManager*)(system->_timer); + JNIEnv *env = 0; + jint res = cached_jvm->AttachCurrentThread(&env, 0); + + if (res != JNI_OK) { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "AttachCurrentThread() failed: %d", res); + abort(); + } + struct timespec tv; tv.tv_sec = 0; tv.tv_nsec = 100 * 1000 * 1000; // 100ms @@ -462,6 +474,13 @@ void* OSystem_Android::timerThreadFunc(void* arg) { nanosleep(&tv, NULL); } + res = cached_jvm->DetachCurrentThread(); + + if (res != JNI_OK) { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "DetachCurrentThread() failed: %d", res); + abort(); + } + return NULL; } -- cgit v1.2.3