OSDN Git Service

Use the correct parent size to initialize animations
authortiger_huang <tiger_huang@htc.com>
Mon, 27 Apr 2015 12:36:46 +0000 (20:36 +0800)
committerTiger Huang <tiger_huang@htc.com>
Fri, 8 May 2015 13:08:47 +0000 (13:08 +0000)
The original logic would use out-of-date parent sizes to initialize
animations. If the screen size is changed after assigning mAnimDw and
mAnimDh in the constructor of WindowStateAnimator, the fromDeltaY
(in the most cases) of TranslateAnimation would be initialized
incorrectly.

In this change, we always use up-to-date parent sizes to initialize
animations to prevent the issue.

https://code.google.com/p/android/issues/detail?id=170348

Change-Id: Ib9c609121228934bdb463263feb1924eb389c1d2

services/core/java/com/android/server/wm/WindowManagerService.java
services/core/java/com/android/server/wm/WindowStateAnimator.java

index 8998d39..63c4461 100644 (file)
@@ -9907,6 +9907,7 @@ public class WindowManagerService extends IWindowManager.Stub
                         winAnimator.setAnimation(a);
                         winAnimator.mAnimDw = w.mLastFrame.left - w.mFrame.left;
                         winAnimator.mAnimDh = w.mLastFrame.top - w.mFrame.top;
+                        winAnimator.mAnimateMove = true;
 
                         //TODO (multidisplay): Accessibility supported only for the default display.
                         if (mAccessibilityController != null
index 4cdfc41..25a3b6c 100644 (file)
@@ -131,6 +131,7 @@ class WindowStateAnimator {
     // used.
     int mAnimDw;
     int mAnimDh;
+    boolean mAnimateMove = false;
     float mDsDx=1, mDtDx=0, mDsDy=0, mDtDy=1;
     float mLastDsDx=1, mLastDtDx=0, mLastDsDy=0, mLastDtDy=1;
 
@@ -304,9 +305,15 @@ class WindowStateAnimator {
                         " wh=" + mWin.mFrame.height() +
                         " dw=" + mAnimDw + " dh=" + mAnimDh +
                         " scale=" + mService.getWindowAnimationScaleLocked());
-                    mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(),
-                            mAnimDw, mAnimDh);
                     final DisplayInfo displayInfo = displayContent.getDisplayInfo();
+                    if (mAnimateMove) {
+                        mAnimateMove = false;
+                        mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(),
+                                mAnimDw, mAnimDh);
+                    } else {
+                        mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(),
+                                displayInfo.appWidth, displayInfo.appHeight);
+                    }
                     mAnimDw = displayInfo.appWidth;
                     mAnimDh = displayInfo.appHeight;
                     mAnimation.setStartTime(mAnimationStartTime != -1