summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
Diffstat (limited to 'sal')
-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.mk59
-rw-r--r--sal/osl/android/.gitignore6
-rw-r--r--sal/osl/android/AndroidManifest.xml24
-rw-r--r--sal/osl/android/Makefile126
-rw-r--r--sal/osl/android/ant.properties17
-rw-r--r--sal/osl/android/build.xml114
-rw-r--r--sal/osl/android/jni/lo-bootstrap.h64
-rw-r--r--sal/osl/android/project.properties11
-rw-r--r--sal/osl/android/res/layout/main.xml12
-rw-r--r--sal/osl/android/res/values/strings.xml4
-rw-r--r--sal/osl/android/src/fi/iki/tml/CommandLine.java176
-rw-r--r--sal/osl/android/src/org/libreoffice/android/Bootstrap.java169
-rw-r--r--sal/osl/unx/file.cxx7
-rw-r--r--sal/osl/unx/module.c7
-rw-r--r--sal/osl/unx/process_impl.cxx26
-rw-r--r--sal/prj/build.lst3
-rw-r--r--sal/prj/d.lst2
-rw-r--r--sal/util/makefile.mk4
21 files changed, 115 insertions, 732 deletions
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/android/.gitignore b/sal/osl/android/.gitignore
deleted file mode 100644
index 9034b9895557..000000000000
--- a/sal/osl/android/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-assets
-bin
-gen
-libs
-obj
-local.properties \ No newline at end of file
diff --git a/sal/osl/android/AndroidManifest.xml b/sal/osl/android/AndroidManifest.xml
deleted file mode 100644
index 159bbf105d75..000000000000
--- a/sal/osl/android/AndroidManifest.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.libreoffice.android"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="9" />
- <!-- This .apk uses a subclass of NativeActivity, so it *has* Java code. -->
- <!-- android:hasCode="false" -->
- <application android:label="@string/app_name"
- android:debuggable="true">
- <!-- <activity android:name="android.app.NativeActivity" -->
- <activity android:name=".Bootstrap"
- android:label="LibreOffice Bootstrap"
- android:configChanges="orientation|keyboardHidden">
- <!-- Tell NativeActivity the name of our .so -->
- <meta-data android:name="android.app.lib_name"
- android:value="lo-bootstrap" />
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/sal/osl/android/Makefile b/sal/osl/android/Makefile
deleted file mode 100644
index b0368e7d3627..000000000000
--- a/sal/osl/android/Makefile
+++ /dev/null
@@ -1,126 +0,0 @@
-# The full path the the app's directory needs to be supplied in a
-# couple of places, unfortunately.
-
-APP_DATA_PATH=/data/data/org.libreoffice.android
-
-NDK_HOME:=$(shell type -p ndk-build)
-NDK_HOME:=$(shell dirname $(NDK_HOME))
-
-SODEST=libs/armeabi-v7a
-OBJLOCAL=obj/local/armeabi-v7a
-
-define COPY
-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
-
-# 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 shared libraries 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.
-#
-# First the cppunittester "program" from here, which as all "program"
-# files we build for Android actually is a shared object.
- $(call COPY,../../$(INPATH)/bin/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)
-#
-# and ones from other modules. Note that depending on when you try
-# this, these might not have been built yet.
-#
- for F in $(SRC_ROOT)/cppu/$(INPATH)/lib/qa_*.so; do \
- $(call COPY,$${F},`basename $${F}`); \
- done
-#
- for F in i18npool_test_breakiterator; do \
- $(call COPY,$(WORKDIR)/LinkTarget/CppunitTest/libtest_$${F}.so); \
- done
-#
-# Other "programs"
- $(call COPY,$(OUTDIR)/bin/uno,libunoexe.so)
-#
-# Libs and UNO components that the tests from other modules need.
-#
- for F in $(strip \
- comphelpgcc3 \
- gcc3_uno \
- i18nisolang1gcc3 \
- i18nutilgcc3 \
- icudatalo \
- icui18nlo \
- icuuclo \
- localedata_en \
- localedata_others \
- reg \
- store \
- ucbhelper4gcc3 \
- uno_cppu \
- uno_salhelpergcc3 \
- uno_cppuhelpergcc3 \
- unoexceptionprotector \
- xml2 \
- xmlreader \
- bootstrap.uno \
- i18npool.uno); do \
- $(call COPY,$(OUTDIR)/lib/lib$${F}.so); \
- done
-#
-# Then the shared GNU C++ library
- $(call COPY,$(NDK_HOME)/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/libgnustl_shared.so)
-#
-# bridgetest components, not in solver
- for F in bridgetest constructors cppobj; do \
- $(call COPY,$(SRC_ROOT)/testtools/$(INPATH)/lib/lib$${F}.uno.so); \
- done
-#
-# 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)/xml/ure/services.rdb assets/xml/ure
- cp $(WORKDIR)/ComponentTarget/i18npool/util/i18npool.component assets/ComponentTarget/i18npool/util
- for F in uno_services uno_types; do \
- 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
- unset JAVA_HOME && ant debug
-
-install: build-ndk
- 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
-# 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"
-#
- 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
-
-clean:
- rm -rf bin assets
diff --git a/sal/osl/android/ant.properties b/sal/osl/android/ant.properties
deleted file mode 100644
index ee52d86d94a4..000000000000
--- a/sal/osl/android/ant.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is used to override default values used by the Ant build system.
-#
-# This file must be checked in Version Control Systems, as it is
-# integral to the build system of your project.
-
-# This file is only used by the Ant script.
-
-# You can use this to override default values such as
-# 'source.dir' for the location of your java source folder and
-# 'out.dir' for the location of your output folder.
-
-# You can also use it define how the release builds are signed by declaring
-# the following properties:
-# 'key.store' for the location of your keystore and
-# 'key.alias' for the name of the key to use.
-# The password will be asked during the build when you use the 'release' target.
-
diff --git a/sal/osl/android/build.xml b/sal/osl/android/build.xml
deleted file mode 100644
index 6b091c49c2bd..000000000000
--- a/sal/osl/android/build.xml
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="LibreOfficeBootstrap" default="help">
-
- <!-- The local.properties file is created and updated by the 'android' tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <loadproperties srcFile="local.properties" />
-
- <!-- The ant.properties file can be created by you. It is only edited by the
- 'android' tool to add properties to it.
- This is the place to change some Ant specific build properties.
- Here are some properties you may want to change/update:
-
- source.dir
- The name of the source directory. Default is 'src'.
- out.dir
- The name of the output directory. Default is 'bin'.
-
- For other overridable properties, look at the beginning of the rules
- files in the SDK, at tools/ant/build.xml
-
- Properties related to the SDK location or the project target should
- be updated using the 'android' tool with the 'update' action.
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems.
-
- -->
- <property file="ant.properties" />
-
- <!-- The project.properties file is created and updated by the 'android'
- tool, as well as ADT.
-
- This contains project specific properties such as project target, and library
- dependencies. Lower level build properties are stored in ant.properties
- (or in .classpath for Eclipse projects).
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems. -->
- <loadproperties srcFile="project.properties" />
-
- <!-- quick check on sdk.dir -->
- <fail
- message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
- unless="sdk.dir"
- />
-
-
-<!-- extension targets. Uncomment the ones where you want to do custom work
- in between standard targets -->
-<!--
- <target name="-pre-build">
- </target>
- <target name="-pre-compile">
- </target>
-
- /* This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir} */
- <target name="-post-compile">
- </target>
--->
-
- <!-- Import the actual build file.
-
- To customize existing targets, there are two options:
- - Customize only one target:
- - copy/paste the target into this file, *before* the
- <import> task.
- - customize it to your needs.
- - Customize the whole content of build.xml
- - copy/paste the content of the rules files (minus the top node)
- into this file, replacing the <import> task.
- - customize to your needs.
-
- ***********************
- ****** IMPORTANT ******
- ***********************
- In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
- in order to avoid having your file be overridden by tools such as "android update project"
- -->
- <!-- version-tag: 1 -->
- <import file="${sdk.dir}/tools/ant/build.xml" />
-
- <!-- Re-define the "-package-resources" target to not compress resources -->
-
- <target name="-package-resources" depends="-crunch">
- <!-- only package resources if *not* a library project -->
- <do-only-if-not-library elseText="Library project: do not package resources..." >
- <aapt executable="${aapt}"
- command="package"
- versioncode="${version.code}"
- versionname="${version.name}"
- debug="${build.is.packaging.debug}"
- manifest="AndroidManifest.xml"
- assets="${asset.absolute.dir}"
- androidjar="${android.jar}"
- apkfolder="${out.absolute.dir}"
- nocrunch="${build.packaging.nocrunch}"
- resourcefilename="${resource.package.file.name}"
- resourcefilter="${aapt.resource.filter}"
- projectLibrariesResName="project.libraries.res"
- projectLibrariesPackageName="project.libraries.package"
- previousBuildType="${build.last.target}"
- buildType="${build.target}">
- <res path="${out.res.absolute.dir}" />
- <res path="${resource.absolute.dir}" />
- <nocompress /> <!-- forces no compression on any files in assets or res/raw -->
- <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
- </aapt>
- </do-only-if-not-library>
- </target>
-
-</project>
diff --git a/sal/osl/android/jni/lo-bootstrap.h b/sal/osl/android/jni/lo-bootstrap.h
deleted file mode 100644
index 258d9d28850c..000000000000
--- a/sal/osl/android/jni/lo-bootstrap.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * 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)
- *
- * 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.
- */
-
-#if defined(ANDROID)
-
-#include <jni.h>
-#include <dlfcn.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-char **lo_dlneeds(const char *library);
-
-void *lo_dlopen(const char *library);
-
-void *lo_dlsym(void *handle,
- const char *symbol);
-
-int lo_dladdr(void *addr,
- Dl_info *info);
-
-void *lo_apkentry(const char *filename,
- size_t *size);
-
-int lo_dlcall_argc_argv(void *function,
- int argc,
- const char **argv);
-
-JavaVM *lo_get_javavm(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/android/project.properties b/sal/osl/android/project.properties
deleted file mode 100644
index 730e911f2f9e..000000000000
--- a/sal/osl/android/project.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-14
diff --git a/sal/osl/android/res/layout/main.xml b/sal/osl/android/res/layout/main.xml
deleted file mode 100644
index 5839d8cda704..000000000000
--- a/sal/osl/android/res/layout/main.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
-<TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Hello World"
- />
-</LinearLayout>
diff --git a/sal/osl/android/res/values/strings.xml b/sal/osl/android/res/values/strings.xml
deleted file mode 100644
index f296dd4b137d..000000000000
--- a/sal/osl/android/res/values/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">LibreOfficeBootstrap</string>
-</resources>
diff --git a/sal/osl/android/src/fi/iki/tml/CommandLine.java b/sal/osl/android/src/fi/iki/tml/CommandLine.java
deleted file mode 100644
index fb5adec2acf5..000000000000
--- a/sal/osl/android/src/fi/iki/tml/CommandLine.java
+++ /dev/null
@@ -1,176 +0,0 @@
-// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-// Copyright (C) 2011 Tor Lillqvist <tml@iki.fi>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-
-package fi.iki.tml;
-
-import java.util.*;
-
-public class CommandLine
- implements Iterable<String>
-{
- private String commandLine;
-
- public class Tokenizer
- implements Iterator<String>
- {
- private int index = 0;
- private String savedNext = null;
-
- public Tokenizer()
- {
- }
-
- public boolean hasNext()
- {
- if (savedNext != null)
- return true;
- try {
- savedNext = next();
- return true;
- }
- catch (NoSuchElementException e) {
- }
- return false;
- }
-
- public String next()
- {
- if (savedNext != null) {
- String result = savedNext;
- savedNext = null;
- return result;
- }
-
- StringBuffer sb = new StringBuffer(commandLine.length());
-
- while (index < commandLine.length() &&
- commandLine.charAt(index) == ' ')
- index++;
-
- if (index == commandLine.length())
- throw new NoSuchElementException();
-
- while (index < commandLine.length() &&
- commandLine.charAt(index) != ' ') {
- char c = commandLine.charAt(index);
- if (c == '\'') {
- index++;
- while (index < commandLine.length() &&
- commandLine.charAt(index) != '\'') {
- sb.append(commandLine.charAt(index));
- index++;
- }
- } else if (c == '"') {
- index++;
- while (index < commandLine.length() &&
- commandLine.charAt(index) != '\"') {
- if (commandLine.charAt(index) == '\\') {
- index++;
- if (index < commandLine.length())
- sb.append(commandLine.charAt(index));
- } else {
- sb.append(commandLine.charAt(index));
- }
- index++;
- }
- } else if (c == '\\') {
- index++;
- if (index < commandLine.length())
- sb.append(commandLine.charAt(index));
- } else {
- sb.append(c);
- }
- index++;
- }
- return sb.toString();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-
- public Iterator<String> iterator()
- {
- return new Tokenizer();
- }
-
- public CommandLine(String commandLine)
- {
- this.commandLine = commandLine;
- }
-
- public String[] split()
- {
- ArrayList<String> argv = new ArrayList<String>(10);
-
- try {
- for (String s : this)
- argv.add(s);
- }
- catch (NoSuchElementException e) {
- }
-
- return argv.toArray(new String[0]);
- }
-
- public static String[] split(String commandLine)
- {
- return new CommandLine(commandLine).split();
- }
-
- public static void main(String[] args)
- {
- class Test
- {
- Test(String commandLine)
- {
- String[] argv = split(commandLine);
- System.out.println("Split of " + commandLine + ":");
- int n = 0;
- for (String s : argv) {
- System.out.println("argv[" + n + "}: length " + s.length() + ": \"" + s + "\"");
- n++;
- }
- }
- }
-
- new Test("");
- new Test(" ");
- new Test(" ");
- new Test(" '' ");
- new Test("abc def");
- new Test("abc '' def");
- new Test("abc \"\" def");
- new Test(" abc def ");
- new Test(" abc def ");
- new Test("abc\" \"def");
- new Test("abc\" \"def \"gh\\i\\\" jkl\"");
- new Test("abc' def' '\\ghi jkl'");
- }
-}
-
-// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sal/osl/android/src/org/libreoffice/android/Bootstrap.java b/sal/osl/android/src/org/libreoffice/android/Bootstrap.java
deleted file mode 100644
index 5e377b27b02e..000000000000
--- a/sal/osl/android/src/org/libreoffice/android/Bootstrap.java
+++ /dev/null
@@ -1,169 +0,0 @@
-// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-// 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)
-//
-// 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.
-
-package org.libreoffice.android;
-
-import android.app.Activity;
-import android.app.NativeActivity;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.util.Log;
-
-import fi.iki.tml.CommandLine;
-
-// We override 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.
-
-public class Bootstrap extends NativeActivity
-{
- private static String TAG = "lo-bootstrap";
-
- private static native boolean setup(String dataDir,
- String apkFile,
- String[] ld_library_path);
-
- public static native boolean setup(int lo_main_ptr,
- Object lo_main_argument,
- int lo_main_delay);
-
- // This is not just a wrapper for the C library dlopen(), but also
- // loads recursively dependent libraries.
- public static native int dlopen(String library);
-
- // This is just a wrapper for the C library dlsym().
- public static native int dlsym(int handle, String symbol);
-
- // To be called after you are sure libgnustl_shared.so
- // has been loaded
- public static native void patch_libgnustl_shared();
-
- // Wrapper for getpid()
- public static native int getpid();
-
- // Wrapper for system()
- public static native void system(String cmdline);
-
- public static void setup(Activity activity)
- {
- String dataDir = null;
-
- ApplicationInfo ai = activity.getApplicationInfo();
- dataDir = ai.dataDir;
- Log.i(TAG, String.format("dataDir=%s\n", dataDir));
-
- String llp = System.getenv("LD_LIBRARY_PATH");
- if (llp == null)
- llp = "/vendor/lib:/system/lib";
-
- String[] llpa = llp.split(":");
-
- if (!setup(dataDir, activity.getApplication().getPackageResourcePath(), llpa))
- return;
-
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- setup(this);
-
- String mainLibrary = getIntent().getStringExtra("lo-main-library");
-
- if (mainLibrary == null)
- mainLibrary = "libcppunittester";
-
- mainLibrary += ".so";
-
- Log.i(TAG, String.format("mainLibrary=%s", mainLibrary));
-
- // Get "command line" to pass to the LO "program"
- String cmdLine = getIntent().getStringExtra("lo-main-cmdline");
-
- if (cmdLine == null)
- cmdLine = "/data/data/org.libreoffice.android/lib/libqa_sal_types.so";
-
- // argv[0] will be replaced by android_main() in lo-bootstrap.c by the
- // pathname of the mainLibrary.
- cmdLine = "dummy-program-name " + cmdLine;
-
- Log.i(TAG, String.format("cmdLine=%s", cmdLine));
-
- String[] argv = CommandLine.split(cmdLine);
-
- // Load the LO "program" here and look up lo_main
- int loLib = dlopen(mainLibrary);
-
- if (loLib == 0) {
- Log.i(TAG, String.format("Could not load %s", mainLibrary));
- return;
- }
-
- int lo_main = dlsym(loLib, "lo_main");
- if (lo_main == 0) {
- Log.i(TAG, String.format("No lo_main in %s", mainLibrary));
- return;
- }
-
- // Tell lo-bootstrap to Start a strace on itself if requested
- String strace_args = getIntent().getStringExtra("lo-strace");
- if (strace_args != null)
- system("/system/xbin/strace -p " + getpid() + " " + (strace_args != "yes" ? strace_args : "" ) + " &");
-
- int delay = 0;
- String sdelay = getIntent().getStringExtra("lo-main-delay");
- if (sdelay != null)
- delay = Integer.parseInt(sdelay);
-
- // Tell lo-bootstrap.c the stuff it needs to know
- if (!setup(lo_main, argv, delay))
- return;
-
- // Finally, call our super-class, NativeActivity's onCreate(),
- // which eventually calls the ANativeActivity_onCreate() in
- // android_native_app_glue.c, which starts a thread in which
- // android_main() from lo-bootstrap.c is called.
-
- // android_main() calls the lo_main() defined in sal/main.h
- // through the function pointer passed to setup() above, with
- // the argc and argv also saved from the setup() call.
- super.onCreate(savedInstanceState);
- }
-
- // This is used to load the 'lo-bootstrap' library on application
- // startup. The library has already been unpacked into
- // /data/data/<app name>/lib/liblo-bootstrap.so at installation
- // time by the package manager.
- static {
- System.loadLibrary("lo-bootstrap");
- }
-}
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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)" != ""