Make service start whitelisting for background activity starts persist
after service start.

If the service was started with allowBackgroundActivityStarts we want
it to be able to start activities even after the service is stopped,
until the 10s timeout expires. That means we have to track the process
that we whitelisted independently of the current service process.

This moves the cleanup callback logic completely into ServiceRecord to
make it easier to see all the moving parts (and because that's where
all the relevant data lives anyway).

Test: Manually verified b/130147122 is fixed.
Test: atest BackgroundActivityLaunchTest
Test: atest RootWindowContainerTests
Test: atest WmTests:ActivityStarterTests
Test: atest CtsWindowManagerDeviceTestCases:ActivityStarterTests
Test: atest CtsAppTestCases:.ServiceTest
Bug: 130147122
Change-Id: Ia9a9a718da4791ca56316fa4500e3d30d11b599c
2 files changed