Refactor where patch_libgnustl_shared() and extract_files() are called

This commit is contained in:
Tor Lillqvist 2012-04-02 12:38:23 +03:00
parent 2906a654d0
commit a9a50cd9ff
3 changed files with 28 additions and 9 deletions

View file

@ -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

View file

@ -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");

View file

@ -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");
}