summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android/system-android.c
diff options
context:
space:
mode:
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