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