From 03d0f8193a7ba62308ef3b0a88eb5005425f07d6 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Thu, 20 Apr 2017 16:57:50 -0700 Subject: [PATCH] Don't clear restart counter when bringing up the service. There is no need for clearing the restart counter when bringing up the service. If the service is being started because of rescheduling, then we need to keep track of the counter and shouldn't clear it. And if it is being started because some other process invoked startService/bindService, then it needs to be cleared and we already do that in unscheduleServiceRestartLocked. Also, update the condition for checking if the service is waiting to restart since +ve restartDelay doesn't always mean that the service is waiting to restart. Bug: 36576035 Test: manual && cts-tradefed run singleCommand cts-dev -m CtsAppTestCases -t android.app.cts.ServiceTest cts-tradefed run singleCommand cts-dev -m CtsAppTestCases -t android.app.cts.ActivityManagerTest cts-tradefed run singleCommand cts-dev -m CtsAppTestCases -t android.app.cts.IntentServiceTest Change-Id: I95b8adc84ef1918fd7dce727a87b71e2561b0938 --- services/core/java/com/android/server/am/ActiveServices.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 3fe8a1efa4eb8..c6e44e0d424c5 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -1728,7 +1728,7 @@ public final class ActiveServices { return null; } - if (!whileRestarting && r.restartDelay > 0) { + if (!whileRestarting && mRestartingServices.contains(r)) { // If waiting for a restart, then do nothing. return null; } @@ -1740,7 +1740,6 @@ public final class ActiveServices { // We are now bringing the service up, so no longer in the // restarting state. if (mRestartingServices.remove(r)) { - r.resetRestartCounter(); clearRestartingIfNeededLocked(r); }