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