diff options
Diffstat (limited to 'android')
-rw-r--r-- | android/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | android/default.properties | 2 | ||||
-rw-r--r-- | android/gen/org/rockbox/R.java | 2 | ||||
-rw-r--r-- | android/res/values/strings.xml | 1 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxActivity.java | 159 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxTimer.java | 17 |
6 files changed, 63 insertions, 121 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index a22c393379..30acaf09f7 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml | |||
@@ -10,7 +10,8 @@ | |||
10 | <action android:name="android.intent.action.MAIN" /> | 10 | <action android:name="android.intent.action.MAIN" /> |
11 | <category android:name="android.intent.category.LAUNCHER" /> | 11 | <category android:name="android.intent.category.LAUNCHER" /> |
12 | </intent-filter> | 12 | </intent-filter> |
13 | </activity> | 13 | </activity> |
14 | <service android:name=".RockboxService"/> | ||
14 | 15 | ||
15 | </application> | 16 | </application> |
16 | <uses-sdk android:minSdkVersion="4" /> | 17 | <uses-sdk android:minSdkVersion="4" /> |
diff --git a/android/default.properties b/android/default.properties index 9d79b12c71..9d135cb85f 100644 --- a/android/default.properties +++ b/android/default.properties | |||
@@ -8,4 +8,4 @@ | |||
8 | # project structure. | 8 | # project structure. |
9 | 9 | ||
10 | # Project target. | 10 | # Project target. |
11 | target=android-4 | 11 | target=android-7 |
diff --git a/android/gen/org/rockbox/R.java b/android/gen/org/rockbox/R.java index 38c177ef36..50f3456e5f 100644 --- a/android/gen/org/rockbox/R.java +++ b/android/gen/org/rockbox/R.java | |||
@@ -12,11 +12,13 @@ public final class R { | |||
12 | } | 12 | } |
13 | public static final class drawable { | 13 | public static final class drawable { |
14 | public static final int icon=0x7f020000; | 14 | public static final int icon=0x7f020000; |
15 | public static final int rb=0x7f020001; | ||
15 | } | 16 | } |
16 | public static final class layout { | 17 | public static final class layout { |
17 | public static final int main=0x7f030000; | 18 | public static final int main=0x7f030000; |
18 | } | 19 | } |
19 | public static final class string { | 20 | public static final class string { |
20 | public static final int app_name=0x7f040000; | 21 | public static final int app_name=0x7f040000; |
22 | public static final int notification=0x7f040001; | ||
21 | } | 23 | } |
22 | } | 24 | } |
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 6c3c8464fd..9320b2624d 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml | |||
@@ -2,4 +2,5 @@ | |||
2 | <resources> | 2 | <resources> |
3 | 3 | ||
4 | <string name="app_name">Rockbox</string> | 4 | <string name="app_name">Rockbox</string> |
5 | <string name="notification">Rockbox</string> | ||
5 | </resources> | 6 | </resources> |
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java index 791cad90ff..eadfd5a40a 100644 --- a/android/src/org/rockbox/RockboxActivity.java +++ b/android/src/org/rockbox/RockboxActivity.java | |||
@@ -21,128 +21,81 @@ | |||
21 | 21 | ||
22 | package org.rockbox; | 22 | package org.rockbox; |
23 | 23 | ||
24 | import java.io.BufferedInputStream; | ||
25 | import java.io.BufferedOutputStream; | ||
26 | import java.io.File; | ||
27 | import java.io.FileOutputStream; | ||
28 | import java.util.Enumeration; | ||
29 | import java.util.zip.ZipEntry; | ||
30 | import java.util.zip.ZipFile; | ||
31 | |||
32 | import android.app.Activity; | 24 | import android.app.Activity; |
33 | import android.graphics.Rect; | 25 | import android.content.Intent; |
34 | import android.os.Bundle; | 26 | import android.os.Bundle; |
35 | import android.util.Log; | 27 | import android.util.Log; |
28 | import android.view.ViewGroup; | ||
36 | import android.view.Window; | 29 | import android.view.Window; |
37 | import android.view.WindowManager; | 30 | import android.view.WindowManager; |
38 | 31 | ||
39 | public class RockboxActivity extends Activity { | 32 | public class RockboxActivity extends Activity { |
40 | /** Called when the activity is first created. */ | 33 | /** Called when the activity is first created. */ |
41 | public RockboxFramebuffer fb; | ||
42 | private Thread rb; | ||
43 | static final int BUFFER = 2048; | ||
44 | /** Called when the activity is first created. */ | ||
45 | @Override | 34 | @Override |
46 | public void onCreate(Bundle savedInstanceState) { | 35 | public void onCreate(Bundle savedInstanceState) |
36 | { | ||
47 | super.onCreate(savedInstanceState); | 37 | super.onCreate(savedInstanceState); |
48 | LOG("start rb"); | ||
49 | requestWindowFeature(Window.FEATURE_NO_TITLE); | 38 | requestWindowFeature(Window.FEATURE_NO_TITLE); |
50 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | 39 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
51 | ,WindowManager.LayoutParams.FLAG_FULLSCREEN); | 40 | ,WindowManager.LayoutParams.FLAG_FULLSCREEN); |
52 | fb = new RockboxFramebuffer(this); | 41 | final Intent intent = new Intent(this, |
53 | if (true) { | 42 | RockboxService.class); |
54 | try | 43 | startService(intent); |
44 | /* Now it gets a bit tricky: | ||
45 | * The service is started in the same thread as we are now, | ||
46 | * but the service also initializes the framebuffer | ||
47 | * Unforunately, this happens *after* any of the default | ||
48 | * startup methods of an activity, so we need to poll for it | ||
49 | * | ||
50 | * In order to get the fb, we need to let the Service start up | ||
51 | * run, we can wait in a separate thread for fb to get ready | ||
52 | * This thread waits for the fb to become ready */ | ||
53 | new Thread(new Runnable() | ||
55 | { | 54 | { |
56 | BufferedOutputStream dest = null; | 55 | public void run() { |
57 | BufferedInputStream is = null; | 56 | while (RockboxService.fb == null) |
58 | ZipEntry entry; | 57 | { |
59 | File file = new File("/data/data/org.rockbox/lib/libmisc.so"); | 58 | try { |
60 | /* use arbitary file to determine whether extracting is needed */ | 59 | Thread.sleep(250); |
61 | File file2 = new File("/data/data/org.rockbox/app_rockbox/rockbox/codecs/mpa.codec"); | 60 | } catch (InterruptedException e) { |
62 | if (!file2.exists() || (file.lastModified() > file2.lastModified())) | 61 | } catch (Exception e) { |
63 | { | 62 | LOG(e.toString()); |
64 | ZipFile zipfile = new ZipFile(file); | 63 | } |
65 | Enumeration<? extends ZipEntry> e = zipfile.entries(); | 64 | /* drawing needs to happen in ui thread */ |
66 | File folder; | 65 | runOnUiThread(new Runnable() |
67 | while(e.hasMoreElements()) { | 66 | { @Override |
68 | entry = (ZipEntry) e.nextElement(); | 67 | public void run() { |
69 | LOG("Extracting: " +entry); | 68 | setContentView(RockboxService.fb); |
70 | if (entry.isDirectory()) | 69 | RockboxService.fb.invalidate(); |
71 | { | 70 | } |
72 | folder = new File(entry.getName()); | 71 | }); |
73 | LOG("mkdir "+ entry); | 72 | } |
74 | try { | 73 | |
75 | folder.mkdirs(); | 74 | } |
76 | } catch (SecurityException ex){ | 75 | }).start(); |
77 | LOG(ex.getMessage()); | ||
78 | } | ||
79 | continue; | ||
80 | } | ||
81 | is = new BufferedInputStream(zipfile.getInputStream(entry)); | ||
82 | int count; | ||
83 | byte data[] = new byte[BUFFER]; | ||
84 | folder = new File(new File(entry.getName()).getParent()); | ||
85 | LOG("" + folder.getAbsolutePath()); | ||
86 | if (!folder.exists()) | ||
87 | folder.mkdirs(); | ||
88 | FileOutputStream fos = new FileOutputStream(entry.getName()); | ||
89 | dest = new BufferedOutputStream(fos, BUFFER); | ||
90 | while ((count = is.read(data, 0, BUFFER)) != -1) { | ||
91 | dest.write(data, 0, count); | ||
92 | } | ||
93 | dest.flush(); | ||
94 | dest.close(); | ||
95 | is.close(); | ||
96 | } | ||
97 | } | ||
98 | } catch(Exception e) { | ||
99 | e.printStackTrace(); | ||
100 | }} | ||
101 | Rect r = new Rect(); | ||
102 | fb.getDrawingRect(r); | ||
103 | LOG(r.left + " " + r.top + " " + r.right + " " + r.bottom); | ||
104 | rb = new Thread(new Runnable() | ||
105 | { | ||
106 | public void run() | ||
107 | { | ||
108 | main(); | ||
109 | } | ||
110 | },"Rockbox thread"); | ||
111 | System.loadLibrary("rockbox"); | ||
112 | rb.setDaemon(false); | ||
113 | setContentView(fb); | ||
114 | } | ||
115 | |||
116 | private void LOG(CharSequence text) | ||
117 | { | ||
118 | Log.d("RockboxBootloader", (String) text); | ||
119 | } | ||
120 | |||
121 | public synchronized void onStart() | ||
122 | { | ||
123 | super.onStart(); | ||
124 | if (!rb.isAlive()) | ||
125 | rb.start(); | ||
126 | } | ||
127 | |||
128 | public void onPause() | ||
129 | { | ||
130 | super.onPause(); | ||
131 | } | 76 | } |
132 | 77 | ||
133 | public void onResume() | 78 | public void onResume() |
134 | { | 79 | { |
135 | super.onResume(); | 80 | super.onResume(); |
136 | switch (rb.getState()) { | 81 | if (RockboxService.fb != null) |
137 | case BLOCKED: LOG("BLOCKED"); break; | 82 | { |
138 | case RUNNABLE: LOG("RUNNABLE"); break; | 83 | try { |
139 | case NEW: LOG("NEW"); break; | 84 | setContentView(RockboxService.fb); |
140 | case TERMINATED: LOG("TERMINATED"); break; | 85 | } catch (IllegalStateException e) { |
141 | case TIMED_WAITING: LOG("TIMED_WAITING"); break; | 86 | /* we are already using the View, |
142 | case WAITING: LOG("WAITING"); break; | 87 | * need to remove it and re-attach it */ |
88 | ViewGroup g = (ViewGroup)RockboxService.fb.getParent(); | ||
89 | g.removeView(RockboxService.fb); | ||
90 | setContentView(RockboxService.fb); | ||
91 | } catch (Exception e) { | ||
92 | LOG(e.toString()); | ||
93 | } | ||
143 | } | 94 | } |
144 | } | 95 | } |
145 | 96 | ||
146 | 97 | private void LOG(CharSequence text) | |
147 | private native void main(); | 98 | { |
99 | Log.d("Rockbox", (String) text); | ||
100 | } | ||
148 | } \ No newline at end of file | 101 | } \ No newline at end of file |
diff --git a/android/src/org/rockbox/RockboxTimer.java b/android/src/org/rockbox/RockboxTimer.java index c7239b4ee6..6491e4ffe9 100644 --- a/android/src/org/rockbox/RockboxTimer.java +++ b/android/src/org/rockbox/RockboxTimer.java | |||
@@ -47,21 +47,6 @@ public class RockboxTimer extends Timer | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | public void pause() | ||
51 | { | ||
52 | cancel(); | ||
53 | } | ||
54 | public void resume() | ||
55 | { | ||
56 | try { | ||
57 | schedule(task, 0, interval); | ||
58 | } catch (IllegalStateException e) { | ||
59 | /* not an error */ | ||
60 | } catch (Exception e) { | ||
61 | LOG(e.toString()); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | public RockboxTimer(long period_inverval_in_ms) | 50 | public RockboxTimer(long period_inverval_in_ms) |
66 | { | 51 | { |
67 | super("tick timer", false); | 52 | super("tick timer", false); |
@@ -72,7 +57,7 @@ public class RockboxTimer extends Timer | |||
72 | 57 | ||
73 | private void LOG(CharSequence text) | 58 | private void LOG(CharSequence text) |
74 | { | 59 | { |
75 | Log.d("RockboxBootloader", (String) text); | 60 | Log.d("Rockbox", (String) text); |
76 | } | 61 | } |
77 | 62 | ||
78 | 63 | ||