summaryrefslogtreecommitdiff
path: root/apps/hosted
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2011-03-11 18:34:35 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2011-03-11 18:34:35 +0000
commit66f2a08f8a37933b9eff79ceabdc2cb42706e48c (patch)
tree704cd88300e33a99335adf1d5e3e4ff6b71a2aed /apps/hosted
parent2e5b7aebde6426058ea7b69424b0335a844a6a18 (diff)
downloadrockbox-66f2a08f8a37933b9eff79ceabdc2cb42706e48c.tar.gz
rockbox-66f2a08f8a37933b9eff79ceabdc2cb42706e48c.zip
Android: Don't share the JNI environment across threads, but obtain it the
correct way git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29569 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/hosted')
-rw-r--r--apps/hosted/android/keyboard.c5
-rw-r--r--apps/hosted/android/notification.c5
-rw-r--r--apps/hosted/android/yesno.c14
3 files changed, 16 insertions, 8 deletions
diff --git a/apps/hosted/android/keyboard.c b/apps/hosted/android/keyboard.c
index 7c16cff079..460011c4f7 100644
--- a/apps/hosted/android/keyboard.c
+++ b/apps/hosted/android/keyboard.c
@@ -26,8 +26,8 @@
26#include "string-extra.h" 26#include "string-extra.h"
27#include "kernel.h" 27#include "kernel.h"
28#include "lang.h" 28#include "lang.h"
29#include "system.h"
29 30
30extern JNIEnv *env_ptr;
31static jclass RockboxKeyboardInput_class; 31static jclass RockboxKeyboardInput_class;
32static jobject RockboxKeyboardInput_instance; 32static jobject RockboxKeyboardInput_instance;
33static jmethodID kbd_inputfunc; 33static jmethodID kbd_inputfunc;
@@ -53,7 +53,9 @@ Java_org_rockbox_RockboxKeyboardInput_put_1result(JNIEnv *env, jobject this,
53 53
54static void kdb_init(void) 54static void kdb_init(void)
55{ 55{
56 JNIEnv *env_ptr = getJavaEnvironment();
56 JNIEnv e = *env_ptr; 57 JNIEnv e = *env_ptr;
58
57 static jmethodID kbd_is_usable; 59 static jmethodID kbd_is_usable;
58 if (RockboxKeyboardInput_class == NULL) 60 if (RockboxKeyboardInput_class == NULL)
59 { 61 {
@@ -87,6 +89,7 @@ static void kdb_init(void)
87 89
88int kbd_input(char* text, int buflen) 90int kbd_input(char* text, int buflen)
89{ 91{
92 JNIEnv *env_ptr = getJavaEnvironment();
90 JNIEnv e = *env_ptr; 93 JNIEnv e = *env_ptr;
91 jstring str = e->NewStringUTF(env_ptr, text); 94 jstring str = e->NewStringUTF(env_ptr, text);
92 jstring ok_text = e->NewStringUTF(env_ptr, str(LANG_KBD_OK)); 95 jstring ok_text = e->NewStringUTF(env_ptr, str(LANG_KBD_OK));
diff --git a/apps/hosted/android/notification.c b/apps/hosted/android/notification.c
index 33a7717012..1c89c51357 100644
--- a/apps/hosted/android/notification.c
+++ b/apps/hosted/android/notification.c
@@ -29,8 +29,8 @@
29#include "misc.h" 29#include "misc.h"
30#include "thread.h" 30#include "thread.h"
31#include "debug.h" 31#include "debug.h"
32#include "system.h"
32 33
33extern JNIEnv *env_ptr;
34extern jclass RockboxService_class; 34extern jclass RockboxService_class;
35extern jobject RockboxService_instance; 35extern jobject RockboxService_instance;
36 36
@@ -47,6 +47,7 @@ static const struct dim dim = { .width = 200, .height = 200 };
47static void track_changed_callback(void *param) 47static void track_changed_callback(void *param)
48{ 48{
49 struct mp3entry* id3 = (struct mp3entry*)param; 49 struct mp3entry* id3 = (struct mp3entry*)param;
50 JNIEnv *env_ptr = getJavaEnvironment();
50 JNIEnv e = *env_ptr; 51 JNIEnv e = *env_ptr;
51 if (id3) 52 if (id3)
52 { 53 {
@@ -109,6 +110,7 @@ static void track_changed_callback(void *param)
109static void track_finished_callback(void *param) 110static void track_finished_callback(void *param)
110{ 111{
111 (void)param; 112 (void)param;
113 JNIEnv *env_ptr = getJavaEnvironment();
112 JNIEnv e = *env_ptr; 114 JNIEnv e = *env_ptr;
113 e->CallVoidMethod(env_ptr, NotificationManager_instance, 115 e->CallVoidMethod(env_ptr, NotificationManager_instance,
114 finishNotification); 116 finishNotification);
@@ -122,6 +124,7 @@ static void track_finished_callback(void *param)
122 124
123void notification_init(void) 125void notification_init(void)
124{ 126{
127 JNIEnv *env_ptr = getJavaEnvironment();
125 JNIEnv e = *env_ptr; 128 JNIEnv e = *env_ptr;
126 jfieldID nNM = e->GetFieldID(env_ptr, RockboxService_class, 129 jfieldID nNM = e->GetFieldID(env_ptr, RockboxService_class,
127 "fg_runner", "Lorg/rockbox/Helper/RunForegroundManager;"); 130 "fg_runner", "Lorg/rockbox/Helper/RunForegroundManager;");
diff --git a/apps/hosted/android/yesno.c b/apps/hosted/android/yesno.c
index 7aca3f7f79..de6ec99a3c 100644
--- a/apps/hosted/android/yesno.c
+++ b/apps/hosted/android/yesno.c
@@ -28,8 +28,8 @@
28#include "settings.h" 28#include "settings.h"
29#include "lang.h" 29#include "lang.h"
30#include "kernel.h" 30#include "kernel.h"
31#include "system.h"
31 32
32extern JNIEnv *env_ptr;
33static jobject RockboxYesno_instance = NULL; 33static jobject RockboxYesno_instance = NULL;
34static jmethodID yesno_func; 34static jmethodID yesno_func;
35static struct semaphore yesno_done; 35static struct semaphore yesno_done;
@@ -44,7 +44,7 @@ Java_org_rockbox_RockboxYesno_put_1result(JNIEnv *env, jobject this, jboolean re
44 semaphore_release(&yesno_done); 44 semaphore_release(&yesno_done);
45} 45}
46 46
47static void yesno_init(void) 47static void yesno_init(JNIEnv *env_ptr)
48{ 48{
49 JNIEnv e = *env_ptr; 49 JNIEnv e = *env_ptr;
50 static jmethodID yesno_is_usable; 50 static jmethodID yesno_is_usable;
@@ -75,7 +75,7 @@ static void yesno_init(void)
75 sleep(HZ/10); 75 sleep(HZ/10);
76} 76}
77 77
78jstring build_message(const struct text_message *message) 78static jstring build_message(JNIEnv *env_ptr, const struct text_message *message)
79{ 79{
80 char msg[1024] = ""; 80 char msg[1024] = "";
81 JNIEnv e = *env_ptr; 81 JNIEnv e = *env_ptr;
@@ -99,10 +99,12 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message,
99{ 99{
100 (void)yes_message; 100 (void)yes_message;
101 (void)no_message; 101 (void)no_message;
102 yesno_init(); 102 JNIEnv *env_ptr = getJavaEnvironment();
103 103
104 yesno_init(env_ptr);
105
104 JNIEnv e = *env_ptr; 106 JNIEnv e = *env_ptr;
105 jstring message = build_message(main_message); 107 jstring message = build_message(env_ptr, main_message);
106 jstring yes = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_YES)); 108 jstring yes = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_YES));
107 jstring no = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_NO)); 109 jstring no = (*env_ptr)->NewStringUTF(env_ptr, str(LANG_SET_BOOL_NO));
108 110