diff options
author | Thomas Martitz <kugel@rockbox.org> | 2014-03-09 18:08:06 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-03-09 18:11:35 +0100 |
commit | 6499ce3e445e1acc5f5707fd164ad5e3c5ab0a43 (patch) | |
tree | 3e1cb19678e5ce9bfd5681d944193ede902805b6 /firmware/target | |
parent | 2a71c0853304b68835fcf87d2bae8295d64abd6c (diff) | |
download | rockbox-6499ce3e445e1acc5f5707fd164ad5e3c5ab0a43.tar.gz rockbox-6499ce3e445e1acc5f5707fd164ad5e3c5ab0a43.zip |
android: Get the port up and running again
The build system needed fixes because the tools paths changed and one tool that
we used (apkbuilder) was removed entirely. Recent NDKs don't ship gcc 4.4.3
anymore, therefore switch to 4.6. The code itself needed a fix for a jni
reference bug that was uncovered by KitKat.
The port now builds with latest sdk (r22) and ndk (r9d).
Change-Id: Id74fa54ba93bbb0ee30373fbe79e92c5ff03201d
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/hosted/android/lcd-android.c | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c index 2b383741d1..a161406cc0 100644 --- a/firmware/target/hosted/android/lcd-android.c +++ b/firmware/target/hosted/android/lcd-android.c | |||
@@ -34,7 +34,6 @@ extern jobject RockboxService_instance; | |||
34 | static jobject RockboxFramebuffer_instance; | 34 | static jobject RockboxFramebuffer_instance; |
35 | static jmethodID java_lcd_update; | 35 | static jmethodID java_lcd_update; |
36 | static jmethodID java_lcd_update_rect; | 36 | static jmethodID java_lcd_update_rect; |
37 | static jmethodID java_lcd_init; | ||
38 | 37 | ||
39 | static jclass AndroidRect_class; | 38 | static jclass AndroidRect_class; |
40 | static jmethodID AndroidRect_constructor; | 39 | static jmethodID AndroidRect_constructor; |
@@ -42,6 +41,7 @@ static jmethodID AndroidRect_constructor; | |||
42 | static int dpi; | 41 | static int dpi; |
43 | static int scroll_threshold; | 42 | static int scroll_threshold; |
44 | static bool display_on; | 43 | static bool display_on; |
44 | static bool connected; | ||
45 | 45 | ||
46 | /* this might actually be called before lcd_init_device() or even main(), so | 46 | /* this might actually be called before lcd_init_device() or even main(), so |
47 | * be sure to only access static storage initalized at library loading, | 47 | * be sure to only access static storage initalized at library loading, |
@@ -49,38 +49,26 @@ static bool display_on; | |||
49 | static void connect_with_java(JNIEnv* env, jobject fb_instance) | 49 | static void connect_with_java(JNIEnv* env, jobject fb_instance) |
50 | { | 50 | { |
51 | JNIEnv e = *env; | 51 | JNIEnv e = *env; |
52 | static bool have_class; | ||
53 | 52 | ||
54 | if (!have_class) | 53 | jclass fb_class = e->GetObjectClass(env, fb_instance); |
55 | { | 54 | /* cache update functions */ |
56 | jclass fb_class = e->GetObjectClass(env, fb_instance); | 55 | java_lcd_update = e->GetMethodID(env, fb_class, |
57 | /* cache update functions */ | 56 | "update", |
58 | java_lcd_update = e->GetMethodID(env, fb_class, | 57 | "(Ljava/nio/ByteBuffer;)V"); |
59 | "update", | 58 | java_lcd_update_rect = e->GetMethodID(env, fb_class, |
60 | "(Ljava/nio/ByteBuffer;)V"); | 59 | "update", |
61 | java_lcd_update_rect = e->GetMethodID(env, fb_class, | 60 | "(Ljava/nio/ByteBuffer;" |
62 | "update", | 61 | "Landroid/graphics/Rect;)V"); |
63 | "(Ljava/nio/ByteBuffer;" | 62 | jmethodID get_dpi = e->GetMethodID(env, fb_class, |
64 | "Landroid/graphics/Rect;)V"); | 63 | "getDpi", "()I"); |
65 | jmethodID get_dpi = e->GetMethodID(env, fb_class, | 64 | jmethodID thresh = e->GetMethodID(env, fb_class, |
66 | "getDpi", "()I"); | 65 | "getScrollThreshold", "()I"); |
67 | jmethodID thresh = e->GetMethodID(env, fb_class, | 66 | /* these don't change with new instances so call them now */ |
68 | "getScrollThreshold", "()I"); | 67 | dpi = e->CallIntMethod(env, fb_instance, get_dpi); |
69 | /* these don't change with new instances so call them now */ | 68 | scroll_threshold = e->CallIntMethod(env, fb_instance, thresh); |
70 | dpi = e->CallIntMethod(env, fb_instance, get_dpi); | 69 | |
71 | scroll_threshold = e->CallIntMethod(env, fb_instance, thresh); | 70 | AndroidRect_constructor = e->GetMethodID(env, AndroidRect_class, |
72 | 71 | "<init>", "(IIII)V"); | |
73 | java_lcd_init = e->GetMethodID(env, fb_class, | ||
74 | "initialize", "(II)V"); | ||
75 | AndroidRect_class = e->FindClass(env, "android/graphics/Rect"); | ||
76 | AndroidRect_constructor = e->GetMethodID(env, AndroidRect_class, | ||
77 | "<init>", "(IIII)V"); | ||
78 | have_class = true; | ||
79 | } | ||
80 | |||
81 | /* we need to setup parts for the java object every time */ | ||
82 | (*env)->CallVoidMethod(env, fb_instance, java_lcd_init, | ||
83 | (jint)LCD_WIDTH, (jint)LCD_HEIGHT); | ||
84 | } | 72 | } |
85 | 73 | ||
86 | /* | 74 | /* |
@@ -132,12 +120,18 @@ Java_org_rockbox_RockboxFramebuffer_surfaceCreated(JNIEnv *env, jobject this, | |||
132 | jobject surfaceholder) | 120 | jobject surfaceholder) |
133 | { | 121 | { |
134 | (void)surfaceholder; | 122 | (void)surfaceholder; |
123 | jclass rect; | ||
135 | 124 | ||
136 | /* Update RockboxFramebuffer_instance */ | 125 | /* Update RockboxFramebuffer_instance */ |
137 | RockboxFramebuffer_instance = (*env)->NewGlobalRef(env, this); | 126 | RockboxFramebuffer_instance = (*env)->NewGlobalRef(env, this); |
138 | 127 | rect = (*env)->FindClass(env, "android/graphics/Rect"); | |
128 | AndroidRect_class = (*env)->NewGlobalRef(env, rect); | ||
139 | /* possibly a new instance - reconnect */ | 129 | /* possibly a new instance - reconnect */ |
140 | connect_with_java(env, this); | 130 | if (!connected) |
131 | { | ||
132 | connect_with_java(env, this); | ||
133 | connected = true; | ||
134 | } | ||
141 | display_on = true; | 135 | display_on = true; |
142 | 136 | ||
143 | /* need to wait for button_queue to be valid to post to */ | 137 | /* need to wait for button_queue to be valid to post to */ |
@@ -163,6 +157,8 @@ Java_org_rockbox_RockboxFramebuffer_surfaceDestroyed(JNIEnv *e, jobject this, | |||
163 | 157 | ||
164 | (*e)->DeleteGlobalRef(e, RockboxFramebuffer_instance); | 158 | (*e)->DeleteGlobalRef(e, RockboxFramebuffer_instance); |
165 | RockboxFramebuffer_instance = NULL; | 159 | RockboxFramebuffer_instance = NULL; |
160 | (*e)->DeleteGlobalRef(e, AndroidRect_class); | ||
161 | AndroidRect_class = NULL; | ||
166 | } | 162 | } |
167 | 163 | ||
168 | bool lcd_active(void) | 164 | bool lcd_active(void) |