From 2e5b7aebde6426058ea7b69424b0335a844a6a18 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 11 Mar 2011 18:34:31 +0000 Subject: Android: use NewGlobalRef for references that are used globally git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29568 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/hosted/android/system-android.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'firmware/target/hosted/android/system-android.c') diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index 92c2d7c..66de4e0 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c @@ -36,10 +36,18 @@ uintptr_t *stackend; extern int main(void); extern void telephony_init_device(void); +extern void lcd_deinit(void); +extern void pcm_deinit(void); void system_exception_wait(void) { } void system_reboot(void) { } -void power_off(void) { } + +void power_off(void) +{ + lcd_deinit(); + pcm_deinit(); + (*env_ptr)->DeleteGlobalRef(env_ptr, RockboxService_class); +} void system_init(void) { @@ -51,18 +59,19 @@ void system_init(void) JNIEXPORT void JNICALL Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) { + jclass class = (*env)->GetObjectClass(env, this); + /* hack!!! we can't have a valid stack pointer otherwise. * but we don't really need it anyway, thread.c only needs it * for overflow detection which doesn't apply for the main thread * (it's managed by the OS) */ - (void)env; - (void)this; volatile uintptr_t stack = 0; stackbegin = stackend = (uintptr_t*) &stack; env_ptr = env; - RockboxService_instance = this; - RockboxService_class = (*env)->GetObjectClass(env, this); + + RockboxService_instance = (*env)->NewGlobalRef(env, this); + RockboxService_class = (*env)->NewGlobalRef(env, class); main(); } -- cgit v1.1