Remove invisible replaced recent task when going to home

There may be multiple tasks with the same base intent by
launching activity with intent flags (FLAG_ACTIVITY_NEW_TASK
| FLAG_ACTIVITY_MULTIPLE_TASK). Since the recents list only
stores the last task for the same task affinity or non-document
identical intent, if the previous task still contains activities,
it may be a leakage.

Bug: 142986867
Test: atest RecentTasksTest# \
      testAddTasksHomeClearUntrackedTasks_expectFinish

Change-Id: Ic6b42f53af31cc574994f1eca4977559cb2db072
2 files changed