Wait for onPictureInPictureUiStateChanged callback

For ActivityThreadTests, there are chances that WM is trying to deliver
PipStateTransactionItem to the app after it's been destroyed by the test
itself. This transaction item is newly introduced from ag/26031127 and
it happens at the very beginning of the entering PiP animation.

Added a countdown latch to wait for the onPictureInPictureUiStateChanged
callback finishes.

Bug: 325128917
Flag: ENABLE_PIP_UI_STATE_CALLBACK_ON_ENTERING
Test: atest --iteration 10 FrameworksCoreTests:ActivityThreadTest
Change-Id: I29f9d6e42ec478023224eed6b138fabcd0bb2e31
1 file changed