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.

As extended version of FS#12063 resources will now be extracted to SD card if
the file /sdcard/rockbox/rockbox-info.txt is found. This file is part of the
extracted resources and can therefore safely be used for checking.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30430 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2011-09-04 19:07:14 +00:00
parent 642736f53b
commit 1b70a7079e

View file

@ -169,7 +169,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) {
@ -184,7 +188,16 @@ 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");
File rockboxInfoFile = new File(rockboxSdDirPath, "rockbox-info.txt");
boolean extractToSd = false;
if(rockboxInfoFile.exists()) {
extractToSd = true;
LOG("extracting resources to SD card");
}
else {
LOG("extracting resources to internal memory");
}
if (!arbitraryFile.exists() || (libMisc.lastModified() > arbitraryFile.lastModified()))
{
try
@ -202,7 +215,16 @@ 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));
/* codecs are now stored as libs, only keep rocks on internal */
if(extractToSd == false
|| fileName.substring(slashIndex).startsWith("/rocks"))
{
file = new File(rockboxDirPath + fileName.substring(slashIndex));
}
else
{
file = new File(rockboxSdDirPath + fileName.substring(slashIndex));
}
if (!entry.isDirectory())
{
@ -230,6 +252,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();