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