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