summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@suse.com>2012-04-02 12:38:23 +0300
committerTor Lillqvist <tlillqvist@suse.com>2012-04-02 12:39:52 +0300
commita9a50cd9ffcd53c631fd13d20aa7e0609d92fc4d (patch)
tree810d3fb6564d46fa573785d6c6b8efc9ed321941
parent2906a654d0c59adae71f4c0fb1c72adb3d5477a0 (diff)
Refactor where patch_libgnustl_shared() and extract_files() are called
-rw-r--r--android/Bootstrap/src/org/libreoffice/android/Bootstrap.java15
-rw-r--r--android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java3
-rw-r--r--sal/android/lo-bootstrap.c19
3 files changed, 28 insertions, 9 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
index c60c9e975a64..443b770f90d5 100644
--- a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
+++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
@@ -38,6 +38,7 @@ import android.util.Log;
import fi.iki.tml.CommandLine;
import java.io.File;
+import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;
@@ -73,7 +74,10 @@ public class Bootstrap extends NativeActivity
// To be called after you are sure libgnustl_shared.so
// has been loaded
- public static native void patch_libgnustl_shared();
+ static native void patch_libgnustl_shared();
+
+ // Extracts files in the .apk that need to be extraced into the app's tree
+ static native void extract_files();
// Wrapper for getpid()
public static native int getpid();
@@ -97,6 +101,8 @@ public class Bootstrap extends NativeActivity
// (contentbroker.cxx), also this called indirectly through the lo-bootstrap library
public static native void initUCBHelper();
+ // This setup() method is called 1) in apps that use *this* class as their activity from onCreate(),
+ // and 2) should be called from other kinds of LO code using apps.
public static void setup(Activity activity)
{
String dataDir = null;
@@ -114,6 +120,13 @@ public class Bootstrap extends NativeActivity
if (!setup(dataDir, activity.getApplication().getPackageResourcePath(), llpa))
return;
+ // We build LO code against the shared GNU C++ library
+ dlopen("libgnustl_shared.so");
+ // and need to patch it.
+ patch_libgnustl_shared();
+
+ // Extract files from the .apk that can't be used mmapped directly from it
+ extract_files();
}
@Override
diff --git a/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
index d47a6ef5edee..93ed87e26cfd 100644
--- a/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -52,9 +52,6 @@ public class DocumentLoader
Bootstrap.putenv("SAL_LOG=yes");
- Bootstrap.dlopen("libgnustl_shared.so");
- Bootstrap.patch_libgnustl_shared();
-
// Load a lot of shlibs here explicitly in advance because that
// makes debugging work better, sigh
Bootstrap.dlopen("libvcllo.so");
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index a216e0d1419c..75a389809014 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -1518,7 +1518,7 @@ extract_files(const char *prefix)
lo_apk_closedir(tree);
}
-// public static native void patch_libgnustl_shared();
+// static native void patch_libgnustl_shared();
__attribute__ ((visibility("default")))
void
@@ -1531,6 +1531,19 @@ Java_org_libreoffice_android_Bootstrap_patch_1libgnustl_1shared(JNIEnv* env,
patch_libgnustl_shared();
}
+// static native void extract_files();
+
+__attribute__ ((visibility("default")))
+void
+Java_org_libreoffice_android_Bootstrap_extract_1files(JNIEnv* env,
+ jobject clazz)
+{
+ (void) env;
+ (void) clazz;
+
+ extract_files(UNPACK_TREE);
+}
+
/* Android's JNI works only to libraries loaded through Java's
* System.loadLibrary(), it seems. Not to functions loaded by a dlopen() call
* in native code. For instance, to call a function in libvcllo.so, we need to
@@ -1666,10 +1679,6 @@ android_main(struct android_app* state)
lo_main_argv[0] = lo_main_info.dli_fname;
}
- patch_libgnustl_shared();
-
- extract_files(UNPACK_TREE);
-
lo_main(lo_main_argc, lo_main_argv);
fprintf (stderr, "exit android_main\n");
}