summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2015-10-03 22:53:37 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2015-10-03 22:54:39 +0200
commit1a6ec13d0805b7aa8c3bdcbfcc444c4916dfc817 (patch)
tree2e8d6d44fbeda30487de7967d55e2c733df5d5e4 /android
parentcdfdf76787b1c3983e4eae0620fe711647ed0b9e (diff)
tdf#93281 clean cache directory on each start
to avoid segfault in native lib. It's only a workaround, but I couldn't see what's wrong with the cache... Change-Id: Iceeee1e190bbbd6efe336d84ddcbd8c4d3a1c621
Diffstat (limited to 'android')
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java45
1 files changed, 35 insertions, 10 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
index 2a60f848e0de..431c384726d0 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
@@ -13,6 +13,7 @@ import android.app.Activity;
import android.content.pm.ApplicationInfo;
import android.util.Log;
+import java.io.File;
import java.io.InputStream;
import java.nio.ByteBuffer;
@@ -54,23 +55,23 @@ public final class LibreOfficeKit
return;
}
- String dataDir = null;
-
ApplicationInfo applicationInfo = activity.getApplicationInfo();
- dataDir = applicationInfo.dataDir;
+ String dataDir = applicationInfo.dataDir;
Log.i(LOGTAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir));
redirectStdio(true);
-
+ // ToDo: ugly workaround - find out why it segfaults with existing cachedir
+ deleteRecursive(activity.getApplication().getCacheDir());
String cacheDir = activity.getApplication().getCacheDir().getAbsolutePath();
String apkFile = activity.getApplication().getPackageResourcePath();
- // If we notice that a fonts.conf file was extracted, automatically
+ // If there is a fonts.conf file in the apk that can be extracted, automatically
// set the FONTCONFIG_FILE env var.
- InputStream inputStream = null;
+ InputStream inputStream;
try {
inputStream = activity.getAssets().open("unpack/etc/fonts/fonts.conf");
} catch (java.io.IOException exception) {
+ inputStream = null;
}
putenv("OOO_DISABLE_RECOVERY=1");
@@ -80,23 +81,47 @@ public final class LibreOfficeKit
}
// TMPDIR is used by osl_getTempDirURL()
- putenv("TMPDIR=" + activity.getCacheDir().getAbsolutePath());
+ putenv("TMPDIR=" + cacheDir);
if (!initializeNative(dataDir, cacheDir, apkFile)) {
- Log.i(LOGTAG, "Initialize native failed!");
+ Log.e(LOGTAG, "Initialize native failed!");
return;
}
-
initializeDone = true;
}
+ /**
+ * Deletes files and recursively deletes directories.
+ *
+ * @param file
+ * File or directory to be deleted.
+ */
+ private static void deleteRecursive(File file) {
+ Log.d(LOGTAG, "deleting cacheDir recursively - this is only a workaround - fixme please");
+ if (file.isDirectory()) {
+ for (File child : file.listFiles())
+ deleteRecursive(child);
+ }
+ file.delete();
+ }
// Now with static loading we always have all native code in one native
// library which we always call liblo-native-code.so, regardless of the
// app. The library has already been unpacked into /data/data/<app
// name>/lib at installation time by the package manager.
static {
- System.loadLibrary("lo-native-code");
+ NativeLibLoader.load();
}
}
+class NativeLibLoader {
+ private static boolean done = false;
+
+ protected static synchronized void load() {
+ if (done)
+ return;
+ System.loadLibrary("lo-native-code");
+ done = true;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */