Bug 1442255 - 1. Replace setLastIntent with extras bundle; r=esawin
authorJim Chen <nchen@mozilla.com>
Tue, 06 Mar 2018 13:52:48 -0500
changeset 461836 47c1e6667b85c4c7fca36f2454bdd54b1474f0af
parent 461835 60b1f8616b22e378c8b0575d9d62bc1ff6463fc6
child 461837 ab953c63958b117b87353f94c682f7e6817bfd04
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1442255
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/GeckoLoader.java
--- 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