Clear mDeferredHideWallpaper if wallpaper is being hidden

We defer wallpaper hiding while AppTransition.isRunning() is true.
However, the state can be changed from 'running' to 'ready', which
makes mDeferredHideWallpaper not to be cleared in time because
handleAnimatingStoppedAndTransitionLocked() would not be called.

When AppTransition is not in 'running' state (animations may be still
running), the logic in WallpaperController.hideWallpapers() would
start hiding wallpapers. However, before applying this patch, it can
only hide the wallpaper surface in WindowState.hideWallpaperWindow(),
but it cannot set the wallpaper to be invisible because
mDeferredHideWallpaper is not cleared.

These conditions cause that the WindowStateAnimator of wallpaper
keeps showing the surface of wallpaper; the WindowStateAnimator of
exiting window keeps hiding the surface of wallpaper frequently.

Bug: 78681867
Bug: 80226677
Test: 1. Run monkey test for hours and see if there is any log like:
         "Performed 6 layouts in a row. Skipping"
      2. Manually open/close activities rapidly and see if wallpaper
         becomes black.
      3. go/wm-smoke

Change-Id: I237fd1942d7365cb747534a21dc98edb076e0d80
Merged-In: I237fd1942d7365cb747534a21dc98edb076e0d80
(cherry picked from commit 50d4546567ecbd143344a75fcacfa15afb5c34d2)
2 files changed