Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 1 | // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | package com.android.server.wm; |
| 4 | |
| 5 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 6 | |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 7 | import static com.android.server.wm.WindowManagerService.LayoutFields.SET_UPDATE_ROTATION; |
| 8 | import static com.android.server.wm.WindowManagerService.LayoutFields.SET_WALLPAPER_MAY_CHANGE; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 9 | import static com.android.server.wm.WindowManagerService.LayoutFields.SET_FORCE_HIDING_CHANGED; |
| 10 | |
| 11 | import static com.android.server.wm.WindowManagerService.H.SET_DIM_PARAMETERS; |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 12 | |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 13 | import android.content.Context; |
| 14 | import android.os.SystemClock; |
| 15 | import android.util.Log; |
| 16 | import android.util.Slog; |
| 17 | import android.view.Surface; |
| 18 | import android.view.WindowManager; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 19 | import android.view.WindowManagerPolicy; |
| 20 | import android.view.animation.Animation; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 21 | |
| 22 | import com.android.internal.policy.impl.PhoneWindowManager; |
| 23 | |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 24 | import java.io.PrintWriter; |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 25 | import java.util.ArrayList; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 26 | |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 27 | /** |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 28 | * Singleton class that carries out the animations and Surface operations in a separate task |
| 29 | * on behalf of WindowManagerService. |
| 30 | */ |
| 31 | public class WindowAnimator { |
Craig Mautner | bb1449b | 2012-03-23 16:11:14 -0700 | [diff] [blame] | 32 | private static final String TAG = "WindowAnimator"; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 33 | |
| 34 | final WindowManagerService mService; |
| 35 | final Context mContext; |
| 36 | final WindowManagerPolicy mPolicy; |
| 37 | |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 38 | ArrayList<WindowStateAnimator> mWinAnimators = new ArrayList<WindowStateAnimator>(); |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 39 | |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 40 | boolean mAnimating; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 41 | boolean mTokenMayBeDrawn; |
| 42 | boolean mForceHiding; |
| 43 | WindowState mWindowAnimationBackground; |
| 44 | int mWindowAnimationBackgroundColor; |
| 45 | int mAdjResult; |
| 46 | |
| 47 | int mPendingLayoutChanges; |
| 48 | |
| 49 | /** Overall window dimensions */ |
| 50 | int mDw, mDh; |
| 51 | |
| 52 | /** Interior window dimensions */ |
| 53 | int mInnerDw, mInnerDh; |
| 54 | |
| 55 | /** Time of current animation step. Reset on each iteration */ |
| 56 | long mCurrentTime; |
| 57 | |
| 58 | /** Skip repeated AppWindowTokens initialization. Note that AppWindowsToken's version of this |
| 59 | * is a long initialized to Long.MIN_VALUE so that it doesn't match this value on startup. */ |
| 60 | private int mTransactionSequence; |
| 61 | |
| 62 | /** The one and only screen rotation if one is happening */ |
| 63 | ScreenRotationAnimation mScreenRotationAnimation = null; |
| 64 | |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 65 | // Window currently running an animation that has requested it be detached |
| 66 | // from the wallpaper. This means we need to ensure the wallpaper is |
| 67 | // visible behind it in case it animates in a way that would allow it to be |
| 68 | // seen. |
| 69 | WindowState mWindowDetachedWallpaper = null; |
| 70 | WindowState mDetachedWallpaper = null; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 71 | DimSurface mWindowAnimationBackgroundSurface = null; |
| 72 | |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 73 | int mBulkUpdateParams = 0; |
| 74 | |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 75 | DimAnimator mDimAnimator = null; |
| 76 | DimAnimator.Parameters mDimParams = null; |
| 77 | |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 78 | static final int WALLPAPER_ACTION_PENDING = 1; |
| 79 | int mPendingActions; |
| 80 | |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 81 | WindowAnimator(final WindowManagerService service, final Context context, |
| 82 | final WindowManagerPolicy policy) { |
| 83 | mService = service; |
| 84 | mContext = context; |
| 85 | mPolicy = policy; |
| 86 | } |
| 87 | |
Craig Mautner | b9836b9 | 2012-06-11 11:40:09 -0700 | [diff] [blame] | 88 | void hideWallpapersLocked(final WindowState w) { |
| 89 | if ((mService.mWallpaperTarget == w && mService.mLowerWallpaperTarget == null) |
| 90 | || mService.mWallpaperTarget == null) { |
| 91 | for (final WindowToken token : mService.mWallpaperTokens) { |
| 92 | for (final WindowState wallpaper : token.windows) { |
| 93 | final WindowStateAnimator winAnimator = wallpaper.mWinAnimator; |
| 94 | if (!winAnimator.mLastHidden) { |
| 95 | winAnimator.hide(); |
Craig Mautner | 507a2ee | 2012-06-13 08:39:38 -0700 | [diff] [blame^] | 96 | mService.dispatchWallpaperVisibility(wallpaper, false); |
Craig Mautner | b9836b9 | 2012-06-11 11:40:09 -0700 | [diff] [blame] | 97 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
| 98 | } |
| 99 | } |
| 100 | token.hidden = true; |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 101 | } |
Craig Mautner | 0afddcb | 2012-05-08 15:38:00 -0700 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 105 | private void testWallpaperAndBackgroundLocked() { |
| 106 | if (mWindowDetachedWallpaper != mDetachedWallpaper) { |
| 107 | if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG, |
| 108 | "Detached wallpaper changed from " + mWindowDetachedWallpaper |
| 109 | + " to " + mDetachedWallpaper); |
| 110 | mWindowDetachedWallpaper = mDetachedWallpaper; |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 111 | mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE; |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | if (mWindowAnimationBackgroundColor != 0) { |
| 115 | // If the window that wants black is the current wallpaper |
| 116 | // target, then the black goes *below* the wallpaper so we |
| 117 | // don't cause the wallpaper to suddenly disappear. |
| 118 | WindowState target = mWindowAnimationBackground; |
| 119 | if (mService.mWallpaperTarget == target |
| 120 | || mService.mLowerWallpaperTarget == target |
| 121 | || mService.mUpperWallpaperTarget == target) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 122 | final int N = mService.mWindows.size(); |
| 123 | for (int i = 0; i < N; i++) { |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 124 | WindowState w = mService.mWindows.get(i); |
| 125 | if (w.mIsWallpaper) { |
| 126 | target = w; |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | if (mWindowAnimationBackgroundSurface == null) { |
| 132 | mWindowAnimationBackgroundSurface = new DimSurface(mService.mFxSession); |
| 133 | } |
| 134 | final int dw = mDw; |
| 135 | final int dh = mDh; |
| 136 | mWindowAnimationBackgroundSurface.show(dw, dh, |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 137 | target.mWinAnimator.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM, |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 138 | mWindowAnimationBackgroundColor); |
| 139 | } else if (mWindowAnimationBackgroundSurface != null) { |
| 140 | mWindowAnimationBackgroundSurface.hide(); |
| 141 | } |
| 142 | } |
| 143 | |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 144 | private void updateWindowsAppsAndRotationAnimationsLocked() { |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 145 | final ArrayList<AppWindowToken> appTokens = mService.mAnimatingAppTokens; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 146 | int i; |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 147 | final int NAT = appTokens.size(); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 148 | for (i=0; i<NAT; i++) { |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 149 | final AppWindowAnimator appAnimator = appTokens.get(i).mAppAnimator; |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 150 | final boolean wasAnimating = appAnimator.animation != null |
Craig Mautner | fbf378c | 2012-04-23 17:24:21 -0700 | [diff] [blame] | 151 | && appAnimator.animation != AppWindowAnimator.sDummyAnimation; |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 152 | if (appAnimator.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 153 | mAnimating = true; |
Craig Mautner | bb1449b | 2012-03-23 16:11:14 -0700 | [diff] [blame] | 154 | } else if (wasAnimating) { |
| 155 | // stopped animating, do one more pass through the layout |
| 156 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 157 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 158 | mService.debugLayoutRepeats("appToken " + appAnimator.mAppToken + " done", |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 159 | mPendingLayoutChanges); |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 160 | } |
Craig Mautner | 83339b4 | 2012-05-01 22:13:23 -0700 | [diff] [blame] | 161 | if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG, |
| 162 | "updateWindowsApps...: done animating " + appAnimator.mAppToken); |
Craig Mautner | bb1449b | 2012-03-23 16:11:14 -0700 | [diff] [blame] | 163 | } |
| 164 | } |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 165 | |
Craig Mautner | bb1449b | 2012-03-23 16:11:14 -0700 | [diff] [blame] | 166 | final int NEAT = mService.mExitingAppTokens.size(); |
| 167 | for (i=0; i<NEAT; i++) { |
Craig Mautner | e4d8a5d | 2012-04-05 13:10:37 -0700 | [diff] [blame] | 168 | final AppWindowAnimator appAnimator = mService.mExitingAppTokens.get(i).mAppAnimator; |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 169 | final boolean wasAnimating = appAnimator.animation != null |
Craig Mautner | fbf378c | 2012-04-23 17:24:21 -0700 | [diff] [blame] | 170 | && appAnimator.animation != AppWindowAnimator.sDummyAnimation; |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 171 | if (appAnimator.stepAnimationLocked(mCurrentTime, mInnerDw, mInnerDh)) { |
Craig Mautner | bb1449b | 2012-03-23 16:11:14 -0700 | [diff] [blame] | 172 | mAnimating = true; |
| 173 | } else if (wasAnimating) { |
| 174 | // stopped animating, do one more pass through the layout |
| 175 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 176 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { |
Craig Mautner | 83339b4 | 2012-05-01 22:13:23 -0700 | [diff] [blame] | 177 | mService.debugLayoutRepeats("exiting appToken " + appAnimator.mAppToken |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 178 | + " done", mPendingLayoutChanges); |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 179 | } |
Craig Mautner | 83339b4 | 2012-05-01 22:13:23 -0700 | [diff] [blame] | 180 | if (WindowManagerService.DEBUG_ANIM) Slog.v(TAG, |
| 181 | "updateWindowsApps...: done animating exiting " + appAnimator.mAppToken); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 182 | } |
| 183 | } |
| 184 | |
Dianne Hackborn | 187ae210 | 2012-04-11 18:12:06 -0700 | [diff] [blame] | 185 | if (mScreenRotationAnimation != null && mScreenRotationAnimation.isAnimating()) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 186 | if (mScreenRotationAnimation.stepAnimationLocked(mCurrentTime)) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 187 | mAnimating = true; |
| 188 | } else { |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 189 | mBulkUpdateParams |= SET_UPDATE_ROTATION; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 190 | mScreenRotationAnimation.kill(); |
| 191 | mScreenRotationAnimation = null; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | private void updateWindowsAndWallpaperLocked() { |
| 197 | ++mTransactionSequence; |
| 198 | |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 199 | ArrayList<WindowStateAnimator> unForceHiding = null; |
| 200 | boolean wallpaperInUnForceHiding = false; |
| 201 | |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 202 | for (int i = mService.mWindows.size() - 1; i >= 0; i--) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 203 | WindowState win = mService.mWindows.get(i); |
| 204 | WindowStateAnimator winAnimator = win.mWinAnimator; |
| 205 | final int flags = winAnimator.mAttrFlags; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 206 | |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 207 | if (winAnimator.mSurface != null) { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 208 | final boolean wasAnimating = winAnimator.mWasAnimating; |
| 209 | final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 210 | |
| 211 | if (WindowManagerService.DEBUG_WALLPAPER) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 212 | Slog.v(TAG, win + ": wasAnimating=" + wasAnimating + |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 213 | ", nowAnimating=" + nowAnimating); |
| 214 | } |
| 215 | |
| 216 | // If this window is animating, make a note that we have |
| 217 | // an animating window and take care of a request to run |
| 218 | // a detached wallpaper animation. |
| 219 | if (nowAnimating) { |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 220 | if (winAnimator.mAnimation != null) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 221 | if ((flags & FLAG_SHOW_WALLPAPER) != 0 |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 222 | && winAnimator.mAnimation.getDetachWallpaper()) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 223 | mDetachedWallpaper = win; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 224 | } |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 225 | final int backgroundColor = winAnimator.mAnimation.getBackgroundColor(); |
| 226 | if (backgroundColor != 0) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 227 | if (mWindowAnimationBackground == null |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 228 | || (winAnimator.mAnimLayer < |
| 229 | mWindowAnimationBackground.mWinAnimator.mAnimLayer)) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 230 | mWindowAnimationBackground = win; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 231 | mWindowAnimationBackgroundColor = backgroundColor; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | } |
| 235 | mAnimating = true; |
| 236 | } |
| 237 | |
| 238 | // If this window's app token is running a detached wallpaper |
| 239 | // animation, make a note so we can ensure the wallpaper is |
| 240 | // displayed behind it. |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 241 | final AppWindowAnimator appAnimator = |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 242 | win.mAppToken == null ? null : win.mAppToken.mAppAnimator; |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 243 | if (appAnimator != null && appAnimator.animation != null |
| 244 | && appAnimator.animating) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 245 | if ((flags & FLAG_SHOW_WALLPAPER) != 0 |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 246 | && appAnimator.animation.getDetachWallpaper()) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 247 | mDetachedWallpaper = win; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 248 | } |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 249 | final int backgroundColor = appAnimator.animation.getBackgroundColor(); |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 250 | if (backgroundColor != 0) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 251 | if (mWindowAnimationBackground == null |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 252 | || (winAnimator.mAnimLayer < |
| 253 | mWindowAnimationBackground.mWinAnimator.mAnimLayer)) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 254 | mWindowAnimationBackground = win; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 255 | mWindowAnimationBackgroundColor = backgroundColor; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 260 | if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == win) { |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 261 | mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 262 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 263 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 264 | mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2", |
| 265 | mPendingLayoutChanges); |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 266 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 269 | if (mPolicy.doesForceHide(win, win.mAttrs)) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 270 | if (!wasAnimating && nowAnimating) { |
Craig Mautner | 83339b4 | 2012-05-01 22:13:23 -0700 | [diff] [blame] | 271 | if (WindowManagerService.DEBUG_ANIM || |
| 272 | WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, |
| 273 | "Animation started that could impact force hide: " + win); |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 274 | mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 275 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 276 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 277 | mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 3", |
| 278 | mPendingLayoutChanges); |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 279 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 280 | mService.mFocusMayChange = true; |
Dianne Hackborn | ac92087 | 2012-05-22 11:49:49 -0700 | [diff] [blame] | 281 | } |
| 282 | if (win.isReadyForDisplay()) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 283 | mForceHiding = true; |
| 284 | } |
Dianne Hackborn | ac92087 | 2012-05-22 11:49:49 -0700 | [diff] [blame] | 285 | if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, |
| 286 | "Force hide " + mForceHiding |
| 287 | + " hasSurface=" + win.mHasSurface |
| 288 | + " policyVis=" + win.mPolicyVisibility |
| 289 | + " destroying=" + win.mDestroying |
| 290 | + " attHidden=" + win.mAttachedHidden |
| 291 | + " vis=" + win.mViewVisibility |
| 292 | + " hidden=" + win.mRootToken.hidden |
| 293 | + " anim=" + win.mWinAnimator.mAnimation); |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 294 | } else if (mPolicy.canBeForceHidden(win, win.mAttrs)) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 295 | final boolean changed; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 296 | if (mForceHiding) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 297 | changed = win.hideLw(false, false); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 298 | if (WindowManagerService.DEBUG_VISIBILITY && changed) Slog.v(TAG, |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 299 | "Now policy hidden: " + win); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 300 | } else { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 301 | changed = win.showLw(false, false); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 302 | if (WindowManagerService.DEBUG_VISIBILITY && changed) Slog.v(TAG, |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 303 | "Now policy shown: " + win); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 304 | if (changed) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 305 | if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 306 | && win.isVisibleNow() /*w.isReadyForDisplay()*/) { |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 307 | if (unForceHiding == null) { |
| 308 | unForceHiding = new ArrayList<WindowStateAnimator>(); |
| 309 | } |
| 310 | unForceHiding.add(winAnimator); |
| 311 | if ((win.mAttrs.flags&WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) { |
| 312 | wallpaperInUnForceHiding = true; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 313 | } |
| 314 | } |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 315 | if (mCurrentFocus == null || mCurrentFocus.mLayer < win.mLayer) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 316 | // We are showing on to of the current |
| 317 | // focus, so re-evaluate focus to make |
| 318 | // sure it is correct. |
| 319 | mService.mFocusMayChange = true; |
| 320 | } |
| 321 | } |
| 322 | } |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 323 | if (changed && (flags & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) { |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 324 | mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 325 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 326 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 327 | mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 4", |
| 328 | mPendingLayoutChanges); |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 329 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 334 | final AppWindowToken atoken = win.mAppToken; |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 335 | if (atoken != null && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 336 | if (atoken.lastTransactionSequence != mTransactionSequence) { |
| 337 | atoken.lastTransactionSequence = mTransactionSequence; |
| 338 | atoken.numInterestingWindows = atoken.numDrawnWindows = 0; |
| 339 | atoken.startingDisplayed = false; |
| 340 | } |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 341 | if ((win.isOnScreen() || winAnimator.mAttrType |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 342 | == WindowManager.LayoutParams.TYPE_BASE_APPLICATION) |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 343 | && !win.mExiting && !win.mDestroying) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 344 | if (WindowManagerService.DEBUG_VISIBILITY || |
| 345 | WindowManagerService.DEBUG_ORIENTATION) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 346 | Slog.v(TAG, "Eval win " + win + ": isDrawn=" + win.isDrawnLw() |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 347 | + ", isAnimating=" + winAnimator.isAnimating()); |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 348 | if (!win.isDrawnLw()) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 349 | Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurface |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 350 | + " pv=" + win.mPolicyVisibility |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 351 | + " mDrawState=" + winAnimator.mDrawState |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 352 | + " ah=" + win.mAttachedHidden |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 353 | + " th=" + atoken.hiddenRequested |
Craig Mautner | a2c7705 | 2012-03-26 12:14:43 -0700 | [diff] [blame] | 354 | + " a=" + winAnimator.mAnimating); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 355 | } |
| 356 | } |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 357 | if (win != atoken.startingWindow) { |
| 358 | if (!atoken.mAppAnimator.freezingScreen || !win.mAppFreezing) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 359 | atoken.numInterestingWindows++; |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 360 | if (win.isDrawnLw()) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 361 | atoken.numDrawnWindows++; |
| 362 | if (WindowManagerService.DEBUG_VISIBILITY || |
| 363 | WindowManagerService.DEBUG_ORIENTATION) Slog.v(TAG, |
| 364 | "tokenMayBeDrawn: " + atoken |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 365 | + " freezingScreen=" + atoken.mAppAnimator.freezingScreen |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 366 | + " mAppFreezing=" + win.mAppFreezing); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 367 | mTokenMayBeDrawn = true; |
| 368 | } |
| 369 | } |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 370 | } else if (win.isDrawnLw()) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 371 | atoken.startingDisplayed = true; |
| 372 | } |
| 373 | } |
Craig Mautner | 749a7bb | 2012-04-02 13:49:53 -0700 | [diff] [blame] | 374 | } else if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) { |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 375 | if (winAnimator.performShowLocked()) { |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 376 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
| 377 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 378 | mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 5", |
| 379 | mPendingLayoutChanges); |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 380 | } |
| 381 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 382 | } |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 383 | final AppWindowAnimator appAnimator = |
| 384 | atoken == null ? null : atoken.mAppAnimator; |
| 385 | if (appAnimator != null && appAnimator.thumbnail != null) { |
| 386 | if (appAnimator.thumbnailTransactionSeq != mTransactionSequence) { |
| 387 | appAnimator.thumbnailTransactionSeq = mTransactionSequence; |
| 388 | appAnimator.thumbnailLayer = 0; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 389 | } |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 390 | if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) { |
| 391 | appAnimator.thumbnailLayer = winAnimator.mAnimLayer; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 392 | } |
| 393 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 394 | } // end forall windows |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 395 | |
| 396 | // If we have windows that are being show due to them no longer |
| 397 | // being force-hidden, apply the appropriate animation to them. |
| 398 | if (unForceHiding != null) { |
| 399 | for (int i=unForceHiding.size()-1; i>=0; i--) { |
| 400 | Animation a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding); |
| 401 | if (a != null) { |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 402 | final WindowStateAnimator winAnimator = unForceHiding.get(i); |
| 403 | winAnimator.setAnimation(a); |
| 404 | winAnimator.mAnimationIsEntrance = true; |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 405 | } |
| 406 | } |
| 407 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | private void testTokenMayBeDrawnLocked() { |
| 411 | // See if any windows have been drawn, so they (and others |
| 412 | // associated with them) can now be shown. |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 413 | final ArrayList<AppWindowToken> appTokens = mService.mAnimatingAppTokens; |
| 414 | final int NT = appTokens.size(); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 415 | for (int i=0; i<NT; i++) { |
Craig Mautner | ef25d7a | 2012-05-15 23:01:47 -0700 | [diff] [blame] | 416 | AppWindowToken wtoken = appTokens.get(i); |
Craig Mautner | 5943163 | 2012-04-04 11:56:44 -0700 | [diff] [blame] | 417 | if (wtoken.mAppAnimator.freezingScreen) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 418 | int numInteresting = wtoken.numInterestingWindows; |
| 419 | if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { |
| 420 | if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, |
| 421 | "allDrawn: " + wtoken |
| 422 | + " interesting=" + numInteresting |
| 423 | + " drawn=" + wtoken.numDrawnWindows); |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 424 | wtoken.mAppAnimator.showAllWindowsLocked(); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 425 | mService.unsetAppFreezingScreenLocked(wtoken, false, true); |
| 426 | if (WindowManagerService.DEBUG_ORIENTATION) Slog.i(TAG, |
| 427 | "Setting mOrientationChangeComplete=true because wtoken " |
| 428 | + wtoken + " numInteresting=" + numInteresting |
| 429 | + " numDrawn=" + wtoken.numDrawnWindows); |
Craig Mautner | 924c215 | 2012-04-23 18:14:07 -0700 | [diff] [blame] | 430 | // This will set mOrientationChangeComplete and cause a pass through layout. |
| 431 | mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 432 | } |
| 433 | } else if (!wtoken.allDrawn) { |
| 434 | int numInteresting = wtoken.numInterestingWindows; |
| 435 | if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { |
| 436 | if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, |
| 437 | "allDrawn: " + wtoken |
| 438 | + " interesting=" + numInteresting |
| 439 | + " drawn=" + wtoken.numDrawnWindows); |
| 440 | wtoken.allDrawn = true; |
| 441 | mPendingLayoutChanges |= PhoneWindowManager.FINISH_LAYOUT_REDO_ANIM; |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 442 | if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 443 | mService.debugLayoutRepeats("testTokenMayBeDrawnLocked", |
| 444 | mPendingLayoutChanges); |
Craig Mautner | cf8cbbe | 2012-03-25 21:54:36 -0700 | [diff] [blame] | 445 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 446 | |
| 447 | // We can now show all of the drawn windows! |
| 448 | if (!mService.mOpeningApps.contains(wtoken)) { |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 449 | mAnimating |= wtoken.mAppAnimator.showAllWindowsLocked(); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | private void performAnimationsLocked() { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 457 | mTokenMayBeDrawn = false; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 458 | mForceHiding = false; |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 459 | mDetachedWallpaper = null; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 460 | mWindowAnimationBackground = null; |
| 461 | mWindowAnimationBackgroundColor = 0; |
| 462 | |
| 463 | updateWindowsAndWallpaperLocked(); |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 464 | if ((mPendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) { |
| 465 | mPendingActions |= WALLPAPER_ACTION_PENDING; |
| 466 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 467 | |
| 468 | if (mTokenMayBeDrawn) { |
| 469 | testTokenMayBeDrawnLocked(); |
| 470 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 471 | } |
| 472 | |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 473 | synchronized void animate() { |
Craig Mautner | bb1449b | 2012-03-23 16:11:14 -0700 | [diff] [blame] | 474 | mPendingLayoutChanges = 0; |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 475 | mCurrentTime = SystemClock.uptimeMillis(); |
Craig Mautner | a608b88 | 2012-03-30 13:03:49 -0700 | [diff] [blame] | 476 | mBulkUpdateParams = 0; |
Chet Haase | 198e564 | 2012-05-10 09:55:15 -0700 | [diff] [blame] | 477 | boolean wasAnimating = mAnimating; |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 478 | mAnimating = false; |
| 479 | if (WindowManagerService.DEBUG_WINDOW_TRACE) { |
| 480 | Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime); |
| 481 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 482 | |
| 483 | // Update animations of all applications, including those |
| 484 | // associated with exiting/removed apps |
| 485 | Surface.openTransaction(); |
| 486 | |
| 487 | try { |
| 488 | updateWindowsAppsAndRotationAnimationsLocked(); |
| 489 | performAnimationsLocked(); |
Craig Mautner | 8a197a4 | 2012-04-24 16:59:36 -0700 | [diff] [blame] | 490 | testWallpaperAndBackgroundLocked(); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 491 | |
| 492 | // THIRD LOOP: Update the surfaces of all windows. |
| 493 | |
| 494 | if (mScreenRotationAnimation != null) { |
| 495 | mScreenRotationAnimation.updateSurfaces(); |
| 496 | } |
| 497 | |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 498 | final int N = mWinAnimators.size(); |
| 499 | for (int i = 0; i < N; i++) { |
Craig Mautner | 0fa77c1 | 2012-06-11 15:57:19 -0700 | [diff] [blame] | 500 | mWinAnimators.get(i).prepareSurfaceLocked(true); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 501 | } |
| 502 | |
Craig Mautner | 6af9b92 | 2012-04-05 19:25:51 -0700 | [diff] [blame] | 503 | if (mDimParams != null) { |
| 504 | mDimAnimator.updateParameters(mContext.getResources(), mDimParams, mCurrentTime); |
| 505 | } |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 506 | if (mDimAnimator != null && mDimAnimator.mDimShown) { |
Craig Mautner | f8d4fbb | 2012-04-11 09:25:53 -0700 | [diff] [blame] | 507 | mAnimating |= mDimAnimator.updateSurface(isDimming(), mCurrentTime, |
Craig Mautner | 6af9b92 | 2012-04-05 19:25:51 -0700 | [diff] [blame] | 508 | !mService.okToDisplay()); |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | if (mService.mBlackFrame != null) { |
| 512 | if (mScreenRotationAnimation != null) { |
| 513 | mService.mBlackFrame.setMatrix( |
| 514 | mScreenRotationAnimation.getEnterTransformation().getMatrix()); |
| 515 | } else { |
| 516 | mService.mBlackFrame.clearMatrix(); |
| 517 | } |
| 518 | } |
Craig Mautner | 7358fbf | 2012-04-12 21:06:33 -0700 | [diff] [blame] | 519 | |
| 520 | if (mService.mWatermark != null) { |
| 521 | mService.mWatermark.drawIfNeeded(); |
| 522 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 523 | } catch (RuntimeException e) { |
| 524 | Log.wtf(TAG, "Unhandled exception in Window Manager", e); |
| 525 | } finally { |
| 526 | Surface.closeTransaction(); |
| 527 | } |
Craig Mautner | c2f9be0 | 2012-03-27 17:32:29 -0700 | [diff] [blame] | 528 | |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 529 | mService.bulkSetParameters(mBulkUpdateParams, mPendingLayoutChanges); |
| 530 | |
| 531 | if (mAnimating) { |
| 532 | mService.scheduleAnimationLocked(); |
Chet Haase | 198e564 | 2012-05-10 09:55:15 -0700 | [diff] [blame] | 533 | } else if (wasAnimating) { |
| 534 | mService.requestTraversalLocked(); |
Craig Mautner | 7d8df39 | 2012-04-06 15:26:23 -0700 | [diff] [blame] | 535 | } |
| 536 | if (WindowManagerService.DEBUG_WINDOW_TRACE) { |
| 537 | Slog.i(TAG, "!!! animate: exit mAnimating=" + mAnimating |
| 538 | + " mBulkUpdateParams=" + Integer.toHexString(mBulkUpdateParams) |
| 539 | + " mPendingLayoutChanges=" + Integer.toHexString(mPendingLayoutChanges)); |
| 540 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | WindowState mCurrentFocus; |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 544 | void setCurrentFocus(final WindowState currentFocus) { |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 545 | mCurrentFocus = currentFocus; |
| 546 | } |
| 547 | |
| 548 | void setDisplayDimensions(final int curWidth, final int curHeight, |
| 549 | final int appWidth, final int appHeight) { |
| 550 | mDw = curWidth; |
| 551 | mDh = curHeight; |
| 552 | mInnerDw = appWidth; |
| 553 | mInnerDh = appHeight; |
| 554 | } |
| 555 | |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 556 | void startDimming(final WindowStateAnimator winAnimator, final float target, |
| 557 | final int width, final int height) { |
| 558 | if (mDimAnimator == null) { |
| 559 | mDimAnimator = new DimAnimator(mService.mFxSession); |
| 560 | } |
Craig Mautner | 067ca32 | 2012-05-18 17:19:51 -0700 | [diff] [blame] | 561 | // Only set dim params on the highest dimmed layer. |
| 562 | final WindowStateAnimator dimWinAnimator = mDimParams == null |
| 563 | ? null : mDimParams.mDimWinAnimator; |
| 564 | // Don't turn on for an unshown surface, or for any layer but the highest dimmed one. |
| 565 | if (winAnimator.mSurfaceShown && |
| 566 | (dimWinAnimator == null || !dimWinAnimator.mSurfaceShown |
| 567 | || dimWinAnimator.mAnimLayer < winAnimator.mAnimLayer)) { |
| 568 | mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, |
| 569 | new DimAnimator.Parameters(winAnimator, width, height, target))); |
| 570 | } |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | // TODO(cmautner): Move into Handler |
| 574 | void stopDimming() { |
| 575 | mService.mH.sendMessage(mService.mH.obtainMessage(SET_DIM_PARAMETERS, null)); |
| 576 | } |
| 577 | |
Craig Mautner | f8d4fbb | 2012-04-11 09:25:53 -0700 | [diff] [blame] | 578 | boolean isDimming() { |
| 579 | return mDimParams != null; |
| 580 | } |
| 581 | |
Craig Mautner | acafd19 | 2012-05-10 10:41:02 -0700 | [diff] [blame] | 582 | boolean isDimming(final WindowStateAnimator winAnimator) { |
| 583 | return mDimParams != null && mDimParams.mDimWinAnimator == winAnimator; |
| 584 | } |
| 585 | |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 586 | public void dump(PrintWriter pw, String prefix, boolean dumpAll) { |
| 587 | if (mWindowDetachedWallpaper != null) { |
| 588 | pw.print(" mWindowDetachedWallpaper="); pw.println(mWindowDetachedWallpaper); |
| 589 | } |
| 590 | if (mWindowAnimationBackgroundSurface != null) { |
| 591 | pw.println(" mWindowAnimationBackgroundSurface:"); |
| 592 | mWindowAnimationBackgroundSurface.printTo(" ", pw); |
| 593 | } |
Craig Mautner | d09cc4b | 2012-04-04 10:23:31 -0700 | [diff] [blame] | 594 | if (mDimAnimator != null) { |
| 595 | pw.println(" mDimAnimator:"); |
| 596 | mDimAnimator.printTo(" ", pw); |
| 597 | } else { |
| 598 | pw.println( " no DimAnimator "); |
| 599 | } |
Craig Mautner | e7ae250 | 2012-03-26 17:11:19 -0700 | [diff] [blame] | 600 | } |
Craig Mautner | bec53f7 | 2012-04-05 11:49:05 -0700 | [diff] [blame] | 601 | |
| 602 | static class SetAnimationParams { |
| 603 | final WindowStateAnimator mWinAnimator; |
| 604 | final Animation mAnimation; |
| 605 | final int mAnimDw; |
| 606 | final int mAnimDh; |
| 607 | public SetAnimationParams(final WindowStateAnimator winAnimator, |
| 608 | final Animation animation, final int animDw, final int animDh) { |
| 609 | mWinAnimator = winAnimator; |
| 610 | mAnimation = animation; |
| 611 | mAnimDw = animDw; |
| 612 | mAnimDh = animDh; |
| 613 | } |
| 614 | } |
Craig Mautner | 4d7349b | 2012-04-20 14:52:47 -0700 | [diff] [blame] | 615 | |
| 616 | synchronized void clearPendingActions() { |
| 617 | mPendingActions = 0; |
| 618 | } |
Craig Mautner | 764983d | 2012-03-22 11:37:36 -0700 | [diff] [blame] | 619 | } |