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