[Libreoffice-commits] .: 6 commits - android/Bootstrap android/experiments configure.in sal/android sal/osl vcl/source

Tor Lillqvist tml at kemper.freedesktop.org
Thu Mar 22 13:55:32 PDT 2012


 android/Bootstrap/src/org/libreoffice/android/Bootstrap.java                                |   20 -
 android/experiments/DocumentLoader/AndroidManifest.xml                                      |    2 
 android/experiments/DocumentLoader/Makefile                                                 |  180 +++++++---
 android/experiments/DocumentLoader/jni/Android.mk                                           |    8 
 android/experiments/DocumentLoader/jni/Application.mk                                       |    3 
 android/experiments/DocumentLoader/local.properties.in                                      |    2 
 android/experiments/DocumentLoader/project.properties                                       |    3 
 android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java |   45 +-
 configure.in                                                                                |    7 
 sal/android/lo-bootstrap.c                                                                  |  130 +++++--
 sal/osl/unx/process_impl.cxx                                                                |    3 
 vcl/source/app/svmain.cxx                                                                   |   22 +
 12 files changed, 331 insertions(+), 94 deletions(-)

New commits:
commit 3e425dfa4b9c2a0198a13b2fb18364a32603080f
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Thu Mar 22 22:49:16 2012 +0200

    More Android hacking

diff --git a/android/experiments/DocumentLoader/Makefile b/android/experiments/DocumentLoader/Makefile
index 5612fbf..0c31954 100644
--- a/android/experiments/DocumentLoader/Makefile
+++ b/android/experiments/DocumentLoader/Makefile
@@ -3,6 +3,19 @@ include ../../../config_host.mk
 # The package of this app
 APP_PACKAGE=org.libreoffice.android.examples
 
+# We can't keep assuming APP_DATA_PATH like this, surely this can vary with
+# Android versions and whatnot, this is temporary and works at least with the
+# SDK 16 emulator...
+
+# Probably would be best to just stop fooling around with the possibilities to
+# set various stuff with the -env command line parameters (and environment
+# variables?) and in a plethora of rc files, and hardcode construction of
+# *all* required pathnames based on the app installation location for Android
+# (and iOS), etc. We don't really win anything by having so many layers of
+# configurability on platforms like Android and iOS where apps based on LO
+# code are very much self-contained pre-packaged thingies.
+APP_DATA_PATH=/data/data/$(APP_PACKAGE)
+
 SODEST=libs/armeabi-v7a
 OBJLOCAL=obj/local/armeabi-v7a
 
@@ -31,32 +44,65 @@ copy-stuff:
 # them.
 #
 	for F in $(strip \
+		   analysislo \
+		   basebmplo \
+		   basegfxlo \
+		   bootstrap.uno \
 		   comphelpgcc3 \
+		   datelo \
+		   expwrap.uno \
+		   fastsax.uno \
+		   fileacc \
+		   fontconfig \
+		   forlo \
+		   foruilo \
+		   freetype \
+		   frmlo \
 		   gcc3_uno \
 		   i18nisolang1gcc3 \
+		   i18npaperlo \
+		   i18npool.uno \
 		   i18nutilgcc3 \
 		   icudatalo \
 		   icui18nlo \
+		   iculelo \
 		   icuuclo \
+		   introspection.uno \
 		   java_uno \
 		   juh \
 		   juhx \
 		   jvmaccessgcc3 \
+		   jvmfwk \
 		   lo-bootstrap \
 		   localedata_en \
 		   localedata_others \
 		   mergedlo \
+		   msfilterlo \
+		   ooxlo \
+		   reflection.uno \
 		   reg \
+		   saxlo \
+		   sclo \
+		   scfiltlo \
+		   sotlo \
+		   stocservices.uno \
 		   store \
+		   svllo \
+		   textinstream.uno \
+		   tllo \
 		   ucbhelper4gcc3 \
 		   uno_cppu \
+		   uno_cppuhelpergcc3 \
 		   uno_sal \
 		   uno_salhelpergcc3 \
 		   uno_cppuhelpergcc3 \
+		   unoxmllo \
+		   utllo \
+		   vbahelperlo \
+		   vcllo \
 		   xml2 \
 		   xmlreader \
-		   bootstrap.uno \
-		   i18npool.uno \
+		   xstor \
 		  ); do \
 	    $(call COPYSO,$(OUTDIR)/lib/lib$${F}.so); \
 	done
