Bug 1533425 - Look for architecture-specific greprefs.js files on Android r=njn

We want to publish a multi-architecture AAR for GeckoView which includes
a single omni.ja, but we archicture-specific changes in greprefs.js that
prevent this from working. This patch causes us to try to read an
architecture-specific greprefs.js first, which will be provided by the
packaging process for the fat AAR.

Differential Revision: https://phabricator.services.mozilla.com/D22526

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Willcox 2019-03-14 19:37:03 +00:00
Родитель be6df29c13
Коммит 98778b5ae2
2 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -116,6 +116,7 @@ public final class GeckoLoader {
}
}
@SuppressWarnings("deprecation") // for Build.CPU_ABI
public synchronized static void setupGeckoEnvironment(final Context context,
final String profilePath,
final Collection<String> env,
@ -176,6 +177,7 @@ public final class GeckoLoader {
}
putenv("MOZ_ANDROID_DEVICE_SDK_VERSION=" + Build.VERSION.SDK_INT);
putenv("MOZ_ANDROID_CPU_ABI=" + Build.CPU_ABI);
setupInitialPrefs(prefs);

Просмотреть файл

@ -4418,7 +4418,7 @@ float MOZ_MAYBE_UNUSED GetPref<float>(const char* aName, float aDefaultValue) {
// Thus, in the omni.jar case, we always load app-specific default
// preferences from omni.jar, whether or not `$app == $gre`.
nsresult rv;
nsresult rv = NS_ERROR_FAILURE;
nsZipFind* findPtr;
nsAutoPtr<nsZipFind> find;
nsTArray<nsCString> prefEntries;
@ -4428,8 +4428,24 @@ float MOZ_MAYBE_UNUSED GetPref<float>(const char* aName, float aDefaultValue) {
RefPtr<nsZipArchive> jarReader =
mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE);
if (jarReader) {
#ifdef MOZ_WIDGET_ANDROID
// Try to load an architecture-specific greprefs.js first. This will be
// present in FAT AAR builds of GeckoView on Android.
const char* abi = getenv("MOZ_ANDROID_CPU_ABI");
if (abi) {
nsAutoCString path;
path.AppendPrintf("%s/greprefs.js", abi);
rv = pref_ReadPrefFromJar(jarReader, path.get());
}
if (NS_FAILED(rv)) {
// Fallback to toplevel greprefs.js if arch-specific load fails.
rv = pref_ReadPrefFromJar(jarReader, "greprefs.js");
}
#else
// Load jar:$gre/omni.jar!/greprefs.js.
rv = pref_ReadPrefFromJar(jarReader, "greprefs.js");
#endif
NS_ENSURE_SUCCESS(rv, Err("pref_ReadPrefFromJar() failed"));
// Load jar:$gre/omni.jar!/defaults/pref/*.js.