summaryrefslogtreecommitdiff
path: root/sal/android
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@suse.com>2012-04-02 11:05:54 +0300
committerTor Lillqvist <tlillqvist@suse.com>2012-04-02 12:39:52 +0300
commitd975f4aab223680260140383f5c16dd31f9cc71d (patch)
tree684909d2d02003c26039775d8067695db3980de2 /sal/android
parentc4f2c60c088f579471714955f5969b60447fbf64 (diff)
Add a JNI_OnLoad() to store the JavaVM* also from non-NativeActivity apps
Diffstat (limited to 'sal/android')
-rw-r--r--sal/android/lo-bootstrap.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index a79b9dd00099..a216e0d1419c 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -71,16 +71,22 @@ struct engine {
int dummy;
};
+/* These vars are valid / used only when this library is used from
+ * NativeActivity-based apps.
+ */
static struct android_app *app;
-static const char *data_dir;
-static const char **library_locations;
-static void *apk_file;
-static int apk_file_size;
static int (*lo_main)(int, const char **);
static int lo_main_argc;
static const char **lo_main_argv;
static int sleep_time = 0;
+/* These are valid / used in all apps. */
+static const char *data_dir;
+static const char **library_locations;
+static void *apk_file;
+static int apk_file_size;
+static JavaVM *the_java_vm;
+
/* Zip data structures */
/* compression methods */
@@ -323,6 +329,20 @@ free_ptrarray(void **pa)
free(pa);
}
+/* The lo-bootstrap shared library is always loaded from Java, so
+ * this is always called by JNI first.
+ */
+__attribute__ ((visibility("default")))
+jint
+JNI_OnLoad(JavaVM* vm, void* reserved)
+{
+ (void) reserved;
+
+ the_java_vm = vm;
+
+ return JNI_VERSION_1_2;
+}
+
__attribute__ ((visibility("default")))
jobjectArray
Java_org_libreoffice_android_Bootstrap_dlneeds(JNIEnv* env,
@@ -1602,7 +1622,7 @@ __attribute__ ((visibility("default")))
JavaVM *
lo_get_javavm(void)
{
- return app->activity->vm;
+ return the_java_vm;
}
__attribute__ ((visibility("default")))