Skip to content

Commit 83339b4

Browse files
author
Craig Mautner
committed
Fix Home key causes wrong animation
Wallpaper logic assumed that if mWallpaperTarget was non-null then any wallpaper animation should be exiting. However, if the existing wallpaper target was already animating away then mWallpaperTarget remains non-null until it is completely gone. Pressing Home during this time was causing the next animation to exit rather than reverse and enter. This fix looks to see if the wallpaper target is animating and if it is to treat it as null for the purpose of determining which direction the animation should go. Fixes bug 6407941. Change-Id: I731267328db0f9972a5aed6f214962f96737dd07
1 parent 1b332db commit 83339b4

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

services/java/com/android/server/wm/WindowAnimator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
140140
mService.debugLayoutRepeats("appToken " + appAnimator.mAppToken + " done",
141141
mPendingLayoutChanges);
142142
}
143+
if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG,
144+
"updateWindowsApps...: done animating " + appAnimator.mAppToken);
143145
}
144146
}
145147

@@ -154,9 +156,11 @@ private void updateWindowsAppsAndRotationAnimationsLocked() {
154156
// stopped animating, do one more pass through the layout
155157
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
156158
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
157-
mService.debugLayoutRepeats("exiting appToken " + appAnimator.mAppToken
159+
mService.debugLayoutRepeats("exiting appToken " + appAnimator.mAppToken
158160
+ " done", mPendingLayoutChanges);
159161
}
162+
if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG,
163+
"updateWindowsApps...: done animating exiting " + appAnimator.mAppToken);
160164
}
161165
}
162166

