Bug 1401737 - 3. Consolidate GeckoAppShell initialization; r=me
authorJim Chen <nchen@mozilla.com>
Thu, 05 Oct 2017 14:59:32 -0400
changeset 427322 e9224d3e7de6883c226be85cfe301a0e82960d26
parent 427321 70203c5f6d177636a3bc1e816562202688fdd7f5
child 427323 9c9bf73f5a4e6be896ca8c34dfc29298cfc285ed
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersme
bugs1401737
milestone58.0a1
Bug 1401737 - 3. Consolidate GeckoAppShell initialization; r=me Consolidate GeckoAppShell initialization to GeckoApplication.onCreate instead of spreading it out over different Activities. r=me for trivial patch. MozReview-Commit-ID: J0iv3qePlci
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
mobile/android/base/java/org/mozilla/gecko/GeckoService.java
mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
mobile/android/search/java/org/mozilla/search/SearchActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1053,18 +1053,16 @@ public abstract class GeckoApp extends G
     /**
      * Called when the activity is first created.
      *
      * Here we initialize all of our profile settings, Firefox Health Report,
      * and other one-shot constructions.
      **/
     @Override
     public void onCreate(Bundle savedInstanceState) {
-        GeckoAppShell.ensureCrashHandling();
-
         // Enable Android Strict Mode for developers' local builds (the "default" channel).
         if ("default".equals(AppConstants.MOZ_UPDATE_CHANNEL)) {
             enableStrictMode();
         }
 
         // Mozglue should already be loaded by BrowserApp.onCreate() in Fennec, but in
         // custom tabs it may not be.
         GeckoLoader.loadMozGlue(getApplicationContext());
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
@@ -197,16 +197,20 @@ public class GeckoApplication extends Ap
         mInBackground = false;
     }
 
     @Override
     public void onCreate() {
         Log.i(LOG_TAG, "zerdatime " + SystemClock.elapsedRealtime() +
               " - application start");
 
+        final Context context = getApplicationContext();
+        GeckoAppShell.ensureCrashHandling();
+        GeckoAppShell.setApplicationContext(context);
+
         // PRNG is a pseudorandom number generator.
         // We need to apply PRNG Fixes before any use of Java Cryptography Architecture.
         // We make use of various JCA methods in data providers for generating GUIDs, as part of FxA
         // flow and during syncing. Note that this is a no-op for devices running API>18, and so we
         // accept the performance penalty on older devices.
         try {
             PRNGFixes.apply();
         } catch (Exception e) {
@@ -218,18 +222,16 @@ public class GeckoApplication extends Ap
 
         mRefWatcher = LeakCanary.install(this);
 
         sSessionUUID = UUID.randomUUID().toString();
 
         GeckoActivityMonitor.getInstance().initialize(this);
         MemoryMonitor.getInstance().init(this);
 
-        final Context context = getApplicationContext();
-        GeckoAppShell.setApplicationContext(context);
         GeckoAppShell.setHapticFeedbackDelegate(this);
         GeckoAppShell.setGeckoInterface(new GeckoAppShell.GeckoInterface() {
             @Override
             public boolean openUriExternal(final String targetURI, final String mimeType,
                                            final String packageName, final String className,
                                            final String action, final String title) {
                 // Default to showing prompt in private browsing to be safe.
                 return IntentHelper.openUriExternal(targetURI, mimeType, packageName,
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoService.java
@@ -96,17 +96,16 @@ public class GeckoService extends Servic
             Log.d(LOGTAG, "Unregistered listener");
         }
         EventDispatcher.getInstance().unregisterGeckoThreadListener(EVENT_LISTENER,
                 "Gecko:ScheduleRun");
     }
 
     @Override // Service
     public void onCreate() {
-        GeckoAppShell.ensureCrashHandling();
         GeckoThread.onResume();
         super.onCreate();
 
         if (DEBUG) {
             Log.d(LOGTAG, "Created");
         }
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
@@ -49,18 +49,16 @@ import org.mozilla.gecko.deeplink.DeepLi
  */
 public class LauncherActivity extends Activity {
     private static final String TAG = LauncherActivity.class.getSimpleName();
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        GeckoAppShell.ensureCrashHandling();
-
         final SafeIntent safeIntent = new SafeIntent(getIntent());
 
         // Is this deep link?
         if (isDeepLink(safeIntent)) {
             dispatchDeepLink(safeIntent);
 
         } else if (isShutdownIntent(safeIntent)) {
             dispatchShutdownIntent();
--- a/mobile/android/search/java/org/mozilla/search/SearchActivity.java
+++ b/mobile/android/search/java/org/mozilla/search/SearchActivity.java
@@ -101,18 +101,16 @@ public class SearchActivity extends Loca
     private static class AsyncQueryHandlerImpl extends AsyncQueryHandler {
         public AsyncQueryHandlerImpl(final ContentResolver that) {
             super(that);
         }
     }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        GeckoAppShell.ensureCrashHandling();
-
         super.onCreate(savedInstanceState);
         setContentView(R.layout.search_activity_main);
 
         suggestionsFragment = (SuggestionsFragment) getSupportFragmentManager().findFragmentById(R.id.suggestions);
         postSearchFragment = (PostSearchFragment)  getSupportFragmentManager().findFragmentById(R.id.postsearch);
 
         searchEngineManager = new SearchEngineManager(this, Distribution.init(getApplicationContext()));
         searchEngineManager.setChangeCallback(this);