From fe0a002965511bfd21bb7a493937e617fe489971 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Fri, 22 Apr 2011 16:36:55 +0200 Subject: [PATCH] Android: store resources on SD card. On the first start Rockbox extracts libmisc.so which in fact is a zip file holding resource files like theme bitmaps. Those can requires quite a bit of memory. Since using Rockbox without SD card is a bit pointless (you need to store your music somewhere after all) it should be an acceptable solution to require an SD card to be present to load resources. Decreases the user data by around 5MiB on 480x800 device. --- android/src/org/rockbox/RockboxService.java | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index 3182b73..ab5d6cd 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java @@ -180,7 +180,11 @@ public class RockboxService extends Service { final int BUFFER = 8*1024; String rockboxDirPath = "/data/data/org.rockbox/app_rockbox/rockbox"; + String rockboxCreditsPath = "/data/data/org.rockbox/app_rockbox/rockbox/rocks/viewers"; + String rockboxSdDirPath = "/sdcard/rockbox"; File rockboxDir = new File(rockboxDirPath); + File rockboxSdDir = new File(rockboxSdDirPath); + File rockboxCreditsDir = new File(rockboxCreditsPath); /* load library before unzipping which may take a while */ synchronized (lock) { @@ -195,7 +199,8 @@ public class RockboxService extends Service */ File libMisc = new File("/data/data/org.rockbox/lib/libmisc.so"); /* use arbitrary file to determine whether extracting is needed */ - File arbitraryFile = new File(rockboxDir, "viewers.config"); + File arbitraryFile = new File(rockboxCreditsPath, "credits.rock"); + LOG(arbitraryFile.getAbsolutePath()); if (!arbitraryFile.exists() || (libMisc.lastModified() > arbitraryFile.lastModified())) { try @@ -213,7 +218,15 @@ public class RockboxService extends Service /* strip off /.rockbox when extracting */ String fileName = entry.getName(); int slashIndex = fileName.indexOf('/', 1); - file = new File(rockboxDirPath + fileName.substring(slashIndex)); + if(fileName.substring(slashIndex).startsWith("/rocks") + || fileName.substring(slashIndex).startsWith("/codecs")) + { + file = new File(rockboxDirPath + fileName.substring(slashIndex)); + } + else + { + file = new File(rockboxSdDirPath + fileName.substring(slashIndex)); + } if (!entry.isDirectory()) { @@ -241,6 +254,7 @@ public class RockboxService extends Service resultReceiver.send(RESULT_LIB_LOAD_PROGRESS, progressData); } } + arbitraryFile.setLastModified(libMisc.lastModified()); } catch(Exception e) { LOG("Exception when unzipping", e); e.printStackTrace(); -- 1.7.4.4