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