Fix flakiness of testTaskChangeCallBacks
1. The test asserts that there will be onDetachedFromWindow. But if
finishAndRemoveTask is called too early before the window is
attached, there won't be the callback. So make sure that
onAttachedToWindow is called before triggering the removal.
2. The task removal callback may come from previous test. So only
count down the latch for removal if the incoming task id is the
one created by the current test method.
Also
- Create virtual display only if needed.
- Replace deprecated callback of TaskStackListener.
Fixes: 212682767
Test: atest TaskStackChangedListenerTest#testTaskChangeCallBacks
Change-Id: Idcfcef3b2a5162cc6b5496ff0a448f8399984dbe
1 file changed