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