Check client hidden state before resetting draw state.

If there are more than activities switched to foreground very quickly,
imagine like: A->B->A, in previous fix, if we found the resumed activity
is hidden in server side, we will reset the drawing state. However, the
resumed activity may be currently visible at client side, and since the
previous transition may not have finished and we will clear the
AppWindowToken in clearChangeLeash, this AppWindowToken may never receive
onAnimationFinished callback, so the mClientHidden will stay in false.

Since server side doesn't require client side to relayout, the allDraw state
will remain in false, which will cause the second transition cannot start.
Therefore, even when resumed activity idled, the stopping activity cannot be
removed from processStoppingActivitiesLocked because isSelfAnimating remains
true.

Fix: 137898192
Bug: 127741025
Test: atest CtsWindowManagerDeviceTestCases:ActivityStarterTests
Test: Manual testing that b/134561008 didn't reproduce.

Change-Id: Ie76b33ec5f12591c3166612e69b49325d7276216
1 file changed