From 3cd48043a32a9406980dd0daf49d90704a9ab4dc Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Mon, 16 Nov 2015 13:01:41 -0800 Subject: [PATCH] Set-up dummy animation when setting a replacing window token Set-up dummy animation so we can start treating windows associated with the replacing app token like they are in transition before the new app window is ready for us to run the real transition animation. This allows us to make the right decisions at various call points where an animation is expected to be running for a replacing window but the real animation isn't set yet. Also, removed unused field indicating if an app token is animating a replacement window since it was always set to true and checked/set to the same value as AppWindowToken.mWillReplaceWindow. Bug: 25645069 Change-Id: Ie216ed5bd60fb2a15da61c7050c9344c48b1c5fb --- .../com/android/server/am/ActivityStackSupervisor.java | 7 +++---- .../core/java/com/android/server/wm/AppWindowToken.java | 2 -- .../java/com/android/server/wm/WindowManagerService.java | 16 ++++++++++------ .../core/java/com/android/server/wm/WindowState.java | 1 - 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 13d3ee1d18bc..0ec4b18ff28a 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -3354,11 +3354,10 @@ public final class ActivityStackSupervisor implements DisplayListener { // preserve the old window until the new one is drawn. This prevents having a gap // between the removal and addition, in which no window is visible. We also want the // entrance of the new window to be properly animated. - mWindowManager.setReplacingWindow(topActivity.appToken, true /* animate */); + mWindowManager.setReplacingWindow(topActivity.appToken); } - final ActivityStack stack = - moveTaskToStackUncheckedLocked(task, stackId, toTop, forceFocus, - "moveTaskToStack:" + reason); + final ActivityStack stack = moveTaskToStackUncheckedLocked( + task, stackId, toTop, forceFocus, "moveTaskToStack:" + reason); // Make sure the task has the appropriate bounds/size for the stack it is in. if (stackId == FULLSCREEN_WORKSPACE_STACK_ID && task.mBounds != null) { diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 425ff9b93b1c..3f4eaace838e 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -128,8 +128,6 @@ class AppWindowToken extends WindowToken { boolean mWillReplaceWindow; // If true, the replaced window was already requested to be removed. boolean mReplacingRemoveRequested; - // Whether the replacement of the window should trigger app transition animation. - boolean mAnimateReplacingWindow; // If not null, the window that will be used to replace the old one. This is being set when // the window is added and unset when this window reports its first draw. WindowState mReplacingWindow; diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 5737d479b753..64ff4e0af7bf 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2077,7 +2077,7 @@ public class WindowManagerService extends IWindowManager.Stub } private void prepareWindowReplacementTransition(AppWindowToken atoken) { - if (atoken == null || !atoken.mWillReplaceWindow || !atoken.mAnimateReplacingWindow) { + if (atoken == null || !atoken.mWillReplaceWindow) { return; } atoken.allDrawn = false; @@ -8585,8 +8585,7 @@ public class WindowManagerService extends IWindowManager.Stub } else if (wtoken != null) { winAnimator.mAnimLayer = w.mLayer + wtoken.mAppAnimator.animLayerAdjustment; - if (wtoken.mWillReplaceWindow && wtoken.mAnimateReplacingWindow && - wtoken.mReplacingWindow != w) { + if (wtoken.mWillReplaceWindow && wtoken.mReplacingWindow != w) { // We know that we will be animating a relaunching window in the near future, // which will receive a z-order increase. We want the replaced window to // immediately receive the same treatment, e.g. to be above the dock divider. @@ -10126,9 +10125,8 @@ public class WindowManagerService extends IWindowManager.Stub * Hint to a token that its activity will relaunch, which will trigger removal and addition of * a window. * @param token Application token for which the activity will be relaunched. - * @param animate Whether to animate the addition of the new window. */ - public void setReplacingWindow(IBinder token, boolean animate) { + public void setReplacingWindow(IBinder token) { synchronized (mWindowMap) { AppWindowToken appWindowToken = findAppWindowToken(token); if (appWindowToken == null) { @@ -10139,7 +10137,13 @@ public class WindowManagerService extends IWindowManager.Stub + " as replacing window."); appWindowToken.mWillReplaceWindow = true; appWindowToken.mHasReplacedWindow = false; - appWindowToken.mAnimateReplacingWindow = animate; + + // Set-up dummy animation so we can start treating windows associated with this token + // like they are in transition before the new app window is ready for us to run the + // real transition animation. + if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, + "setReplacingWindow() Setting dummy animation on: " + appWindowToken); + appWindowToken.mAppAnimator.setDummyAnimation(); } } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 673c21ff9931..b2d6a8850501 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1388,7 +1388,6 @@ final class WindowState implements WindowManagerPolicy.WindowState { && token.mHasReplacedWindow) { if (DEBUG_ADD_REMOVE) Slog.d(TAG, "Removing replacing window: " + this); token.mWillReplaceWindow = false; - token.mAnimateReplacingWindow = false; token.mReplacingRemoveRequested = false; token.mReplacingWindow = null; token.mHasReplacedWindow = false; -- 2.11.0