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