OSDN Git Service

Don't attempt to work on empty pending starts list
authorChristopher Tate <ctate@google.com>
Sat, 16 Feb 2019 00:48:22 +0000 (16:48 -0800)
committerChristopher Tate <ctate@google.com>
Tue, 19 Feb 2019 19:31:57 +0000 (11:31 -0800)
Also plug a bookkeeping hole where information about pending service
starts was cleared but delayed starts relying on that information were
accidentally left dangling.

Fixes: 124467582
Fixes: 124399808
Test: apct/device_boot_health_check_extra
Change-Id: Ic1fec244c76be0969860fd5abee31be575ce0eca

services/core/java/com/android/server/am/ActiveServices.java

index 026430b..aebe2b7 100644 (file)
@@ -319,10 +319,6 @@ public final class ActiveServices {
                 ServiceRecord r = mDelayedStartList.remove(0);
                 if (DEBUG_DELAYED_STARTS) Slog.v(TAG_SERVICE,
                         "REM FR DELAY LIST (exec next): " + r);
-                if (r.pendingStarts.size() <= 0) {
-                    Slog.w(TAG, "**** NO PENDING STARTS! " + r + " startReq=" + r.startRequested
-                            + " delayedStop=" + r.delayedStop);
-                }
                 if (DEBUG_DELAYED_SERVICE) {
                     if (mDelayedStartList.size() > 0) {
                         Slog.v(TAG_SERVICE, "Remaining delayed list:");
@@ -332,11 +328,16 @@ public final class ActiveServices {
                     }
                 }
                 r.delayed = false;
-                try {
-                    startServiceInnerLocked(this, r.pendingStarts.get(0).intent, r, false, true,
-                            false);
-                } catch (TransactionTooLargeException e) {
-                    // Ignore, nobody upstack cares.
+                if (r.pendingStarts.size() <= 0) {
+                    Slog.wtf(TAG, "**** NO PENDING STARTS! " + r + " startReq=" + r.startRequested
+                            + " delayedStop=" + r.delayedStop);
+                } else {
+                    try {
+                        startServiceInnerLocked(this, r.pendingStarts.get(0).intent, r, false, true,
+                                false);
+                    } catch (TransactionTooLargeException e) {
+                        // Ignore, nobody upstack cares.
+                    }
                 }
             }
             if (mStartingBackground.size() > 0) {
@@ -2978,6 +2979,7 @@ public final class ActiveServices {
         // Clear start entries.
         r.clearDeliveredStartsLocked();
         r.pendingStarts.clear();
+        smap.mDelayedStartList.remove(r);
 
         if (r.app != null) {
             synchronized (r.stats.getBatteryStats()) {