mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07: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
75ef95bcdc
commit
b195811fd6
@ -79,6 +79,8 @@ class GeckoAppShell
|
|||||||
static private final int NOTIFY_IME_CANCELCOMPOSITION = 2;
|
static private final int NOTIFY_IME_CANCELCOMPOSITION = 2;
|
||||||
static private final int NOTIFY_IME_FOCUSCHANGE = 3;
|
static private final int NOTIFY_IME_FOCUSCHANGE = 3;
|
||||||
|
|
||||||
|
static private final long kFreeSpaceThreshold = 19660800L; // 150Mb
|
||||||
|
|
||||||
/* The Android-side API: API methods that Android calls */
|
/* The Android-side API: API methods that Android calls */
|
||||||
|
|
||||||
// Initialization methods
|
// Initialization methods
|
||||||
@ -92,7 +94,7 @@ class GeckoAppShell
|
|||||||
public static native void onLowMemory();
|
public static native void onLowMemory();
|
||||||
public static native void callObserver(String observerKey, String topic, String data);
|
public static native void callObserver(String observerKey, String topic, String data);
|
||||||
public static native void removeObserver(String observerKey);
|
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
|
// java-side stuff
|
||||||
public static void loadGeckoLibs(String apkName) {
|
public static void loadGeckoLibs(String apkName) {
|
||||||
@ -120,6 +122,13 @@ class GeckoAppShell
|
|||||||
|
|
||||||
f = Environment.getDownloadCacheDirectory();
|
f = Environment.getDownloadCacheDirectory();
|
||||||
GeckoAppShell.putenv("EXTERNAL_STORAGE=" + f.getPath());
|
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;
|
File downloadDir = null;
|
||||||
if (Build.VERSION.SDK_INT >= 8)
|
if (Build.VERSION.SDK_INT >= 8)
|
||||||
downloadDir = GeckoApp.mAppContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
|
downloadDir = GeckoApp.mAppContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
|
||||||
@ -129,7 +138,17 @@ class GeckoAppShell
|
|||||||
|
|
||||||
putLocaleEnv();
|
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() {
|
private static void putLocaleEnv() {
|
||||||
|
@ -439,7 +439,7 @@ static void * mozload(const char * path, void *zip,
|
|||||||
|
|
||||||
if (extractLibs) {
|
if (extractLibs) {
|
||||||
char fullpath[256];
|
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);
|
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "resolved %s to %s", path, fullpath);
|
||||||
extractFile(fullpath, entry, data);
|
extractFile(fullpath, entry, data);
|
||||||
handle = __wrap_dlopen(fullpath, RTLD_LAZY);
|
handle = __wrap_dlopen(fullpath, RTLD_LAZY);
|
||||||
@ -640,8 +640,10 @@ loadLibs(const char *apkName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" NS_EXPORT void JNICALL
|
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;
|
const char* str;
|
||||||
// XXX: java doesn't give us true UTF8, we should figure out something
|
// XXX: java doesn't give us true UTF8, we should figure out something
|
||||||
// better to do here
|
// better to do here
|
||||||
|
Loading…
Reference in New Issue
Block a user