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