From 046cec3aa7fd58a9519cad8d693b47a2400e1742 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Wed, 16 Mar 2011 14:33:55 +0000 Subject: Android: Partly revert r29569 and only call the new getJavaEnvironment() when needed. The environment is fine to share in general, just not across OS threads, so it's only needed for functions which are possibly called from multiple OS threads (only 1 currently). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29601 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/hosted/android/system-target.h | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'firmware/target/hosted/android/system-target.h') diff --git a/firmware/target/hosted/android/system-target.h b/firmware/target/hosted/android/system-target.h index 9145ab1e84..325c1012af 100644 --- a/firmware/target/hosted/android/system-target.h +++ b/firmware/target/hosted/android/system-target.h @@ -21,8 +21,6 @@ #ifndef __SYSTEM_TARGET_H__ #define __SYSTEM_TARGET_H__ -#include - #define disable_irq() #define enable_irq() #define disable_irq_save() 0 @@ -32,19 +30,15 @@ void power_off(void); void wait_for_interrupt(void); void interrupt(void); -/* A JNI environment is specific to its thread, so use the correct way to - * obtain it: share a pointer to the JavaVM structure and ask that the JNI - * environment attached to the current thread. */ -static inline JNIEnv* getJavaEnvironment(void) -{ - extern JavaVM *vm_ptr; - JNIEnv *env = NULL; - - if (vm_ptr) - (*vm_ptr)->GetEnv(vm_ptr, (void**) &env, JNI_VERSION_1_2); - - return env; -} + /* don't pull in jni.h for every user of this file, it should be only needed + * within the target tree (if at all) + * define this before #including system.h or system-target.h */ +#ifdef _SYSTEM_WITH_JNI +#include +/* + * discover the JNIEnv for this the calling thread in case it's not known */ +extern JNIEnv* getJavaEnvironment(void); +#endif /* _SYSTEM_WITH_JNI */ #endif /* __SYSTEM_TARGET_H__ */ -- cgit v1.2.3