summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sal/inc/sal/ByteBufferWrapper.hxx23
-rw-r--r--touch/Library_libotouch.mk4
-rw-r--r--touch/source/android/android.cxx34
3 files changed, 44 insertions, 17 deletions
diff --git a/sal/inc/sal/ByteBufferWrapper.hxx b/sal/inc/sal/ByteBufferWrapper.hxx
index 954922d65b16..63bb618278d6 100644
--- a/sal/inc/sal/ByteBufferWrapper.hxx
+++ b/sal/inc/sal/ByteBufferWrapper.hxx
@@ -21,25 +21,14 @@ namespace org { namespace libreoffice { namespace touch {
class ByteBufferWrapper
{
private:
- JNIEnv *env;
- jobject object;
+ jobject object;
public:
- ByteBufferWrapper(JNIEnv *e, jobject o) :
- env(e)
- {
- object = env->NewGlobalRef(o);
- }
-
- sal_uInt8* pointer()
- {
- return (sal_uInt8 *) env->GetDirectBufferAddress(object);
- }
-
- void operator()(sal_uInt8 * /* p */)
- {
- env->DeleteGlobalRef(object);
- }
+ ByteBufferWrapper(JNIEnv *env, jobject o);
+
+ sal_uInt8* pointer();
+
+ void operator()(sal_uInt8 *p);
};
}; }; };
diff --git a/touch/Library_libotouch.mk b/touch/Library_libotouch.mk
index 1e06db466583..17d1f4529084 100644
--- a/touch/Library_libotouch.mk
+++ b/touch/Library_libotouch.mk
@@ -33,6 +33,10 @@ $(eval $(call gb_Library_add_exception_objects,libotouch,\
ifeq ($(OS),ANDROID)
+$(eval $(call gb_Library_use_libraries,libotouch,\
+ lo-bootstrap \
+))
+
$(eval $(call gb_Library_add_exception_objects,libotouch,\
touch/source/android/android \
))
diff --git a/touch/source/android/android.cxx b/touch/source/android/android.cxx
index 06768c86c646..3a116b18e643 100644
--- a/touch/source/android/android.cxx
+++ b/touch/source/android/android.cxx
@@ -10,9 +10,43 @@
#include <jni.h>
#include <sal/ByteBufferWrapper.hxx>
+#include <osl/detail/android-bootstrap.h>
using org::libreoffice::touch::ByteBufferWrapper;
+static JNIEnv *get_env()
+{
+ JavaVMAttachArgs args = {
+ JNI_VERSION_1_2,
+ NULL,
+ NULL
+ };
+
+ JavaVM *jvm = lo_get_javavm();
+ JNIEnv *env = NULL;
+
+ jvm->AttachCurrentThread(&env, &args);
+ return env;
+}
+
+__attribute__ ((visibility("default")))
+ByteBufferWrapper::ByteBufferWrapper(JNIEnv *env, jobject o)
+{
+ object = env->NewGlobalRef(o);
+}
+
+__attribute__ ((visibility("default")))
+sal_uInt8* ByteBufferWrapper::pointer()
+{
+ return (sal_uInt8 *) get_env()->GetDirectBufferAddress(object);
+}
+
+__attribute__ ((visibility("default")))
+void ByteBufferWrapper::operator()(sal_uInt8 * /* p */)
+{
+ get_env()->DeleteGlobalRef(object);
+}
+
extern "C"
__attribute__ ((visibility("default")))
jlong