Bug 1219016 - Don't use GeckoThread state to detect GeckoApp relaunching; r=snorp
authorJim Chen <nchen@mozilla.com>
Wed, 11 Nov 2015 21:28:59 -0500
changeset 308418 f2bffacca04c239a253cf6906cd98210a7381285
parent 308417 5f9371f97e1e21f10fa20b39f33774116cfcf5f0
child 308419 9dbbf81894ca3903dad663333987fe01ddfac63b
push id7470
push users.kaspari@gmail.com
push dateThu, 12 Nov 2015 12:51:02 +0000
reviewerssnorp
bugs1219016
milestone45.0a1
Bug 1219016 - Don't use GeckoThread state to detect GeckoApp relaunching; r=snorp Right now we use the GeckoThread state to detect whether GeckoApp is first launching or is being restored after being destroyed. However, because of headless mode, GeckoThread could already be running on GeckoApp's first launch, so we need a separate way to detect relaunching.
mobile/android/base/GeckoApp.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -165,16 +165,18 @@ public abstract class GeckoApp
 
     public static final String SAVED_STATE_IN_BACKGROUND   = "inBackground";
     public static final String SAVED_STATE_PRIVATE_SESSION = "privateSession";
 
     // Delay before running one-time "cleanup" tasks that may be needed
     // after a version upgrade.
     private static final int CLEANUP_DEFERRAL_SECONDS = 15;
 
+    private static boolean sAlreadyLoaded;
+
     protected RelativeLayout mRootLayout;
     protected RelativeLayout mMainLayout;
 
     protected RelativeLayout mGeckoLayout;
     private View mCameraView;
     private OrientationEventListener mCameraOrientationEventListener;
     public List<GeckoAppShell.AppStateListener> mAppStateListeners = new LinkedList<GeckoAppShell.AppStateListener>();
     protected MenuPanel mMenuPanel;
@@ -1296,25 +1298,26 @@ public abstract class GeckoApp
         // restart, and will be propagated to Gecko accordingly, so there's
         // no need to touch that here.
         if (BrowserLocaleManager.getInstance().systemLocaleDidChange()) {
             Log.i(LOGTAG, "System locale changed. Restarting.");
             doRestart();
             return;
         }
 
-        if (GeckoThread.isLaunched()) {
+        if (sAlreadyLoaded) {
             // This happens when the GeckoApp activity is destroyed by Android
             // without killing the entire application (see Bug 769269).
             mIsRestoringActivity = true;
             Telemetry.addToHistogram("FENNEC_RESTORING_ACTIVITY", 1);
 
         } else {
             final String uri = getURIFromIntent(intent);
 
+            sAlreadyLoaded = true;
             GeckoThread.ensureInit(args, action,
                     /* debugging */ ACTION_DEBUG.equals(action));
 
             if (!TextUtils.isEmpty(uri)) {
                 // Start a speculative connection as soon as Gecko loads.
                 GeckoThread.speculativeConnect(uri);
             }
         }