1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 import java
.io
.BufferedInputStream
;
25 import java
.io
.BufferedOutputStream
;
27 import java
.io
.FileOutputStream
;
28 import java
.util
.Enumeration
;
29 import java
.util
.zip
.ZipEntry
;
30 import java
.util
.zip
.ZipFile
;
32 import android
.app
.Activity
;
33 import android
.graphics
.Rect
;
34 import android
.os
.Bundle
;
35 import android
.util
.Log
;
36 import android
.view
.Window
;
37 import android
.view
.WindowManager
;
39 public class RockboxActivity
extends Activity
{
40 /** Called when the activity is first created. */
41 public RockboxFramebuffer fb
;
43 static final int BUFFER
= 2048;
44 /** Called when the activity is first created. */
46 public void onCreate(Bundle savedInstanceState
) {
47 super.onCreate(savedInstanceState
);
49 requestWindowFeature(Window
.FEATURE_NO_TITLE
);
50 getWindow().setFlags(WindowManager
.LayoutParams
.FLAG_FULLSCREEN
51 ,WindowManager
.LayoutParams
.FLAG_FULLSCREEN
);
52 fb
= new RockboxFramebuffer(this);
56 BufferedOutputStream dest
= null;
57 BufferedInputStream is
= null;
59 File file
= new File("/data/data/org.rockbox/lib/libmisc.so");
60 /* use arbitary file to determine whether extracting is needed */
61 File file2
= new File("/data/data/org.rockbox/app_rockbox/rockbox/codecs/mpa.codec");
62 if (!file2
.exists() || (file
.lastModified() > file2
.lastModified()))
64 ZipFile zipfile
= new ZipFile(file
);
65 Enumeration
<?
extends ZipEntry
> e
= zipfile
.entries();
67 while(e
.hasMoreElements()) {
68 entry
= (ZipEntry
) e
.nextElement();
69 LOG("Extracting: " +entry
);
70 if (entry
.isDirectory())
72 folder
= new File(entry
.getName());
76 } catch (SecurityException ex
){
81 is
= new BufferedInputStream(zipfile
.getInputStream(entry
));
83 byte data
[] = new byte[BUFFER
];
84 folder
= new File(new File(entry
.getName()).getParent());
85 LOG("" + folder
.getAbsolutePath());
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
);
98 } catch(Exception e
) {
102 fb
.getDrawingRect(r
);
103 LOG(r
.left
+ " " + r
.top
+ " " + r
.right
+ " " + r
.bottom
);
104 rb
= new Thread(new Runnable()
111 System
.loadLibrary("rockbox");
116 private void LOG(CharSequence text
)
118 Log
.d("RockboxBootloader", (String
) text
);
121 public synchronized void onStart()
128 public void onPause()
133 public void onResume()
136 switch (rb
.getState()) {
137 case BLOCKED
: LOG("BLOCKED"); break;
138 case RUNNABLE
: LOG("RUNNABLE"); break;
139 case NEW
: LOG("NEW"); break;
140 case TERMINATED
: LOG("TERMINATED"); break;
141 case TIMED_WAITING
: LOG("TIMED_WAITING"); break;
142 case WAITING
: LOG("WAITING"); break;
147 private native void main();