summaryrefslogtreecommitdiff
path: root/sal/android
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@suse.com>2012-01-25 16:41:45 +0200
committerTor Lillqvist <tlillqvist@suse.com>2012-01-25 19:39:06 +0200
commit25f78344e8dea95cedb0b981f08865d676154e5b (patch)
treec47a47c65587669ee0cfa5c4efbe0c79cb94e762 /sal/android
parentc4e35496393c73e73a297e8c5398cb6f96a35e46 (diff)
Bin global_android_app and instead use lo-bootstrap API
Instead of introducing a global variable, use the already existing saved android_app pointer in lo-bootstrap.c, and just add a function to retrieve it from there. Store it in the AndroidSalInstance. Reanme osl/detail/android.h back to android_native_app_glue.h, which is the name of that file in NDK/sources. "android.h" sounded to me too grand, as if it was some universal Android header. But if we do start to modify the android_native_app_glue stuff heavily, then it indeed makes sense to call it something else. Until then, revert also some whitespace changes to android_native_app_glue.c for it to be as close as possible to the "upstream" one in the NDK, for clarity.
Diffstat (limited to 'sal/android')
-rw-r--r--sal/android/android_native_app_glue.c15
-rw-r--r--sal/android/lo-bootstrap.c7
2 files changed, 10 insertions, 12 deletions
diff --git a/sal/android/android_native_app_glue.c b/sal/android/android_native_app_glue.c
index efd7a4b8c38e..cf5d8e8575fd 100644
--- a/sal/android/android_native_app_glue.c
+++ b/sal/android/android_native_app_glue.c
@@ -22,7 +22,7 @@
#include <unistd.h>
#include <sys/resource.h>
-#include "osl/detail/android.h"
+#include "osl/detail/android_native_app_glue.h"
#include <android/log.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__))
@@ -236,14 +236,9 @@ static void* android_app_entry(void* param) {
// --------------------------------------------------------------------
static struct android_app* android_app_create(ANativeActivity* activity,
- void* savedState, size_t savedStateSize)
-{
+ void* savedState, size_t savedStateSize) {
struct android_app* android_app = (struct android_app*)malloc(sizeof(struct android_app));
memset(android_app, 0, sizeof(struct android_app));
-
- // get this across to VCL.
- global_android_app = android_app;
-
android_app->activity = activity;
pthread_mutex_init(&android_app->mutex, NULL);
@@ -419,13 +414,9 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue)
android_app_set_input((struct android_app*)activity->instance, NULL);
}
-__attribute__ ((visibility("default"))) struct android_app *global_android_app = NULL;
-
__attribute__ ((visibility("default"))) void ANativeActivity_onCreate(ANativeActivity* activity,
- void* savedState, size_t savedStateSize)
-{
+ void* savedState, size_t savedStateSize) {
LOGI("Creating: %p\n", activity);
-
activity->callbacks->onDestroy = onDestroy;
activity->callbacks->onStart = onStart;
activity->callbacks->onResume = onResume;
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index bd9049432081..3cb8d3a25300 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -1470,6 +1470,13 @@ lo_get_javavm(void)
}
__attribute__ ((visibility("default")))
+struct android_app *
+lo_get_app(void)
+{
+ return app;
+}
+
+__attribute__ ((visibility("default")))
void
android_main(struct android_app* state)
{