Implement issue #3201795: Improve transition when keyboard comes up

ViewRoot now does a fade animation between a snapshot of the previous
layout to the new one when its content rect changes.

Also tweaked some things in the window manager to fix problems in
deciding when to animate the movement of a window and when not to.

Change-Id: I9b4b3bd53c8258bd39a2f2fc315e77cfc56a409c
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 5e49404..27ec1af 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -6848,6 +6848,8 @@
             }
 
             if (!mParentFrame.equals(pf)) {
+                //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame
+                //        + " to " + pf);
                 mParentFrame.set(pf);
                 mContentChanged = true;
             }
@@ -7734,12 +7736,10 @@
          * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
          */
         boolean shouldAnimateMove() {
-            return mContentChanged && !mAnimating && !mLastHidden && !mDisplayFrozen
+            return mContentChanged && !mExiting && !mLastHidden && !mDisplayFrozen
                     && (mFrame.top != mLastFrame.top
                             || mFrame.left != mLastFrame.left)
-                    && (mAttachedWindow == null
-                            || (mAttachedWindow.mAnimation == null
-                                    && !mAttachedWindow.shouldAnimateMove()))
+                    && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove())
                     && mPolicy.isScreenOn();
         }
 
@@ -9223,6 +9223,7 @@
             if (!gone || !win.mHaveFrame) {
                 if (!win.mLayoutAttached) {
                     if (initial) {
+                        //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
                         win.mContentChanged = false;
                     }
                     mPolicy.layoutWindowLw(win, win.mAttrs, null);
@@ -9257,6 +9258,7 @@
                 if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled)
                         || !win.mHaveFrame) {
                     if (initial) {
+                        //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
                         win.mContentChanged = false;
                     }
                     mPolicy.layoutWindowLw(win, win.mAttrs, win.mAttachedWindow);
@@ -9455,7 +9457,6 @@
                             w.setAnimation(a);
                             animDw = w.mLastFrame.left - w.mFrame.left;
                             animDh = w.mLastFrame.top - w.mFrame.top;
-                            w.mContentChanged = false;
                         }
 
                         // Execute animation.
@@ -10242,6 +10243,11 @@
                     w.mOrientationChanging = false;
                 }
 
+                if (w.mContentChanged) {
+                    //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
+                    w.mContentChanged = false;
+                }
+
                 final boolean canBeSeen = w.isDisplayedLw();
 
                 if (someoneLosingFocus && w == mCurrentFocus && canBeSeen) {