diff options
-rw-r--r-- | android/Bootstrap/.gitignore (renamed from sal/osl/android/.gitignore) | 0 | ||||
-rw-r--r-- | android/Bootstrap/AndroidManifest.xml (renamed from sal/osl/android/AndroidManifest.xml) | 0 | ||||
-rw-r--r-- | android/Bootstrap/Makefile (renamed from sal/osl/android/Makefile) | 33 | ||||
-rw-r--r-- | android/Bootstrap/ant.properties (renamed from sal/osl/android/ant.properties) | 0 | ||||
-rw-r--r-- | android/Bootstrap/build.xml (renamed from sal/osl/android/build.xml) | 0 | ||||
-rw-r--r-- | android/Bootstrap/project.properties (renamed from sal/osl/android/project.properties) | 0 | ||||
-rw-r--r-- | android/Bootstrap/res/layout/main.xml (renamed from sal/osl/android/res/layout/main.xml) | 0 | ||||
-rw-r--r-- | android/Bootstrap/res/values/strings.xml (renamed from sal/osl/android/res/values/strings.xml) | 0 | ||||
-rw-r--r-- | android/Bootstrap/src/fi/iki/tml/CommandLine.java (renamed from sal/osl/android/src/fi/iki/tml/CommandLine.java) | 0 | ||||
-rw-r--r-- | android/Bootstrap/src/org/libreoffice/android/Bootstrap.java (renamed from sal/osl/android/src/org/libreoffice/android/Bootstrap.java) | 3 | ||||
-rw-r--r-- | android/experiments/DocumentLoader/AndroidManifest.xml (renamed from android/examples/DocumentLoader/AndroidManifest.xml) | 0 | ||||
-rw-r--r-- | android/experiments/DocumentLoader/Makefile | 120 | ||||
-rw-r--r-- | android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java (renamed from android/examples/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java) | 38 | ||||
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/makefile.mk | 3 | ||||
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 10 | ||||
-rw-r--r-- | sal/android/android_native_app_glue.c (renamed from sal/osl/android/jni/android_native_app_glue.c) | 0 | ||||
-rw-r--r-- | sal/android/android_native_app_glue.h (renamed from sal/osl/android/jni/android_native_app_glue.h) | 0 | ||||
-rw-r--r-- | sal/android/lo-bootstrap.c (renamed from sal/osl/android/jni/lo-bootstrap.c) | 16 | ||||
-rw-r--r-- | sal/android/makefile.mk | 59 | ||||
-rw-r--r-- | sal/osl/unx/file.cxx | 7 | ||||
-rw-r--r-- | sal/osl/unx/module.c | 7 | ||||
-rw-r--r-- | sal/osl/unx/process_impl.cxx | 26 | ||||
-rw-r--r-- | sal/prj/build.lst | 3 | ||||
-rw-r--r-- | sal/prj/d.lst | 2 | ||||
-rw-r--r-- | sal/util/makefile.mk | 4 | ||||
-rw-r--r-- | solenv/inc/unxandr/lo-bootstrap.h (renamed from sal/osl/android/jni/lo-bootstrap.h) | 0 |
26 files changed, 292 insertions, 39 deletions
diff --git a/sal/osl/android/.gitignore b/android/Bootstrap/.gitignore index 9034b9895557..9034b9895557 100644 --- a/sal/osl/android/.gitignore +++ b/android/Bootstrap/.gitignore diff --git a/sal/osl/android/AndroidManifest.xml b/android/Bootstrap/AndroidManifest.xml index 159bbf105d75..159bbf105d75 100644 --- a/sal/osl/android/AndroidManifest.xml +++ b/android/Bootstrap/AndroidManifest.xml diff --git a/sal/osl/android/Makefile b/android/Bootstrap/Makefile index b0368e7d3627..d8a7004579c7 100644 --- a/sal/osl/android/Makefile +++ b/android/Bootstrap/Makefile @@ -17,13 +17,9 @@ endef # The default target just builds. -# lo-bootstrap.jar is used from other LO apps than the test ones we -# include in the .apk here. - all: build-ant lo-bootstrap.jar -build-ndk: - ndk-build V=1 +copy-stuff: # # Copy shared libraries we need to libs/armeabi-v7a so that ant will # include them in the .apk. @@ -31,16 +27,21 @@ build-ndk: # Copy them to obj/local/armeabi-v7a, too, where gdb will look for # them. # -# First the cppunittester "program" from here, which as all "program" + mkdir -p $(SODEST) $(OBJLOCAL) +# +# First the most important one, liblo-bootstrap.so + $(call COPY,$(OUTDIR)/lib/liblo-bootstrap.so) +# +# Then the cppunittester "program". As all "program" # files we build for Android actually is a shared object. - $(call COPY,../../$(INPATH)/bin/cppunittester,libcppunittester.so) + $(call COPY,$(OUTDIR)/bin/cppunit/cppunittester,libcppunittester.so) # # The cppunit library $(call COPY,$(OUTDIR)/lib/libcppunit-1.12.so) # # cppunit "plug-ins", first ones from sal # - $(call COPY,../../$(INPATH)/lib/*.so) + $(call COPY,../../sal/$(INPATH)/lib/*.so) # # and ones from other modules. Note that depending on when you try # this, these might not have been built yet. @@ -101,26 +102,28 @@ build-ndk: sed -e 's!uri="./!uri="$(APP_DATA_PATH)/lib/!g' <$(SRC_ROOT)/testtools/$(INPATH)/lib/$${F}.rdb >assets/lib/$${F}.rdb; \ done -build-ant: build-ndk +build-ant: copy-stuff unset JAVA_HOME && ant debug -install: build-ndk +lo-bootstrap.jar: build-ant + cd bin/classes && jar cvf ../../lo-bootstrap.jar fi/iki/tml org/libreoffice/android/Bootstrap.class + +install: copy-stuff lo-bootstrap.jar + cp lo-bootstrap.jar $(OUTDIR)bin unset JAVA_HOME && ant debug install @echo @echo 'Run it with something like what "make run" does (see Makefile)' @echo -lo-bootstrap.jar: build-ant - cd bin/classes && jar cvf ../../lo-bootstrap.jar fi/iki/tml org/libreoffice/android/Bootstrap.class - -run: install +run: # Note: these are just examples. # adb shell am start -n org.libreoffice.android/.Bootstrap -e lo-main-library libcppunittester -e lo-main-cmdline "$(APP_DATA_PATH)/lib/libqa_sal_types.so" # + sleep 10 adb shell am start -n org.libreoffice.android/.Bootstrap -e lo-main-library libcppunittester -e lo-main-cmdline "$(APP_DATA_PATH)/lib/libtest_i18npool_test_breakiterator.so --protector libunoexceptionprotector.so unoexceptionprotector '-env:UNO_TYPES=file:///assets/bin/udkapi.rdb file:///assets/bin/types.rdb' '-env:UNO_SERVICES=file:///assets/xml/ure/services.rdb file:///assets/ComponentTarget/i18npool/util/i18npool.component' -env:LO_LIB_DIR=file://$(APP_DATA_PATH)/lib" # - adb shell am start -n org.libreoffice.android/.Bootstrap -e lo-main-library libunoexe -e lo-main-cmdline "-ro /assets/lib/uno_services.rdb -ro /assets/lib/uno_types.rdb -s com.sun.star.test.bridge.BridgeTest -- com.sun.star.test.bridge.CppTestObject" -e lo-main-delay 2 +# adb shell am start -n org.libreoffice.android/.Bootstrap -e lo-main-library libunoexe -e lo-main-cmdline "-ro /assets/lib/uno_services.rdb -ro /assets/lib/uno_types.rdb -s com.sun.star.test.bridge.BridgeTest -- com.sun.star.test.bridge.CppTestObject" -e lo-main-delay 2 clean: rm -rf bin assets diff --git a/sal/osl/android/ant.properties b/android/Bootstrap/ant.properties index ee52d86d94a4..ee52d86d94a4 100644 --- a/sal/osl/android/ant.properties +++ b/android/Bootstrap/ant.properties diff --git a/sal/osl/android/build.xml b/android/Bootstrap/build.xml index 6b091c49c2bd..6b091c49c2bd 100644 --- a/sal/osl/android/build.xml +++ b/android/Bootstrap/build.xml diff --git a/sal/osl/android/project.properties b/android/Bootstrap/project.properties index 730e911f2f9e..730e911f2f9e 100644 --- a/sal/osl/android/project.properties +++ b/android/Bootstrap/project.properties diff --git a/sal/osl/android/res/layout/main.xml b/android/Bootstrap/res/layout/main.xml index 5839d8cda704..5839d8cda704 100644 --- a/sal/osl/android/res/layout/main.xml +++ b/android/Bootstrap/res/layout/main.xml diff --git a/sal/osl/android/res/values/strings.xml b/android/Bootstrap/res/values/strings.xml index f296dd4b137d..f296dd4b137d 100644 --- a/sal/osl/android/res/values/strings.xml +++ b/android/Bootstrap/res/values/strings.xml diff --git a/sal/osl/android/src/fi/iki/tml/CommandLine.java b/android/Bootstrap/src/fi/iki/tml/CommandLine.java index fb5adec2acf5..fb5adec2acf5 100644 --- a/sal/osl/android/src/fi/iki/tml/CommandLine.java +++ b/android/Bootstrap/src/fi/iki/tml/CommandLine.java diff --git a/sal/osl/android/src/org/libreoffice/android/Bootstrap.java b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java index 5e377b27b02e..46ce235d3ad4 100644 --- a/sal/osl/android/src/org/libreoffice/android/Bootstrap.java +++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java @@ -72,6 +72,9 @@ public class Bootstrap extends NativeActivity // Wrapper for system() public static native void system(String cmdline); + // Wrapper for putenv() + public static native void putenv(String string); + public static void setup(Activity activity) { String dataDir = null; diff --git a/android/examples/DocumentLoader/AndroidManifest.xml b/android/experiments/DocumentLoader/AndroidManifest.xml index c137311155d1..c137311155d1 100644 --- a/android/examples/DocumentLoader/AndroidManifest.xml +++ b/android/experiments/DocumentLoader/AndroidManifest.xml diff --git a/android/experiments/DocumentLoader/Makefile b/android/experiments/DocumentLoader/Makefile new file mode 100644 index 000000000000..7db82ae1a43a --- /dev/null +++ b/android/experiments/DocumentLoader/Makefile @@ -0,0 +1,120 @@ +NDK_HOME:=$(shell type -p ndk-build) +NDK_HOME:=$(shell dirname $(NDK_HOME)) + +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) $(OBJLOCAL)$(if $(2),/$(2)) +endef + +define COPYJAR +cp $(1) libs +endef + +# The default target just builds. + +all: build-ant + +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. +# +# Copy them to obj/local/armeabi-v7a, too, where gdb will look for +# them. +# + for F in $(strip \ + comphelpgcc3 \ + gcc3_uno \ + i18nisolang1gcc3 \ + i18nutilgcc3 \ + icudatalo \ + icui18nlo \ + icuuclo \ + java_uno \ + juh \ + juhx \ + jvmaccessgcc3 \ + lo-bootstrap \ + localedata_en \ + localedata_others \ + reg \ + sal_textenc \ + store \ + ucbhelper4gcc3 \ + uno_cppu \ + uno_sal \ + uno_salhelpergcc3 \ + uno_cppuhelpergcc3 \ + xml2 \ + xmlreader \ + bootstrap.uno \ + i18npool.uno \ + ); do \ + $(call COPYSO,$(OUTDIR)/lib/lib$${F}.so); \ + done +# +# Then the shared GNU C++ library + $(call COPYSO,$(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. + mkdir -p assets/bin assets/lib 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 $(SRC_ROOT)/odk/examples/java/DocumentHandling/test/test1.odt assets + cp $(WORKDIR)/ComponentTarget/i18npool/util/i18npool.component assets/ComponentTarget/i18npool/util +# +# 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) + echo set solib-search-path ./obj/local/armeabi-v7a >$(SODEST)/gdb.setup + +build-ant: copy-stuff + unset JAVA_HOME && ant debug + +install: copy-stuff + unset JAVA_HOME && ant debug install + @echo + @echo 'Run it with something like what "make run" does (see Makefile)' + @echo + +run: install + adb shell am start -n org.libreoffice.android.examples/.DocumentLoader -e input /assets/test1.odt + +clean: + rm -rf bin assets diff --git a/android/examples/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java index 41f69dd019b0..819cf82ccaba 100644 --- a/android/examples/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java +++ b/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java @@ -30,13 +30,7 @@ package org.libreoffice.android.examples; import android.app.Activity; import android.os.Bundle; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.EditText; +import android.util.Log; import com.sun.star.uno.UnoRuntime; @@ -45,6 +39,8 @@ import org.libreoffice.android.Bootstrap; public class DocumentLoader extends Activity { + private static String TAG = "DocumentLoader"; + @Override public void onCreate(Bundle savedInstanceState) { @@ -52,29 +48,49 @@ public class DocumentLoader try { - Thread.sleep(20000); - 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"); + + 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"); + com.sun.star.lang.XMultiComponentFactory xMCF = xContext.getServiceManager(); Object oDesktop = xMCF.createInstanceWithContext( "com.sun.star.frame.Desktop", xContext); + Log.i(TAG, "oDesktop is" + (oDesktop!=null ? " not" : "") + " null"); + com.sun.star.frame.XComponentLoader xCompLoader = (com.sun.star.frame.XComponentLoader) UnoRuntime.queryInterface( com.sun.star.frame.XComponentLoader.class, oDesktop); - // Getting the given starting directory - String sUrl = "file:///assets/inputfile.doc"; + 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[] = diff --git a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk index 78f1457e49d0..03c4f58e37d8 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk +++ b/jvmfwk/plugins/sunmajor/pluginlib/makefile.mk @@ -69,6 +69,9 @@ SHL1STDLIBS= \ $(SALHELPERLIB) \ $(SALLIB) +.IF "$(OS)" == "ANDROID" +SHL1STDLIBS+=-llo-bootstrap +.ENDIF .IF "$(GUI)" == "WNT" .IF "$(COM)"!="GCC" diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 7a54b4452865..0af05d923087 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -64,6 +64,10 @@ #include "vendorlist.hxx" #include "diagnostics.h" +#ifdef ANDROID +#include <lo-bootstrap.h> +#endif + #if defined HAVE_VALGRIND_H #include <valgrind.h> #else @@ -758,10 +762,8 @@ javaPluginError jfw_plugin_startJavaVirtualMachine( (void) cOptions; // On Android we always have a Java VM as we only expect this code // to be run in an Android app anyway. - struct JNIInvokeInterface* * (*lo_get_javavm)(void) = (struct JNIInvokeInterface* * (*)(void)) dlsym(RTLD_DEFAULT, "lo_get_javavm"); - fprintf(stderr, "Got lo_get_javavm = %p", lo_get_javavm); - *ppVm = (JavaVM *) (*lo_get_javavm)(); - fprintf(stderr, "lo_get_javavm returns %p", (*lo_get_javavm)()); + *ppVm = lo_get_javavm(); + fprintf(stderr, "lo_get_javavm returns %p", *ppVm); #endif return errcode; diff --git a/sal/osl/android/jni/android_native_app_glue.c b/sal/android/android_native_app_glue.c index 8ff9f69d9946..8ff9f69d9946 100644 --- a/sal/osl/android/jni/android_native_app_glue.c +++ b/sal/android/android_native_app_glue.c diff --git a/sal/osl/android/jni/android_native_app_glue.h b/sal/android/android_native_app_glue.h index 1b8c1f10725d..1b8c1f10725d 100644 --- a/sal/osl/android/jni/android_native_app_glue.h +++ b/sal/android/android_native_app_glue.h diff --git a/sal/osl/android/jni/lo-bootstrap.c b/sal/android/lo-bootstrap.c index d9c1e32958ab..6ac285d498d1 100644 --- a/sal/osl/android/jni/lo-bootstrap.c +++ b/sal/android/lo-bootstrap.c @@ -434,6 +434,22 @@ Java_org_libreoffice_android_Bootstrap_system(JNIEnv* env, (*env)->ReleaseStringUTFChars(env, cmdline, s); } +// public static native void putenv(String string); + +void +Java_org_libreoffice_android_Bootstrap_putenv(JNIEnv* env, + jobject clazz, + jstring string) +{ + const jbyte *s = (*env)->GetStringUTFChars(env, string, NULL); + + LOGI("putenv(%s)", s); + + putenv(s); + + (*env)->ReleaseStringUTFChars(env, string, s); +} + char ** lo_dlneeds(const char *library) { diff --git a/sal/android/makefile.mk b/sal/android/makefile.mk new file mode 100644 index 000000000000..74de4ee1997a --- /dev/null +++ b/sal/android/makefile.mk @@ -0,0 +1,59 @@ +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http:#www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# Major Contributor(s): +# Copyright (C) 2011 Tor Lillqvist <tml@iki.fi> (initial developer) +# Copyright (C) 2011 SUSE Linux http://suse.com (initial developer's employer) +# +# Zip parsing code lifted from Mozilla's other-licenses/android/APKOpen.cpp, +# by Michael Wu <mwu@mozilla.com>. +# +# All Rights Reserved. +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. + +PRJ = .. +PRJNAME = sal +TARGET = lo-bootstrap + +# Too many warnings from android_native_app_glue.[ch] +EXTERNAL_WARNINGS_NOT_ERRORS = TRUE + +.INCLUDE : settings.mk + +.IF "$(OS)" != "ANDROID" +ALL: + @: do nothing +.ENDIF + +SHL1TARGET = $(TARGET) + +SHL1OBJS = \ + $(SLO)$/lo-bootstrap.obj + +# We don't want to link liblo-bootstrap.so against +# libgnustl_shared.so. The Android dynamic linker won't find it +# anyway. One very point of liblo-bootstrap is its wrapper for +# dlopen() that searches also in the app's lib folder for needed +# shared libraries. So just re-define STDSHLCUIMT. + +STDSHLCUIMT := -llog -landroid + +# Also don't pointless + +.INCLUDE : target.mk diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index ccc87e3ed7b7..1bf76a81f08e 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -56,6 +56,10 @@ #endif /* MACOSX */ +#ifdef ANDROID +#include <lo-bootstrap.h> +#endif + #ifdef DEBUG_OSL_FILE # define OSL_FILE_TRACE osl_trace # define PERROR( a, b ) perror( a ); fprintf( stderr, b ) @@ -917,8 +921,7 @@ SAL_CALL osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal_uIn { void *address; size_t size; - void *(*lo_apkentry)(const char *, size_t *) = (void *(*)(const char *, size_t *)) dlsym(RTLD_DEFAULT, "lo_apkentry"); - address = (*lo_apkentry)(buffer, &size); + address = lo_apkentry(buffer, &size); return osl_openMemoryAsFile(address, size, pHandle); } #endif diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c index 952449db8ed2..38a49b7e4744 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.c @@ -43,6 +43,10 @@ #include <sys/ldr.h> #endif +#ifdef ANDROID +#include <lo-bootstrap.h> +#endif + /* implemented in file.c */ extern int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32); @@ -96,8 +100,7 @@ static sal_Bool getModulePathFromAddress(void * address, rtl_String ** path) { Dl_info dl_info; #ifdef ANDROID - int (*lo_dladdr)(void *, Dl_info *) = dlsym(RTLD_DEFAULT, "lo_dladdr"); - result = (*lo_dladdr)(address, &dl_info); + result = lo_dladdr(address, &dl_info); #else result = dladdr(address, &dl_info); #endif diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 1edbf898f891..83c5c8872dbe 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -59,6 +59,10 @@ #include "uunxapi.h" +#ifdef ANDROID +#include <lo-bootstrap.h> +#endif + /*************************************** osl_bootstrap_getExecutableFile_Impl(). @@ -129,11 +133,25 @@ oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( oslProcessError result = osl_Process_E_NotFound; #ifdef ANDROID - /* On Android we want the address of the "lo_main()" function, as - * that is what corresponds to "main()" in LibreOffice programs on - * normal desktop OSes. + /* On Android we in theory want the address of the "lo_main()" + * function, as that is what corresponds to "main()" in + * LibreOffice programs on normal desktop OSes. + * + * But that is true only for apps with a "native activity", using + * <sal/main.h> and the org.libreoffice.android.Bootstrap + * mechanism. For more normal (?) Android apps that just use + * LibreOffice libraries (components) where the main program is in + * Java, that just use LibreOffice libraries, there is no + * lo_main(). (Note that we don't know for sure yet how + * complicated it might be to write such Android apps...) + * + * Maybe best to just pick some function in liblo-bootstrap.so + * which also such Java apps *must* load as the very first + * LibreOffice native library. We store all LibreOffice native + * shared libraries an app uses in the same folder anyway, so it + * doesn't really matter. */ - void * addr = dlsym (RTLD_DEFAULT, "lo_main"); + void * addr = (void *) &lo_dlopen; #else /* Determine address of "main()" function. */ void * addr = dlsym (RTLD_DEFAULT, "main"); diff --git a/sal/prj/build.lst b/sal/prj/build.lst index 47b8f58ecac9..f7f16ad12796 100644 --- a/sal/prj/build.lst +++ b/sal/prj/build.lst @@ -3,13 +3,14 @@ sa sal usr1 - all sa_mkout NULL sa sal\inc nmake - all sa_inc NULL sa sal\typesconfig nmake - all sa_tc sa_inc NULL sa sal\cpprt nmake - u sa_cpprt sa_util sa_inc NULL +sa sal\android nmake - u sa_android NULL sa sal\rtl\source nmake - all sa_rtl sa_tc.u sa_inc NULL sa sal\textenc nmake - all sa_textenc sa_tc.u sa_inc NULL sa sal\systools\win32\uwinapi nmake - n sa_uwinapi sa_inc NULL sa sal\systools\win32\onlineupdate nmake - n sa_onlineupdate sa_uwinapi.n sa_inc NULL sa sal\osl\w32 nmake - n sa_osln sa_inc NULL sa sal\qa nmake - all sa_qa sa_util NULL -sa sal\osl\unx nmake - u sa_oslu sa_tc.u sa_inc NULL +sa sal\osl\unx nmake - u sa_oslu sa_android.u sa_tc.u sa_inc NULL sa sal\osl\all nmake - all sa_oslall sa_tc.u sa_inc NULL sa sal\util nmake - all sa_util sa_tc.u sa_oslall sa_uwinapi.n sa_onlineupdate.n sa_osln.n sa_oslu.u sa_rtl sa_textenc NULL sa sal\util\sal_textenc nmake - all sa_util_saltextenc sa_util NULL diff --git a/sal/prj/d.lst b/sal/prj/d.lst index c7f93ed06309..1d73422d2fae 100644 --- a/sal/prj/d.lst +++ b/sal/prj/d.lst @@ -31,6 +31,8 @@ symlink: %_DEST%\lib\libuno_sal.dylib.3 %_DEST%\lib\libuno_sal.dylib ..\%__SRC%\lib\*.sl %_DEST%\lib\*.sl ..\%__SRC%\lib\*.a %_DEST%\lib\*.a +..\%__SRC%\lib\liblo-bootstrap.so %_DEST%\lib\liblo-bootstrap.so + ..\%__SRC%\slb\sal.lib %_DEST%\lib\xsal.lib ..\%__SRC%\bin\*.dll %_DEST%\bin\*.dll diff --git a/sal/util/makefile.mk b/sal/util/makefile.mk index 981f3cbbe632..d81780a9bf79 100644 --- a/sal/util/makefile.mk +++ b/sal/util/makefile.mk @@ -113,6 +113,10 @@ SHL1STDLIBS+= -z allextract -staticlib=Crun -z defaultextract SHL1STDLIBS+=-framework CoreFoundation -framework Carbon .ENDIF +.IF "$(OS)" == "ANDROID" +SHL1STDLIBS+=-llo-bootstrap +.ENDIF + SHL1LIBS+=$(SLB)$/$(TARGET).lib .IF "$(linkinc)" != "" diff --git a/sal/osl/android/jni/lo-bootstrap.h b/solenv/inc/unxandr/lo-bootstrap.h index 258d9d28850c..258d9d28850c 100644 --- a/sal/osl/android/jni/lo-bootstrap.h +++ b/solenv/inc/unxandr/lo-bootstrap.h |