mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 608042 - Add ability to make fat android builds that extract APK to disk r=dougt a=blocking-fennec
--HG-- extra : rebase_source : 60be05d268c70c08a5979e6480e40add3dc72b9d
This commit is contained in:
parent
288dd1f477
commit
b872b843b0
@ -79,6 +79,8 @@ class GeckoAppShell
|
||||
static private final int NOTIFY_IME_CANCELCOMPOSITION = 2;
|
||||
static private final int NOTIFY_IME_FOCUSCHANGE = 3;
|
||||
|
||||
static private final long kFreeSpaceThreshold = 19660800L; // 150Mb
|
||||
|
||||
/* The Android-side API: API methods that Android calls */
|
||||
|
||||
// Initialization methods
|
||||
@ -92,7 +94,7 @@ class GeckoAppShell
|
||||
public static native void onLowMemory();
|
||||
public static native void callObserver(String observerKey, String topic, String data);
|
||||
public static native void removeObserver(String observerKey);
|
||||
public static native void loadLibs(String apkName);
|
||||
public static native void loadLibs(String apkName, boolean shouldExtract);
|
||||
|
||||
// java-side stuff
|
||||
public static void loadGeckoLibs(String apkName) {
|
||||
@ -120,6 +122,13 @@ class GeckoAppShell
|
||||
|
||||
f = Environment.getDownloadCacheDirectory();
|
||||
GeckoAppShell.putenv("EXTERNAL_STORAGE=" + f.getPath());
|
||||
File cacheFile = GeckoApp.mAppContext.getCacheDir();
|
||||
GeckoAppShell.putenv("CACHE_PATH=" + cacheFile.getPath());
|
||||
|
||||
// gingerbread introduces File.getUsableSpace(). We should use that.
|
||||
StatFs cacheStats = new StatFs(cacheFile.getPath());
|
||||
long freeSpace = cacheStats.getFreeBlocks() * cacheStats.getBlockSize();
|
||||
|
||||
File downloadDir = null;
|
||||
if (Build.VERSION.SDK_INT >= 8)
|
||||
downloadDir = GeckoApp.mAppContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
|
||||
@ -129,7 +138,17 @@ class GeckoAppShell
|
||||
|
||||
putLocaleEnv();
|
||||
|
||||
loadLibs(apkName);
|
||||
boolean shouldExtact = freeSpace > kFreeSpaceThreshold;
|
||||
if (!shouldExtact) {
|
||||
// remove any previously extracted libs since we're apparently low
|
||||
Iterator cacheFiles = Arrays.asList(cacheFile.listFiles()).iterator();
|
||||
while (cacheFiles.hasNext()) {
|
||||
File libFile = (File)cacheFiles.next();
|
||||
if (libFile.getName().endsWith(".so"))
|
||||
libFile.delete();
|
||||
}
|
||||
}
|
||||
loadLibs(apkName, shouldExtact);
|
||||
}
|
||||
|
||||
private static void putLocaleEnv() {
|
||||
|
@ -439,7 +439,7 @@ static void * mozload(const char * path, void *zip,
|
||||
|
||||
if (extractLibs) {
|
||||
char fullpath[256];
|
||||
snprintf(fullpath, 256, "/data/data/" ANDROID_PACKAGE_NAME "/%s", path + 4);
|
||||
snprintf(fullpath, 256, "%s/%s", getenv("CACHE_PATH"), path + 4);
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "resolved %s to %s", path, fullpath);
|
||||
extractFile(fullpath, entry, data);
|
||||
handle = __wrap_dlopen(fullpath, RTLD_LAZY);
|
||||
@ -640,8 +640,10 @@ loadLibs(const char *apkName)
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_loadLibs(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName)
|
||||
Java_org_mozilla_gecko_GeckoAppShell_loadLibs(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName, jboolean jShouldExtract)
|
||||
{
|
||||
if (jShouldExtract)
|
||||
extractLibs = 1;
|
||||
const char* str;
|
||||
// XXX: java doesn't give us true UTF8, we should figure out something
|
||||
// better to do here
|
||||
|
Loading…
Reference in New Issue
Block a user