Index: android/src/org/rockbox/RockboxService.java =================================================================== --- android/src/org/rockbox/RockboxService.java (revision 27749) +++ android/src/org/rockbox/RockboxService.java (working copy) @@ -3,9 +3,12 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.nio.channels.FileChannel; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -130,9 +133,22 @@ } catch(Exception e) { e.printStackTrace(); } - + File file = new File("/sdcard/rockbox/librockbox.so"); + String loadlib = "rockbox"; + if (file.exists()) { + loadlib = "/sdcard/rockbox/librockbox.so"; + String path = getFilesDir().toString() + "/librockbox.so"; + LOG("Loading from /sdcard"); + File out = new File(path); + try { + copyFile(file, out); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } System.loadLibrary("rockbox"); - + Thread rb = new Thread(new Runnable() { public void run() @@ -143,7 +159,27 @@ rb.setDaemon(false); rb.start(); } + public static void copyFile(File sourceFile, File destFile) throws IOException { + if(!destFile.exists()) { + destFile.createNewFile(); + } + FileChannel source = null; + FileChannel destination = null; + try { + source = new FileInputStream(sourceFile).getChannel(); + destination = new FileOutputStream(destFile).getChannel(); + destination.transferFrom(source, 0, source.size()); + } + finally { + if(source != null) { + source.close(); + } + if(destination != null) { + destination.close(); + } + } + } private native void main(); @Override public IBinder onBind(Intent intent) {