summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
Diffstat (limited to 'sal')
-rw-r--r--sal/android/libreofficekit-jni.c29
-rw-r--r--sal/android/lo-bootstrap.c30
2 files changed, 40 insertions, 19 deletions
diff --git a/sal/android/libreofficekit-jni.c b/sal/android/libreofficekit-jni.c
index 3563d5b7891e..cf8308afa01b 100644
--- a/sal/android/libreofficekit-jni.c
+++ b/sal/android/libreofficekit-jni.c
@@ -24,7 +24,9 @@
#include <osl/detail/android-bootstrap.h>
-//#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "LibreOfficeKit", __VA_ARGS__))
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "LibreOfficeKit", __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "LibreOfficeKit", __VA_ARGS__))
/* These are valid / used in all apps. */
@@ -34,9 +36,13 @@ extern void *apk_file;
extern int apk_file_size;
extern void Java_org_libreoffice_android_Bootstrap_putenv(JNIEnv* env, jobject clazz, jstring string);
-extern jboolean Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env, jobject clazz, jboolean state);
+extern void Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env, jobject clazz, jboolean state);
extern void Java_org_libreoffice_android_Bootstrap_extract_1files(JNIEnv* env, jobject clazz);
+extern LibreOfficeKit *libreofficekit_hook(const char* install_path);
+
+static LibreOfficeKit* pOffice;
+
/// Call the same method from Bootstrap.
__attribute__ ((visibility("default")))
void
@@ -49,12 +55,12 @@ Java_org_libreoffice_android_LibreOfficeKit_putenv(JNIEnv* env,
/// Call the same method from Bootstrap.
__attribute__ ((visibility("default")))
-jboolean
+void
Java_org_libreoffice_android_LibreOfficeKit_redirect_1stdio(JNIEnv* env,
jobject clazz,
jboolean state)
{
- return Java_org_libreoffice_android_Bootstrap_redirect_1stdio(env, clazz, state);
+ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(env, clazz, state);
}
/// Call the same method from Bootstrap.
@@ -119,10 +125,25 @@ Java_org_libreoffice_android_LibreOfficeKit_init__Ljava_lang_String_2Ljava_lang_
(*env)->ReleaseStringUTFChars(env, apkFile, apkFilePath);
if (!setup_cdir())
+ {
+ LOGE("setup_cdir failed");
return JNI_FALSE;
+ }
if (!setup_assets_tree())
+ {
+ LOGE("setup_assets_tree failed");
return JNI_FALSE;
+ }
+
+ pOffice = libreofficekit_hook(data_dir);
+ if (!pOffice)
+ {
+ LOGE("libreofficekit_hook returned null");
+ return JNI_FALSE;
+ }
+
+ LOGI("LibreOfficeKit successfully initialized");
return JNI_TRUE;
}
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c
index 973c1b25116a..a7765bed563e 100644
--- a/sal/android/lo-bootstrap.c
+++ b/sal/android/lo-bootstrap.c
@@ -42,11 +42,11 @@ struct engine {
};
/* These are valid / used in all apps. */
-static const char *data_dir;
-static const char *cache_dir;
-static void *apk_file;
-static int apk_file_size;
-static JavaVM *the_java_vm;
+const char *data_dir;
+const char *cache_dir;
+void *apk_file;
+int apk_file_size;
+JavaVM *the_java_vm;
/* Zip data structures */
@@ -1019,7 +1019,7 @@ redirect_to_null(void)
}
__attribute__ ((visibility("default")))
-jboolean
+void
Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
jobject clazz,
jboolean state)
@@ -1031,22 +1031,22 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
(void) env;
(void) clazz;
- if (state == current)
- return current;
+ if (state == current)
+ return;
if (state == JNI_FALSE) {
if (!redirect_to_null())
- return current;
+ return;
} else {
if (pipe(stdout_pipe) == -1) {
LOGE("redirect_stdio: Could not create pipes: %s", strerror(errno));
- return current;
+ return;
}
if (pipe(stderr_pipe) == -1) {
LOGE("redirect_stdio: Could not create pipes: %s", strerror(errno));
close(stdout_pipe[0]);
close(stdout_pipe[1]);
- return current;
+ return;
}
LOGI("redirect_stdio: stdout pipe: [%d,%d], stderr pipe: [%d,%d]",
stdout_pipe[0], stdout_pipe[1], stderr_pipe[0], stderr_pipe[1]);
@@ -1057,7 +1057,7 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
close(stdout_pipe[1]);
close(stderr_pipe[0]);
close(stderr_pipe[1]);
- return current;
+ return;
}
if (dup2(stderr_pipe[1], 2) == -1) {
@@ -1070,7 +1070,7 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
close(stdout_pipe[1]);
close(stderr_pipe[0]);
close(stderr_pipe[1]);
- return current;
+ return;
}
close(stdout_pipe[1]);
close(stderr_pipe[1]);
@@ -1082,11 +1082,11 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
redirect_to_null();
close(stdout_pipe[0]);
close(stderr_pipe[0]);
- return current;
+ return;
}
}
current = state;
- return current;
+ return;
}
__attribute__ ((visibility("default")))