Skip to content

Commit e7ae250

Browse files
author
Craig Mautner
committed
Move wallpaper animations int WindowAnimator.
More refactoring. This time wallpaper animations were broken up from WindowManagerService and the layout piece kept there while the animation piece was moved into WindwoAnimator. Also, applyAnimationLocked and applyEnterAnimationLocked were moved from WindowManagerService to WindowState. Change-Id: I05935023702ce05fdfdc804342ec14f719cdfea4
1 parent 54e1553 commit e7ae250

File tree

4 files changed

+248
-228
lines changed

4 files changed

+248
-228
lines changed

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

Lines changed: 66 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
import android.view.WindowManager.LayoutParams;
1414
import android.view.WindowManagerPolicy;
1515
import android.view.animation.Animation;
16-
import android.view.animation.AnimationUtils;
1716

1817
import com.android.internal.policy.impl.PhoneWindowManager;
1918

19+
import java.io.PrintWriter;
20+
2021
/**
2122
* @author cmautner@google.com (Craig Mautner)
2223
* Singleton class that carries out the animations and Surface operations in a separate task
@@ -55,13 +56,60 @@ public class WindowAnimator {
5556
/** The one and only screen rotation if one is happening */
5657
ScreenRotationAnimation mScreenRotationAnimation = null;
5758

59+
// Window currently running an animation that has requested it be detached
60+
// from the wallpaper. This means we need to ensure the wallpaper is
61+
// visible behind it in case it animates in a way that would allow it to be
62+
// seen.
63+
WindowState mWindowDetachedWallpaper = null;
64+
WindowState mDetachedWallpaper = null;
65+
boolean mWallpaperMayChange;
66+
DimSurface mWindowAnimationBackgroundSurface = null;
67+
5868
WindowAnimator(final WindowManagerService service, final Context context,
5969
final WindowManagerPolicy policy) {
6070
mService = service;
6171
mContext = context;
6272
mPolicy = policy;
6373
}
6474

75+
private void testWallpaperAndBackgroundLocked() {
76+
if (mWindowDetachedWallpaper != mDetachedWallpaper) {
77+
if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
78+
"Detached wallpaper changed from " + mWindowDetachedWallpaper
79+
+ " to " + mDetachedWallpaper);
80+
mWindowDetachedWallpaper = mDetachedWallpaper;
81+
mWallpaperMayChange = true;
82+
}
83+
84+
if (mWindowAnimationBackgroundColor != 0) {
85+
// If the window that wants black is the current wallpaper
86+
// target, then the black goes *below* the wallpaper so we
87+
// don't cause the wallpaper to suddenly disappear.
88+
WindowState target = mWindowAnimationBackground;
89+
if (mService.mWallpaperTarget == target
90+
|| mService.mLowerWallpaperTarget == target
91+
|| mService.mUpperWallpaperTarget == target) {
92+
for (int i=0; i<mService.mWindows.size(); i++) {
93+
WindowState w = mService.mWindows.get(i);
94+
if (w.mIsWallpaper) {
95+
target = w;
96+
break;
97+
}
98+
}
99+
}
100+
if (mWindowAnimationBackgroundSurface == null) {
101+
mWindowAnimationBackgroundSurface = new DimSurface(mService.mFxSession);
102+
}
103+
final int dw = mDw;
104+
final int dh = mDh;
105+
mWindowAnimationBackgroundSurface.show(dw, dh,
106+
target.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM,
107+
mWindowAnimationBackgroundColor);
108+
} else if (mWindowAnimationBackgroundSurface != null) {
109+
mWindowAnimationBackgroundSurface.hide();
110+
}
111+
}
112+
65113
private void updateWindowsAppsAndRotationAnimationsLocked() {
66114
int i;
67115
final int NAT = mService.mAppTokens.size();
@@ -120,38 +168,6 @@ private void updateWindowsAndWallpaperLocked() {
120168
final WindowManager.LayoutParams attrs = w.mAttrs;
121169

122170
if (w.mSurface != null) {
123-
// Take care of the window being ready to display.
124-
if (w.commitFinishDrawingLocked(mCurrentTime)) {
125-
if ((w.mAttrs.flags
126-
& WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
127-
if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
128-
"First draw done in potential wallpaper target " + w);
129-
mService.mInnerFields.mWallpaperMayChange = true;
130-
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
131-
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
132-
mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 1");
133-
}
134-
}
135-
}
136-
137-
// If the window has moved due to its containing
138-
// content frame changing, then we'd like to animate
139-
// it. The checks here are ordered by what is least
140-
// likely to be true first.
141-
if (w.shouldAnimateMove()) {
142-
// Frame has moved, containing content frame
143-
// has also moved, and we're not currently animating...
144-
// let's do something.
145-
Animation a = AnimationUtils.loadAnimation(mContext,
146-
com.android.internal.R.anim.window_move_from_decor);
147-
winAnimator.setAnimation(a);
148-
w.mAnimDw = w.mLastFrame.left - w.mFrame.left;
149-
w.mAnimDh = w.mLastFrame.top - w.mFrame.top;
150-
} else {
151-
w.mAnimDw = mInnerDw;
152-
w.mAnimDh = mInnerDh;
153-
}
154-
155171
final boolean wasAnimating = winAnimator.mWasAnimating;
156172
final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
157173

@@ -202,7 +218,7 @@ private void updateWindowsAndWallpaperLocked() {
202218
}
203219

204220
if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == w) {
205-
mService.mInnerFields.mWallpaperMayChange = true;
221+
mWallpaperMayChange = true;
206222
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
207223
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
208224
mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2");
@@ -255,7 +271,7 @@ private void updateWindowsAndWallpaperLocked() {
255271
}
256272
if (changed && (attrs.flags
257273
& WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
258-
mService.mInnerFields.mWallpaperMayChange = true;
274+
mWallpaperMayChange = true;
259275
mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
260276
if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
261277
mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 4");
@@ -571,13 +587,15 @@ public void prepareSurfaceLocked(final WindowState w, final boolean recoveringMe
571587

572588
void animate() {
573589
mPendingLayoutChanges = 0;
590+
mWallpaperMayChange = false;
574591
mCurrentTime = SystemClock.uptimeMillis();
575592

576593
// Update animations of all applications, including those
577594
// associated with exiting/removed apps
578595
Surface.openTransaction();
579596

580597
try {
598+
testWallpaperAndBackgroundLocked();
581599
updateWindowsAppsAndRotationAnimationsLocked();
582600
performAnimationsLocked();
583601

@@ -611,6 +629,10 @@ void animate() {
611629
} finally {
612630
Surface.closeTransaction();
613631
}
632+
633+
if (mWallpaperMayChange) {
634+
mService.notifyWallpaperMayChange();
635+
}
614636
}
615637

616638
WindowState mCurrentFocus;
@@ -626,4 +648,13 @@ void setDisplayDimensions(final int curWidth, final int curHeight,
626648
mInnerDh = appHeight;
627649
}
628650

651+
public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
652+
if (mWindowDetachedWallpaper != null) {
653+
pw.print(" mWindowDetachedWallpaper="); pw.println(mWindowDetachedWallpaper);
654+
}
655+
if (mWindowAnimationBackgroundSurface != null) {
656+
pw.println(" mWindowAnimationBackgroundSurface:");
657+
mWindowAnimationBackgroundSurface.printTo(" ", pw);
658+
}
659+
}
629660
}

0 commit comments

Comments
 (0)