Bug 1292602 - Set notification client before launching Gecko to avoid crash on notification r?sebastian
Gecko could potentially send notifications via ShowAlertNotification (or any related method). It's possible
for this to happen very soon after launching Gecko, so we need to set the GeckoAppShell's notificationClient
before launching Gecko to ensure that it can handle notifications (this also avoids the associated crash - we
could try to do null-checks instead, but that would result in dropped notifications, which doesn't seem
useful).
MozReview-Commit-ID: 5MG8bBnt12M
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1217,16 +1217,19 @@ public abstract class GeckoApp
// the app context, because various parts of Fennec (e.g.,
// GeckoScreenOrientation) use GAS to access the Activity in
// the guise of fetching a Context.
// When that's fixed, `this` can change to
// `(GeckoApplication) getApplication()` here.
GeckoAppShell.setContextGetter(this);
GeckoAppShell.setApplicationContext(getApplicationContext());
GeckoAppShell.setGeckoInterface(this);
+ // We need to set the notification client before launching Gecko, since Gecko could start
+ // sending notifications immediately after startup, which we don't want to lose/crash on.
+ GeckoAppShell.setNotificationClient(makeNotificationClient());
Tabs.getInstance().attachToContext(this);
try {
Favicons.initializeWithContext(this);
} catch (Exception e) {
Log.e(LOGTAG, "Exception starting favicon cache. Corrupt resources?", e);
}
@@ -1477,17 +1480,16 @@ public abstract class GeckoApp
});
// We use per-profile prefs here, because we're tracking against
// a Gecko pref. The same applies to the locale switcher!
BrowserLocaleManager.storeAndNotifyOSLocale(GeckoSharedPrefs.forProfile(GeckoApp.this), osLocale);
}
});
- GeckoAppShell.setNotificationClient(makeNotificationClient());
IntentHelper.init(this);
}
@Override
public void onStart() {
super.onStart();
if (mIsAbortingAppLaunch) {
return;