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