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
This commit is contained in:
Sudheer Shanka
2017-04-20 16:57:50 -07:00
parent fc533da920
commit 03d0f8193a

View File

@@ -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);
}