summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/src/org/rockbox/RockboxActivity.java4
-rw-r--r--android/src/org/rockbox/RockboxFramebuffer.java21
-rw-r--r--android/src/org/rockbox/RockboxPCM.java3
-rw-r--r--android/src/org/rockbox/RockboxService.java6
-rw-r--r--firmware/target/hosted/android/lcd-android.c78
5 files changed, 56 insertions, 56 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java
index e50ff59df3..b4ca9a6d2a 100644
--- a/android/src/org/rockbox/RockboxActivity.java
+++ b/android/src/org/rockbox/RockboxActivity.java
@@ -52,7 +52,7 @@ public class RockboxActivity extends Activity
52 /* Now it gets a bit tricky: 52 /* Now it gets a bit tricky:
53 * The service is started in the same thread as we are now, 53 * The service is started in the same thread as we are now,
54 * but the service also initializes the framebuffer 54 * but the service also initializes the framebuffer
55 * Unforunately, this happens *after* any of the default 55 * Unfortunately, this happens *after* any of the default
56 * startup methods of an activity, so we need to poll for it 56 * startup methods of an activity, so we need to poll for it
57 * 57 *
58 * In order to get the fb, we need to let the Service start up 58 * In order to get the fb, we need to let the Service start up
@@ -71,7 +71,7 @@ public class RockboxActivity extends Activity
71 } 71 }
72 /* drawing needs to happen in ui thread */ 72 /* drawing needs to happen in ui thread */
73 runOnUiThread(new Runnable() 73 runOnUiThread(new Runnable()
74 { @Override 74 {
75 public void run() { 75 public void run() {
76 loadingdialog.dismiss(); 76 loadingdialog.dismiss();
77 setContentView(RockboxService.fb); 77 setContentView(RockboxService.fb);
diff --git a/android/src/org/rockbox/RockboxFramebuffer.java b/android/src/org/rockbox/RockboxFramebuffer.java
index 070ef5cbc9..e90eb86dbd 100644
--- a/android/src/org/rockbox/RockboxFramebuffer.java
+++ b/android/src/org/rockbox/RockboxFramebuffer.java
@@ -36,37 +36,34 @@ public class RockboxFramebuffer extends View
36 private Bitmap btm; 36 private Bitmap btm;
37 private ByteBuffer native_buf; 37 private ByteBuffer native_buf;
38 38
39 public RockboxFramebuffer(Context c) 39 public RockboxFramebuffer(Context c, int lcd_width,
40 int lcd_height, ByteBuffer native_fb)
40 { 41 {
41 super(c); 42 super(c);
42 btm = null;
43 43
44 /* Needed so we can catch KeyEvents */ 44 /* Needed so we can catch KeyEvents */
45 setFocusable(true); 45 setFocusable(true);
46 setFocusableInTouchMode(true); 46 setFocusableInTouchMode(true);
47 setClickable(true); 47 setClickable(true);
48 btm = Bitmap.createBitmap(lcd_width, lcd_height, Bitmap.Config.RGB_565);
49 native_buf = native_fb;
48 requestFocus(); 50 requestFocus();
49 } 51 }
50 52
51 public void onDraw(Canvas c) 53 public void onDraw(Canvas c)
52 { 54 {
53 if (btm != null) 55 c.drawBitmap(btm, 0.0f, 0.0f, null);
54 c.drawBitmap(btm, 0.0f, 0.0f, null);
55 } 56 }
56 57
57 public void java_lcd_init(int lcd_width, int lcd_height, ByteBuffer native_fb) 58 @SuppressWarnings("unused")
58 { 59 private void java_lcd_update()
59 btm = Bitmap.createBitmap(lcd_width, lcd_height, Bitmap.Config.RGB_565);
60 native_buf = native_fb;
61 }
62
63 public void java_lcd_update()
64 { 60 {
65 btm.copyPixelsFromBuffer(native_buf); 61 btm.copyPixelsFromBuffer(native_buf);
66 postInvalidate(); 62 postInvalidate();
67 } 63 }
68 64
69 public void java_lcd_update_rect(int x, int y, int w, int h) 65 @SuppressWarnings("unused")
66 private void java_lcd_update_rect(int x, int y, int w, int h)
70 { 67 {
71 /* can't copy a partial buffer */ 68 /* can't copy a partial buffer */
72 btm.copyPixelsFromBuffer(native_buf); 69 btm.copyPixelsFromBuffer(native_buf);
diff --git a/android/src/org/rockbox/RockboxPCM.java b/android/src/org/rockbox/RockboxPCM.java
index a3d09a43eb..46bdd121f0 100644
--- a/android/src/org/rockbox/RockboxPCM.java
+++ b/android/src/org/rockbox/RockboxPCM.java
@@ -148,7 +148,7 @@ public class RockboxPCM extends AudioTrack
148 buf = new byte[max_len*3/4]; 148 buf = new byte[max_len*3/4];
149 refill_mark = max_len - buf.length; 149 refill_mark = max_len - buf.length;
150 } 150 }
151 @Override 151
152 public void onMarkerReached(AudioTrack track) 152 public void onMarkerReached(AudioTrack track)
153 { 153 {
154 /* push new data to the hardware */ 154 /* push new data to the hardware */
@@ -186,7 +186,6 @@ public class RockboxPCM extends AudioTrack
186 } 186 }
187 } 187 }
188 188
189 @Override
190 public void onPeriodicNotification(AudioTrack track) 189 public void onPeriodicNotification(AudioTrack track)
191 { 190 {
192 } 191 }
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java
index 964404c745..be02342768 100644
--- a/android/src/org/rockbox/RockboxService.java
+++ b/android/src/org/rockbox/RockboxService.java
@@ -64,6 +64,7 @@ public class RockboxService extends Service
64 private Object[] mStopForegroundArgs = new Object[1]; 64 private Object[] mStopForegroundArgs = new Object[1];
65 private IntentFilter itf; 65 private IntentFilter itf;
66 private BroadcastReceiver batt_monitor; 66 private BroadcastReceiver batt_monitor;
67 @SuppressWarnings("unused")
67 private int battery_level; 68 private int battery_level;
68 69
69 @Override 70 @Override
@@ -118,7 +119,6 @@ public class RockboxService extends Service
118 private void startservice() 119 private void startservice()
119 { 120 {
120 final int BUFFER = 8*1024; 121 final int BUFFER = 8*1024;
121 final Context me = this;
122 Thread rb = new Thread(new Runnable() 122 Thread rb = new Thread(new Runnable()
123 { 123 {
124 public void run() 124 public void run()
@@ -135,7 +135,7 @@ public class RockboxService extends Service
135 ZipEntry entry; 135 ZipEntry entry;
136 File file = new File("/data/data/org.rockbox/" + 136 File file = new File("/data/data/org.rockbox/" +
137 "lib/libmisc.so"); 137 "lib/libmisc.so");
138 /* use arbitary file to determine whether extracting is needed */ 138 /* use arbitrary file to determine whether extracting is needed */
139 File file2 = new File("/data/data/org.rockbox/" + 139 File file2 = new File("/data/data/org.rockbox/" +
140 "app_rockbox/rockbox/codecs/mpa.codec"); 140 "app_rockbox/rockbox/codecs/mpa.codec");
141 if (!file2.exists() || (file.lastModified() > file2.lastModified())) 141 if (!file2.exists() || (file.lastModified() > file2.lastModified()))
@@ -184,8 +184,6 @@ public class RockboxService extends Service
184 } 184 }
185 185
186 System.loadLibrary("rockbox"); 186 System.loadLibrary("rockbox");
187
188 fb = new RockboxFramebuffer(me);
189 main(); 187 main();
190 } 188 }
191 },"Rockbox thread"); 189 },"Rockbox thread");
diff --git a/firmware/target/hosted/android/lcd-android.c b/firmware/target/hosted/android/lcd-android.c
index 1043dfa35c..fc9e22a921 100644
--- a/firmware/target/hosted/android/lcd-android.c
+++ b/firmware/target/hosted/android/lcd-android.c
@@ -29,7 +29,8 @@ extern JNIEnv *env_ptr;
29extern jclass RockboxService_class; 29extern jclass RockboxService_class;
30extern jobject RockboxService_instance; 30extern jobject RockboxService_instance;
31 31
32static jobject Framebuffer_instance; 32static jclass RockboxFramebuffer_class;
33static jobject RockboxFramebuffer_instance;
33static jmethodID java_lcd_update; 34static jmethodID java_lcd_update;
34static jmethodID java_lcd_update_rect; 35static jmethodID java_lcd_update_rect;
35 36
@@ -37,46 +38,51 @@ static bool display_on;
37 38
38void lcd_init_device(void) 39void lcd_init_device(void)
39{ 40{
40 /* get the RockboxFramebuffer instance allocated by the activity */ 41 JNIEnv e = *env_ptr;
41 jfieldID id = (*env_ptr)->GetStaticFieldID(env_ptr, 42 RockboxFramebuffer_class = e->FindClass(env_ptr,
42 RockboxService_class, 43 "org/rockbox/RockboxFramebuffer");
43 "fb", 44 /* instantiate a RockboxFramebuffer instance
44 "Lorg/rockbox/RockboxFramebuffer;"); 45 *
45 46 * Pass lcd width and height and our framebuffer so the java layer
46 Framebuffer_instance = (*env_ptr)->GetStaticObjectField(env_ptr, 47 * can create a Bitmap which directly maps to it
47 RockboxService_class, 48 **/
48 id); 49
49 50 /* map the framebuffer to a ByteBuffer, this way lcd updates will
50 jclass Framebuffer_class = (*env_ptr)->GetObjectClass(env_ptr, 51 * be directly feched from the framebuffer */
51 Framebuffer_instance); 52 jobject buf = e->NewDirectByteBuffer(env_ptr,
52 53 lcd_framebuffer,
53 /* get the java init function and call it. it'll set up a bitmap 54 (jlong)sizeof(lcd_framebuffer));
54 * based on LCD_WIDTH, LCD_HEIGHT and the ByteBuffer which directly maps 55
55 * our framebuffer */ 56 jmethodID constructor = e->GetMethodID(env_ptr,
56 57 RockboxFramebuffer_class,
57 jmethodID java_init_lcd = (*env_ptr)->GetMethodID(env_ptr, 58 "<init>",
58 Framebuffer_class, 59 "(Landroid/content/Context;" /* Service */
59 "java_lcd_init", 60 "II" /* lcd width/height */
60 "(IILjava/nio/ByteBuffer;)V"); 61 "Ljava/nio/ByteBuffer;)V"); /* ByteBuffer */
62
63 RockboxFramebuffer_instance = e->NewObject(env_ptr,
64 RockboxFramebuffer_class,
65 constructor,
66 RockboxService_instance,
67 (jint)LCD_WIDTH,
68 (jint)LCD_HEIGHT,
69 buf);
70
71 /* cache update functions */
61 java_lcd_update = (*env_ptr)->GetMethodID(env_ptr, 72 java_lcd_update = (*env_ptr)->GetMethodID(env_ptr,
62 Framebuffer_class, 73 RockboxFramebuffer_class,
63 "java_lcd_update", 74 "java_lcd_update",
64 "()V"); 75 "()V");
65 java_lcd_update_rect = (*env_ptr)->GetMethodID(env_ptr, 76 java_lcd_update_rect = (*env_ptr)->GetMethodID(env_ptr,
66 Framebuffer_class, 77 RockboxFramebuffer_class,
67 "java_lcd_update_rect", 78 "java_lcd_update_rect",
68 "(IIII)V"); 79 "(IIII)V");
69 80
70 /* map the framebuffer to a ByteBuffer, this way lcd updates will 81 /* at last, give RockboxService the Framebuffer instance */
71 * be directly feched from the framebuffer */ 82 jfieldID id = e->GetStaticFieldID(env_ptr, RockboxService_class,
72 jobject buf = (*env_ptr)->NewDirectByteBuffer(env_ptr, 83 "fb", "Lorg/rockbox/RockboxFramebuffer;");
73 lcd_framebuffer, 84 e->SetStaticObjectField(env_ptr, RockboxService_class,
74 sizeof(lcd_framebuffer)); 85 id, RockboxFramebuffer_instance);
75
76 (*env_ptr)->CallVoidMethod(env_ptr,
77 Framebuffer_instance,
78 java_init_lcd,
79 LCD_WIDTH, LCD_HEIGHT, buf);
80 display_on = true; 86 display_on = true;
81} 87}
82 88
@@ -84,14 +90,14 @@ void lcd_update(void)
84{ 90{
85 /* tell the system we're ready for drawing */ 91 /* tell the system we're ready for drawing */
86 if (display_on) 92 if (display_on)
87 (*env_ptr)->CallVoidMethod(env_ptr, Framebuffer_instance, java_lcd_update); 93 (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, java_lcd_update);
88} 94}
89 95
90void lcd_update_rect(int x, int y, int height, int width) 96void lcd_update_rect(int x, int y, int height, int width)
91{ 97{
92 if (display_on) 98 if (display_on)
93 { 99 {
94 (*env_ptr)->CallVoidMethod(env_ptr, Framebuffer_instance, java_lcd_update_rect, 100 (*env_ptr)->CallVoidMethod(env_ptr, RockboxFramebuffer_instance, java_lcd_update_rect,
95 x, y, height, width); 101 x, y, height, width);
96 } 102 }
97} 103}