Make the removal in finish-package-activities deterministic

Sometimes the removal of activity may be deferred by animating.
And it is possible that the deferred record is removed with
another finishing activity (finishIfPossible ->
performSurfacePlacement -> handleCompleteDeferredRemoval) that
causes index of bounds in forAllActivities (next index is
size-1, but the size becomes size-2).

Now the activities to finish are collected to an independent list
so it won't be affected by any changes of hierarchy containers.

The checking for home activity can also be removed because if
home is restarted, it won't appear in the collected list.

Bug: 160752989
Test: ActivityStackTests# \
      testFinishDisabledPackageActivities_FinishAliveActivities
      testFinishDisabledPackageActivities_RemoveNonAliveActivities

Change-Id: I2fcbac35fb23295cfe54856c5f08eae97fa6b87f
1 file changed