diff options
-rw-r--r-- | android/src/org/rockbox/RockboxActivity.java | 1 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxService.java | 131 |
2 files changed, 68 insertions, 64 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java index fb41b90579..7c9022e1ba 100644 --- a/android/src/org/rockbox/RockboxActivity.java +++ b/android/src/org/rockbox/RockboxActivity.java | |||
@@ -31,6 +31,7 @@ import android.view.WindowManager; | |||
31 | 31 | ||
32 | public class RockboxActivity extends Activity | 32 | public class RockboxActivity extends Activity |
33 | { | 33 | { |
34 | private ProgressDialog loadingdialog; | ||
34 | /** Called when the activity is first created. */ | 35 | /** Called when the activity is first created. */ |
35 | @Override | 36 | @Override |
36 | public void onCreate(Bundle savedInstanceState) | 37 | public void onCreate(Bundle savedInstanceState) |
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index 1416886ce8..32970821d0 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java | |||
@@ -38,6 +38,7 @@ import java.util.zip.ZipFile; | |||
38 | import android.app.Notification; | 38 | import android.app.Notification; |
39 | import android.app.NotificationManager; | 39 | import android.app.NotificationManager; |
40 | import android.app.PendingIntent; | 40 | import android.app.PendingIntent; |
41 | import android.app.ProgressDialog; | ||
41 | import android.app.Service; | 42 | import android.app.Service; |
42 | import android.content.BroadcastReceiver; | 43 | import android.content.BroadcastReceiver; |
43 | import android.content.Context; | 44 | import android.content.Context; |
@@ -82,13 +83,14 @@ public class RockboxService extends Service | |||
82 | /* Running on an older platform: fall back to old API */ | 83 | /* Running on an older platform: fall back to old API */ |
83 | mStartForeground = mStopForeground = null; | 84 | mStartForeground = mStopForeground = null; |
84 | } | 85 | } |
85 | startservice(); | ||
86 | instance = this; | 86 | instance = this; |
87 | startservice(); | ||
87 | } | 88 | } |
88 | 89 | ||
89 | private void do_start(Intent intent) | 90 | private void do_start(Intent intent) |
90 | { | 91 | { |
91 | LOG("Start Service"); | 92 | LOG("Start Service"); |
93 | |||
92 | /* Display a notification about us starting. | 94 | /* Display a notification about us starting. |
93 | * We put an icon in the status bar. */ | 95 | * We put an icon in the status bar. */ |
94 | create_notification(); | 96 | create_notification(); |
@@ -116,74 +118,75 @@ public class RockboxService extends Service | |||
116 | 118 | ||
117 | private void startservice() | 119 | private void startservice() |
118 | { | 120 | { |
119 | fb = new RockboxFramebuffer(this); | ||
120 | final int BUFFER = 8*1024; | 121 | final int BUFFER = 8*1024; |
121 | /* the following block unzips libmisc.so, which contains the files | 122 | final Context me = this; |
122 | * we ship, such as themes. It's needed to put it into a .so file | ||
123 | * because there's no other way to ship files and have access | ||
124 | * to them from native code | ||
125 | */ | ||
126 | try | ||
127 | { | ||
128 | BufferedOutputStream dest = null; | ||
129 | BufferedInputStream is = null; | ||
130 | ZipEntry entry; | ||
131 | File file = new File("/data/data/org.rockbox/" + | ||
132 | "lib/libmisc.so"); | ||
133 | /* use arbitary file to determine whether extracting is needed */ | ||
134 | File file2 = new File("/data/data/org.rockbox/" + | ||
135 | "app_rockbox/rockbox/codecs/mpa.codec"); | ||
136 | if (!file2.exists() || (file.lastModified() > file2.lastModified())) | ||
137 | { | ||
138 | ZipFile zipfile = new ZipFile(file); | ||
139 | Enumeration<? extends ZipEntry> e = zipfile.entries(); | ||
140 | File folder; | ||
141 | while(e.hasMoreElements()) | ||
142 | { | ||
143 | entry = (ZipEntry) e.nextElement(); | ||
144 | LOG("Extracting: " +entry); | ||
145 | if (entry.isDirectory()) | ||
146 | { | ||
147 | folder = new File(entry.getName()); | ||
148 | LOG("mkdir "+ entry); | ||
149 | try { | ||
150 | folder.mkdirs(); | ||
151 | } catch (SecurityException ex) { | ||
152 | LOG(ex.getMessage()); | ||
153 | } | ||
154 | continue; | ||
155 | } | ||
156 | is = new BufferedInputStream(zipfile.getInputStream(entry), | ||
157 | BUFFER); | ||
158 | int count; | ||
159 | byte data[] = new byte[BUFFER]; | ||
160 | folder = new File(new File(entry.getName()).getParent()); | ||
161 | LOG("" + folder.getAbsolutePath()); | ||
162 | if (!folder.exists()) | ||
163 | folder.mkdirs(); | ||
164 | FileOutputStream fos = new FileOutputStream(entry.getName()); | ||
165 | dest = new BufferedOutputStream(fos, BUFFER); | ||
166 | while ((count = is.read(data, 0, BUFFER)) != -1) | ||
167 | dest.write(data, 0, count); | ||
168 | dest.flush(); | ||
169 | dest.close(); | ||
170 | is.close(); | ||
171 | } | ||
172 | } | ||
173 | } catch(FileNotFoundException e) { | ||
174 | LOG("FileNotFoundException when unzipping", e); | ||
175 | e.printStackTrace(); | ||
176 | } catch(IOException e) { | ||
177 | LOG("IOException when unzipping", e); | ||
178 | e.printStackTrace(); | ||
179 | } | ||
180 | |||
181 | System.loadLibrary("rockbox"); | ||
182 | |||
183 | Thread rb = new Thread(new Runnable() | 123 | Thread rb = new Thread(new Runnable() |
184 | { | 124 | { |
185 | public void run() | 125 | public void run() |
186 | { | 126 | { |
127 | /* the following block unzips libmisc.so, which contains the files | ||
128 | * we ship, such as themes. It's needed to put it into a .so file | ||
129 | * because there's no other way to ship files and have access | ||
130 | * to them from native code | ||
131 | */ | ||
132 | try | ||
133 | { | ||
134 | BufferedOutputStream dest = null; | ||
135 | BufferedInputStream is = null; | ||
136 | ZipEntry entry; | ||
137 | File file = new File("/data/data/org.rockbox/" + | ||
138 | "lib/libmisc.so"); | ||
139 | /* use arbitary file to determine whether extracting is needed */ | ||
140 | File file2 = new File("/data/data/org.rockbox/" + | ||
141 | "app_rockbox/rockbox/codecs/mpa.codec"); | ||
142 | if (!file2.exists() || (file.lastModified() > file2.lastModified())) | ||
143 | { | ||
144 | ZipFile zipfile = new ZipFile(file); | ||
145 | Enumeration<? extends ZipEntry> e = zipfile.entries(); | ||
146 | File folder; | ||
147 | while(e.hasMoreElements()) | ||
148 | { | ||
149 | entry = (ZipEntry) e.nextElement(); | ||
150 | LOG("Extracting: " +entry); | ||
151 | if (entry.isDirectory()) | ||
152 | { | ||
153 | folder = new File(entry.getName()); | ||
154 | LOG("mkdir "+ entry); | ||
155 | try { | ||
156 | folder.mkdirs(); | ||
157 | } catch (SecurityException ex) { | ||
158 | LOG(ex.getMessage()); | ||
159 | } | ||
160 | continue; | ||
161 | } | ||
162 | is = new BufferedInputStream(zipfile.getInputStream(entry), | ||
163 | BUFFER); | ||
164 | int count; | ||
165 | byte data[] = new byte[BUFFER]; | ||
166 | folder = new File(new File(entry.getName()).getParent()); | ||
167 | LOG("" + folder.getAbsolutePath()); | ||
168 | if (!folder.exists()) | ||
169 | folder.mkdirs(); | ||
170 | FileOutputStream fos = new FileOutputStream(entry.getName()); | ||
171 | dest = new BufferedOutputStream(fos, BUFFER); | ||
172 | while ((count = is.read(data, 0, BUFFER)) != -1) | ||
173 | dest.write(data, 0, count); | ||
174 | dest.flush(); | ||
175 | dest.close(); | ||
176 | is.close(); | ||
177 | } | ||
178 | } | ||
179 | } catch(FileNotFoundException e) { | ||
180 | LOG("FileNotFoundException when unzipping", e); | ||
181 | e.printStackTrace(); | ||
182 | } catch(IOException e) { | ||
183 | LOG("IOException when unzipping", e); | ||
184 | e.printStackTrace(); | ||
185 | } | ||
186 | |||
187 | System.loadLibrary("rockbox"); | ||
188 | |||
189 | fb = new RockboxFramebuffer(me); | ||
187 | main(); | 190 | main(); |
188 | } | 191 | } |
189 | },"Rockbox thread"); | 192 | },"Rockbox thread"); |