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