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
1 file changed