summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android/system-android.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-03-16 14:33:55 +0000
committerThomas Martitz <kugel@rockbox.org>2011-03-16 14:33:55 +0000
commit046cec3aa7fd58a9519cad8d693b47a2400e1742 (patch)
treecb0ba0773a3e8b3cef5d7690e2822f03d1425ddb /firmware/target/hosted/android/system-android.c
parentefa9f13500d1672d0b631520e92e08f3ff61e45c (diff)
downloadrockbox-046cec3aa7fd58a9519cad8d693b47a2400e1742.tar.gz
rockbox-046cec3aa7fd58a9519cad8d693b47a2400e1742.zip
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
Diffstat (limited to 'firmware/target/hosted/android/system-android.c')
-rw-r--r--firmware/target/hosted/android/system-android.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c
index 8d36198c61..686453cfbb 100644
--- a/firmware/target/hosted/android/system-android.c
+++ b/firmware/target/hosted/android/system-android.c
@@ -27,7 +27,8 @@
27 27
28 28
29/* global fields for use with various JNI calls */ 29/* global fields for use with various JNI calls */
30JavaVM *vm_ptr; 30static JavaVM *vm_ptr;
31JNIEnv *env_ptr;
31jobject RockboxService_instance; 32jobject RockboxService_instance;
32jclass RockboxService_class; 33jclass RockboxService_class;
33 34
@@ -47,6 +48,22 @@ void system_init(void)
47 telephony_init_device(); 48 telephony_init_device();
48} 49}
49 50
51JNIEXPORT jint JNICALL
52JNI_OnLoad(JavaVM *vm, void* reserved)
53{
54 (void)reserved;
55 vm_ptr = vm;
56
57 return JNI_VERSION_1_2;
58}
59
60JNIEnv* getJavaEnvironment(void)
61{
62 JNIEnv* env;
63 (*vm_ptr)->GetEnv(vm_ptr, (void**) &env, JNI_VERSION_1_2);
64 return env;
65}
66
50/* this is the entry point of the android app initially called by jni */ 67/* this is the entry point of the android app initially called by jni */
51JNIEXPORT void JNICALL 68JNIEXPORT void JNICALL
52Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) 69Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this)
@@ -58,8 +75,8 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this)
58 75
59 volatile uintptr_t stack = 0; 76 volatile uintptr_t stack = 0;
60 stackbegin = stackend = (uintptr_t*) &stack; 77 stackbegin = stackend = (uintptr_t*) &stack;
78 env_ptr = env;
61 79
62 (*env)->GetJavaVM(env, &vm_ptr);
63 RockboxService_instance = this; 80 RockboxService_instance = this;
64 RockboxService_class = (*env)->GetObjectClass(env, this); 81 RockboxService_class = (*env)->GetObjectClass(env, this);
65 82