@@ -246,9 +250,9 @@ private void updateWindowsAndWallpaperLocked() {
246250

247251
if (mPolicy.doesForceHide(win, win.mAttrs)) {
248252
if (!wasAnimating && nowAnimating) {
249-
if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
250-
"Animation started that could impact force hide: "
251-
+ win);
253+
if (WindowManagerService.DEBUG_ANIM ||
254+
WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG,
255+
"Animation started that could impact force hide: " + win);
252256
mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED;
253257
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
254258
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@
130130
import android.view.animation.AnimationUtils;
131131
import android.view.animation.Interpolator;
132132
import android.view.animation.ScaleAnimation;
133-
import android.view.animation.Transformation;
134-
import android.view.animation.TranslateAnimation;
135133

136134
import java.io.BufferedWriter;
137135
import java.io.DataInputStream;
@@ -3231,12 +3229,21 @@ private boolean applyAnimationLocked(AppWindowToken wtoken,
32313229
if (mNextAppTransitionType == ActivityOptions.ANIM_CUSTOM) {
32323230
a = loadAnimation(mNextAppTransitionPackage, enter ?
32333231
mNextAppTransitionEnter : mNextAppTransitionExit);
3232+
if (DEBUG_ANIM) Slog.v(TAG, "applyAnimation: wtoken=" + wtoken
3233+
+ " anim=" + a + " nextAppTransition=ANIM_CUSTOM"
3234+
+ " transit=" + transit + " Callers " + Debug.getCallers(3));
32343235
} else if (mNextAppTransitionType == ActivityOptions.ANIM_SCALE_UP) {
32353236
a = createScaleUpAnimationLocked(transit, enter);
32363237
initialized = true;
3238+
if (DEBUG_ANIM) Slog.v(TAG, "applyAnimation: wtoken=" + wtoken
3239+
+ " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
3240+
+ " transit=" + transit + " Callers " + Debug.getCallers(3));
32373241
} else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL) {
32383242
a = createThumbnailAnimationLocked(transit, enter, false);
32393243
initialized = true;
3244+
if (DEBUG_ANIM) Slog.v(TAG, "applyAnimation: wtoken=" + wtoken
3245+
+ " anim=" + a + " nextAppTransition=ANIM_THUMBNAIL"
3246+
+ " transit=" + transit + " Callers " + Debug.getCallers(3));
32403247
} else {
32413248
int animAttr = 0;
32423249
switch (transit) {
@@ -3295,7 +3302,7 @@ private boolean applyAnimationLocked(AppWindowToken wtoken,
32953302
if (DEBUG_ANIM) Slog.v(TAG, "applyAnimation: wtoken=" + wtoken
32963303
+ " anim=" + a
32973304
+ " animAttr=0x" + Integer.toHexString(animAttr)
3298-
+ " transit=" + transit);
3305+
+ " transit=" + transit + " Callers " + Debug.getCallers(3));
32993306
}
33003307
if (a != null) {
33013308
if (DEBUG_ANIM) {
@@ -7810,7 +7817,9 @@ public int handleAppTransitionReadyLocked() {
78107817
mToTopApps.clear();
78117818
}
78127819

7813-
WindowState oldWallpaper = mWallpaperTarget;
7820+
WindowState oldWallpaper =
7821+
mWallpaperTarget != null && mWallpaperTarget.mWinAnimator.isAnimating()
7822+
? null : mWallpaperTarget;
78147823

78157824
adjustWallpaperWindowsLocked();
78167825
mInnerFields.mWallpaperMayChange = false;
@@ -8117,8 +8126,8 @@ private void updateResizingWindows(final WindowState w) {
81178126
// to go through the process of getting informed
81188127
// by the application when it has finished drawing.
81198128
if (w.mOrientationChanging) {
8120-
if (DEBUG_ORIENTATION) Slog.v(TAG,
8121-
"Orientation start waiting for draw in "
8129+
if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.v(TAG,
8130+
"Orientation start waiting for draw mDrawState=DRAW_PENDING in "
81228131
+ w + ", surface " + winAnimator.mSurface);
81238132
winAnimator.mDrawState = WindowStateAnimator.DRAW_PENDING;
81248133
if (w.mAppToken != null) {

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ void finishExit() {
380380

381381
boolean finishDrawingLocked() {
382382
if (mDrawState == DRAW_PENDING) {
383-
if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
384-
TAG, "finishDrawingLocked: " + this + " in " + mSurface);
383+
if (DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
384+
TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in "
385+
+ mSurface);
385386
mDrawState = COMMIT_DRAW_PENDING;
386387
return true;
387388
}
@@ -393,7 +394,8 @@ boolean commitFinishDrawingLocked(long currentTime) {
393394
if (mDrawState != COMMIT_DRAW_PENDING) {
394395
return false;
395396
}
396-
//Slog.i(TAG, "commitFinishDrawingLocked: Draw pending. " + mSurface);
397+
if (DEBUG_ANIM)
398+
Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurface);
397399
mDrawState = READY_TO_SHOW;
398400
final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING;
399401
final AppWindowToken atoken = mWin.mAppToken;
@@ -526,8 +528,8 @@ Surface createSurfaceLocked() {
526528
if (mSurface == null) {
527529
mReportDestroySurface = false;
528530
mSurfacePendingDestroy = false;
529-
if (DEBUG_ORIENTATION) Slog.i(TAG,
530-
"createSurface " + this + ": DRAW NOW PENDING");
531+
if (DEBUG_ANIM || DEBUG_ORIENTATION) Slog.i(TAG,
532+
"createSurface " + this + ": mDrawState=DRAW_PENDING");
531533
mDrawState = DRAW_PENDING;
532534
if (mWin.mAppToken != null) {
533535
mWin.mAppToken.allDrawn = false;
@@ -1062,6 +1064,9 @@ public void prepareSurfaceLocked(final boolean recoveringMemory) {
10621064
}
10631065
}
10641066
} else {
1067+
if (DEBUG_ANIM) {
1068+
Slog.v(TAG, "prepareSurface: No changes in animation for " + mWin);
1069+
}
10651070
displayed = true;
10661071
}
10671072

@@ -1145,6 +1150,7 @@ boolean performShowLocked() {
11451150

11461151
// Force the show in the next prepareSurfaceLocked() call.
11471152
mLastAlpha = -1;
1153+
if (DEBUG_ANIM) Slog.v(TAG, "performShowLocked: mDrawState=HAS_DRAWN");
11481154
mDrawState = HAS_DRAWN;
11491155
mService.scheduleAnimationLocked();
11501156

@@ -1285,7 +1291,7 @@ boolean applyAnimationLocked(int transit, boolean isEntrance) {
12851291
+ " anim=" + anim + " attr=0x" + Integer.toHexString(attr)
12861292
+ " a=" + a
12871293
+ " mAnimation=" + mAnimation
1288-
+ " isEntrance=" + isEntrance);
1294+
+ " isEntrance=" + isEntrance + " Callers " + Debug.getCallers(3));
12891295
if (a != null) {
12901296
if (WindowManagerService.DEBUG_ANIM) {
12911297
RuntimeException e = null;

0 commit comments

Comments
 (0)