Remove trimmable tasks on activity idle
Previously, the unreachable/inactive tasks may be removed when
adding a task to recents list. That may causes the indirect caller
to encounter index out of bounds exception when iteration tasks.
Because activity-idle should be a standalone event that it should
not be called in any loop, and it is also the place to handle
stopping and finishing activities. So it is a relatively safe place
to remove the trimmable tasks. Besides, the movement of invocation
may avoid additional time when launching activity that triggers trim.
Also simplify the setup of RecentTasksTest to reduce 60%+ execution
time of the test class.
Bug: 169124675
Test: atest RecentTasksTest
Change-Id: I49003b834ac55a44bf36ad59f920d4e662f9e427
3 files changed