diff options
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/android/lcd-android.c | 25 | ||||
-rw-r--r-- | firmware/target/hosted/android/pcm-android.c | 11 | ||||
-rw-r--r-- | firmware/target/hosted/android/system-android.c | 19 |
3 files changed, 43 insertions, 12 deletions
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index 0cde160e65..08a4075795 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c | |||
@@ -47,8 +47,16 @@ static bool display_on; | |||
47 | void connect_with_java(JNIEnv* env, jobject fb_instance) | 47 | void connect_with_java(JNIEnv* env, jobject fb_instance) |
48 | { | 48 | { |
49 | JNIEnv e = *env; | 49 | JNIEnv e = *env; |
50 | static bool have_class; | 50 | |
51 | RockboxFramebuffer_instance = fb_instance; | 51 | /* Update RockboxFramebuffer_instance */ |
52 | if (!e->IsSameObject(env, RockboxFramebuffer_instance, fb_instance)) { | ||
53 | if (RockboxFramebuffer_instance != NULL) | ||
54 | e->DeleteGlobalRef(env, RockboxFramebuffer_instance); | ||
55 | |||
56 | RockboxFramebuffer_instance = e->NewGlobalRef(env, fb_instance); | ||
57 | } | ||
58 | |||
59 | static bool have_class = false; | ||
52 | if (!have_class) | 60 | if (!have_class) |
53 | { | 61 | { |
54 | jclass fb_class = e->GetObjectClass(env, fb_instance); | 62 | jclass fb_class = e->GetObjectClass(env, fb_instance); |
@@ -70,10 +78,13 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
70 | java_lcd_init = e->GetMethodID(env, fb_class, | 78 | java_lcd_init = e->GetMethodID(env, fb_class, |
71 | "java_lcd_init", | 79 | "java_lcd_init", |
72 | "(IILjava/nio/ByteBuffer;)V"); | 80 | "(IILjava/nio/ByteBuffer;)V"); |
73 | 81 | ||
74 | native_buffer = e->NewDirectByteBuffer(env, | 82 | jobject buffer = e->NewDirectByteBuffer(env, |
75 | lcd_framebuffer, | 83 | lcd_framebuffer, |
76 | (jlong)sizeof(lcd_framebuffer)); | 84 | (jlong)sizeof(lcd_framebuffer)); |
85 | |||
86 | native_buffer = e->NewGlobalRef(env, buffer); | ||
87 | |||
77 | have_class = true; | 88 | have_class = true; |
78 | } | 89 | } |
79 | /* we need to setup parts for the java object every time */ | 90 | /* we need to setup parts for the java object every time */ |
@@ -81,6 +92,12 @@ void connect_with_java(JNIEnv* env, jobject fb_instance) | |||
81 | (jint)LCD_WIDTH, (jint)LCD_HEIGHT, native_buffer); | 92 | (jint)LCD_WIDTH, (jint)LCD_HEIGHT, native_buffer); |
82 | } | 93 | } |
83 | 94 | ||
95 | void lcd_deinit(void) | ||
96 | { | ||
97 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxFramebuffer_instance); | ||
98 | (*env_ptr)->DeleteGlobalRef(env_ptr, native_buffer); | ||
99 | } | ||
100 | |||
84 | /* | 101 | /* |
85 | * Do nothing here and connect with the java object later (if it isn't already) | 102 | * Do nothing here and connect with the java object later (if it isn't already) |
86 | */ | 103 | */ |
diff --git a/firmware/target/hosted/android/pcm-android.c b/firmware/target/hosted/android/pcm-android.c index c8bc410a54..f4ed4b1b33 100644 --- a/firmware/target/hosted/android/pcm-android.c +++ b/firmware/target/hosted/android/pcm-android.c | |||
@@ -35,7 +35,6 @@ static char *pcm_data_start; | |||
35 | static jmethodID play_pause_method; | 35 | static jmethodID play_pause_method; |
36 | static jmethodID stop_method; | 36 | static jmethodID stop_method; |
37 | static jmethodID set_volume_method; | 37 | static jmethodID set_volume_method; |
38 | static jclass RockboxPCM_class; | ||
39 | static jobject RockboxPCM_instance; | 38 | static jobject RockboxPCM_instance; |
40 | 39 | ||
41 | 40 | ||
@@ -155,10 +154,11 @@ void pcm_play_dma_init(void) | |||
155 | **/ | 154 | **/ |
156 | JNIEnv e = *env_ptr; | 155 | JNIEnv e = *env_ptr; |
157 | /* get the class and its constructor */ | 156 | /* get the class and its constructor */ |
158 | RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); | 157 | jclass RockboxPCM_class = e->FindClass(env_ptr, "org/rockbox/RockboxPCM"); |
159 | jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V"); | 158 | jmethodID constructor = e->GetMethodID(env_ptr, RockboxPCM_class, "<init>", "()V"); |
160 | /* instance = new RockboxPCM() */ | 159 | /* instance = new RockboxPCM() */ |
161 | RockboxPCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor); | 160 | jobject PCM_instance = e->NewObject(env_ptr, RockboxPCM_class, constructor); |
161 | RockboxPCM_instance = e->NewGlobalRef(env_ptr, PCM_instance); | ||
162 | /* cache needed methods */ | 162 | /* cache needed methods */ |
163 | play_pause_method = e->GetMethodID(env_ptr, RockboxPCM_class, "play_pause", "(Z)V"); | 163 | play_pause_method = e->GetMethodID(env_ptr, RockboxPCM_class, "play_pause", "(Z)V"); |
164 | set_volume_method = e->GetMethodID(env_ptr, RockboxPCM_class, "set_volume", "(I)V"); | 164 | set_volume_method = e->GetMethodID(env_ptr, RockboxPCM_class, "set_volume", "(I)V"); |
@@ -167,6 +167,11 @@ void pcm_play_dma_init(void) | |||
167 | pcm_play_get_more_callback((void*)&pcm_data_start, &pcm_data_size); | 167 | pcm_play_get_more_callback((void*)&pcm_data_start, &pcm_data_size); |
168 | } | 168 | } |
169 | 169 | ||
170 | void pcm_deinit(void) | ||
171 | { | ||
172 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxPCM_instance); | ||
173 | } | ||
174 | |||
170 | void pcm_postinit(void) | 175 | void pcm_postinit(void) |
171 | { | 176 | { |
172 | } | 177 | } |
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index 92c2d7cf5d..66de4e0ebb 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c | |||
@@ -36,10 +36,18 @@ uintptr_t *stackend; | |||
36 | 36 | ||
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); | ||
40 | extern void pcm_deinit(void); | ||
39 | 41 | ||
40 | void system_exception_wait(void) { } | 42 | void system_exception_wait(void) { } |
41 | void system_reboot(void) { } | 43 | void system_reboot(void) { } |
42 | void power_off(void) { } | 44 | |
45 | void power_off(void) | ||
46 | { | ||
47 | lcd_deinit(); | ||
48 | pcm_deinit(); | ||
49 | (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxService_class); | ||
50 | } | ||
43 | 51 | ||
44 | void system_init(void) | 52 | void system_init(void) |
45 | { | 53 | { |
@@ -51,18 +59,19 @@ void system_init(void) | |||
51 | JNIEXPORT void JNICALL | 59 | JNIEXPORT void JNICALL |
52 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | 60 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) |
53 | { | 61 | { |
62 | jclass class = (*env)->GetObjectClass(env, this); | ||
63 | |||
54 | /* hack!!! we can't have a valid stack pointer otherwise. | 64 | /* hack!!! we can't have a valid stack pointer otherwise. |
55 | * but we don't really need it anyway, thread.c only needs it | 65 | * but we don't really need it anyway, thread.c only needs it |
56 | * for overflow detection which doesn't apply for the main thread | 66 | * for overflow detection which doesn't apply for the main thread |
57 | * (it's managed by the OS) */ | 67 | * (it's managed by the OS) */ |
58 | 68 | ||
59 | (void)env; | ||
60 | (void)this; | ||
61 | volatile uintptr_t stack = 0; | 69 | volatile uintptr_t stack = 0; |
62 | stackbegin = stackend = (uintptr_t*) &stack; | 70 | stackbegin = stackend = (uintptr_t*) &stack; |
63 | env_ptr = env; | 71 | env_ptr = env; |
64 | RockboxService_instance = this; | 72 | |
65 | RockboxService_class = (*env)->GetObjectClass(env, this); | 73 | RockboxService_instance = (*env)->NewGlobalRef(env, this); |
74 | RockboxService_class = (*env)->NewGlobalRef(env, class); | ||
66 | 75 | ||
67 | main(); | 76 | main(); |
68 | } | 77 | } |