summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2011-03-11 18:34:31 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2011-03-11 18:34:31 +0000
commit2e5b7aebde6426058ea7b69424b0335a844a6a18 (patch)
tree2ce54c30eb646b1d78d38ff34ff3eb3f76955bff /apps
parent7228f2fa9faf587bab51f2e3c1727b7ca962b441 (diff)
downloadrockbox-2e5b7aebde6426058ea7b69424b0335a844a6a18.tar.gz
rockbox-2e5b7aebde6426058ea7b69424b0335a844a6a18.tar.bz2
rockbox-2e5b7aebde6426058ea7b69424b0335a844a6a18.zip
Android: use NewGlobalRef for references that are used globally
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29568 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/hosted/android/keyboard.c11
-rw-r--r--apps/hosted/android/notification.c7
-rw-r--r--apps/hosted/android/yesno.c20
3 files changed, 21 insertions, 17 deletions
diff --git a/apps/hosted/android/keyboard.c b/apps/hosted/android/keyboard.c
index 9407d970fd..7c16cff079 100644
--- a/apps/hosted/android/keyboard.c
+++ b/apps/hosted/android/keyboard.c
@@ -59,14 +59,17 @@ static void kdb_init(void)
{
semaphore_init(&kbd_wakeup, 1, 0);
/* get the class and its constructor */
- RockboxKeyboardInput_class = e->FindClass(env_ptr,
+ jclass kbInput_class = e->FindClass(env_ptr,
"org/rockbox/RockboxKeyboardInput");
+ RockboxKeyboardInput_class = e->NewGlobalRef(env_ptr, kbInput_class);
jmethodID constructor = e->GetMethodID(env_ptr,
RockboxKeyboardInput_class,
"<init>", "()V");
- RockboxKeyboardInput_instance = e->NewObject(env_ptr,
- RockboxKeyboardInput_class,
- constructor);
+ jobject kbInput_instance = e->NewObject(env_ptr,
+ RockboxKeyboardInput_class,
+ constructor);
+ RockboxKeyboardInput_instance = e->NewGlobalRef(env_ptr,
+ kbInput_instance);
kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class,
"kbd_input",
"(Ljava/lang/String;"
diff --git a/apps/hosted/android/notification.c b/apps/hosted/android/notification.c
index 443200698c..33a7717012 100644
--- a/apps/hosted/android/notification.c
+++ b/apps/hosted/android/notification.c
@@ -125,13 +125,14 @@ void notification_init(void)
JNIEnv e = *env_ptr;
jfieldID nNM = e->GetFieldID(env_ptr, RockboxService_class,
"fg_runner", "Lorg/rockbox/Helper/RunForegroundManager;");
- NotificationManager_instance = e->GetObjectField(env_ptr,
- RockboxService_instance, nNM);
- if (NotificationManager_instance == NULL)
+ jobject nMN_instance = e->GetObjectField(env_ptr,
+ RockboxService_instance, nNM);
+ if (nMN_instance == NULL)
{
DEBUGF("Failed to get RunForegroundManager instance. Performance will be bad");
return;
}
+ NotificationManager_instance = e->NewGlobalRef(env_ptr, nMN_instance);
jclass class = e->GetObjectClass(env_ptr, NotificationManager_instance);
updateNotification = e->GetMethodID(env_ptr, class, "updateNotification",
diff --git a/apps/hosted/android/yesno.c b/apps/hosted/android/yesno.c
index a1de64e3f9..7aca3f7f79 100644
--- a/apps/hosted/android/yesno.c
+++ b/apps/hosted/android/yesno.c
@@ -30,7 +30,6 @@
#include "kernel.h"
extern JNIEnv *env_ptr;
-static jclass RockboxYesno_class = NULL;
static jobject RockboxYesno_instance = NULL;
static jmethodID yesno_func;
static struct semaphore yesno_done;
@@ -49,24 +48,25 @@ static void yesno_init(void)
{
JNIEnv e = *env_ptr;
static jmethodID yesno_is_usable;
- if (RockboxYesno_class == NULL)
+ if (RockboxYesno_instance == NULL)
{
semaphore_init(&yesno_done, 1, 0);
/* get the class and its constructor */
- RockboxYesno_class = e->FindClass(env_ptr,
- "org/rockbox/RockboxYesno");
+ jclass yesno_class = e->FindClass(env_ptr,
+ "org/rockbox/RockboxYesno");
jmethodID constructor = e->GetMethodID(env_ptr,
- RockboxYesno_class,
+ yesno_class,
"<init>", "()V");
- RockboxYesno_instance = e->NewObject(env_ptr,
- RockboxYesno_class,
- constructor);
- yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class,
+ jobject yesno_instance = e->NewObject(env_ptr,
+ yesno_class,
+ constructor);
+ RockboxYesno_instance = e->NewGlobalRef(env_ptr, yesno_instance);
+ yesno_func = e->GetMethodID(env_ptr, yesno_class,
"yesno_display",
"(Ljava/lang/String;"
"Ljava/lang/String;"
"Ljava/lang/String;)V");
- yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class,
+ yesno_is_usable = e->GetMethodID(env_ptr, yesno_class,
"is_usable", "()Z");
}
/* need to get it every time incase the activity died/restarted */