Bug 1546153 - Fix NPE at BrowserApp.onCreate() caused by mBrowserToolbar being null. r=VladBaicu
authorAnuta Logigan <anuta.vlad@softvision.ro>
Thu, 25 Apr 2019 16:39:26 +0200
changeset 531283 86c7622bc218906e28cf73c18c7e3b867d7839e3
parent 531282 1a2d4ae3d07fe29a616ed2d71fb4597d1f5a1274
child 531284 330882d258d25a37a8479befbc40d94ca675db77
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersVladBaicu
bugs1546153
milestone68.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 1546153 - Fix NPE at BrowserApp.onCreate() caused by mBrowserToolbar being null. r=VladBaicu Differential Revision: https://phabricator.services.mozilla.com//D28857
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -634,18 +634,18 @@ public class BrowserApp extends GeckoApp
         // This has to be prepared prior to calling GeckoApp.onCreate, because
         // widget code and BrowserToolbar need it, and they're created by the
         // layout, which GeckoApp takes care of.
         final GeckoApplication app = (GeckoApplication) getApplication();
         app.prepareLightweightTheme();
 
         super.onCreate(savedInstanceState);
 
-        if (mIsAbortingAppLaunch) {
-          return;
+        if (isShutDownOrAbort()) {
+            return;
         }
 
         mOnboardingHelper = new OnboardingHelper(this, safeStartingIntent);
         initSwitchboardAndMma(this, safeStartingIntent, isInAutomation);
         initTelemetryUploader(isInAutomation);
 
         mBrowserChrome = (ViewGroup) findViewById(R.id.browser_chrome);
         mActionBarFlipper = (ViewFlipper) findViewById(R.id.browser_actionbar);
@@ -1078,17 +1078,17 @@ public class BrowserApp extends GeckoApp
             openUrls(urls);
         }
     }
 
     @Override
     public void onResume() {
         super.onResume();
 
-        if (mIsAbortingAppLaunch) {
+        if (isShutDownOrAbort()) {
             return;
         }
 
         if (!mHasResumed) {
             getAppEventDispatcher().unregisterUiThreadListener(this, "Prompt:ShowTop");
             mHasResumed = true;
         }
 
@@ -1099,17 +1099,17 @@ public class BrowserApp extends GeckoApp
         }
     }
 
     @Override
     public void onPause() {
         dismissTabHistoryFragment();
 
         super.onPause();
-        if (mIsAbortingAppLaunch) {
+        if (isShutDownOrAbort()) {
             return;
         }
 
         if (mHasResumed) {
             // Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
             getAppEventDispatcher().registerUiThreadListener(this, "Prompt:ShowTop");
             mHasResumed = false;
         }
@@ -1163,29 +1163,29 @@ public class BrowserApp extends GeckoApp
                 }
             }
         }
     }
 
     @Override
     public void onRestart() {
         super.onRestart();
-        if (mIsAbortingAppLaunch) {
+        if (isShutDownOrAbort()) {
             return;
         }
 
         for (final BrowserAppDelegate delegate : delegates) {
             delegate.onRestart(this);
         }
     }
 
     @Override
     public void onStart() {
         super.onStart();
-        if (mIsAbortingAppLaunch) {
+        if (isShutDownOrAbort()) {
             return;
         }
 
         // Queue this work so that the first launch of the activity doesn't
         // trigger profile init too early.
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
@@ -1212,17 +1212,17 @@ public class BrowserApp extends GeckoApp
 
         MmaDelegate.track(MmaDelegate.RESUMED_FROM_BACKGROUND);
         MmaDelegate.notifyDefaultBrowserStatus(this);
     }
 
     @Override
     public void onStop() {
         super.onStop();
-        if (mIsAbortingAppLaunch) {
+        if (isShutDownOrAbort()) {
             return;
         }
 
         if (mPipController.isInPipMode()) {
             // If screen is locked we should exit PictureInPicture mode
             moveTaskToBack(true);
             mPipController.cleanResources();
         }
@@ -1505,17 +1505,17 @@ public class BrowserApp extends GeckoApp
             return true;
         }
 
         return false;
     }
 
     @Override
     public void onDestroy() {
-        if (mIsAbortingAppLaunch) {
+        if (isShutDownOrAbort()) {
             super.onDestroy();
             return;
         }
 
         if (mProgressView != null) {
             mProgressView.setDynamicToolbar(null);
         }
 
@@ -4237,9 +4237,13 @@ public class BrowserApp extends GeckoApp
     }
 
     private void dismissTabHistoryFragment() {
         TabHistoryFragment frag = (TabHistoryFragment) getSupportFragmentManager().findFragmentByTag(TAB_HISTORY_FRAGMENT_TAG);
         if (frag != null) {
             frag.dismiss();
         }
     }
+
+    private boolean isShutDownOrAbort() {
+        return mIsAbortingAppLaunch || mShutdownOnDestroy;
+    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -345,17 +345,17 @@ public abstract class GeckoApp extends G
 
     private String mPrivateBrowsingSession;
     private boolean mPrivateBrowsingSessionOutdated;
     private static final int MAX_PRIVATE_TABS_UPDATE_WAIT_MSEC = 500;
 
     private volatile HealthRecorder mHealthRecorder;
     private volatile Locale mLastLocale;
 
-    private boolean mShutdownOnDestroy;
+    protected boolean mShutdownOnDestroy;
     private boolean mRestartOnShutdown;
 
     private boolean mWasFirstTabShownAfterActivityUnhidden;
     private boolean mIsFullscreen;
 
     abstract public int getLayout();
 
     abstract public View getDoorhangerOverlay();