diff options
Diffstat (limited to 'firmware/target/hosted/android/system-android.c')
-rw-r--r-- | firmware/target/hosted/android/system-android.c | 21 |
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 */ |
30 | JavaVM *vm_ptr; | 30 | static JavaVM *vm_ptr; |
31 | JNIEnv *env_ptr; | ||
31 | jobject RockboxService_instance; | 32 | jobject RockboxService_instance; |
32 | jclass RockboxService_class; | 33 | jclass RockboxService_class; |
33 | 34 | ||
@@ -47,6 +48,22 @@ void system_init(void) | |||
47 | telephony_init_device(); | 48 | telephony_init_device(); |
48 | } | 49 | } |
49 | 50 | ||
51 | JNIEXPORT jint JNICALL | ||
52 | JNI_OnLoad(JavaVM *vm, void* reserved) | ||
53 | { | ||
54 | (void)reserved; | ||
55 | vm_ptr = vm; | ||
56 | |||
57 | return JNI_VERSION_1_2; | ||
58 | } | ||
59 | |||
60 | JNIEnv* 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 */ |
51 | JNIEXPORT void JNICALL | 68 | JNIEXPORT void JNICALL |
52 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | 69 | Java_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 | ||