1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Thomas Martitz 2011-03-16 14:33:55 +00:00
parent efa9f13500
commit 046cec3aa7
10 changed files with 50 additions and 55 deletions

View file

@ -27,7 +27,8 @@
/* global fields for use with various JNI calls */
JavaVM *vm_ptr;
static JavaVM *vm_ptr;
JNIEnv *env_ptr;
jobject RockboxService_instance;
jclass RockboxService_class;
@ -47,6 +48,22 @@ void system_init(void)
telephony_init_device();
}
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void* reserved)
{
(void)reserved;
vm_ptr = vm;
return JNI_VERSION_1_2;
}
JNIEnv* getJavaEnvironment(void)
{
JNIEnv* env;
(*vm_ptr)->GetEnv(vm_ptr, (void**) &env, JNI_VERSION_1_2);
return env;
}
/* this is the entry point of the android app initially called by jni */
JNIEXPORT void JNICALL
Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this)
@ -58,8 +75,8 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this)
volatile uintptr_t stack = 0;
stackbegin = stackend = (uintptr_t*) &stack;
env_ptr = env;
(*env)->GetJavaVM(env, &vm_ptr);
RockboxService_instance = this;
RockboxService_class = (*env)->GetObjectClass(env, this);