diff --git a/mozglue/android/APKOpen.cpp b/mozglue/android/APKOpen.cpp index eb53ba1fbdd..11ec545c7d2 100644 --- a/mozglue/android/APKOpen.cpp +++ b/mozglue/android/APKOpen.cpp @@ -104,10 +104,16 @@ JNI_Throw(JNIEnv* jenv, const char* classname, const char* msg) #undef JNI_STUBS static void * xul_handle = NULL; +#ifndef MOZ_FOLD_LIBS static void * sqlite_handle = NULL; -static void * nss_handle = NULL; static void * nspr_handle = NULL; static void * plc_handle = NULL; +#else +#define sqlite_handle nss_handle +#define nspr_handle nss_handle +#define plc_handle nss_handle +#endif +static void * nss_handle = NULL; template inline void xul_dlsym(const char *symbolName, T *value) @@ -257,8 +263,18 @@ loadGeckoLibs(const char *apkName) return SUCCESS; } -static int loadSQLiteLibs(const char *apkName) +static mozglueresult loadNSSLibs(const char *apkName); + +static mozglueresult +loadSQLiteLibs(const char *apkName) { + if (sqlite_handle) + return SUCCESS; + +#ifdef MOZ_FOLD_LIBS + if (loadNSSLibs(apkName) != SUCCESS) + return FAILURE; +#else chdir(getenv("GRE_HOME")); RefPtr zip = ZipCollection::GetZip(apkName); @@ -284,6 +300,7 @@ static int loadSQLiteLibs(const char *apkName) __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libmozsqlite3!"); return FAILURE; } +#endif setup_sqlite_functions(sqlite_handle); return SUCCESS; @@ -292,6 +309,9 @@ static int loadSQLiteLibs(const char *apkName) static mozglueresult loadNSSLibs(const char *apkName) { + if (nss_handle && nspr_handle && plc_handle) + return SUCCESS; + chdir(getenv("GRE_HOME")); RefPtr zip = ZipCollection::GetZip(apkName); @@ -308,6 +328,7 @@ loadNSSLibs(const char *apkName) nss_handle = __wrap_dlopen(file, RTLD_GLOBAL | RTLD_LAZY); delete [] file; +#ifndef MOZ_FOLD_LIBS file = new char[strlen(apkName) + sizeof("!/libnspr4.so")]; sprintf(file, "%s!/libnspr4.so", apkName); nspr_handle = __wrap_dlopen(file, RTLD_GLOBAL | RTLD_LAZY); @@ -317,6 +338,7 @@ loadNSSLibs(const char *apkName) sprintf(file, "%s!/libplc4.so", apkName); plc_handle = __wrap_dlopen(file, RTLD_GLOBAL | RTLD_LAZY); delete [] file; +#endif #ifdef MOZ_CRASHREPORTER free(file_ids); @@ -328,6 +350,7 @@ loadNSSLibs(const char *apkName) return FAILURE; } +#ifndef MOZ_FOLD_LIBS if (!nspr_handle) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libnspr4!"); return FAILURE; @@ -337,6 +360,7 @@ loadNSSLibs(const char *apkName) __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libplc4!"); return FAILURE; } +#endif return setup_nss_functions(nss_handle, nspr_handle, plc_handle); } diff --git a/mozglue/android/Makefile.in b/mozglue/android/Makefile.in index 5b6070846d6..d2e0fb628dd 100644 --- a/mozglue/android/Makefile.in +++ b/mozglue/android/Makefile.in @@ -19,6 +19,10 @@ DEFINES += \ -DANDROID_PACKAGE_NAME='"$(ANDROID_PACKAGE_NAME)"' \ $(NULL) +ifdef MOZ_FOLD_LIBS +DEFINES += -DMOZ_FOLD_LIBS +endif + CPPSRCS = \ nsGeckoUtils.cpp \ APKOpen.cpp \