bug 714972 - Opening links from external apps doesn't work after OOM r=mfinkle a=akeybl
authorBrad Lassey <blassey@mozilla.com>
Tue, 03 Jan 2012 21:47:48 -0800
changeset 84867 cd69196df47d5cad5045f6973156bd9729dcd4cb
parent 84866 997eae181a58d0c6c9cc3d658ec5e340b2e8b500
child 84868 f826346fc7a0188edd94e3f1a44a0189908198a4
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, akeybl
bugs714972
milestone11.0a2
bug 714972 - Opening links from external apps doesn't work after OOM r=mfinkle a=akeybl
mobile/android/base/GeckoApp.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -103,16 +103,17 @@ abstract public class GeckoApp
 
     private LinearLayout mMainLayout;
     private RelativeLayout mGeckoLayout;
     public static SurfaceView cameraView;
     public static GeckoApp mAppContext;
     public static boolean mFullScreen = false;
     public static File sGREDir = null;
     public static Menu sMenu;
+    private static GeckoThread sGeckoThread = null;
     public Handler mMainHandler;
     private File mProfileDir;
     private static boolean sIsGeckoReady = false;
 
     private IntentFilter mConnectivityFilter;
     private IntentFilter mBatteryFilter;
 
     private BroadcastReceiver mConnectivityReceiver;
@@ -378,39 +379,16 @@ abstract public class GeckoApp
             throws NameNotFoundException, ClassNotFoundException {
         Context pluginContext = this.mAppContext.createPackageContext(packageName,
                 Context.CONTEXT_INCLUDE_CODE |
                 Context.CONTEXT_IGNORE_SECURITY);
         ClassLoader pluginCL = pluginContext.getClassLoader();
         return pluginCL.loadClass(className);
     }
 
-    // Returns true when the intent is going to be handled by gecko launch
-    boolean launch(Intent intent)
-    {
-        Log.w(LOGTAG, "zerdatime " + new Date().getTime() + " - launch");
-        
-        if (!checkAndSetLaunchState(LaunchState.Launching, LaunchState.Launched))
-            return false;
-
-        if (intent == null)
-            intent = getIntent();
-
-        String args = intent.getStringExtra("args");
-        if (args != null && args.contains("-profile")) {
-            // XXX: TO-DO set mProfileDir to the path passed in
-            mUserDefinedProfile = true;
-        }
-
-        prefetchDNS(intent.getData());
-        new GeckoThread(intent, mLastUri, mLastTitle).start();
-
-        return true;
-    }
-
     @Override
     public boolean onCreateOptionsMenu(Menu menu)
     {
         sMenu = menu;
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.layout.gecko_menu, menu);
         return true;
     }
@@ -1423,32 +1401,51 @@ abstract public class GeckoApp
         mMainHandler = new Handler();
         Log.w(LOGTAG, "zerdatime " + new Date().getTime() + " - onCreate");
         if (savedInstanceState != null) {
             mLastUri = savedInstanceState.getString(SAVED_STATE_URI);
             mLastTitle = savedInstanceState.getString(SAVED_STATE_TITLE);
             mLastViewport = savedInstanceState.getString(SAVED_STATE_VIEWPORT);
             mLastScreen = savedInstanceState.getByteArray(SAVED_STATE_SCREEN);
         }
-        String uri = getIntent().getDataString();
+
+        Intent intent = getIntent();
+        String uri = intent.getDataString();
         String title = uri;
         if (uri != null && uri.length() > 0) {
             mLastUri = uri;
             mLastTitle = title;
         }
 
         if (mLastUri == null || mLastUri.equals("") ||
             mLastUri.equals("about:home")) {
             showAboutHome();
         }
 
+        mAppContext = this;
+
+        if (sGREDir == null)
+            sGREDir = new File(this.getApplicationInfo().dataDir);
+
+        String args = intent.getStringExtra("args");
+        if (args != null && args.contains("-profile")) {
+            // XXX: TO-DO set mProfileDir to the path passed in
+            mUserDefinedProfile = true;
+        }
+
+        prefetchDNS(intent.getData());
+
+        sGeckoThread = new GeckoThread(intent, mLastUri, mLastTitle);
+        if (!ACTION_DEBUG.equals(intent.getAction()) &&
+            checkAndSetLaunchState(LaunchState.Launching, LaunchState.Launched))
+            sGeckoThread.start();
+
         super.onCreate(savedInstanceState);
 
         setContentView(R.layout.gecko_app);
-        mAppContext = this;
 
         if (Build.VERSION.SDK_INT >= 11) {
             mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.gecko_app_actionbar, null);
 
             GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg));
             GeckoActionBar.setDisplayOptions(this, ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM |
                                                                                   ActionBar.DISPLAY_SHOW_HOME |
                                                                                   ActionBar.DISPLAY_SHOW_TITLE |
@@ -1508,19 +1505,16 @@ abstract public class GeckoApp
 
             mGeckoLayout.addView(mLayerController.getView(), 0);
         }
 
         mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);
 
         Log.w(LOGTAG, "zerdatime " + new Date().getTime() + " - UI almost up");
 
-        if (sGREDir == null)
-            sGREDir = new File(this.getApplicationInfo().dataDir);
-
         if (!sTryCatchAttached) {
             sTryCatchAttached = true;
             mMainHandler.post(new Runnable() {
                 public void run() {
                     try {
                         Looper.loop();
                     } catch (Exception e) {
                         Log.e(LOGTAG, "top level exception", e);
@@ -1648,23 +1642,23 @@ abstract public class GeckoApp
         final String action = intent.getAction();
         if (ACTION_DEBUG.equals(action) &&
             checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) {
 
             mMainHandler.postDelayed(new Runnable() {
                 public void run() {
                     Log.i(LOGTAG, "Launching from debug intent after 5s wait");
                     setLaunchState(LaunchState.Launching);
-                    launch(getIntent());
+                    sGeckoThread.start();
                 }
             }, 1000 * 5 /* 5 seconds */);
             Log.i(LOGTAG, "Intent : ACTION_DEBUG - waiting 5s before launching");
             return;
         }
-        if (checkLaunchState(LaunchState.WaitForDebugger) || launch(intent))
+        if (checkLaunchState(LaunchState.WaitForDebugger) || intent == getIntent())
             return;
 
         if (Intent.ACTION_MAIN.equals(action)) {
             Log.i(LOGTAG, "Intent : ACTION_MAIN");
             GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
         }
         else if (Intent.ACTION_VIEW.equals(action)) {
             prefetchDNS(intent.getData());