Request transition for explicit finishing visible activity

Set finishing may be a part of cleanup, it is to aggressive for
handling transition. Such as a transition is created even if when
removing background tasks. It is also unnecessary to request
transition when finishing invisible activity. Otherwise the pending
transition may affect the next launch animation.

Bug: 202378926
Test: atest ActivityRecordTests# \
      testFinishActivityIfPossible_nonVisibleNoAppTransition
      testFinishActivityIfPossible_collectToExistingTransition
Test: setprop persist.debug.shell_transit 1; reboot
      Remove task from recents and launch any app, the
      transition animation runs normally.

Change-Id: Ib1509d9ad6a4e8f733e968f5f3e753dd44ab57f7
7 files changed