Fix flaky TaskStackChangedListenerTest

The test was flaky is because the activity can be killed before the test
finished running.

The test activity would be killed in onPostResumed and the latch count
down is happening in onResumed. After that, the test was trying to
access task ID via the activity. It is possible that when accessing
task ID, the activity is no longer there.

To fix that, keep the task ID when creating the activity in the test.
This will significantly reduce, if not eliminate, the flakiness inside.

Mark as pre-submit candidate to be monitored.

Test: atest TaskStackChangedListenerTest
Bug: 119893767
Change-Id: I3826282b395169097cb3496e47557d622a8fc856
1 file changed