Tighten rules for blocking activity starts.

This means we now block various cases where we failed to before,
including where an app launches an activity shortly after the home
button has been pressed, e.g. from within onPause() - either
immediately or after some blocking call.

Details:
- We no longer use process state at all, since a process may remain
  top for a time after the user has switched away and its
  windows have ceased to be visible.
- We no longer allow a start if callerApp.hasForegroundActivities(),
  because we are checking for windows visible to the user and an
  activity may be considered foreground even when it doesn't have such
  windows.
- Windows are only considered visible if isNowVisible() is true,
  rather than isVisible().

Bug: 128688247
Test: atest BackgroundActivityLaunchTest RootWindowContainerTests \
 WmTests:ActivityStarterTests \
 CtsActivityManagerDeviceTestCases:ActivityStarterTests
Test: Manual verification with self-restarting test app
Change-Id: I9863d8637661f15828ced435ff23812a4beef78d
6 files changed