summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-04 12:25:25 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-04 12:25:25 +0000
commit04dc00b7caa9f505ed3dd55fe5922910d004fa80 (patch)
tree52798713d9afae61746d72ff79a1826f1781ab8d
parentf0611f878101caa323b3b0693c0cf7170f59fe00 (diff)
downloadrockbox-04dc00b7caa9f505ed3dd55fe5922910d004fa80.tar.gz
rockbox-04dc00b7caa9f505ed3dd55fe5922910d004fa80.zip
Add a few forgotten files, Fix potential startup problem. Fix absolute touchscreen mode.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27693 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--android/res/drawable-hdpi/rb.pngbin0 -> 468 bytes
-rw-r--r--android/res/drawable-ldpi/rb.pngbin0 -> 468 bytes
-rw-r--r--android/res/drawable-mdpi/rb.pngbin0 -> 468 bytes
-rw-r--r--android/src/org/rockbox/RockboxActivity.java31
-rw-r--r--android/src/org/rockbox/RockboxService.java173
-rw-r--r--firmware/target/hosted/android/button-android.c13
6 files changed, 188 insertions, 29 deletions
diff --git a/android/res/drawable-hdpi/rb.png b/android/res/drawable-hdpi/rb.png
new file mode 100644
index 0000000000..6d21c98bf1
--- /dev/null
+++ b/android/res/drawable-hdpi/rb.png
Binary files differ
diff --git a/android/res/drawable-ldpi/rb.png b/android/res/drawable-ldpi/rb.png
new file mode 100644
index 0000000000..6d21c98bf1
--- /dev/null
+++ b/android/res/drawable-ldpi/rb.png
Binary files differ
diff --git a/android/res/drawable-mdpi/rb.png b/android/res/drawable-mdpi/rb.png
new file mode 100644
index 0000000000..6d21c98bf1
--- /dev/null
+++ b/android/res/drawable-mdpi/rb.png
Binary files differ
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java
index 2bafb6688d..3be9e3ed47 100644
--- a/android/src/org/rockbox/RockboxActivity.java
+++ b/android/src/org/rockbox/RockboxActivity.java
@@ -53,24 +53,21 @@ public class RockboxActivity extends Activity {
53 new Thread(new Runnable() 53 new Thread(new Runnable()
54 { 54 {
55 public void run() { 55 public void run() {
56 while (RockboxService.fb == null) 56 try {
57 { 57 while (RockboxService.fb == null)
58 try { 58 Thread.sleep(250);
59 Thread.sleep(250); 59 } catch (InterruptedException e) {
60 } catch (InterruptedException e) { 60 } catch (Exception e) {
61 } catch (Exception e) { 61 LOG(e.toString());
62 LOG(e.toString()); 62 }
63 /* drawing needs to happen in ui thread */
64 runOnUiThread(new Runnable()
65 { @Override
66 public void run() {
67 setContentView(RockboxService.fb);
68 RockboxService.fb.invalidate();
63 } 69 }
64 /* drawing needs to happen in ui thread */ 70 });
65 runOnUiThread(new Runnable()
66 { @Override
67 public void run() {
68 setContentView(RockboxService.fb);
69 RockboxService.fb.invalidate();
70 }
71 });
72 }
73
74 } 71 }
75 }).start(); 72 }).start();
76 } 73 }
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java
new file mode 100644
index 0000000000..5c74d19ebf
--- /dev/null
+++ b/android/src/org/rockbox/RockboxService.java
@@ -0,0 +1,173 @@
1package org.rockbox;
2
3import java.io.BufferedInputStream;
4import java.io.BufferedOutputStream;
5import java.io.File;
6import java.io.FileOutputStream;
7import java.util.Enumeration;
8import java.util.zip.ZipEntry;
9import java.util.zip.ZipFile;
10
11import android.app.Notification;
12import android.app.NotificationManager;
13import android.app.PendingIntent;
14import android.app.Service;
15import android.content.Intent;
16import android.os.Binder;
17import android.os.IBinder;
18import android.util.Log;
19
20public class RockboxService extends Service
21{
22 public static RockboxFramebuffer fb = null;
23 @Override
24 public void onCreate()
25 {
26 mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
27 startservice();
28 }
29
30 private void do_start(Intent intent)
31 {
32 LOG("Start Service");
33 }
34
35 private void LOG(CharSequence text)
36 {
37 Log.d("Rockbox", (String) text);
38 }
39
40 @Override
41 public void onStart(Intent intent, int startId) {
42 do_start(intent);
43 }
44
45 @Override
46 public int onStartCommand(Intent intent, int flags, int startId)
47 {
48 do_start(intent);
49 /* Display a notification about us starting. We put an icon in the status bar. */
50 showNotification();
51 return START_STICKY;
52 }
53
54 private void startservice()
55 {
56 fb = new RockboxFramebuffer(this);
57 final int BUFFER = 2048;
58 /* the following block unzips libmisc.so, which contains the files
59 * we ship, such as themes. It's needed to put it into a .so file
60 * because there's no other way to ship files and have access
61 * to them from native code
62 */
63 try
64 {
65 BufferedOutputStream dest = null;
66 BufferedInputStream is = null;
67 ZipEntry entry;
68 File file = new File("/data/data/org.rockbox/lib/libmisc.so");
69 /* use arbitary file to determine whether extracting is needed */
70 File file2 = new File("/data/data/org.rockbox/app_rockbox/rockbox/codecs/mpa.codec");
71 if (!file2.exists() || (file.lastModified() > file2.lastModified()))
72 {
73 ZipFile zipfile = new ZipFile(file);
74 Enumeration<? extends ZipEntry> e = zipfile.entries();
75 File folder;
76 while(e.hasMoreElements()) {
77 entry = (ZipEntry) e.nextElement();
78 LOG("Extracting: " +entry);
79 if (entry.isDirectory())
80 {
81 folder = new File(entry.getName());
82 LOG("mkdir "+ entry);
83 try {
84 folder.mkdirs();
85 } catch (SecurityException ex){
86 LOG(ex.getMessage());
87 }
88 continue;
89 }
90 is = new BufferedInputStream(zipfile.getInputStream(entry));
91 int count;
92 byte data[] = new byte[BUFFER];
93 folder = new File(new File(entry.getName()).getParent());
94 LOG("" + folder.getAbsolutePath());
95 if (!folder.exists())
96 folder.mkdirs();
97 FileOutputStream fos = new FileOutputStream(entry.getName());
98 dest = new BufferedOutputStream(fos, BUFFER);
99 while ((count = is.read(data, 0, BUFFER)) != -1) {
100 dest.write(data, 0, count);
101 }
102 dest.flush();
103 dest.close();
104 is.close();
105 }
106 }
107 } catch(Exception e) {
108 e.printStackTrace();
109 }
110
111 System.loadLibrary("rockbox");
112
113 Thread rb = new Thread(new Runnable()
114 {
115 public void run()
116 {
117 main();
118 }
119 },"Rockbox thread");
120 rb.setDaemon(false);
121 rb.start();
122 }
123
124 private native void main();
125 @Override
126 public IBinder onBind(Intent intent) {
127 // TODO Auto-generated method stub
128 return null;
129 }
130 private NotificationManager mNM;
131
132 /**
133 * Class for clients to access. Because we know this service always
134 * runs in the same process as its clients, we don't need to deal with
135 * IPC.
136 */
137 public class LocalBinder extends Binder {
138 RockboxService getService() {
139 return RockboxService.this;
140 }
141 }
142
143 /* heavily based on the example found on
144 * http://developer.android.com/reference/android/app/Service.html
145 */
146 public void showNotification() {
147 // In this sample, we'll use the same text for the ticker and the expanded notification
148 CharSequence text = getText(R.string.notification);
149
150 // Set the icon, scrolling text and timestamp
151 Notification notification = new Notification(R.drawable.rb, text,
152 System.currentTimeMillis());
153
154 // The PendingIntent to launch our activity if the user selects this notification
155 Intent intent = new Intent(this, RockboxActivity.class);
156 PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
157
158
159 // Set the info for the views that show in the notification panel.
160 notification.setLatestEventInfo(this, getText(R.string.notification), text, contentIntent);
161
162 // Send the notification.
163 // We use a layout id because it is a unique number. We use it later to cancel.
164 mNM.notify(R.string.notification, notification);
165
166 /*
167 * this call makes the service run as foreground, which
168 * provides enough cpu time to do music decoding in the
169 * background
170 */
171 startForeground(R.string.notification, notification);
172 }
173}
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c
index 67e8ca1f89..1172880908 100644
--- a/firmware/target/hosted/android/button-android.c
+++ b/firmware/target/hosted/android/button-android.c
@@ -27,7 +27,6 @@
27#include "system.h" 27#include "system.h"
28#include "touchscreen.h" 28#include "touchscreen.h"
29 29
30static long last_touch;
31static int last_y, last_x; 30static int last_y, last_x;
32 31
33static enum { 32static enum {
@@ -48,7 +47,6 @@ Java_org_rockbox_RockboxFramebuffer_pixelHandler(JNIEnv*env, jobject this,
48 (void)this; 47 (void)this;
49 last_x = x; 48 last_x = x;
50 last_y = y; 49 last_y = y;
51 last_touch = current_tick;
52} 50}
53 51
54/* 52/*
@@ -68,20 +66,11 @@ Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
68 66
69void button_init_device(void) 67void button_init_device(void)
70{ 68{
71 last_touch = current_tick;
72} 69}
73 70
74int button_read_device(int *data) 71int button_read_device(int *data)
75{ 72{
76 /* get grid button/coordinates based on the current touchscreen mode */ 73 /* get grid button/coordinates based on the current touchscreen mode */
77 int btn = touchscreen_to_pixels(last_x, last_y, data); 74 int btn = touchscreen_to_pixels(last_x, last_y, data);
78 if (last_state == STATE_DOWN) 75 return (last_state == STATE_DOWN ? btn : 0);
79 {
80 return btn;
81 }
82 else
83 {
84 *data = last_x = last_y = 0;
85 return 0;
86 }
87} 76}