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