Do not hide animating window behind keyguard.

The transition from clock to keyguard when restarting the device
was janky. The cause was that the clock app was animating away
which kept the adjustWallpaperWindowsLocked() method from setting
the keyguard as the new mWallpaperTarget. At the same time the
WindowAnimator saw that the keyguard was readyToDisplay() which
set mForceHiding true causing the clock to become hidden. Since
the clock was mWallpaperTarget the wallpaper was hidden at the
same time.

This fix does not allow mForceHiding to hide an animating
window.

Fixes bug 6649988.

Change-Id: Ie5cb0dfcc987d5ee1ad2351cf520629b8e301a2b
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index efed0a4..d82f659 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -292,7 +292,7 @@
                             + " anim=" + win.mWinAnimator.mAnimation);
                 } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) {
                     final boolean changed;
-                    if (mForceHiding) {
+                    if (mForceHiding && !winAnimator.isAnimating()) {
                         changed = win.hideLw(false, false);
                         if (WindowManagerService.DEBUG_VISIBILITY && changed) Slog.v(TAG,
                                 "Now policy hidden: " + win);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 28c8b06..c94a3c7 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -1740,8 +1740,6 @@
                             mWallpaperTarget = oldW;
                             foundW = oldW;
                             foundI = oldI;
-                            mLowerWallpaperTarget = null;
-                            mUpperWallpaperTarget = null;
                         } 
                         // Now set the upper and lower wallpaper targets
                         // correctly, and make sure that we are positioning
@@ -3162,6 +3160,7 @@
             set.addAnimation(scale);
             alpha.setDuration(duration);
             set.addAnimation(alpha);
+            set.setDetachWallpaper(true);
             a = set;
         } else {
             a = createExitAnimationLocked(transit, duration);