Fix race of releasing leashes with shell recents transition

The code flow:
RecentsAnimationController#finishController
 mOnFinishedListener.accept(this);
  RecentsAnimationCallbacks#onAnimationFinished
   *Post to "main" thread
    RecentsAnimationListener#onRecentsAnimationFinished
     TaskAnimationManager#cleanUpRecentsAnimation
      Invoke SurfaceControl#release
 *Post to "UiThreadHelper" thread
  RemoteTransitionCompat.RecentsControllerWrap#finish
   Invoke SurfaceControl.Transaction#remove
   on the same SurfaceControl.

Then it may be either NullPointerException from
SurfaceControl#checkNotReleased. Or rarely native crash by
changing the surface control from 2 threads at the same time.

Bug: 238192072
Bug: 238047903
Bug: 237631001
Bug: 237497909
Bug: 235616350
Test: Loop launch app and swipe to home.

Change-Id: I7e4ce2c273b8396ed464eb48426fd4435d6c5338
1 file changed