Do not depend on task activities decrementing with finish.

It is possible for a task to be cleared when a single activity is
finished. For example, if only task overlays are present after an
activity is removed, the task can be cleared under certain
conditions. As a result, we can not rely on only a single activity
being removed from a task when it is finished.

This changelist addresses this issue by caching the list of actvities
under a task that will not be modified as activities are finished.

Change-Id: Id3b0813deebd0bc31b2ff7ae7f69a2833dcb0a61
Fixes: 64291682
Test: atest FrameworksServicesTests:com.android.server.am.ActivityStackTests#testFinishDisabledPackageActivities
Test: atest FrameworksServicesTests:com.android.server.am.ActivityStackTests#testHandleAppDied
5 files changed