@@ -66,14 +112,58 @@ copy-stuff:
 #
 # Then other "assets". Let the directory structure under assets mimic
 # that under solver for now.
-	mkdir -p assets/bin assets/lib assets/xml/ure assets/ComponentTarget/i18npool/util
+	mkdir -p assets/bin/ure assets/lib assets/program assets/xml/ure assets/ComponentTarget/i18npool/util
 	cp $(OUTDIR)/bin/udkapi.rdb assets/bin
 	cp $(OUTDIR)/bin/types.rdb assets/bin
-	cp $(OUTDIR)/bin/uno.ini assets
-	cp $(OUTDIR)/xml/ure/services.rdb assets/xml/ure
+	cp $(OUTDIR)/bin/ure/types.rdb assets/bin/ure
+# For some reason the vnd.sun.star.expand:$LO_LIB_DIR doesn't seem to work, it expands to empty!?
+# So just hardcode the known APP_DATA_PATH for now...
+	for F in xml/services xml/ure/services; do \
+		sed -e 's!uri="vnd.sun.star.expand:$$LO_LIB_DIR/!uri="file://$(APP_DATA_PATH)/lib/!g' <$(OUTDIR)/$$F.rdb >assets/$$F.rdb; \
+	done
 	cp $(SRC_ROOT)/odk/examples/java/DocumentHandling/test/test1.odt assets
 	cp $(WORKDIR)/ComponentTarget/i18npool/util/i18npool.component assets/ComponentTarget/i18npool/util
 #
