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