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