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