Post ActivityLaunchAnimator timeout on Looper.mainLooper()

This CL fixes weird shade state bugs that can happen during Activity
launches animated by the ActivityLaunchAnimator.

Before this CL, if a WindowManager timeout happened (i.e. WM never
starts or cancels the remote animation) *and* that the launchContainer
(the ViewRootImpl where the launch started) was detached, then the
timeout would never be triggered, leaving our UI in an invalid state.
This bug is currently easily reproducible using the steps from
b/300056100#comment4, where we incorrectly animate an activity launch
from a dialog then instantly dismiss that dialog.

This CL fixes this bug by posting the timeout on Looper.getMainLooper()
instead of using launchContainer.postDelayed(). That way, the timeout is
always called after 1s if WM didn't start or cancel the remote
animation.

I suspect that this is somehow what is also happening with b/288507023,
but I was not able to confirm this theory yet.

Bug: b/300056100
Bug: b/288507023
Test: Manual, made sure that b/300056100#comment4 is not reproducible
 with this CL. Unfortunately ActivityLaunchAnimator is in a separate
 library so it can't use our DelayableExecutor (that is testable), so
 I don't think there is a good way to write a unit test for this.
Change-Id: Iaa019d6d0aabdf97af0cb6995ad81270f275f3e7
2 files changed