diff options
-rw-r--r-- | android/src/org/rockbox/RockboxKeyboardInput.java | 14 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxYesno.java | 35 | ||||
-rw-r--r-- | apps/hosted/keyboard.c | 66 | ||||
-rw-r--r-- | apps/hosted/yesno.c | 37 | ||||
-rw-r--r-- | firmware/export/config.h | 3 |
5 files changed, 74 insertions, 81 deletions
diff --git a/android/src/org/rockbox/RockboxKeyboardInput.java b/android/src/org/rockbox/RockboxKeyboardInput.java index 3024b6b685..210cbbd258 100644 --- a/android/src/org/rockbox/RockboxKeyboardInput.java +++ b/android/src/org/rockbox/RockboxKeyboardInput.java | |||
@@ -43,21 +43,13 @@ public class RockboxKeyboardInput | |||
43 | { | 43 | { |
44 | public void onComplete(int resultCode, Intent data) | 44 | public void onComplete(int resultCode, Intent data) |
45 | { | 45 | { |
46 | if (resultCode == Activity.RESULT_OK) | 46 | put_result(resultCode == Activity.RESULT_OK, |
47 | { | 47 | data.getStringExtra("value")); |
48 | result = data.getStringExtra("value"); | ||
49 | } | ||
50 | else { | ||
51 | result = ""; | ||
52 | } | ||
53 | } | 48 | } |
54 | }); | 49 | }); |
55 | } | 50 | } |
56 | public String get_result() | ||
57 | { | ||
58 | return result; | ||
59 | } | ||
60 | 51 | ||
52 | private native void put_result(boolean accepted, String new_string); | ||
61 | public boolean is_usable() | 53 | public boolean is_usable() |
62 | { | 54 | { |
63 | return RockboxService.get_instance().get_activity() != null; | 55 | return RockboxService.get_instance().get_activity() != null; |
diff --git a/android/src/org/rockbox/RockboxYesno.java b/android/src/org/rockbox/RockboxYesno.java index f6554715be..aa5e83d749 100644 --- a/android/src/org/rockbox/RockboxYesno.java +++ b/android/src/org/rockbox/RockboxYesno.java | |||
@@ -26,15 +26,8 @@ import android.content.Intent; | |||
26 | 26 | ||
27 | public class RockboxYesno | 27 | public class RockboxYesno |
28 | { | 28 | { |
29 | private boolean result; | 29 | @SuppressWarnings("unused") |
30 | private boolean have_result; | 30 | private void yesno_display(String text) |
31 | |||
32 | public RockboxYesno() | ||
33 | { | ||
34 | have_result = false; | ||
35 | } | ||
36 | |||
37 | public void yesno_display(String text) | ||
38 | { | 31 | { |
39 | RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity(); | 32 | RockboxActivity a = (RockboxActivity) RockboxService.get_instance().get_activity(); |
40 | Intent kbd = new Intent(a, YesnoActivity.class); | 33 | Intent kbd = new Intent(a, YesnoActivity.class); |
@@ -43,30 +36,16 @@ public class RockboxYesno | |||
43 | { | 36 | { |
44 | public void onComplete(int resultCode, Intent data) | 37 | public void onComplete(int resultCode, Intent data) |
45 | { | 38 | { |
46 | if (resultCode == Activity.RESULT_OK) | 39 | put_result(resultCode == Activity.RESULT_OK); |
47 | { | ||
48 | result = true; | ||
49 | have_result = true; | ||
50 | } | ||
51 | else { | ||
52 | result = false; | ||
53 | have_result = true; | ||
54 | } | ||
55 | } | 40 | } |
56 | }); | 41 | }); |
57 | } | 42 | } |
58 | 43 | ||
59 | public boolean result_ready() | 44 | @SuppressWarnings("unused") |
60 | { | 45 | private boolean is_usable() |
61 | return have_result; | ||
62 | } | ||
63 | public boolean get_result() | ||
64 | { | ||
65 | return result; | ||
66 | } | ||
67 | |||
68 | public boolean is_usable() | ||
69 | { | 46 | { |
70 | return RockboxService.get_instance().get_activity() != null; | 47 | return RockboxService.get_instance().get_activity() != null; |
71 | } | 48 | } |
49 | |||
50 | private native void put_result(boolean result); | ||
72 | } | 51 | } |
diff --git a/apps/hosted/keyboard.c b/apps/hosted/keyboard.c index 2b77825af0..6cc14d654f 100644 --- a/apps/hosted/keyboard.c +++ b/apps/hosted/keyboard.c | |||
@@ -23,21 +23,40 @@ | |||
23 | #if (CONFIG_PLATFORM&PLATFORM_ANDROID) | 23 | #if (CONFIG_PLATFORM&PLATFORM_ANDROID) |
24 | #include <jni.h> | 24 | #include <jni.h> |
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include <stdio.h> | 26 | #include "string-extra.h" |
27 | #include <string.h> | 27 | #include "kernel.h" |
28 | #include <system.h> | ||
29 | 28 | ||
30 | extern JNIEnv *env_ptr; | 29 | extern JNIEnv *env_ptr; |
31 | static jclass RockboxKeyboardInput_class; | 30 | static jclass RockboxKeyboardInput_class; |
32 | static jobject RockboxKeyboardInput_instance; | 31 | static jobject RockboxKeyboardInput_instance; |
33 | static jmethodID kbd_inputfunc, kbd_result; | 32 | static jmethodID kbd_inputfunc; |
33 | static struct wakeup kbd_wakeup; | ||
34 | static bool accepted; | ||
35 | static jstring new_string; | ||
36 | |||
37 | JNIEXPORT void JNICALL | ||
38 | Java_org_rockbox_RockboxKeyboardInput_put_1result(JNIEnv *env, jobject this, | ||
39 | jboolean _accepted, | ||
40 | jstring _new_string) | ||
41 | { | ||
42 | (void)env;(void)this; | ||
43 | |||
44 | accepted = (bool)_accepted; | ||
45 | if (accepted) | ||
46 | { | ||
47 | new_string = _new_string; | ||
48 | (*env)->NewGlobalRef(env, new_string); /* prevet GC'ing */ | ||
49 | } | ||
50 | wakeup_signal(&kbd_wakeup); | ||
51 | } | ||
34 | 52 | ||
35 | static void kdb_init(void) | 53 | static void kdb_init(void) |
36 | { | 54 | { |
37 | JNIEnv e = *env_ptr; | 55 | JNIEnv e = *env_ptr; |
38 | jmethodID kbd_is_usable; | 56 | static jmethodID kbd_is_usable; |
39 | if (RockboxKeyboardInput_class == NULL) | 57 | if (RockboxKeyboardInput_class == NULL) |
40 | { | 58 | { |
59 | wakeup_init(&kbd_wakeup); | ||
41 | /* get the class and its constructor */ | 60 | /* get the class and its constructor */ |
42 | RockboxKeyboardInput_class = e->FindClass(env_ptr, | 61 | RockboxKeyboardInput_class = e->FindClass(env_ptr, |
43 | "org/rockbox/RockboxKeyboardInput"); | 62 | "org/rockbox/RockboxKeyboardInput"); |
@@ -49,12 +68,11 @@ static void kdb_init(void) | |||
49 | constructor); | 68 | constructor); |
50 | kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, | 69 | kbd_inputfunc = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, |
51 | "kbd_input", "(Ljava/lang/String;)V"); | 70 | "kbd_input", "(Ljava/lang/String;)V"); |
52 | kbd_result = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, | 71 | kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, |
53 | "get_result", "()Ljava/lang/String;"); | 72 | "is_usable", "()Z"); |
54 | } | 73 | } |
74 | |||
55 | /* need to get it every time incase the activity died/restarted */ | 75 | /* need to get it every time incase the activity died/restarted */ |
56 | kbd_is_usable = e->GetMethodID(env_ptr, RockboxKeyboardInput_class, | ||
57 | "is_usable", "()Z"); | ||
58 | while (!e->CallBooleanMethod(env_ptr, RockboxKeyboardInput_instance, | 76 | while (!e->CallBooleanMethod(env_ptr, RockboxKeyboardInput_instance, |
59 | kbd_is_usable)) | 77 | kbd_is_usable)) |
60 | sleep(HZ/10); | 78 | sleep(HZ/10); |
@@ -64,24 +82,22 @@ int kbd_input(char* text, int buflen) | |||
64 | { | 82 | { |
65 | JNIEnv e = *env_ptr; | 83 | JNIEnv e = *env_ptr; |
66 | jstring str = e->NewStringUTF(env_ptr, text); | 84 | jstring str = e->NewStringUTF(env_ptr, text); |
67 | jobject ret; | 85 | const char *utf8_string; |
68 | const char* retchars; | ||
69 | kdb_init(); | 86 | kdb_init(); |
70 | 87 | ||
71 | e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance,kbd_inputfunc,str); | 88 | e->CallVoidMethod(env_ptr, RockboxKeyboardInput_instance,kbd_inputfunc,str); |
72 | 89 | ||
73 | do { | 90 | wakeup_wait(&kbd_wakeup, TIMEOUT_BLOCK); |
74 | sleep(HZ/10); | 91 | |
75 | ret = e->CallObjectMethod(env_ptr, RockboxKeyboardInput_instance, | 92 | if (accepted) |
76 | kbd_result); | 93 | { |
77 | } while (!ret); | 94 | utf8_string = e->GetStringUTFChars(env_ptr, new_string, 0); |
78 | 95 | strlcpy(text, utf8_string, buflen); | |
79 | retchars = e->GetStringUTFChars(env_ptr, ret, 0); | 96 | e->ReleaseStringUTFChars(env_ptr, new_string, utf8_string); |
80 | if (retchars[0]) | 97 | e->DeleteGlobalRef(env_ptr, new_string); |
81 | strncpy(text, retchars, buflen); | 98 | } |
82 | e->ReleaseStringUTFChars(env_ptr, ret, retchars); | ||
83 | 99 | ||
84 | return text[0] ? 0 : 1; /* return 0 on success */ | 100 | return !accepted; /* return 0 on success */ |
85 | } | 101 | } |
86 | 102 | ||
87 | int load_kbd(unsigned char* filename) | 103 | int load_kbd(unsigned char* filename) |
diff --git a/apps/hosted/yesno.c b/apps/hosted/yesno.c index 9858e66438..2a8c02edd5 100644 --- a/apps/hosted/yesno.c +++ b/apps/hosted/yesno.c | |||
@@ -24,22 +24,34 @@ | |||
24 | #include <jni.h> | 24 | #include <jni.h> |
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include <stdio.h> | 26 | #include <stdio.h> |
27 | #include <system.h> | ||
28 | #include "yesno.h" | 27 | #include "yesno.h" |
29 | #include "settings.h" | 28 | #include "settings.h" |
30 | #include "lang.h" | 29 | #include "lang.h" |
30 | #include "kernel.h" | ||
31 | 31 | ||
32 | extern JNIEnv *env_ptr; | 32 | extern JNIEnv *env_ptr; |
33 | static jclass RockboxYesno_class = NULL; | 33 | static jclass RockboxYesno_class = NULL; |
34 | static jobject RockboxYesno_instance = NULL; | 34 | static jobject RockboxYesno_instance = NULL; |
35 | static jmethodID yesno_func, result_ready, yesno_result; | 35 | static jmethodID yesno_func; |
36 | static struct wakeup yesno_wakeup; | ||
37 | static bool ret; | ||
38 | |||
39 | JNIEXPORT void JNICALL | ||
40 | Java_org_rockbox_RockboxYesno_put_1result(JNIEnv *env, jobject this, jboolean result) | ||
41 | { | ||
42 | (void)env; | ||
43 | (void)this; | ||
44 | ret = (bool)result; | ||
45 | wakeup_signal(&yesno_wakeup); | ||
46 | } | ||
36 | 47 | ||
37 | static void yesno_init(void) | 48 | static void yesno_init(void) |
38 | { | 49 | { |
39 | JNIEnv e = *env_ptr; | 50 | JNIEnv e = *env_ptr; |
40 | jmethodID yesno_is_usable; | 51 | static jmethodID yesno_is_usable; |
41 | if (RockboxYesno_class == NULL) | 52 | if (RockboxYesno_class == NULL) |
42 | { | 53 | { |
54 | wakeup_init(&yesno_wakeup); | ||
43 | /* get the class and its constructor */ | 55 | /* get the class and its constructor */ |
44 | RockboxYesno_class = e->FindClass(env_ptr, | 56 | RockboxYesno_class = e->FindClass(env_ptr, |
45 | "org/rockbox/RockboxYesno"); | 57 | "org/rockbox/RockboxYesno"); |
@@ -51,14 +63,10 @@ static void yesno_init(void) | |||
51 | constructor); | 63 | constructor); |
52 | yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class, | 64 | yesno_func = e->GetMethodID(env_ptr, RockboxYesno_class, |
53 | "yesno_display", "(Ljava/lang/String;)V"); | 65 | "yesno_display", "(Ljava/lang/String;)V"); |
54 | yesno_result = e->GetMethodID(env_ptr, RockboxYesno_class, | 66 | yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class, |
55 | "get_result", "()Z"); | 67 | "is_usable", "()Z"); |
56 | result_ready = e->GetMethodID(env_ptr, RockboxYesno_class, | ||
57 | "result_ready", "()Z"); | ||
58 | } | 68 | } |
59 | /* need to get it every time incase the activity died/restarted */ | 69 | /* need to get it every time incase the activity died/restarted */ |
60 | yesno_is_usable = e->GetMethodID(env_ptr, RockboxYesno_class, | ||
61 | "is_usable", "()Z"); | ||
62 | while (!e->CallBooleanMethod(env_ptr, RockboxYesno_instance, | 70 | while (!e->CallBooleanMethod(env_ptr, RockboxYesno_instance, |
63 | yesno_is_usable)) | 71 | yesno_is_usable)) |
64 | sleep(HZ/10); | 72 | sleep(HZ/10); |
@@ -92,16 +100,13 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, | |||
92 | 100 | ||
93 | JNIEnv e = *env_ptr; | 101 | JNIEnv e = *env_ptr; |
94 | jstring message = build_message(main_message); | 102 | jstring message = build_message(main_message); |
95 | jboolean ret; | ||
96 | 103 | ||
97 | e->CallVoidMethod(env_ptr, RockboxYesno_instance, yesno_func, message); | 104 | e->CallVoidMethod(env_ptr, RockboxYesno_instance, yesno_func, message); |
98 | |||
99 | do { | ||
100 | sleep(HZ/10); | ||
101 | ret = e->CallBooleanMethod(env_ptr, RockboxYesno_instance, result_ready); | ||
102 | } while (!ret); | ||
103 | 105 | ||
104 | ret = e->CallBooleanMethod(env_ptr, RockboxYesno_instance, yesno_result); | 106 | wakeup_wait(&yesno_wakeup, TIMEOUT_BLOCK); |
107 | |||
108 | e->DeleteLocalRef(env_ptr, message); | ||
109 | |||
105 | return ret ? YESNO_YES : YESNO_NO; | 110 | return ret ? YESNO_YES : YESNO_NO; |
106 | } | 111 | } |
107 | 112 | ||
diff --git a/firmware/export/config.h b/firmware/export/config.h index d005aae976..3a7328315b 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -721,7 +721,8 @@ Lyre prototype 1 */ | |||
721 | 721 | ||
722 | #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ | 722 | #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ |
723 | || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) \ | 723 | || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) \ |
724 | || defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) | 724 | || defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) \ |
725 | || defined(APPLICATION) | ||
725 | #define HAVE_WAKEUP_OBJECTS | 726 | #define HAVE_WAKEUP_OBJECTS |
726 | #endif | 727 | #endif |
727 | 728 | ||