Bug 1393452 - Don't crash when FeedService is restarted after being killed. r?sebastian draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 24 Aug 2017 20:06:33 +0200
changeset 652285 022a95eade982ec156bda61f0c37db1376e139c4
parent 651456 6ffcdde3eaba8f47ed27e4c3c762201e534aaaf0
child 728060 96dfb8cd656719b825f671ca5221c62fc5c6d904
push id76025
push usermozilla@buttercookie.de
push dateThu, 24 Aug 2017 18:08:25 +0000
reviewerssebastian
bugs1393452
milestone57.0a1
Bug 1393452 - Don't crash when FeedService is restarted after being killed. r?sebastian MozReview-Commit-ID: BAtDI5EqSA6
mobile/android/base/java/org/mozilla/gecko/feeds/FeedService.java
--- 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);