Fix issue #10779747: Calendar Storage crash observed...

...while setting up a new user from settings.

The delayed service start stuff was too aggressive -- it would
allow a process to be killed between the an onReceive() that calls
startService() and that service being started.  This means that
apps that set up global state that they expect to remain set up
during that time could be lost.

This is the first part of a fix, which tightens up when we allow
services to be delayed.  Now we will immediately start the service
as long as it currently as a process running that is not in the
cached state.  (Previously we would delay if the process was in
the receiver state.)

This unfortunately means that our service start delay is much
less effective.  To address that, there will be a follow-on change
to tie broadcast delivery into this to see if we can delay the
finish of a broadcast as long as there are background services
starting in that process.

Change-Id: I2bba2295d10699ee3479375bbe87114b2cbb0826
2 files changed