Bug 1442255 - 1. Replace setLastIntent with extras bundle; r=esawin
GeckoLoader.setLastIntent is not a very good API for setting environment
variables and is often forgotten. Replace it with an extras bundle that
is passed to setupGeckoEnvironment.
MozReview-Commit-ID: IFhHjLdwFC5
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
@@ -10,28 +10,28 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
+import android.os.Bundle;
import android.os.Environment;
import java.util.ArrayList;
import android.util.Log;
import org.mozilla.gecko.annotation.JNITarget;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.geckoview.BuildConfig;
public final class GeckoLoader {
private static final String LOGTAG = "GeckoLoader";
- private static volatile SafeIntent sIntent;
private static File sCacheFile;
private static File sGREDir;
/* Synchronized on GeckoLoader.class. */
private static boolean sSQLiteLibsLoaded;
private static boolean sNSSLibsLoaded;
private static boolean sMozGlueLoaded;
private static String[] sEnvList;
@@ -86,40 +86,37 @@ public final class GeckoLoader {
// check if the old tmp dir is there
File oldDir = new File(tmpDir.getParentFile(), "app_tmp");
if (oldDir.exists()) {
delTree(oldDir);
}
return tmpDir;
}
- public static void setLastIntent(SafeIntent intent) {
- sIntent = intent;
- }
-
public static void addEnvironmentToIntent(Intent intent) {
if (sEnvList != null) {
for (int ix = 0; ix < sEnvList.length; ix++) {
intent.putExtra("env" + ix, sEnvList[ix]);
}
}
}
- public static void setupGeckoEnvironment(Context context, String profilePath) {
+ public synchronized static void setupGeckoEnvironment(final Context context,
+ final String profilePath,
+ final Bundle extras) {
// if we have an intent (we're being launched by an activity)
// read in any environmental variables from it here
- final SafeIntent intent = sIntent;
- if (intent != null) {
+ if (extras != null) {
final ArrayList<String> envList = new ArrayList<String>();
- String env = intent.getStringExtra("env0");
+ String env = extras.getString("env0");
Log.d(LOGTAG, "Gecko environment env0: " + env);
for (int c = 1; env != null; c++) {
envList.add(env);
putenv(env);
- env = intent.getStringExtra("env" + c);
+ env = extras.getString("env" + c);
Log.d(LOGTAG, "env" + c + ": " + env);
}
if (envList.size() > 0) {
sEnvList = envList.toArray(new String[envList.size()]);
}
}
try {
@@ -154,37 +151,27 @@ public final class GeckoLoader {
if (Build.VERSION.SDK_INT >= 17) {
android.os.UserManager um = (android.os.UserManager)context.getSystemService(Context.USER_SERVICE);
if (um != null) {
putenv("MOZ_ANDROID_USER_SERIAL_NUMBER=" + um.getSerialNumberForUser(android.os.Process.myUserHandle()));
} else {
Log.d(LOGTAG, "Unable to obtain user manager service on a device with SDK version " + Build.VERSION.SDK_INT);
}
}
- setupLocaleEnvironment();
+
+ putenv("LANG=" + Locale.getDefault().toString());
- // We don't need this any more.
- sIntent = null;
+ // env from extras could have reset out linker flags; set them again.
+ loadLibsSetupLocked(context);
}
private static void loadLibsSetupLocked(Context context) {
- // The package data lib directory isn't placed in ld.so's
- // search path, so we have to manually load libraries that
- // libxul will depend on. Not ideal.
-
- File cacheFile = getCacheDir(context);
+ // setup the libs cache
putenv("GRE_HOME=" + getGREDir(context).getPath());
-
- // setup the libs cache
- String linkerCache = System.getenv("MOZ_LINKER_CACHE");
- if (linkerCache == null) {
- linkerCache = cacheFile.getPath();
- putenv("MOZ_LINKER_CACHE=" + linkerCache);
- }
-
+ putenv("MOZ_LINKER_CACHE=" + getCacheDir(context).getPath());
putenv("MOZ_LINKER_EXTRACT=1");
}
@RobocopTarget
public synchronized static void loadSQLiteLibs(final Context context, final String apkName) {
if (sSQLiteLibsLoaded) {
return;
}
@@ -463,20 +450,16 @@ public final class GeckoLoader {
sMozGlueLoaded = true;
}
public synchronized static void loadGeckoLibs(final Context context, final String apkName) {
loadLibsSetupLocked(context);
loadGeckoLibsNative(apkName);
}
- private static void setupLocaleEnvironment() {
- putenv("LANG=" + Locale.getDefault().toString());
- }
-
@SuppressWarnings("serial")
public static class AbortException extends Exception {
public AbortException(String msg) {
super(msg);
}
}
@JNITarget