Bug 1393452 - Don't crash when FeedService is restarted after being killed. r?sebastian
MozReview-Commit-ID: BAtDI5EqSA6
--- a/mobile/android/base/java/org/mozilla/gecko/feeds/FeedService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/feeds/FeedService.java
@@ -63,21 +63,25 @@ public class FeedService extends IntentS
public void onCreate() {
super.onCreate();
browserDB = BrowserDB.from(this);
}
@Override
protected void onHandleIntent(Intent intent) {
+ if (intent == null) {
+ // If we're restarted by the OS after having been killed earlier (which shouldn't happen,
+ // as with Intent redelivery disabled IntentService launches with START_NOT_STICKY, but
+ // anyway...), the intent will be null. Since we won't have a wakelock in that case and
+ // completeWakefulIntent doesn't like being passed null intents, we just return early.
+ return;
+ }
+
try {
- if (intent == null) {
- return;
- }
-
Log.d(LOGTAG, "Service started with action: " + intent.getAction());
if (!isInExperiment(this)) {
Log.d(LOGTAG, "Not in content notifications experiment. Skipping.");
return;
}
FeedAction action = createActionForIntent(intent);