summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-11-17 10:44:04 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-12-04 23:04:27 +0100
commit333a894ba84553762542c47636791f92360c69b5 (patch)
tree008016ec1fd0df7c322333ddd261ee8a2af9cd7d
parent8dc0d82aadb7d6b2a9429a520f121f7dc4c47c1d (diff)
android: cleanup LibreOfficeKit initialization in Java
Change-Id: I7688968e92ae4b3d6fef19c4544ae91bdcd8b1b9
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java30
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/TileProviderFactory.java2
2 files changed, 15 insertions, 17 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
index afd81b33eff3..4fe2061c335b 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/LibreOfficeKit.java
@@ -15,27 +15,23 @@ import android.util.Log;
import java.io.InputStream;
-// final because subclassing would be meaningless.
+// 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.
public final class LibreOfficeKit
{
- private long handle;
-
- public static void loadStatic() {
-
- }
+ private static String LOGTAG = LibreOfficeKit.class.getSimpleName();
// private constructor because instantiating would be meaningless
- private LibreOfficeKit()
- {
+ private LibreOfficeKit() {
}
- private static String TAG = "LibreOfficeKit";
-
- // 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.
+ // Trigger library initialization - as this is done automatically by executing the "static" block, this method remains empty. However we need this to manually (at the right time) can force library initialization.
+ public static void initializeLibrary() {
+ }
+ // Trigger initialization on the JNI - LOKit side.
private static native boolean initializeNative(String dataDir, String cacheDir, String apkFile);
public static native long getLibreOfficeKitHandle();
@@ -53,14 +49,15 @@ public final class LibreOfficeKit
// LO-based apps.
public static synchronized void init(Activity activity)
{
- if (initializeDone)
+ if (initializeDone) {
return;
+ }
String dataDir = null;
ApplicationInfo applicationInfo = activity.getApplicationInfo();
dataDir = applicationInfo.dataDir;
- Log.i(TAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir));
+ Log.i(LOGTAG, String.format("Initializing LibreOfficeKit, dataDir=%s\n", dataDir));
redirectStdio(true);
@@ -85,6 +82,7 @@ public final class LibreOfficeKit
putenv("TMPDIR=" + activity.getCacheDir().getAbsolutePath());
if (!initializeNative(dataDir, cacheDir, apkFile)) {
+ Log.i(LOGTAG, "Initialize native failed!");
return;
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProviderFactory.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProviderFactory.java
index 5cd3ed0ea833..3bfe0b7febf5 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProviderFactory.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProviderFactory.java
@@ -13,7 +13,7 @@ public class TileProviderFactory {
public static void initialize() {
if (currentTileProvider == TileProviderID.LOKIT) {
- LibreOfficeKit.loadStatic();
+ LibreOfficeKit.initializeLibrary();
}
}