summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/android')
-rw-r--r--firmware/target/hosted/android/lcd-android.c11
-rw-r--r--firmware/target/hosted/android/pcm-android.c13
-rw-r--r--firmware/target/hosted/android/system-android.c12
3 files changed, 8 insertions, 28 deletions
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;
46void connect_with_java(JNIEnv* env, jobject fb_instance) 46void 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;
33static jmethodID play_pause_method; 33static jmethodID play_pause_method;
34static jmethodID stop_method; 34static jmethodID stop_method;
35static jmethodID set_volume_method; 35static jmethodID set_volume_method;
36static jclass RockboxPCM_class;
36static jobject RockboxPCM_instance; 37static 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
173void pcm_deinit(void)
174{
175 JNIEnv *env_ptr = getJavaEnvironment();
176
177 (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxPCM_instance);
178}
179
180void pcm_postinit(void) 173void 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;
37extern int main(void); 37extern int main(void);
38extern void telephony_init_device(void); 38extern void telephony_init_device(void);
39extern void lcd_deinit(void); 39extern void lcd_deinit(void);
40extern void pcm_deinit(void);
41 40
42void system_exception_wait(void) { } 41void system_exception_wait(void) { }
43void system_reboot(void) { } 42void system_reboot(void) { }
44 43
45void power_off(void) 44void 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
55void system_init(void) 49void system_init(void)
@@ -62,8 +56,6 @@ void system_init(void)
62JNIEXPORT void JNICALL 56JNIEXPORT void JNICALL
63Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) 57Java_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}