diff options
-rw-r--r-- | apps/hosted/android/keyboard.c | 11 | ||||
-rw-r--r-- | apps/hosted/android/notification.c | 7 | ||||
-rw-r--r-- | apps/hosted/android/yesno.c | 17 | ||||
-rw-r--r-- | firmware/target/hosted/android/lcd-android.c | 11 | ||||
-rw-r--r-- | firmware/target/hosted/android/pcm-android.c | 13 | ||||
-rw-r--r-- | firmware/target/hosted/android/system-android.c | 12 |
6 files changed, 23 insertions, 48 deletions
diff --git a/apps/hosted/android/keyboard.c b/apps/hosted/android/keyboard.c index 460011c4f7..f9bbcbb261 100644 --- a/apps/hosted/android/keyboard.c +++ b/apps/hosted/android/keyboard.c | |||
@@ -61,17 +61,14 @@ static void kdb_init(void) | |||
61 | { | 61 | { |
62 | semaphore_init(&kbd_wakeup, 1, 0); | 62 | semaphore_init(&kbd_wakeup, 1, 0); |
63 | /* get the class and its constructor */ | 63 | /* get the class and its constructor */ |
64 | jclass kbInput_class = e->FindClass(env_ptr, | 64 | RockboxKeyboardInput_class = e->FindClass(env_ptr, |
65 | "org/rockbox/RockboxKeyboardInput"); | 65 | "org/rockbox/RockboxKeyboardInput"); |
66 | RockboxKeyboardInput_class = e->NewGlobalRef(env_ptr, kbInput_class); | ||
67 | jmethodID constructor = e->GetMethodID(env_ptr, | 66 | jmethodID constructor = e->GetMethodID(env_ptr, |
68 | RockboxKeyboardInput_class, | 67 | RockboxKeyboardInput_class, |
69 | "<init>", "()V"); | 68 | "<init>", "()V"); |
70 | jobject kbInput_instance = e->NewObject(env_ptr, | 69 | RockboxKeyboardInput_instance = e->NewObject(env_ptr, |
71 | RockboxKeyboardInput_class, | 70 | RockboxKeyboardInput_class, |
72 | constructor); | 71 | constructor); |
73 | RockboxKeyboardInput_instance = e->NewGlobalRef(env_ptr, | ||
74 | kbInput_instance); | ||
75 | kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, | 72 | kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, |
76 | "kbd_input", | 73 | "kbd_input", |
77 | "(Ljava/lang/String;" | 74 | "(Ljava/lang/String;" |
diff --git a/apps/hosted/android/notification.c b/apps/hosted/android/notification.c index 1c89c51357..e7c425b7c1 100644 --- a/apps/hosted/android/notification.c +++ b/apps/hosted/android/notification.c | |||
@@ -128,14 +128,13 @@ void notification_init(void) | |||
128 | JNIEnv e = *env_ptr; | 128 | JNIEnv e = *env_ptr; |
129 | jfieldID nNM = e->GetFieldID(env_ptr, RockboxService_class, | 129 | jfieldID nNM = e->GetFieldID(env_ptr, RockboxService_class, |
130 | "fg_runner", "Lorg/rockbox/Helper/RunForegroundManager;"); | 130 | "fg_runner", "Lorg/rockbox/Helper/RunForegroundManager;"); |
131 | jobject nMN_instance = e->GetObjectField(env_ptr, | 131 | NotificationManager_instance = e->GetObjectField(env_ptr, |
132 | RockboxService_instance, nNM); | 132 | RockboxService_instance, nNM); |
133 | if (nMN_instance == NULL) | 133 | if (NotificationManager_instance == NULL) |
134 | { | 134 | { |
135 | DEBUGF("Failed to get RunForegroundManager instance. Performance will be bad"); | 135 | DEBUGF("Failed to get RunForegroundManager instance. Performance will be bad"); |
136 | return; | 136 | return; |
137 | } | 137 | } |
138 | NotificationManager_instance = e->NewGlobalRef(env_ptr, nMN_instance); | ||
139 | 138 | ||
140 | jclass class = e->GetObjectClass(env_ptr, NotificationManager_instance); | 139 | jclass class = e->GetObjectClass(env_ptr, NotificationManager_instance); |
141 | updateNotification = e->GetMethodID(env_ptr, class, "updateNotification", | 140 | updateNotification = e->GetMethodID(env_ptr, class, "updateNotification", |
diff --git a/apps/hosted/android/yesno.c b/apps/hosted/android/yesno.c index de6ec99a3c..2e85ea2bc1 100644 --- a/apps/hosted/android/yesno.c +++ b/apps/hosted/android/yesno.c | |||
@@ -52,21 +52,20 @@ static void yesno_init(JNIEnv *env_ptr) | |||
52 | { | 52 | { |
53 | semaphore_init(&yesno_done, 1, 0); | 53 | semaphore_init(&yesno_done, 1, 0); |
54 | /* get the class and its constructor */ | 54 | /* get the class and its constructor */ |
55 | jclass yesno_class = e->FindClass(env_ptr, | 55 | jclass RockboxYesno_class = e->FindClass(env_ptr, |
56 | "org/rockbox/RockboxYesno"); | 56 | "org/rockbox/RockboxYesno"); |
57 | jmethodID constructor = e->GetMethodID(env_ptr, | 57 | jmethodID constructor = e->GetMethodID(env_ptr, |
58 | yesno_class, | 58 | RockboxYesno_class, |
59 | "<init>", "()V"); | 59 | "<init>", "()V"); |
60 | jobject yesno_instance = e->NewObject(env_ptr, | 60 | RockboxYesno_instance = e->NewObject(env_ptr, |
61 | yesno_class, | 61 | RockboxYesno_class, |
62 | constructor); | 62 | constructor); |
63 | RockboxYesno_instance = e->NewGlobalRef(env_ptr, yesno_instance); | 63 | yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class, |
64 | yesno_func = e->GetMethodID(env_ptr, yesno_class, | ||
65 | "yesno_display", | 64 | "yesno_display", |
66 | "(Ljava/lang/String;" | 65 | "(Ljava/lang/String;" |
67 | "Ljava/lang/String;" | 66 | "Ljava/lang/String;" |
68 | "Ljava/lang/String;)V"); | 67 | "Ljava/lang/String;)V"); |
69 | yesno_is_usable = e->GetMethodID(env_ptr, yesno_class, | 68 | yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class, |
70 | "is_usable", "()Z"); | 69 | "is_usable", "()Z"); |
71 | } | 70 | } |
72 | /* need to get it every time incase the activity died/restarted */ | 71 | /* need to get it every time incase the activity died/restarted */ |
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index 66ddcd5e3e..f9d7917a5e 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c | |||
@@ -46,7 +46,6 @@ static bool display_on; | |||
46 | void connect_with_java(JNIEnv* env, jobject fb_instance) | 46 | void connect_with_java(JNIEnv* env, jobject fb_instance) |
47 | { | 47 | { |
48 | JNIEnv e = *env; | 48 | JNIEnv e = *env; |
49 | |||
50 | /* Update RockboxFramebuffer_instance */ | 49 | /* Update RockboxFramebuffer_instance */ |
51 | if (!e->IsSameObject(env, RockboxFramebuffer_instance, fb_instance)) { | 50 | if (!e->IsSameObject(env, RockboxFramebuffer_instance, fb_instance)) { |
52 | if (RockboxFramebuffer_instance != NULL) | 51 | if (RockboxFramebuffer_instance != NULL) |
@@ -55,7 +54,7 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
55 | RockboxFramebuffer_instance = e->NewGlobalRef(env, fb_instance); | 54 | RockboxFramebuffer_instance = e->NewGlobalRef(env, fb_instance); |
56 | } | 55 | } |
57 | 56 | ||
58 | static bool have_class = false; | 57 | static bool have_class; |
59 | if (!have_class) | 58 | if (!have_class) |
60 | { | 59 | { |
61 | jclass fb_class = e->GetObjectClass(env, fb_instance); | 60 | jclass fb_class = e->GetObjectClass(env, fb_instance); |
@@ -77,13 +76,10 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
77 | java_lcd_init = e->GetMethodID(env, fb_class, | 76 | java_lcd_init = e->GetMethodID(env, fb_class, |
78 | "java_lcd_init", | 77 | "java_lcd_init", |
79 | "(IILjava/nio/ByteBuffer;)V"); | 78 | "(IILjava/nio/ByteBuffer;)V"); |
80 | 79 | ||
81 | jobject buffer = e->NewDirectByteBuffer(env, | 80 | native_buffer = e->NewDirectByteBuffer(env, |
82 | lcd_framebuffer, | 81 | lcd_framebuffer, |
83 | (jlong)sizeof(lcd_framebuffer)); | 82 | (jlong)sizeof(lcd_framebuffer)); |
84 | |||
85 | native_buffer = e->NewGlobalRef(env, buffer); | ||
86 | |||
87 | have_class = true; | 83 | have_class = true; |
88 | } | 84 | } |
89 | /* we need to setup parts for the java object every time */ | 85 | /* we need to setup parts for the java object every time */ |
@@ -96,7 +92,6 @@ void lcd_deinit(void) | |||
96 | JNIEnv *env_ptr = getJavaEnvironment(); | 92 | JNIEnv *env_ptr = getJavaEnvironment(); |
97 | 93 | ||
98 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxFramebuffer_instance); | 94 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxFramebuffer_instance); |
99 | (*env_ptr)->DeleteGlobalRef(env_ptr, native_buffer); | ||
100 | } | 95 | } |
101 | 96 | ||
102 | /* | 97 | /* |
diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c index 4b6df7f878..0f59f3f2ab 100644 --- a/firmware/target/hosted/android/pcm-android.c +++ b/firmware/target/hosted/android/pcm-android.c | |||
@@ -33,6 +33,7 @@ static char *pcm_data_start; | |||
33 | static jmethodID play_pause_method; | 33 | static jmethodID play_pause_method; |
34 | static jmethodID stop_method; | 34 | static jmethodID stop_method; |
35 | static jmethodID set_volume_method; | 35 | static jmethodID set_volume_method; |
36 | static jclass RockboxPCM_class; | ||
36 | static jobject RockboxPCM_instance; | 37 | static jobject RockboxPCM_instance; |
37 | 38 | ||
38 | 39 | ||
@@ -157,11 +158,10 @@ void pcm_play_dma_init(void) | |||
157 | JNIEnv *env_ptr = getJavaEnvironment(); | 158 | JNIEnv *env_ptr = getJavaEnvironment(); |
158 | JNIEnv e = *env_ptr; | 159 | JNIEnv e = *env_ptr; |
159 | /* get the class and its constructor */ | 160 | /* get the class and its constructor */ |
160 | jclass RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); | 161 | RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); |
161 | jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V"); | 162 | jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V"); |
162 | /* instance = new RockboxPCM() */ | 163 | /* instance = new RockboxPCM() */ |
163 | jobject PCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor); | 164 | RockboxPCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor); |
164 | RockboxPCM_instance = e->NewGlobalRef(env_ptr, PCM_instance); | ||
165 | /* cache needed methods */ | 165 | /* cache needed methods */ |
166 | play_pause_method = e->GetMethodID(env_ptr, RockboxPCM_class, "play_pause", "(Z)V"); | 166 | play_pause_method = e->GetMethodID(env_ptr, RockboxPCM_class, "play_pause", "(Z)V"); |
167 | set_volume_method = e->GetMethodID(env_ptr, RockboxPCM_class, "set_volume", "(I)V"); | 167 | set_volume_method = e->GetMethodID(env_ptr, RockboxPCM_class, "set_volume", "(I)V"); |
@@ -170,13 +170,6 @@ void pcm_play_dma_init(void) | |||
170 | pcm_play_get_more_callback((void*)&pcm_data_start, &pcm_data_size); | 170 | pcm_play_get_more_callback((void*)&pcm_data_start, &pcm_data_size); |
171 | } | 171 | } |
172 | 172 | ||
173 | void pcm_deinit(void) | ||
174 | { | ||
175 | JNIEnv *env_ptr = getJavaEnvironment(); | ||
176 | |||
177 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxPCM_instance); | ||
178 | } | ||
179 | |||
180 | void pcm_postinit(void) | 173 | void pcm_postinit(void) |
181 | { | 174 | { |
182 | } | 175 | } |
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index f9f0605b49..c499631132 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c | |||
@@ -37,19 +37,13 @@ uintptr_t *stackend; | |||
37 | extern int main(void); | 37 | extern int main(void); |
38 | extern void telephony_init_device(void); | 38 | extern void telephony_init_device(void); |
39 | extern void lcd_deinit(void); | 39 | extern void lcd_deinit(void); |
40 | extern void pcm_deinit(void); | ||
41 | 40 | ||
42 | void system_exception_wait(void) { } | 41 | void system_exception_wait(void) { } |
43 | void system_reboot(void) { } | 42 | void system_reboot(void) { } |
44 | 43 | ||
45 | void power_off(void) | 44 | void power_off(void) |
46 | { | 45 | { |
47 | JNIEnv *env_ptr = getJavaEnvironment(); | ||
48 | |||
49 | lcd_deinit(); | 46 | lcd_deinit(); |
50 | pcm_deinit(); | ||
51 | |||
52 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxService_class); | ||
53 | } | 47 | } |
54 | 48 | ||
55 | void system_init(void) | 49 | void system_init(void) |
@@ -62,8 +56,6 @@ void system_init(void) | |||
62 | JNIEXPORT void JNICALL | 56 | JNIEXPORT void JNICALL |
63 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | 57 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) |
64 | { | 58 | { |
65 | jclass class = (*env)->GetObjectClass(env, this); | ||
66 | |||
67 | /* hack!!! we can't have a valid stack pointer otherwise. | 59 | /* hack!!! we can't have a valid stack pointer otherwise. |
68 | * but we don't really need it anyway, thread.c only needs it | 60 | * but we don't really need it anyway, thread.c only needs it |
69 | * for overflow detection which doesn't apply for the main thread | 61 | * for overflow detection which doesn't apply for the main thread |
@@ -73,8 +65,8 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | |||
73 | stackbegin = stackend = (uintptr_t*) &stack; | 65 | stackbegin = stackend = (uintptr_t*) &stack; |
74 | 66 | ||
75 | (*env)->GetJavaVM(env, &vm_ptr); | 67 | (*env)->GetJavaVM(env, &vm_ptr); |
76 | RockboxService_instance = (*env)->NewGlobalRef(env, this); | 68 | RockboxService_instance = this; |
77 | RockboxService_class = (*env)->NewGlobalRef(env, class); | 69 | RockboxService_class = (*env)->GetObjectClass(env, this); |
78 | 70 | ||
79 | main(); | 71 | main(); |
80 | } | 72 | } |