+# Set up lofficerc, the "inifile" (see soffice_main())
+	echo '[Bootstrap]' > assets/program/lofficerc
+	echo 'Logo=1' >> assets/program/lofficerc
+	echo 'NativeProgress=1' >> assets/program/lofficerc
+	echo 'URE_BOOTSTRAP=file:///assets/program/fundamentalrc' >> assets/program/lofficerc
+#	echo 'RTL_LOGFILE=file:///dev/log/main' >> assets/program/lofficerc
+	echo "HOME=$(APP_DATA_PATH)/files" >> assets/program/lofficerc
+	echo "OSL_SOCKET_PATH=$(APP_DATA_PATH)/files" >> assets/program/lofficerc
+#
+# Set up fundamentalrc
+	echo '[Bootstrap]' > assets/program/fundamentalrc
+	echo "LO_LIB_DIR=file:$(APP_DATA_PATH)/lib/" >> assets/program/fundamentalrc
+	echo "URE_LIB_DIR=file://$(APP_DATA_PATH)/lib/" >> assets/program/fundamentalrc # checkme - is this used to find configs ?
+	echo 'BRAND_BASE_DIR=file:///assets' >> assets/program/fundamentalrc
+	echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry module:$${BRAND_BASE_DIR}/share/registry/modules res:$${BRAND_BASE_DIR}/share/registry user:$${$$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/registrymodifications.xcu' >> assets/program/fundamentalrc
+	echo 'URE_BIN_DIR=file:///assets/ure/bin/dir/not-here/can-we/exec-anyway' >> assets/program/fundamentalrc
+	echo 'URE_MORE_TYPES=file:///assets/bin/ure/types.rdb file:///assets/bin/types.rdb' >> assets/program/fundamentalrc
+	echo 'URE_MORE_SERVICES=file:///assets/xml/ure/services.rdb file:///assets/xml/services.rdb <$$BRAND_BASE_DIR/program/services>*' >> assets/program/fundamentalrc
+# Set up unorc
+	echo '[Bootstrap]' > assets/program/unorc
+	echo "URE_INTERNAL_LIB_DIR=file://$(APP_DATA_PATH)/lib/" >> assets/program/unorc
+	echo 'UNO_TYPES=file:///assets/bin/ure/types.rdb file:///assets/bin/types.rdb $${URE_MORE_TYPES}' >> assets/program/unorc
+	echo 'UNO_SERVICES=file:///assets/xml/ure/services.rdb file:///assets/xml/services.rdb $${URE_MORE_SERVICES}' >> assets/program/unorc
+# Set up bootstraprc
+	echo '[Bootstrap]' > assets/program/bootstraprc
+	echo 'InstallMode=<installmode>' >> assets/program/bootstraprc
+	echo 'ProductKey=LibreOffice 3.6' >> assets/program/bootstraprc
+	echo "UserInstallation=file://$(APP_DATA_PATH)/files/.libreoffice" >> assets/program/bootstraprc
+
+# Set up versionrc
+	echo '[Version]' > assets/program/versionrc
+	echo 'AllLanguages=en-US' >> assets/program/versionrc
+	echo 'BuildVersion=' >> assets/program/versionrc
+	echo 'buildid=dead-beef' >> assets/program/versionrc
+	echo 'ProductBuildid=3' >> assets/program/versionrc
+	echo 'ProductMajor=360' >> assets/program/versionrc
+	echo 'ProductMinor=1' >> assets/program/versionrc
+	echo 'ProductSource=OOO350' >> assets/program/versionrc
+	echo 'ReferenceOOoMajorMinor=3.6' >> assets/program/versionrc
+#
 # Then gdbserver and gdb.setup so that we can debug with ndk-gdb.
 #
 	cp $(ANDROID_NDK_HOME)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver $(SODEST)
@@ -105,7 +195,7 @@ build-ant: copy-stuff
 #
 	unset JAVA_HOME && $(ANT) debug
 
-install: copy-stuff
+install: build-ant
 	unset JAVA_HOME && $(ANT) debug install
 	@echo
 	@echo 'Run it with something like what "make run" does (see Makefile)'
diff --git a/android/experiments/DocumentLoader/jni/Android.mk b/android/experiments/DocumentLoader/jni/Android.mk
new file mode 100644
index 0000000..939a1ea
--- /dev/null
+++ b/android/experiments/DocumentLoader/jni/Android.mk
@@ -0,0 +1,8 @@
+# Needed just to satisfy ndk-gdb for now, but maybe later we will actually add
+# some JNI code here
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/android/experiments/DocumentLoader/jni/Application.mk b/android/experiments/DocumentLoader/jni/Application.mk
new file mode 100644
index 0000000..f326d1a
--- /dev/null
+++ b/android/experiments/DocumentLoader/jni/Application.mk
@@ -0,0 +1,3 @@
+# File needed by ndk-gdb
+APP_ABI := armeabi-v7a
+APP_PLATFORM := android-14
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 819cf82..f1e6ed5 100644
--- a/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -50,30 +50,39 @@ public class DocumentLoader
 
             Bootstrap.setup(this);
 
-            Bootstrap.dlopen("libjuh.so");
-
-            // Load more shlibs here explicitly in advance because
-            // that makes debugging work better, sigh
-            Bootstrap.dlopen("libuno_cppu.so");
-            Bootstrap.dlopen("libuno_salhelpergcc3.so");
-            Bootstrap.dlopen("libuno_cppuhelpergcc3.so");
-            Bootstrap.dlopen("libbootstrap.uno.so");
-            Bootstrap.dlopen("libgcc3_uno.so");
-            Bootstrap.dlopen("libjava_uno.so");
+            // Load a lot of shlibs here explicitly in advance because that
+            // makes debugging work better, sigh
+            Bootstrap.dlopen("libvcllo.so");
             
-            Bootstrap.putenv("UNO_TYPES=file:///assets/bin/udkapi.rdb file:///assets/bin/types.rdb");
-            Bootstrap.putenv("UNO_SERVICES=file:///assets/xml/ure/services.rdb");
-            // Bootstrap.putenv("INIFILENAME=vnd.sun.star.pathname:/assets/uno.ini");
-
             com.sun.star.uno.XComponentContext xContext = null;
 
             xContext = com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext();
 
             Log.i(TAG, "xContext is" + (xContext!=null ? " not" : "") + " null");
 
+            Log.i(TAG, "Sleeping NOW");
+            Thread.sleep(20000);
+
             com.sun.star.lang.XMultiComponentFactory xMCF =
                 xContext.getServiceManager();
 
+            Log.i(TAG, "xMCF is" + (xMCF!=null ? " not" : "") + " null");
+
+            String input = getIntent().getStringExtra("input");
+            if (input == null)
+                input = "/assets/test1.odt";
+
+            // We need to fake up abn argv, and the argv[0] even needs to
+            // point to some file name that we can pretend is the "program".
+            // setCommandArgs() will prefix argv[0] with the app's data
+            // directory.
+
+            String[] argv = { "lo-document-loader", input };
+
+            Bootstrap.setCommandArgs(argv);
+
+            Bootstrap.initVCL();
+
             Object oDesktop = xMCF.createInstanceWithContext(
                 "com.sun.star.frame.Desktop", xContext);
 
@@ -86,12 +95,6 @@ public class DocumentLoader
 
             Log.i(TAG, "xCompLoader is" + (xCompLoader!=null ? " not" : "") + " null");
 
-            String input = getIntent().getStringExtra("input");
-            if (input == null)
-                input = "/assets/test1.odt";
-
-            String sUrl = "file://" + input;
-
             // Loading the wanted document
             com.sun.star.beans.PropertyValue propertyValues[] =
                 new com.sun.star.beans.PropertyValue[1];
@@ -99,6 +102,8 @@ public class DocumentLoader
             propertyValues[0].Name = "Hidden";
             propertyValues[0].Value = new Boolean(true);
 
+            String sUrl = "file://" + input;
+
             Object oDoc =
                 xCompLoader.loadComponentFromURL
                 (sUrl, "_blank", 0, propertyValues);
commit 581422994812c3ad0a4e8e3cd74cfac382f58b13
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Thu Mar 22 22:47:01 2012 +0200

    Add JNI wrappers for InitVCL and osl_setCommandArgs

diff --git a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
index 8fbcee9..e5f2f1e 100644
--- a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
+++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
@@ -51,6 +51,11 @@ public class Bootstrap extends NativeActivity
 {
     private static String TAG = "lo-bootstrap";
 
+    // Native methods in this class are all implemented in
+    // sal/android/lo-bootstrap.c as the lo-bootstrap library is loaded with
+    // System.loadLibrary() and Android's JNI works only to such libraries, it
+    // seems.
+
     private static native boolean setup(String dataDir,
                                         String apkFile,
                                         String[] ld_library_path);
@@ -79,6 +84,15 @@ public class Bootstrap extends NativeActivity
     // Wrapper for putenv()
     public static native void putenv(String string);
 
+    // A wrapper for InitVCL() in libvcl (svmain.cxx), called indirectly
+    // through the lo-bootstrap library
+    public static native void initVCL();
+
+    // A wrapper for osl_setCommandArgs(). Before calling
+    // osl_setCommandArgs(), argv[0] is prefixed with the parent directory of
+    // where the lo-bootstrap library is.
+    public static native void setCommandArgs(String[] argv);
+
     public static void setup(Activity activity)
     {
         String dataDir = null;
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index 96d6058..27f4e07 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -533,46 +533,60 @@ Java_org_libreoffice_android_Bootstrap_setup__Ljava_lang_String_2Ljava_lang_Stri
     return JNI_TRUE;
 }
 
-// public statuc native boolean setup(int lo_main_ptr,
-//                                    Object lo_main_argument,
-//                                    int lo_main_delay);
-
-__attribute__ ((visibility("default")))
-jboolean
-Java_org_libreoffice_android_Bootstrap_setup__ILjava_lang_Object_2I(JNIEnv* env,
-                                                                    jobject clazz,
-                                                                    void *lo_main_ptr,
-                                                                    jobject lo_main_argument,
-                                                                    jint lo_main_delay)
+static jboolean
+get_jni_string_array(JNIEnv *env,
+                     const char *function_and_parameter_name,
+                     jobject strv,
+                     int *argc,
+                     const char ***argv)
 {
     jclass StringArray;
     int i;
 
-    (void) clazz;
-
-    lo_main = lo_main_ptr;
-
     StringArray = (*env)->FindClass(env, "[Ljava/lang/String;");
     if (StringArray == NULL) {
         LOGE("Could not find String[] class");
         return JNI_FALSE;
     }
 
-    if (!(*env)->IsInstanceOf(env, lo_main_argument, StringArray)) {
-        LOGE("lo_main_argument is not a String[]?");
+    if (!(*env)->IsInstanceOf(env, strv, StringArray)) {
+        LOGE("%s is not a String[]?", function_and_parameter_name);
         return JNI_FALSE;
     }
 
-    lo_main_argc = (*env)->GetArrayLength(env, lo_main_argument);
-    lo_main_argv = malloc(sizeof(char *) * (lo_main_argc+1));
+    *argc = (*env)->GetArrayLength(env, strv);
+    *argv = malloc(sizeof(char *) * (*argc+1));
 
-    for (i = 0; i < lo_main_argc; i++) {
-        const char *s = (*env)->GetStringUTFChars(env, (*env)->GetObjectArrayElement(env, lo_main_argument, i), NULL);
-        lo_main_argv[i] = strdup(s);
-        (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, lo_main_argument, i), s);
+    for (i = 0; i < *argc; i++) {
+        const char *s = (*env)->GetStringUTFChars(env, (*env)->GetObjectArrayElement(env, strv, i), NULL);
+        (*argv)[i] = strdup(s);
+        (*env)->ReleaseStringUTFChars(env, (*env)->GetObjectArrayElement(env, strv, i), s);
         /* LOGI("argv[%d] = %s", i, lo_main_argv[i]); */
     }
-    lo_main_argv[lo_main_argc] = NULL;
+    (*argv)[*argc] = NULL;
+
+    return JNI_TRUE;
+}
+
+
+// public static native boolean setup(int lo_main_ptr,
+//                                    Object lo_main_argument,
+//                                    int lo_main_delay);
+
+__attribute__ ((visibility("default")))
+jboolean
+Java_org_libreoffice_android_Bootstrap_setup__ILjava_lang_Object_2I(JNIEnv* env,
+                                                                    jobject clazz,
+                                                                    void *lo_main_ptr,
+                                                                    jobject lo_main_argument,
+                                                                    jint lo_main_delay)
+{
+    (void) clazz;
+
+    lo_main = lo_main_ptr;
+
+    if (!get_jni_string_array(env, "setup: lo_main_argument", lo_main_argument, &lo_main_argc, &lo_main_argv))
+        return JNI_FALSE;
 
     sleep_time = lo_main_delay;
 
@@ -1484,6 +1498,8 @@ extract_files(const char *prefix)
     lo_apk_closedir(tree);
 }
 
+// public static native void patch_libgnustl_shared();
+
 __attribute__ ((visibility("default")))
 void
 Java_org_libreoffice_android_Bootstrap_patch_libgnustl_shared(JNIEnv* env,
@@ -1495,6 +1511,72 @@ Java_org_libreoffice_android_Bootstrap_patch_libgnustl_shared(JNIEnv* env,
     patch_libgnustl_shared();
 }
 
+/* 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
+ * have its JNI wrapper here, and then call the VCL function from it. Oh well,
+ * one could say it's clean to have all the Android-specific JNI functions
+ * here in this file.
+ */
+
+// public static native void initVCL();
+
+__attribute__ ((visibility("default")))
+void
+Java_org_libreoffice_android_Bootstrap_initVCL(JNIEnv* env,
+                                               jobject clazz)
+{
+    void (*InitVCLWrapper)(void);
+    (void) env;
+    (void) clazz;
+
+    /* This obviously should be called only after libvcllo.so has been loaded */
+
+    InitVCLWrapper = dlsym(RTLD_DEFAULT, "InitVCLWrapper");
+    if (InitVCLWrapper == NULL) {
+        LOGE("InitVCL: InitVCLWrapper not found");
+        return;
+    }
+    (*InitVCLWrapper)();
+}
+
+__attribute__ ((visibility("default")))
+void
+Java_org_libreoffice_android_Bootstrap_setCommandArgs(JNIEnv* env,
+                                                      jobject clazz,
+                                                      jobject argv)
+{
+    char **c_argv;
+    int c_argc;
+    Dl_info lo_bootstrap_info;
+    void (*osl_setCommandArgs)(int, char **);
+
+    (void) clazz;
+
+    if (!get_jni_string_array(env, "setCommandArgs :argv", argv, &c_argc, (const char ***) &c_argv))
+        return;
+
+    if (lo_dladdr(Java_org_libreoffice_android_Bootstrap_setCommandArgs, &lo_bootstrap_info) != 0) {
+        char *new_argv0 = malloc(strlen(lo_bootstrap_info.dli_fname) + strlen(c_argv[0]));
+        char *slash;
+        strcpy(new_argv0, lo_bootstrap_info.dli_fname);
+        slash = strrchr(new_argv0, '/');
+        if (slash != NULL)
+            *slash = '\0';
+        slash = strrchr(new_argv0, '/');
+        strcpy(slash+1, c_argv[0]);
+        free(c_argv[0]);
+        c_argv[0] = new_argv0;
+    }
+
+    osl_setCommandArgs = dlsym(RTLD_DEFAULT, "osl_setCommandArgs");
+    if (osl_setCommandArgs == NULL) {
+        LOGE("setCommandArgs: osl_setCommandArgs not found");
+        return;
+    }
+    (*osl_setCommandArgs)(c_argc, c_argv);
+}
+
 __attribute__ ((visibility("default")))
 JavaVM *
 lo_get_javavm(void)
commit 38603465cc00e1638c21c123117ea863acdee887
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Thu Mar 22 22:46:06 2012 +0200

    No point searching PATH on Android and iOS

diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index 3c1831d..f2b90b8 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -270,6 +270,7 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
             }
             if (ppArgs[0] != 0)
             {
+#if !defined(ANDROID) && !defined(IOS) // No use searching PATH on Android or iOS
                 /* see @ osl_getExecutableFile(). */
                 if (rtl_ustr_indexOfChar (rtl_uString_getStr(ppArgs[0]), sal_Unicode('/')) == -1)
                 {
@@ -289,7 +290,7 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
                         rtl_uString_release (pSearchPath);
                     }
                 }
-
+#endif
                 rtl_uString * pArg0 = 0;
                 if (realpath_u (ppArgs[0], &pArg0))
                 {
commit 871cc191fc7b815df89ecf488cd3e18aae680b1d
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Thu Mar 22 22:44:51 2012 +0200

    Add a wrapper for InitVCL(), to be called from Java on Android

diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index cf98fb8..2624e6c 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -56,6 +56,11 @@
 #include <ole2.h>   // for _beginthreadex
 #endif
 
+#ifdef ANDROID
+#include <cppuhelper/bootstrap.hxx>
+#include <jni.h>
+#endif
+
 // [ed 5/14/02 Add in explicit check for quartz graphics.  OS X will define
 // unx for both quartz and X11 graphics, but we include svunx.h only if we're
 // building X11 graphics layers.
@@ -327,6 +332,23 @@ sal_Bool InitVCL( const ::com::sun::star::uno::Reference< ::com::sun::star::lang
     return sal_True;
 }
 
+#ifdef ANDROID
+
+extern "C" __attribute__ ((visibility("default"))) void
+InitVCLWrapper()
+{
+    uno::Reference<uno::XComponentContext> xContext( cppu::defaultBootstrap_InitialComponentContext() );
+    uno::Reference<lang::XMultiComponentFactory> xFactory( xContext->getServiceManager() );
+
+    uno::Reference<lang::XMultiServiceFactory> xSM( xFactory, uno::UNO_QUERY_THROW );
+
+    comphelper::setProcessServiceFactory( xSM );
+
+    InitVCL( xSM );
+}
+
+#endif
+
 namespace
 {
 
commit a3035495eb67651e5bf3d785ac8f1a73eb3abf37
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Wed Mar 21 19:56:18 2012 +0200

    Make the DocumentLoader experimental app build again

diff --git a/android/experiments/DocumentLoader/AndroidManifest.xml b/android/experiments/DocumentLoader/AndroidManifest.xml
index c137311..e3001d6 100644
--- a/android/experiments/DocumentLoader/AndroidManifest.xml
+++ b/android/experiments/DocumentLoader/AndroidManifest.xml
@@ -4,7 +4,7 @@
       android:versionCode="1"
       android:versionName="1.0">
     <uses-sdk android:minSdkVersion="9" />
-    <application android:label="@string/app_name"
+    <application android:label="LO Experimental DocumentLoader"
                  android:debuggable="true">
         <activity android:name=".DocumentLoader"
                   android:label="LO DocumentLoader"
diff --git a/android/experiments/DocumentLoader/Makefile b/android/experiments/DocumentLoader/Makefile
index 7db82ae..5612fbf 100644
--- a/android/experiments/DocumentLoader/Makefile
+++ b/android/experiments/DocumentLoader/Makefile
@@ -1,12 +1,13 @@
-NDK_HOME:=$(shell type -p ndk-build)
-NDK_HOME:=$(shell dirname $(NDK_HOME))
+include ../../../config_host.mk
+
+# The package of this app
+APP_PACKAGE=org.libreoffice.android.examples
 
 SODEST=libs/armeabi-v7a
 OBJLOCAL=obj/local/armeabi-v7a
 
 define COPYSO
-cp $(1) $(SODEST)$(if $(2),/$(2)) && \
-arm-linux-androideabi-strip --strip-debug $(SODEST)$(if $(2),/$(2),/$(notdir $(1))) && \
+cp $(1) $(SODEST)$(if $(2),/$(2)) && $(STRIP) --strip-debug $(SODEST)$(if $(2),/$(2),/$(notdir $(1))) && \
 cp $(1) $(OBJLOCAL)$(if $(2),/$(2))
 endef
 
@@ -18,37 +19,11 @@ endef
 
 all: build-ant
 
-copy-stuff:
+copy-stuff: 
 # First always clean 
 	rm -rf libs $(OBJLOCAL)
 	mkdir -p $(SODEST) $(OBJLOCAL)
 #
-# Copy jar files we need, and even construct one.
-#
-	for F in $(strip \
-		   java_uno \
-		   juh \
-		   jurt \
-		   ridl \
-		   unoloader \
-		  ); do \
-	    $(call COPYJAR,$(OUTDIR)/bin/$${F}.jar); \
-	done
-#
-# lo-bootstrap.jar from ../../Bootstrap
-#
-	cp ../../Bootstrap/lo-bootstrap.jar libs
-#
-# com.sun.star.frame.XComponentLoader is not in any jar
-#
-	cd libs && \
-	    LD_LIBRARY_PATH=$(OUTDIR_FOR_BUILD)/lib \
-	    DYLD_LIBRARY_PATH=$(OUTDIR_FOR_BUILD)/lib \
-	    $(OUTDIR_FOR_BUILD)/bin/javamaker -BUCR -nD \
-		$(OUTDIR)/bin/udkapi.rdb $(OUTDIR)/bin/offapi.rdb \
-		-Tcom.sun.star.frame.XComponentLoader && \
-	    jar cvf more.jar com
-#
 # Copy shared libraries (including UNO components) we need to
 # libs/armeabi-v7a so that ant will include them in the .apk.
 #
@@ -70,8 +45,8 @@ copy-stuff:
 		   lo-bootstrap \
 		   localedata_en \
 		   localedata_others \
+		   mergedlo \
 		   reg \
-		   sal_textenc \
 		   store \
 		   ucbhelper4gcc3 \
 		   uno_cppu \
@@ -87,7 +62,7 @@ copy-stuff:
 	done
 #
 # Then the shared GNU C++ library
-	$(call COPYSO,$(NDK_HOME)/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/libgnustl_shared.so)
+	$(call COPYSO,$(ANDROID_NDK_HOME)/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/libgnustl_shared.so)
 #
 # Then other "assets". Let the directory structure under assets mimic
 # that under solver for now.
@@ -101,20 +76,47 @@ copy-stuff:
 #
 # Then gdbserver and gdb.setup so that we can debug with ndk-gdb.
 #
-	cp $(NDK_HOME)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver $(SODEST)
+	cp $(ANDROID_NDK_HOME)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver $(SODEST)
 	echo set solib-search-path ./obj/local/armeabi-v7a >$(SODEST)/gdb.setup
 
 build-ant: copy-stuff
-	unset JAVA_HOME && ant debug
+#
+# Copy jar files we need, and even construct one.
+#
+	for F in $(strip \
+		   java_uno \
+		   juh \
+		   jurt \
+		   ridl \
+		   unoloader \
+		  ); do \
+	    $(call COPYJAR,$(OUTDIR)/bin/$${F}.jar); \
+	done
+#
+# com.sun.star.frame.XComponentLoader is not in any jar
+#
+	cd libs && \
+	    LD_LIBRARY_PATH=$(OUTDIR_FOR_BUILD)/lib \
+	    DYLD_LIBRARY_PATH=$(OUTDIR_FOR_BUILD)/lib \
+	    $(OUTDIR_FOR_BUILD)/bin/javamaker -BUCR -nD \
+		$(OUTDIR)/bin/udkapi.rdb $(OUTDIR)/bin/offapi.rdb \
+		-Tcom.sun.star.frame.XComponentLoader && \
+	    jar cvf more.jar com
+#
+	unset JAVA_HOME && $(ANT) debug
 
 install: copy-stuff
-	unset JAVA_HOME && ant debug install
+	unset JAVA_HOME && $(ANT) debug install
 	@echo
 	@echo 'Run it with something like what "make run" does (see Makefile)'
 	@echo
 
-run: install
+uninstall:
+	$(ANDROID_SDK_HOME)/platform-tools/adb uninstall $(APP_PACKAGE)
+
+run:
 	adb shell am start -n org.libreoffice.android.examples/.DocumentLoader -e input /assets/test1.odt
 
 clean:
-	rm -rf bin assets
+	$(ANT) clean
+	rm -rf assets libs $(SODEST) $(OBJLOCAL)
diff --git a/android/experiments/DocumentLoader/local.properties.in b/android/experiments/DocumentLoader/local.properties.in
new file mode 100644
index 0000000..27c8eb5
--- /dev/null
+++ b/android/experiments/DocumentLoader/local.properties.in
@@ -0,0 +1,2 @@
+# Location of the SDK. This is only used by Ant.
+sdk.dir=@ANDROID_SDK_HOME@
diff --git a/android/experiments/DocumentLoader/project.properties b/android/experiments/DocumentLoader/project.properties
index 730e911..06b2d88 100644
--- a/android/experiments/DocumentLoader/project.properties
+++ b/android/experiments/DocumentLoader/project.properties
@@ -9,3 +9,6 @@
 
 # Project target.
 target=android-14
+
+# Use the Bootstrap class
+android.library.reference.1=../../Bootstrap
diff --git a/configure.in b/configure.in
index cdd4b42..ef42ca9 100644
--- a/configure.in
+++ b/configure.in
@@ -3254,6 +3254,7 @@ if test "$cross_compiling" = "yes"; then
     tar cf - \
         bin/repo-list.in \
         android/Bootstrap/local.properties.in \
+        android/experiments/DocumentLoader/local.properties.in \
         android/qa/sc/local.properties.in \
         android/qa/desktop/local.properties.in \
         config.guess \
@@ -11238,7 +11239,11 @@ else
     echo > config_host.mk.last
 fi
 
-AC_CONFIG_FILES([config_host.mk ooo.lst bin/repo-list android/Bootstrap/local.properties android/qa/sc/local.properties android/qa/desktop/local.properties])
+AC_CONFIG_FILES([config_host.mk ooo.lst bin/repo-list \
+android/Bootstrap/local.properties \
+android/experiments/DocumentLoader/local.properties \
+android/qa/sc/local.properties \
+android/qa/desktop/local.properties])
 AC_OUTPUT
 
 # touch the config timestamp file set_soenv.stamp
commit 2cbb41b3ab036504f66418b28559aa40fd773b61
Author: Tor Lillqvist <tlillqvist at suse.com>
Date:   Wed Mar 21 19:55:50 2012 +0200

    Edit a comment a bit

diff --git a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
index ac5d027..8fbcee9 100644
--- a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
+++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java
@@ -41,11 +41,11 @@ import java.io.File;
 import java.util.Arrays;
 import java.util.Scanner;
 
-// We override NativeActivity so that we can get at the intent of the
+// We extend NativeActivity so that we can get at the intent of the
 // activity and its extra parameters, that we use to tell us what
 // actual LibreOffice "program" to run. I.e. something that on desktop
-// OSes would be a program, but for Androis is actually built as a
-// shared object, with an "lo_main" function.
+// OSes would be a program, but for Android is actually built as a
+// shared object, with a "lo_main" function.
 
 public class Bootstrap extends NativeActivity
 {


More information about the Libreoffice-commits mailing list