diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-08-02 20:34:47 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-08-02 20:34:47 +0000 |
commit | 240923a801382c86545d10be167a15892a556fb6 (patch) | |
tree | 3c0e07ec3abf0c493a0b24b0b57e8bbd0200f7f6 /android/src/org/rockbox/RockboxActivity.java | |
parent | 850efead04f10488b478a0f255a2464a01156a7f (diff) |
Rockbox as an application: Commit current Android port progress.
General state is: Rockbox is usable (plays music, saves configuration, touchscreen works too).
Problems:
- Playing music in the background (i.e. when switching to another app) doesn't work reliably, but I'm working on that now.
- no cabbiev2 (only some preliminary files for it), no other default theme.
- screen flickers sometimes if the updates are too frequent
- no multi screen apk/package
- strange behavior when a phone call comes in
The java files (and the eclipse project) resides in android/, which is also supposed to be the build folder.
I've put a small README in there for instructions. There are some steps needed after the make part, which are described there,
and which eclipse mostly handles. But there ought to be some script/makefile rules which do that instead in the future.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27668 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android/src/org/rockbox/RockboxActivity.java')
-rw-r--r-- | android/src/org/rockbox/RockboxActivity.java | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java new file mode 100644 index 0000000000..791cad90ff --- /dev/null +++ b/android/src/org/rockbox/RockboxActivity.java @@ -0,0 +1,148 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 Thomas Martitz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +package org.rockbox; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.util.Enumeration; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import android.app.Activity; +import android.graphics.Rect; +import android.os.Bundle; +import android.util.Log; +import android.view.Window; +import android.view.WindowManager; + +public class RockboxActivity extends Activity { + /** Called when the activity is first created. */ + public RockboxFramebuffer fb; + private Thread rb; + static final int BUFFER = 2048; + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + LOG("start rb"); + requestWindowFeature(Window.FEATURE_NO_TITLE); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN + ,WindowManager.LayoutParams.FLAG_FULLSCREEN); + fb = new RockboxFramebuffer(this); + if (true) { + try + { + BufferedOutputStream dest = null; + BufferedInputStream is = null; + ZipEntry entry; + File file = new File("/data/data/org.rockbox/lib/libmisc.so"); + /* use arbitary file to determine whether extracting is needed */ + File file2 = new File("/data/data/org.rockbox/app_rockbox/rockbox/codecs/mpa.codec"); + if (!file2.exists() || (file.lastModified() > file2.lastModified())) + { + ZipFile zipfile = new ZipFile(file); + Enumeration<? extends ZipEntry> e = zipfile.entries(); + File folder; + while(e.hasMoreElements()) { + entry = (ZipEntry) e.nextElement(); + LOG("Extracting: " +entry); + if (entry.isDirectory()) + { + folder = new File(entry.getName()); + LOG("mkdir "+ entry); + try { + folder.mkdirs(); + } catch (SecurityException ex){ + LOG(ex.getMessage()); + } + continue; + } + is = new BufferedInputStream(zipfile.getInputStream(entry)); + int count; + byte data[] = new byte[BUFFER]; + folder = new File(new File(entry.getName()).getParent()); + LOG("" + folder.getAbsolutePath()); + if (!folder.exists()) + folder.mkdirs(); + FileOutputStream fos = new FileOutputStream(entry.getName()); + dest = new BufferedOutputStream(fos, BUFFER); + while ((count = is.read(data, 0, BUFFER)) != -1) { + dest.write(data, 0, count); + } + dest.flush(); + dest.close(); + is.close(); + } + } + } catch(Exception e) { + e.printStackTrace(); + }} + Rect r = new Rect(); + fb.getDrawingRect(r); + LOG(r.left + " " + r.top + " " + r.right + " " + r.bottom); + rb = new Thread(new Runnable() + { + public void run() + { + main(); + } + },"Rockbox thread"); + System.loadLibrary("rockbox"); + rb.setDaemon(false); + setContentView(fb); + } + + private void LOG(CharSequence text) + { + Log.d("RockboxBootloader", (String) text); + } + + public synchronized void onStart() + { + super.onStart(); + if (!rb.isAlive()) + rb.start(); + } + + public void onPause() + { + super.onPause(); + } + + public void onResume() + { + super.onResume(); + switch (rb.getState()) { + case BLOCKED: LOG("BLOCKED"); break; + case RUNNABLE: LOG("RUNNABLE"); break; + case NEW: LOG("NEW"); break; + case TERMINATED: LOG("TERMINATED"); break; + case TIMED_WAITING: LOG("TIMED_WAITING"); break; + case WAITING: LOG("WAITING"); break; + } + } + + + private native void main(); +}
\ No newline at end of file |