Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1 | package com.android.server.wm; |
| 2 | |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 3 | import static android.app.ActivityManagerInternal.APP_TRANSITION_SAVED_SURFACE; |
| 4 | import static android.app.ActivityManagerInternal.APP_TRANSITION_STARTING_WINDOW; |
| 5 | import static android.app.ActivityManagerInternal.APP_TRANSITION_TIMEOUT; |
| 6 | import static android.app.ActivityManagerInternal.APP_TRANSITION_WINDOWS_DRAWN; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 7 | import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
| 8 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 9 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 10 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION; |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 11 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 12 | import static android.view.WindowManager.LayoutParams.TYPE_DREAM; |
| 13 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 14 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; |
| 15 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; |
| 16 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 17 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
| 18 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG; |
| 19 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; |
| 20 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 21 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG; |
| 22 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
| 23 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
| 24 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT; |
| 25 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
| 26 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
| 27 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_POWER; |
| 28 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW; |
| 29 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT; |
| 30 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 31 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT; |
| 32 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_TRACE; |
Chong Zhang | 4ffc318 | 2016-05-04 15:06:02 -0700 | [diff] [blame] | 33 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEEP_SCREEN_ON; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 34 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS; |
| 35 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS; |
Chong Zhang | 4ffc318 | 2016-05-04 15:06:02 -0700 | [diff] [blame] | 36 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_KEEP_SCREEN_ON; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 37 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 38 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 39 | import static com.android.server.wm.WindowManagerService.H.DO_TRAVERSAL; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 40 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_APP_TRANSITION_STARTING; |
| 41 | import static com.android.server.wm.WindowManagerService.H.NOTIFY_STARTING_WINDOW_DRAWN; |
| 42 | import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS; |
| 43 | import static com.android.server.wm.WindowManagerService.H.REPORT_WINDOWS_CHANGE; |
| 44 | import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION; |
| 45 | import static com.android.server.wm.WindowManagerService.H.UPDATE_DOCKED_STACK_DIVIDER; |
| 46 | import static com.android.server.wm.WindowManagerService.H.WINDOW_FREEZE_TIMEOUT; |
| 47 | import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD; |
| 48 | import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 49 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES; |
| 50 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
| 51 | import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_NONE; |
| 52 | |
| 53 | import android.graphics.Bitmap; |
| 54 | import android.graphics.Canvas; |
| 55 | import android.graphics.PixelFormat; |
| 56 | import android.graphics.Rect; |
| 57 | import android.os.Debug; |
| 58 | import android.os.PowerManager; |
| 59 | import android.os.RemoteException; |
| 60 | import android.os.SystemClock; |
| 61 | import android.os.Trace; |
| 62 | import android.provider.Settings; |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 63 | import android.util.ArraySet; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 64 | import android.util.Slog; |
| 65 | import android.view.Display; |
| 66 | import android.view.DisplayInfo; |
| 67 | import android.view.Surface; |
| 68 | import android.view.SurfaceControl; |
| 69 | import android.view.View; |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 70 | import android.view.WindowManager.LayoutParams; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 71 | import android.view.animation.Animation; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 72 | |
Jorim Jaggi | d75962e | 2016-05-03 15:10:03 -0700 | [diff] [blame] | 73 | import com.android.server.wm.WindowManagerService.H; |
| 74 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 75 | import java.io.PrintWriter; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 76 | import java.util.ArrayList; |
| 77 | |
| 78 | /** |
| 79 | * Positions windows and their surfaces. |
| 80 | * |
| 81 | * It sets positions of windows by calculating their frames and then applies this by positioning |
| 82 | * surfaces according to these frames. Z layer is still assigned withing WindowManagerService. |
| 83 | */ |
| 84 | class WindowSurfacePlacer { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 85 | private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowSurfacePlacer" : TAG_WM; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 86 | private final WindowManagerService mService; |
| 87 | private final WallpaperController mWallpaperControllerLocked; |
| 88 | |
| 89 | private boolean mInLayout = false; |
| 90 | |
| 91 | /** Only do a maximum of 6 repeated layouts. After that quit */ |
| 92 | private int mLayoutRepeatCount; |
| 93 | |
| 94 | static final int SET_UPDATE_ROTATION = 1 << 0; |
| 95 | static final int SET_WALLPAPER_MAY_CHANGE = 1 << 1; |
| 96 | static final int SET_FORCE_HIDING_CHANGED = 1 << 2; |
| 97 | static final int SET_ORIENTATION_CHANGE_COMPLETE = 1 << 3; |
| 98 | static final int SET_TURN_ON_SCREEN = 1 << 4; |
| 99 | static final int SET_WALLPAPER_ACTION_PENDING = 1 << 5; |
| 100 | |
| 101 | boolean mWallpaperMayChange = false; |
| 102 | boolean mOrientationChangeComplete = true; |
| 103 | boolean mWallpaperActionPending = false; |
| 104 | |
| 105 | private boolean mWallpaperForceHidingChanged = false; |
| 106 | private Object mLastWindowFreezeSource = null; |
| 107 | private Session mHoldScreen = null; |
| 108 | private boolean mObscured = false; |
| 109 | private boolean mSyswin = false; |
| 110 | private float mScreenBrightness = -1; |
| 111 | private float mButtonBrightness = -1; |
| 112 | private long mUserActivityTimeout = -1; |
| 113 | private boolean mUpdateRotation = false; |
| 114 | private final Rect mTmpStartRect = new Rect(); |
Wale Ogunwale | b4ec0a3 | 2015-12-14 10:31:43 -0800 | [diff] [blame] | 115 | private final Rect mTmpContentRect = new Rect(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 116 | |
| 117 | // Set to true when the display contains content to show the user. |
| 118 | // When false, the display manager may choose to mirror or blank the display. |
| 119 | private boolean mDisplayHasContent = false; |
| 120 | |
| 121 | // Only set while traversing the default display based on its content. |
| 122 | // Affects the behavior of mirroring on secondary displays. |
| 123 | private boolean mObscureApplicationContentOnSecondaryDisplays = false; |
| 124 | |
| 125 | private float mPreferredRefreshRate = 0; |
| 126 | |
| 127 | private int mPreferredModeId = 0; |
| 128 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 129 | private boolean mTraversalScheduled; |
Jorim Jaggi | c402520 | 2015-10-22 16:43:34 +0200 | [diff] [blame] | 130 | private int mDeferDepth = 0; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 131 | |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 132 | private boolean mSustainedPerformanceModeEnabled = false; |
| 133 | private boolean mSustainedPerformanceModeCurrent = false; |
| 134 | |
Chong Zhang | 4ffc318 | 2016-05-04 15:06:02 -0700 | [diff] [blame] | 135 | // Following variables are for debugging screen wakelock only. |
| 136 | // Last window that requires screen wakelock |
| 137 | WindowState mHoldScreenWindow = null; |
| 138 | // Last window that obscures all windows below |
| 139 | WindowState mObsuringWindow = null; |
| 140 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 141 | private static final class LayerAndToken { |
| 142 | public int layer; |
| 143 | public AppWindowToken token; |
| 144 | } |
| 145 | private final LayerAndToken mTmpLayerAndToken = new LayerAndToken(); |
| 146 | |
Jorim Jaggi | 3dac63a | 2016-03-01 12:37:07 +0100 | [diff] [blame] | 147 | private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>(); |
| 148 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 149 | public WindowSurfacePlacer(WindowManagerService service) { |
| 150 | mService = service; |
| 151 | mWallpaperControllerLocked = mService.mWallpaperControllerLocked; |
| 152 | } |
| 153 | |
Jorim Jaggi | c402520 | 2015-10-22 16:43:34 +0200 | [diff] [blame] | 154 | /** |
| 155 | * See {@link WindowManagerService#deferSurfaceLayout()} |
| 156 | */ |
| 157 | void deferLayout() { |
| 158 | mDeferDepth++; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * See {@link WindowManagerService#continueSurfaceLayout()} |
| 163 | */ |
| 164 | void continueLayout() { |
| 165 | mDeferDepth--; |
| 166 | if (mDeferDepth <= 0) { |
| 167 | performSurfacePlacement(); |
| 168 | } |
| 169 | } |
| 170 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 171 | final void performSurfacePlacement() { |
Jorim Jaggi | c402520 | 2015-10-22 16:43:34 +0200 | [diff] [blame] | 172 | if (mDeferDepth > 0) { |
| 173 | return; |
| 174 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 175 | int loopCount = 6; |
| 176 | do { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 177 | mTraversalScheduled = false; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 178 | performSurfacePlacementLoop(); |
| 179 | mService.mH.removeMessages(DO_TRAVERSAL); |
| 180 | loopCount--; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 181 | } while (mTraversalScheduled && loopCount > 0); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 182 | mWallpaperActionPending = false; |
| 183 | } |
| 184 | |
| 185 | private void performSurfacePlacementLoop() { |
| 186 | if (mInLayout) { |
| 187 | if (DEBUG) { |
| 188 | throw new RuntimeException("Recursive call!"); |
| 189 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 190 | Slog.w(TAG, "performLayoutAndPlaceSurfacesLocked called while in layout. Callers=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 191 | + Debug.getCallers(3)); |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | if (mService.mWaitingForConfig) { |
| 196 | // Our configuration has changed (most likely rotation), but we |
| 197 | // don't yet have the complete configuration to report to |
| 198 | // applications. Don't do any window layout until we have it. |
| 199 | return; |
| 200 | } |
| 201 | |
| 202 | if (!mService.mDisplayReady) { |
| 203 | // Not yet initialized, nothing to do. |
| 204 | return; |
| 205 | } |
| 206 | |
| 207 | Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmLayout"); |
| 208 | mInLayout = true; |
| 209 | |
| 210 | boolean recoveringMemory = false; |
| 211 | if (!mService.mForceRemoves.isEmpty()) { |
| 212 | recoveringMemory = true; |
| 213 | // Wait a little bit for things to settle down, and off we go. |
| 214 | while (!mService.mForceRemoves.isEmpty()) { |
Wale Ogunwale | adde52e | 2016-07-16 13:11:55 -0700 | [diff] [blame] | 215 | final WindowState ws = mService.mForceRemoves.remove(0); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 216 | Slog.i(TAG, "Force removing: " + ws); |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 217 | ws.removeImmediately(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 218 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 219 | Slog.w(TAG, "Due to memory failure, waiting a bit for next layout"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 220 | Object tmp = new Object(); |
| 221 | synchronized (tmp) { |
| 222 | try { |
| 223 | tmp.wait(250); |
| 224 | } catch (InterruptedException e) { |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | try { |
| 230 | performSurfacePlacementInner(recoveringMemory); |
| 231 | |
| 232 | mInLayout = false; |
| 233 | |
| 234 | if (mService.needsLayout()) { |
| 235 | if (++mLayoutRepeatCount < 6) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 236 | requestTraversal(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 237 | } else { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 238 | Slog.e(TAG, "Performed 6 layouts in a row. Skipping"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 239 | mLayoutRepeatCount = 0; |
| 240 | } |
| 241 | } else { |
| 242 | mLayoutRepeatCount = 0; |
| 243 | } |
| 244 | |
| 245 | if (mService.mWindowsChanged && !mService.mWindowChangeListeners.isEmpty()) { |
| 246 | mService.mH.removeMessages(REPORT_WINDOWS_CHANGE); |
| 247 | mService.mH.sendEmptyMessage(REPORT_WINDOWS_CHANGE); |
| 248 | } |
| 249 | } catch (RuntimeException e) { |
| 250 | mInLayout = false; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 251 | Slog.wtf(TAG, "Unhandled exception while laying out windows", e); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); |
| 255 | } |
| 256 | |
| 257 | void debugLayoutRepeats(final String msg, int pendingLayoutChanges) { |
| 258 | if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 259 | Slog.v(TAG, "Layouts looping: " + msg + |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 260 | ", mPendingLayoutChanges = 0x" + Integer.toHexString(pendingLayoutChanges)); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | // "Something has changed! Let's make it correct now." |
| 265 | private void performSurfacePlacementInner(boolean recoveringMemory) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 266 | if (DEBUG_WINDOW_TRACE) Slog.v(TAG, "performSurfacePlacementInner: entry. Called by " |
| 267 | + Debug.getCallers(3)); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 268 | |
| 269 | int i; |
| 270 | boolean updateInputWindowsNeeded = false; |
| 271 | |
| 272 | if (mService.mFocusMayChange) { |
| 273 | mService.mFocusMayChange = false; |
| 274 | updateInputWindowsNeeded = mService.updateFocusedWindowLocked( |
| 275 | UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/); |
| 276 | } |
| 277 | |
| 278 | // Initialize state of exiting tokens. |
| 279 | final int numDisplays = mService.mDisplayContents.size(); |
| 280 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 281 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 282 | for (i=displayContent.mExitingTokens.size()-1; i>=0; i--) { |
| 283 | displayContent.mExitingTokens.get(i).hasVisible = false; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 288 | // Initialize state of exiting applications. |
| 289 | final AppTokenList exitingAppTokens = |
| 290 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 291 | for (int tokenNdx = exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) { |
| 292 | exitingAppTokens.get(tokenNdx).hasVisible = false; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | mHoldScreen = null; |
Chong Zhang | 4ffc318 | 2016-05-04 15:06:02 -0700 | [diff] [blame] | 297 | mHoldScreenWindow = null; |
| 298 | mObsuringWindow = null; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 299 | mScreenBrightness = -1; |
| 300 | mButtonBrightness = -1; |
| 301 | mUserActivityTimeout = -1; |
| 302 | mObscureApplicationContentOnSecondaryDisplays = false; |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 303 | mSustainedPerformanceModeCurrent = false; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 304 | mService.mTransactionSequence++; |
| 305 | |
| 306 | final DisplayContent defaultDisplay = mService.getDefaultDisplayContentLocked(); |
| 307 | final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo(); |
| 308 | final int defaultDw = defaultInfo.logicalWidth; |
| 309 | final int defaultDh = defaultInfo.logicalHeight; |
| 310 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 311 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 312 | ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces"); |
Robert Carr | 68e5c9e | 2016-09-14 10:50:09 -0700 | [diff] [blame^] | 313 | mService.openSurfaceTransaction(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 314 | try { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 315 | applySurfaceChangesTransaction(recoveringMemory, numDisplays, defaultDw, defaultDh); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 316 | } catch (RuntimeException e) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 317 | Slog.wtf(TAG, "Unhandled exception in Window Manager", e); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 318 | } finally { |
Robert Carr | 68e5c9e | 2016-09-14 10:50:09 -0700 | [diff] [blame^] | 319 | mService.closeSurfaceTransaction(); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 320 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 321 | "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces"); |
| 322 | } |
| 323 | |
| 324 | final WindowList defaultWindows = defaultDisplay.getWindowList(); |
| 325 | |
| 326 | // If we are ready to perform an app transition, check through |
| 327 | // all of the app tokens to be shown and see if they are ready |
| 328 | // to go. |
| 329 | if (mService.mAppTransition.isReady()) { |
| 330 | defaultDisplay.pendingLayoutChanges |= handleAppTransitionReadyLocked(defaultWindows); |
| 331 | if (DEBUG_LAYOUT_REPEATS) |
| 332 | debugLayoutRepeats("after handleAppTransitionReadyLocked", |
| 333 | defaultDisplay.pendingLayoutChanges); |
| 334 | } |
| 335 | |
| 336 | if (!mService.mAnimator.mAppWindowAnimating && mService.mAppTransition.isRunning()) { |
| 337 | // We have finished the animation of an app transition. To do |
| 338 | // this, we have delayed a lot of operations like showing and |
| 339 | // hiding apps, moving apps in Z-order, etc. The app token list |
| 340 | // reflects the correct Z-order, but the window list may now |
| 341 | // be out of sync with it. So here we will just rebuild the |
| 342 | // entire app window list. Fun! |
| 343 | defaultDisplay.pendingLayoutChanges |= |
| 344 | mService.handleAnimatingStoppedAndTransitionLocked(); |
| 345 | if (DEBUG_LAYOUT_REPEATS) |
| 346 | debugLayoutRepeats("after handleAnimStopAndXitionLock", |
| 347 | defaultDisplay.pendingLayoutChanges); |
| 348 | } |
| 349 | |
| 350 | if (mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0 |
| 351 | && !mService.mAppTransition.isReady()) { |
| 352 | // At this point, there was a window with a wallpaper that |
| 353 | // was force hiding other windows behind it, but now it |
| 354 | // is going away. This may be simple -- just animate |
| 355 | // away the wallpaper and its window -- or it may be |
| 356 | // hard -- the wallpaper now needs to be shown behind |
| 357 | // something that was hidden. |
| 358 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 359 | if (DEBUG_LAYOUT_REPEATS) |
| 360 | debugLayoutRepeats("after animateAwayWallpaperLocked", |
| 361 | defaultDisplay.pendingLayoutChanges); |
| 362 | } |
| 363 | mWallpaperForceHidingChanged = false; |
| 364 | |
| 365 | if (mWallpaperMayChange) { |
| 366 | if (DEBUG_WALLPAPER_LIGHT) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 367 | Slog.v(TAG, "Wallpaper may change! Adjusting"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 368 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 369 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("WallpaperMayChange", |
| 370 | defaultDisplay.pendingLayoutChanges); |
| 371 | } |
| 372 | |
| 373 | if (mService.mFocusMayChange) { |
| 374 | mService.mFocusMayChange = false; |
| 375 | if (mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, |
| 376 | false /*updateInputWindows*/)) { |
| 377 | updateInputWindowsNeeded = true; |
| 378 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if (mService.needsLayout()) { |
| 383 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 384 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("mLayoutNeeded", |
| 385 | defaultDisplay.pendingLayoutChanges); |
| 386 | } |
| 387 | |
| 388 | for (i = mService.mResizingWindows.size() - 1; i >= 0; i--) { |
| 389 | WindowState win = mService.mResizingWindows.get(i); |
| 390 | if (win.mAppFreezing) { |
| 391 | // Don't remove this window until rotation has completed. |
| 392 | continue; |
| 393 | } |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 394 | // Discard the saved surface if window size is changed, it can't be reused. |
Chong Zhang | bef461f | 2015-10-27 11:38:24 -0700 | [diff] [blame] | 395 | if (win.mAppToken != null) { |
| 396 | win.mAppToken.destroySavedSurfaces(); |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 397 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 398 | win.reportResized(); |
| 399 | mService.mResizingWindows.remove(i); |
| 400 | } |
| 401 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 402 | if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG, |
| 403 | "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 404 | if (mOrientationChangeComplete) { |
| 405 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 406 | mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE; |
| 407 | mService.mLastFinishedFreezeSource = mLastWindowFreezeSource; |
| 408 | mService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT); |
| 409 | } |
| 410 | mService.stopFreezingDisplayLocked(); |
| 411 | } |
| 412 | |
| 413 | // Destroy the surface of any windows that are no longer visible. |
Filip Gruszczynski | 19723a4 | 2015-11-25 15:01:48 -0800 | [diff] [blame] | 414 | boolean wallpaperDestroyed = false; |
| 415 | i = mService.mDestroySurface.size(); |
| 416 | if (i > 0) { |
| 417 | do { |
| 418 | i--; |
| 419 | WindowState win = mService.mDestroySurface.get(i); |
| 420 | win.mDestroying = false; |
| 421 | if (mService.mInputMethodWindow == win) { |
| 422 | mService.mInputMethodWindow = null; |
| 423 | } |
| 424 | if (mWallpaperControllerLocked.isWallpaperTarget(win)) { |
| 425 | wallpaperDestroyed = true; |
| 426 | } |
Robert Carr | 13f7be9e | 2015-12-02 18:39:45 -0800 | [diff] [blame] | 427 | win.destroyOrSaveSurface(); |
Filip Gruszczynski | 19723a4 | 2015-11-25 15:01:48 -0800 | [diff] [blame] | 428 | } while (i > 0); |
| 429 | mService.mDestroySurface.clear(); |
| 430 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 431 | |
| 432 | // Time to remove any exiting tokens? |
| 433 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 434 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 435 | ArrayList<WindowToken> exitingTokens = displayContent.mExitingTokens; |
| 436 | for (i = exitingTokens.size() - 1; i >= 0; i--) { |
| 437 | WindowToken token = exitingTokens.get(i); |
| 438 | if (!token.hasVisible) { |
| 439 | exitingTokens.remove(i); |
| 440 | if (token.windowType == TYPE_WALLPAPER) { |
| 441 | mWallpaperControllerLocked.removeWallpaperToken(token); |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | // Time to remove any exiting applications? |
| 448 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 449 | // Initialize state of exiting applications. |
| 450 | final AppTokenList exitingAppTokens = |
| 451 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 452 | for (i = exitingAppTokens.size() - 1; i >= 0; i--) { |
| 453 | AppWindowToken token = exitingAppTokens.get(i); |
| 454 | if (!token.hasVisible && !mService.mClosingApps.contains(token) && |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 455 | (!token.mIsExiting || token.isEmpty())) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 456 | // Make sure there is no animation running on this token, |
| 457 | // so any windows associated with it will be removed as |
| 458 | // soon as their animations are complete |
| 459 | token.mAppAnimator.clearAnimation(); |
| 460 | token.mAppAnimator.animating = false; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 461 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, |
| 462 | "performLayout: App token exiting now removed" + token); |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 463 | token.removeIfPossible(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 464 | } |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | if (wallpaperDestroyed) { |
| 469 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 470 | defaultDisplay.layoutNeeded = true; |
| 471 | } |
| 472 | |
| 473 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 474 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 475 | if (displayContent.pendingLayoutChanges != 0) { |
| 476 | displayContent.layoutNeeded = true; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | // Finally update all input windows now that the window changes have stabilized. |
| 481 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
| 482 | |
| 483 | mService.setHoldScreenLocked(mHoldScreen); |
| 484 | if (!mService.mDisplayFrozen) { |
| 485 | if (mScreenBrightness < 0 || mScreenBrightness > 1.0f) { |
| 486 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1); |
| 487 | } else { |
| 488 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager( |
| 489 | toBrightnessOverride(mScreenBrightness)); |
| 490 | } |
| 491 | if (mButtonBrightness < 0 |
| 492 | || mButtonBrightness > 1.0f) { |
| 493 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1); |
| 494 | } else { |
| 495 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager( |
| 496 | toBrightnessOverride(mButtonBrightness)); |
| 497 | } |
| 498 | mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager( |
| 499 | mUserActivityTimeout); |
| 500 | } |
| 501 | |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 502 | if (mSustainedPerformanceModeCurrent != mSustainedPerformanceModeEnabled) { |
| 503 | mSustainedPerformanceModeEnabled = mSustainedPerformanceModeCurrent; |
| 504 | mService.mPowerManagerInternal.powerHint( |
| 505 | mService.mPowerManagerInternal.POWER_HINT_SUSTAINED_PERFORMANCE_MODE, |
| 506 | (mSustainedPerformanceModeEnabled ? 1 : 0)); |
| 507 | } |
| 508 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 509 | if (mService.mTurnOnScreen) { |
| 510 | if (mService.mAllowTheaterModeWakeFromLayout |
| 511 | || Settings.Global.getInt(mService.mContext.getContentResolver(), |
| 512 | Settings.Global.THEATER_MODE_ON, 0) == 0) { |
| 513 | if (DEBUG_VISIBILITY || DEBUG_POWER) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 514 | Slog.v(TAG, "Turning screen on after layout!"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 515 | } |
| 516 | mService.mPowerManager.wakeUp(SystemClock.uptimeMillis(), |
| 517 | "android.server.wm:TURN_ON"); |
| 518 | } |
| 519 | mService.mTurnOnScreen = false; |
| 520 | } |
| 521 | |
| 522 | if (mUpdateRotation) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 523 | if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 524 | if (mService.updateRotationUncheckedLocked(false)) { |
| 525 | mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION); |
| 526 | } else { |
| 527 | mUpdateRotation = false; |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | if (mService.mWaitingForDrawnCallback != null || |
| 532 | (mOrientationChangeComplete && !defaultDisplay.layoutNeeded && |
| 533 | !mUpdateRotation)) { |
| 534 | mService.checkDrawnWindowsLocked(); |
| 535 | } |
| 536 | |
| 537 | final int N = mService.mPendingRemove.size(); |
| 538 | if (N > 0) { |
| 539 | if (mService.mPendingRemoveTmp.length < N) { |
| 540 | mService.mPendingRemoveTmp = new WindowState[N+10]; |
| 541 | } |
| 542 | mService.mPendingRemove.toArray(mService.mPendingRemoveTmp); |
| 543 | mService.mPendingRemove.clear(); |
| 544 | DisplayContentList displayList = new DisplayContentList(); |
| 545 | for (i = 0; i < N; i++) { |
Wale Ogunwale | adde52e | 2016-07-16 13:11:55 -0700 | [diff] [blame] | 546 | final WindowState w = mService.mPendingRemoveTmp[i]; |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 547 | w.removeImmediately(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 548 | final DisplayContent displayContent = w.getDisplayContent(); |
| 549 | if (displayContent != null && !displayList.contains(displayContent)) { |
| 550 | displayList.add(displayContent); |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | for (DisplayContent displayContent : displayList) { |
Filip Gruszczynski | 92e432c | 2015-12-15 19:17:09 -0800 | [diff] [blame] | 555 | mService.mLayersController.assignLayersLocked(displayContent.getWindowList()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 556 | displayContent.layoutNeeded = true; |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | // Remove all deferred displays stacks, tasks, and activities. |
| 561 | for (int displayNdx = mService.mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 562 | mService.mDisplayContents.valueAt(displayNdx).checkCompleteDeferredRemoval(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | if (updateInputWindowsNeeded) { |
| 566 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 567 | } |
Chong Zhang | b15758a | 2015-11-17 12:12:03 -0800 | [diff] [blame] | 568 | mService.setFocusTaskRegionLocked(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 569 | |
| 570 | // Check to see if we are now in a state where the screen should |
| 571 | // be enabled, because the window obscured flags have changed. |
| 572 | mService.enableScreenIfNeededLocked(); |
| 573 | |
| 574 | mService.scheduleAnimationLocked(); |
Jorim Jaggi | 3dac63a | 2016-03-01 12:37:07 +0100 | [diff] [blame] | 575 | mService.mWindowPlacerLocked.destroyPendingSurfaces(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 576 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 577 | if (DEBUG_WINDOW_TRACE) Slog.e(TAG, |
Wale Ogunwale | 69cf50f | 2015-11-13 11:08:36 -0800 | [diff] [blame] | 578 | "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 579 | } |
| 580 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 581 | private void applySurfaceChangesTransaction(boolean recoveringMemory, int numDisplays, |
| 582 | int defaultDw, int defaultDh) { |
| 583 | if (mService.mWatermark != null) { |
| 584 | mService.mWatermark.positionSurface(defaultDw, defaultDh); |
| 585 | } |
| 586 | if (mService.mStrictModeFlash != null) { |
| 587 | mService.mStrictModeFlash.positionSurface(defaultDw, defaultDh); |
| 588 | } |
| 589 | if (mService.mCircularDisplayMask != null) { |
| 590 | mService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh, |
| 591 | mService.mRotation); |
| 592 | } |
| 593 | if (mService.mEmulatorDisplayOverlay != null) { |
| 594 | mService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh, |
| 595 | mService.mRotation); |
| 596 | } |
| 597 | |
| 598 | boolean focusDisplayed = false; |
| 599 | |
| 600 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
| 601 | final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx); |
| 602 | boolean updateAllDrawn = false; |
| 603 | WindowList windows = displayContent.getWindowList(); |
| 604 | DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
| 605 | final int displayId = displayContent.getDisplayId(); |
| 606 | final int dw = displayInfo.logicalWidth; |
| 607 | final int dh = displayInfo.logicalHeight; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 608 | final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY); |
| 609 | |
| 610 | // Reset for each display. |
| 611 | mDisplayHasContent = false; |
| 612 | mPreferredRefreshRate = 0; |
| 613 | mPreferredModeId = 0; |
| 614 | |
| 615 | int repeats = 0; |
| 616 | do { |
| 617 | repeats++; |
| 618 | if (repeats > 6) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 619 | Slog.w(TAG, "Animation repeat aborted after too many iterations"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 620 | displayContent.layoutNeeded = false; |
| 621 | break; |
| 622 | } |
| 623 | |
| 624 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats( |
| 625 | "On entry to LockedInner", displayContent.pendingLayoutChanges); |
| 626 | |
| 627 | if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 && |
| 628 | mWallpaperControllerLocked.adjustWallpaperWindows()) { |
Filip Gruszczynski | 92e432c | 2015-12-15 19:17:09 -0800 | [diff] [blame] | 629 | mService.mLayersController.assignLayersLocked(windows); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 630 | displayContent.layoutNeeded = true; |
| 631 | } |
| 632 | |
| 633 | if (isDefaultDisplay |
| 634 | && (displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 635 | if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 636 | if (mService.updateOrientationFromAppTokensLocked(true)) { |
| 637 | displayContent.layoutNeeded = true; |
| 638 | mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION); |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_LAYOUT) != 0) { |
| 643 | displayContent.layoutNeeded = true; |
| 644 | } |
| 645 | |
| 646 | // FIRST LOOP: Perform a layout, if needed. |
| 647 | if (repeats < LAYOUT_REPEAT_THRESHOLD) { |
| 648 | performLayoutLockedInner(displayContent, repeats == 1, |
| 649 | false /* updateInputWindows */); |
| 650 | } else { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 651 | Slog.w(TAG, "Layout repeat skipped after too many iterations"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | // FIRST AND ONE HALF LOOP: Make WindowManagerPolicy think |
| 655 | // it is animating. |
| 656 | displayContent.pendingLayoutChanges = 0; |
| 657 | |
| 658 | if (isDefaultDisplay) { |
| 659 | mService.mPolicy.beginPostLayoutPolicyLw(dw, dh); |
| 660 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 661 | WindowState w = windows.get(i); |
| 662 | if (w.mHasSurface) { |
Wale Ogunwale | caa53af | 2016-07-17 14:50:26 -0700 | [diff] [blame] | 663 | mService.mPolicy.applyPostLayoutPolicyLw( |
| 664 | w, w.mAttrs, w.getParentWindow()); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | displayContent.pendingLayoutChanges |= |
| 668 | mService.mPolicy.finishPostLayoutPolicyLw(); |
| 669 | if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after finishPostLayoutPolicyLw", |
| 670 | displayContent.pendingLayoutChanges); |
| 671 | } |
| 672 | } while (displayContent.pendingLayoutChanges != 0); |
| 673 | |
| 674 | mObscured = false; |
| 675 | mSyswin = false; |
| 676 | displayContent.resetDimming(); |
| 677 | |
| 678 | // Only used if default window |
| 679 | final boolean someoneLosingFocus = !mService.mLosingFocus.isEmpty(); |
| 680 | |
| 681 | for (int i = windows.size() - 1; i >= 0; i--) { |
| 682 | WindowState w = windows.get(i); |
Robert Carr | 0d00c2e | 2016-02-29 17:45:02 -0800 | [diff] [blame] | 683 | final Task task = w.getTask(); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 684 | final boolean obscuredChanged = w.mObscured != mObscured; |
| 685 | |
| 686 | // Update effect. |
| 687 | w.mObscured = mObscured; |
| 688 | if (!mObscured) { |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 689 | handleNotObscuredLocked(w, displayInfo); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 690 | } |
| 691 | |
Chong Zhang | 112eb8c | 2015-11-02 11:17:00 -0800 | [diff] [blame] | 692 | w.applyDimLayerIfNeeded(); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 693 | |
| 694 | if (isDefaultDisplay && obscuredChanged |
| 695 | && mWallpaperControllerLocked.isWallpaperTarget(w) && w.isVisibleLw()) { |
| 696 | // This is the wallpaper target and its obscured state |
| 697 | // changed... make sure the current wallaper's visibility |
| 698 | // has been updated accordingly. |
| 699 | mWallpaperControllerLocked.updateWallpaperVisibility(); |
| 700 | } |
| 701 | |
| 702 | final WindowStateAnimator winAnimator = w.mWinAnimator; |
| 703 | |
| 704 | // If the window has moved due to its containing content frame changing, then |
Filip Gruszczynski | f52dd20 | 2015-11-15 20:36:38 -0800 | [diff] [blame] | 705 | // notify the listeners and optionally animate it. Simply checking a change of |
| 706 | // position is not enough, because being move due to dock divider is not a trigger |
| 707 | // for animation. |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 708 | if (w.hasMoved()) { |
| 709 | // Frame has moved, containing content frame has also moved, and we're not |
| 710 | // currently animating... let's do something. |
| 711 | final int left = w.mFrame.left; |
| 712 | final int top = w.mFrame.top; |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 713 | final boolean adjustedForMinimizedDockOrIme = task != null |
| 714 | && (task.mStack.isAdjustedForMinimizedDockedStack() |
| 715 | || task.mStack.isAdjustedForIme()); |
Filip Gruszczynski | f52dd20 | 2015-11-15 20:36:38 -0800 | [diff] [blame] | 716 | if ((w.mAttrs.privateFlags & PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0 |
Chong Zhang | baba783 | 2016-03-24 10:21:26 -0700 | [diff] [blame] | 717 | && !w.isDragResizing() && !adjustedForMinimizedDockOrIme |
Robert Carr | c729460 | 2016-05-13 11:32:05 -0700 | [diff] [blame] | 718 | && (task == null || w.getTask().mStack.hasMovementAnimations()) |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 719 | && !w.mWinAnimator.mLastHidden) { |
Filip Gruszczynski | f52dd20 | 2015-11-15 20:36:38 -0800 | [diff] [blame] | 720 | winAnimator.setMoveAnimation(left, top); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | //TODO (multidisplay): Accessibility supported only for the default display. |
| 724 | if (mService.mAccessibilityController != null |
| 725 | && displayId == Display.DEFAULT_DISPLAY) { |
| 726 | mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked(); |
| 727 | } |
| 728 | |
| 729 | try { |
Wale Ogunwale | 7774bd5 | 2016-06-17 09:44:22 -0700 | [diff] [blame] | 730 | w.mClient.moved(left, top); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 731 | } catch (RemoteException e) { |
| 732 | } |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 733 | w.mMovedByResize = false; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 734 | } |
| 735 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 736 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing"); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 737 | w.mContentChanged = false; |
| 738 | |
| 739 | // Moved from updateWindowsAndWallpaperLocked(). |
| 740 | if (w.mHasSurface) { |
| 741 | // Take care of the window being ready to display. |
| 742 | final boolean committed = winAnimator.commitFinishDrawingLocked(); |
| 743 | if (isDefaultDisplay && committed) { |
| 744 | if (w.mAttrs.type == TYPE_DREAM) { |
| 745 | // HACK: When a dream is shown, it may at that |
| 746 | // point hide the lock screen. So we need to |
| 747 | // redo the layout to let the phone window manager |
| 748 | // make this happen. |
| 749 | displayContent.pendingLayoutChanges |= |
| 750 | FINISH_LAYOUT_REDO_LAYOUT; |
| 751 | if (DEBUG_LAYOUT_REPEATS) { |
| 752 | debugLayoutRepeats("dream and commitFinishDrawingLocked true", |
| 753 | displayContent.pendingLayoutChanges); |
| 754 | } |
| 755 | } |
| 756 | if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) { |
| 757 | if (DEBUG_WALLPAPER_LIGHT) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 758 | Slog.v(TAG, "First draw done in potential wallpaper target " + w); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 759 | mWallpaperMayChange = true; |
| 760 | displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 761 | if (DEBUG_LAYOUT_REPEATS) { |
| 762 | debugLayoutRepeats("wallpaper and commitFinishDrawingLocked true", |
| 763 | displayContent.pendingLayoutChanges); |
| 764 | } |
| 765 | } |
| 766 | } |
Chong Zhang | e22006d | 2016-05-09 10:59:59 -0700 | [diff] [blame] | 767 | if (!winAnimator.isAnimationStarting() && !winAnimator.isWaitingForOpening()) { |
Filip Gruszczynski | c46f41c | 2016-01-05 11:29:21 -0800 | [diff] [blame] | 768 | // Updates the shown frame before we set up the surface. This is needed |
| 769 | // because the resizing could change the top-left position (in addition to |
| 770 | // size) of the window. setSurfaceBoundariesLocked uses mShownPosition to |
Jorim Jaggi | 5c80c41 | 2016-04-19 20:03:47 -0700 | [diff] [blame] | 771 | // position the surface. |
| 772 | // |
| 773 | // If an animation is being started, we can't call this method because the |
| 774 | // animation hasn't processed its initial transformation yet, but in general |
| 775 | // we do want to update the position if the window is animating. |
Filip Gruszczynski | c46f41c | 2016-01-05 11:29:21 -0800 | [diff] [blame] | 776 | winAnimator.computeShownFrameLocked(); |
| 777 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 778 | winAnimator.setSurfaceBoundariesLocked(recoveringMemory); |
| 779 | } |
| 780 | |
| 781 | final AppWindowToken atoken = w.mAppToken; |
| 782 | if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 783 | Slog.d(TAG, "updateWindows: starting " + w |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 784 | + " isOnScreen=" + w.isOnScreen() + " allDrawn=" + atoken.allDrawn |
| 785 | + " freezingScreen=" + atoken.mAppAnimator.freezingScreen); |
| 786 | } |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 787 | if (atoken != null && (!atoken.allDrawn || !atoken.allDrawnExcludingSaved |
| 788 | || atoken.mAppAnimator.freezingScreen)) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 789 | if (atoken.lastTransactionSequence != mService.mTransactionSequence) { |
| 790 | atoken.lastTransactionSequence = mService.mTransactionSequence; |
| 791 | atoken.numInterestingWindows = atoken.numDrawnWindows = 0; |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 792 | atoken.numInterestingWindowsExcludingSaved = 0; |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 793 | atoken.numDrawnWindowsExcludingSaved = 0; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 794 | atoken.startingDisplayed = false; |
| 795 | } |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 796 | if (!atoken.allDrawn && w.mightAffectAllDrawn(false /* visibleOnly */)) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 797 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 798 | Slog.v(TAG, "Eval win " + w + ": isDrawn=" |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 799 | + w.isDrawnLw() |
Jorim Jaggi | 5c80c41 | 2016-04-19 20:03:47 -0700 | [diff] [blame] | 800 | + ", isAnimationSet=" + winAnimator.isAnimationSet()); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 801 | if (!w.isDrawnLw()) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 802 | Slog.v(TAG, "Not displayed: s=" |
Robert Carr | e6a8351 | 2015-11-03 16:09:21 -0800 | [diff] [blame] | 803 | + winAnimator.mSurfaceController |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 804 | + " pv=" + w.mPolicyVisibility |
| 805 | + " mDrawState=" + winAnimator.drawStateToString() |
Wale Ogunwale | 9d14790 | 2016-07-16 11:58:55 -0700 | [diff] [blame] | 806 | + " ph=" + w.isParentWindowHidden() |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 807 | + " th=" + atoken.hiddenRequested |
| 808 | + " a=" + winAnimator.mAnimating); |
| 809 | } |
| 810 | } |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 811 | if (w != atoken.startingWindow) { |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 812 | if (w.isInteresting()) { |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 813 | atoken.numInterestingWindows++; |
| 814 | if (w.isDrawnLw()) { |
| 815 | atoken.numDrawnWindows++; |
| 816 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 817 | Slog.v(TAG, "tokenMayBeDrawn: " + atoken |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 818 | + " w=" + w + " numInteresting=" |
| 819 | + atoken.numInterestingWindows |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 820 | + " freezingScreen=" |
| 821 | + atoken.mAppAnimator.freezingScreen |
| 822 | + " mAppFreezing=" + w.mAppFreezing); |
| 823 | updateAllDrawn = true; |
| 824 | } |
| 825 | } |
| 826 | } else if (w.isDrawnLw()) { |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 827 | mService.mH.sendEmptyMessage(NOTIFY_STARTING_WINDOW_DRAWN); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 828 | atoken.startingDisplayed = true; |
| 829 | } |
| 830 | } |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 831 | if (!atoken.allDrawnExcludingSaved |
| 832 | && w.mightAffectAllDrawn(true /* visibleOnly */)) { |
| 833 | if (w != atoken.startingWindow && w.isInteresting()) { |
| 834 | atoken.numInterestingWindowsExcludingSaved++; |
| 835 | if (w.isDrawnLw() && !w.isAnimatingWithSavedSurface()) { |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 836 | atoken.numDrawnWindowsExcludingSaved++; |
Chong Zhang | 8e4bda9 | 2016-05-04 15:08:18 -0700 | [diff] [blame] | 837 | if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) |
| 838 | Slog.v(TAG, "tokenMayBeDrawnExcludingSaved: " + atoken |
| 839 | + " w=" + w + " numInteresting=" |
| 840 | + atoken.numInterestingWindowsExcludingSaved |
| 841 | + " freezingScreen=" |
| 842 | + atoken.mAppAnimator.freezingScreen |
| 843 | + " mAppFreezing=" + w.mAppFreezing); |
| 844 | updateAllDrawn = true; |
| 845 | } |
| 846 | } |
| 847 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | if (isDefaultDisplay && someoneLosingFocus && w == mService.mCurrentFocus |
| 851 | && w.isDisplayedLw()) { |
| 852 | focusDisplayed = true; |
| 853 | } |
| 854 | |
| 855 | mService.updateResizingWindows(w); |
| 856 | } |
| 857 | |
| 858 | mService.mDisplayManagerInternal.setDisplayProperties(displayId, |
| 859 | mDisplayHasContent, |
| 860 | mPreferredRefreshRate, |
| 861 | mPreferredModeId, |
| 862 | true /* inTraversal, must call performTraversalInTrans... below */); |
| 863 | |
Wale Ogunwale | 15ead90 | 2016-09-02 14:30:11 -0700 | [diff] [blame] | 864 | displayContent.stopDimmingIfNeeded(); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 865 | |
| 866 | if (updateAllDrawn) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 867 | // See if any windows have been drawn, so they (and others associated with them) |
| 868 | // can now be shown. |
| 869 | displayContent.updateAllDrawn(); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 870 | } |
| 871 | } |
| 872 | |
| 873 | if (focusDisplayed) { |
| 874 | mService.mH.sendEmptyMessage(REPORT_LOSING_FOCUS); |
| 875 | } |
| 876 | |
| 877 | // Give the display manager a chance to adjust properties |
| 878 | // like display rotation if it needs to. |
| 879 | mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager(); |
| 880 | } |
| 881 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 882 | boolean isInLayout() { |
| 883 | return mInLayout; |
| 884 | } |
| 885 | |
| 886 | final void performLayoutLockedInner(final DisplayContent displayContent, |
| 887 | boolean initial, boolean updateInputWindows) { |
| 888 | if (!displayContent.layoutNeeded) { |
| 889 | return; |
| 890 | } |
| 891 | displayContent.layoutNeeded = false; |
| 892 | WindowList windows = displayContent.getWindowList(); |
| 893 | boolean isDefaultDisplay = displayContent.isDefaultDisplay; |
| 894 | |
| 895 | DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
| 896 | final int dw = displayInfo.logicalWidth; |
| 897 | final int dh = displayInfo.logicalHeight; |
| 898 | |
| 899 | if (mService.mInputConsumer != null) { |
| 900 | mService.mInputConsumer.layout(dw, dh); |
| 901 | } |
| 902 | |
Vladislav Kaznacheev | 0d50d86 | 2016-03-29 15:43:28 -0700 | [diff] [blame] | 903 | if (mService.mWallpaperInputConsumer != null) { |
| 904 | mService.mWallpaperInputConsumer.layout(dw, dh); |
| 905 | } |
| 906 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 907 | final int N = windows.size(); |
| 908 | int i; |
| 909 | |
| 910 | if (DEBUG_LAYOUT) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 911 | Slog.v(TAG, "-------------------------------------"); |
| 912 | Slog.v(TAG, "performLayout: needed=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 913 | + displayContent.layoutNeeded + " dw=" + dw + " dh=" + dh); |
| 914 | } |
| 915 | |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 916 | mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation, |
Andrii Kulian | 8072d11 | 2016-09-16 11:11:01 -0700 | [diff] [blame] | 917 | mService.mGlobalConfiguration.uiMode); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 918 | if (isDefaultDisplay) { |
| 919 | // Not needed on non-default displays. |
| 920 | mService.mSystemDecorLayer = mService.mPolicy.getSystemDecorLayerLw(); |
| 921 | mService.mScreenRect.set(0, 0, dw, dh); |
| 922 | } |
| 923 | |
Wale Ogunwale | b4ec0a3 | 2015-12-14 10:31:43 -0800 | [diff] [blame] | 924 | mService.mPolicy.getContentRectLw(mTmpContentRect); |
| 925 | displayContent.resize(mTmpContentRect); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 926 | |
| 927 | int seq = mService.mLayoutSeq+1; |
| 928 | if (seq < 0) seq = 0; |
| 929 | mService.mLayoutSeq = seq; |
| 930 | |
| 931 | boolean behindDream = false; |
| 932 | |
| 933 | // First perform layout of any root windows (not attached |
| 934 | // to another window). |
| 935 | int topAttached = -1; |
| 936 | for (i = N-1; i >= 0; i--) { |
| 937 | final WindowState win = windows.get(i); |
| 938 | |
| 939 | // Don't do layout of a window if it is not visible, or |
| 940 | // soon won't be visible, to avoid wasting time and funky |
| 941 | // changes while a window is animating away. |
| 942 | final boolean gone = (behindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs)) |
| 943 | || win.isGoneForLayoutLw(); |
| 944 | |
| 945 | if (DEBUG_LAYOUT && !win.mLayoutAttached) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 946 | Slog.v(TAG, "1ST PASS " + win |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 947 | + ": gone=" + gone + " mHaveFrame=" + win.mHaveFrame |
| 948 | + " mLayoutAttached=" + win.mLayoutAttached |
| 949 | + " screen changed=" + win.isConfigChanged()); |
| 950 | final AppWindowToken atoken = win.mAppToken; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 951 | if (gone) Slog.v(TAG, " GONE: mViewVisibility=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 952 | + win.mViewVisibility + " mRelayoutCalled=" |
| 953 | + win.mRelayoutCalled + " hidden=" |
Wale Ogunwale | a6cc361 | 2016-08-04 07:25:33 -0700 | [diff] [blame] | 954 | + win.mToken.hidden + " hiddenRequested=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 955 | + (atoken != null && atoken.hiddenRequested) |
Wale Ogunwale | 9d14790 | 2016-07-16 11:58:55 -0700 | [diff] [blame] | 956 | + " parentHidden=" + win.isParentWindowHidden()); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 957 | else Slog.v(TAG, " VIS: mViewVisibility=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 958 | + win.mViewVisibility + " mRelayoutCalled=" |
| 959 | + win.mRelayoutCalled + " hidden=" |
Wale Ogunwale | a6cc361 | 2016-08-04 07:25:33 -0700 | [diff] [blame] | 960 | + win.mToken.hidden + " hiddenRequested=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 961 | + (atoken != null && atoken.hiddenRequested) |
Wale Ogunwale | 9d14790 | 2016-07-16 11:58:55 -0700 | [diff] [blame] | 962 | + " parentHidden=" + win.isParentWindowHidden()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | // If this view is GONE, then skip it -- keep the current |
| 966 | // frame, and let the caller know so they can ignore it |
| 967 | // if they want. (We do the normal layout for INVISIBLE |
| 968 | // windows, since that means "perform layout as normal, |
| 969 | // just don't display"). |
| 970 | if (!gone || !win.mHaveFrame || win.mLayoutNeeded |
Robert Carr | 31aa98b | 2016-07-20 15:29:03 -0700 | [diff] [blame] | 971 | || ((win.isConfigChanged() || win.setReportResizeHints()) |
Jorim Jaggi | 5c80c41 | 2016-04-19 20:03:47 -0700 | [diff] [blame] | 972 | && !win.isGoneForLayoutLw() && |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 973 | ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || |
| 974 | (win.mHasSurface && win.mAppToken != null && |
| 975 | win.mAppToken.layoutConfigChanges)))) { |
| 976 | if (!win.mLayoutAttached) { |
| 977 | if (initial) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 978 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 979 | win.mContentChanged = false; |
| 980 | } |
| 981 | if (win.mAttrs.type == TYPE_DREAM) { |
| 982 | // Don't layout windows behind a dream, so that if it |
| 983 | // does stuff like hide the status bar we won't get a |
| 984 | // bad transition when it goes away. |
| 985 | behindDream = true; |
| 986 | } |
| 987 | win.mLayoutNeeded = false; |
| 988 | win.prelayout(); |
| 989 | mService.mPolicy.layoutWindowLw(win, null); |
| 990 | win.mLayoutSeq = seq; |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 991 | |
| 992 | // Window frames may have changed. Update dim layer with the new bounds. |
| 993 | final Task task = win.getTask(); |
| 994 | if (task != null) { |
| 995 | displayContent.mDimLayerController.updateDimLayer(task); |
| 996 | } |
| 997 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 998 | if (DEBUG_LAYOUT) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 999 | " LAYOUT: mFrame=" |
| 1000 | + win.mFrame + " mContainingFrame=" |
| 1001 | + win.mContainingFrame + " mDisplayFrame=" |
| 1002 | + win.mDisplayFrame); |
| 1003 | } else { |
| 1004 | if (topAttached < 0) topAttached = i; |
| 1005 | } |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | boolean attachedBehindDream = false; |
| 1010 | |
| 1011 | // Now perform layout of attached windows, which usually |
| 1012 | // depend on the position of the window they are attached to. |
| 1013 | // XXX does not deal with windows that are attached to windows |
| 1014 | // that are themselves attached. |
| 1015 | for (i = topAttached; i >= 0; i--) { |
| 1016 | final WindowState win = windows.get(i); |
| 1017 | |
| 1018 | if (win.mLayoutAttached) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1019 | if (DEBUG_LAYOUT) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1020 | "2ND PASS " + win + " mHaveFrame=" + win.mHaveFrame + " mViewVisibility=" |
| 1021 | + win.mViewVisibility + " mRelayoutCalled=" + win.mRelayoutCalled); |
| 1022 | // If this view is GONE, then skip it -- keep the current |
| 1023 | // frame, and let the caller know so they can ignore it |
| 1024 | // if they want. (We do the normal layout for INVISIBLE |
| 1025 | // windows, since that means "perform layout as normal, |
| 1026 | // just don't display"). |
| 1027 | if (attachedBehindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs)) { |
| 1028 | continue; |
| 1029 | } |
| 1030 | if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) |
| 1031 | || !win.mHaveFrame || win.mLayoutNeeded) { |
| 1032 | if (initial) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1033 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1034 | win.mContentChanged = false; |
| 1035 | } |
| 1036 | win.mLayoutNeeded = false; |
| 1037 | win.prelayout(); |
Wale Ogunwale | caa53af | 2016-07-17 14:50:26 -0700 | [diff] [blame] | 1038 | mService.mPolicy.layoutWindowLw(win, win.getParentWindow()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1039 | win.mLayoutSeq = seq; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1040 | if (DEBUG_LAYOUT) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1041 | " LAYOUT: mFrame=" + win.mFrame + " mContainingFrame=" |
| 1042 | + win.mContainingFrame + " mDisplayFrame=" + win.mDisplayFrame); |
| 1043 | } |
| 1044 | } else if (win.mAttrs.type == TYPE_DREAM) { |
| 1045 | // Don't layout windows behind a dream, so that if it |
| 1046 | // does stuff like hide the status bar we won't get a |
| 1047 | // bad transition when it goes away. |
| 1048 | attachedBehindDream = behindDream; |
| 1049 | } |
| 1050 | } |
| 1051 | |
Chong Zhang | 4c9ba52a | 2015-11-10 18:36:33 -0800 | [diff] [blame] | 1052 | // Window frames may have changed. Tell the input dispatcher about it. |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1053 | mService.mInputMonitor.setUpdateInputWindowsNeededLw(); |
| 1054 | if (updateInputWindows) { |
| 1055 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 1056 | } |
| 1057 | |
| 1058 | mService.mPolicy.finishLayoutLw(); |
Jorim Jaggi | 61f39a7 | 2015-10-29 16:54:18 +0100 | [diff] [blame] | 1059 | mService.mH.sendEmptyMessage(UPDATE_DOCKED_STACK_DIVIDER); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | /** |
| 1063 | * @param windows List of windows on default display. |
| 1064 | * @return bitmap indicating if another pass through layout must be made. |
| 1065 | */ |
| 1066 | private int handleAppTransitionReadyLocked(WindowList windows) { |
| 1067 | int appsCount = mService.mOpeningApps.size(); |
| 1068 | if (!transitionGoodToGo(appsCount)) { |
| 1069 | return 0; |
| 1070 | } |
Chong Zhang | 8784be6 | 2016-06-28 15:25:07 -0700 | [diff] [blame] | 1071 | Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "AppTransitionReady"); |
| 1072 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1073 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "**** GOOD TO GO"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1074 | int transit = mService.mAppTransition.getAppTransition(); |
| 1075 | if (mService.mSkipAppTransitionAnimation) { |
| 1076 | transit = AppTransition.TRANSIT_UNSET; |
| 1077 | } |
| 1078 | mService.mSkipAppTransitionAnimation = false; |
| 1079 | mService.mNoAnimationNotifyOnTransitionFinished.clear(); |
| 1080 | |
Jorim Jaggi | d75962e | 2016-05-03 15:10:03 -0700 | [diff] [blame] | 1081 | mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1082 | |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1083 | final DisplayContent displayContent = mService.getDefaultDisplayContentLocked(); |
| 1084 | displayContent.rebuildAppWindowList(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1085 | |
| 1086 | mWallpaperMayChange = false; |
| 1087 | |
| 1088 | // The top-most window will supply the layout params, |
| 1089 | // and we will determine it below. |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1090 | LayoutParams animLp = null; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1091 | int bestAnimLayer = -1; |
| 1092 | boolean fullscreenAnim = false; |
| 1093 | boolean voiceInteraction = false; |
| 1094 | |
Chong Zhang | ec8299c | 2016-07-29 13:09:40 -0700 | [diff] [blame] | 1095 | int i; |
| 1096 | for (i = 0; i < appsCount; i++) { |
| 1097 | final AppWindowToken wtoken = mService.mOpeningApps.valueAt(i); |
| 1098 | // Clearing the mAnimatingExit flag before entering animation. It's set to |
| 1099 | // true if app window is removed, or window relayout to invisible. |
| 1100 | // This also affects window visibility. We need to clear it *before* |
| 1101 | // maybeUpdateTransitToWallpaper() as the transition selection depends on |
| 1102 | // wallpaper target visibility. |
| 1103 | wtoken.clearAnimatingFlags(); |
| 1104 | |
| 1105 | } |
| 1106 | // Adjust wallpaper before we pull the lower/upper target, since pending changes |
| 1107 | // (like the clearAnimatingFlags() above) might affect wallpaper target result. |
Chong Zhang | ec8299c | 2016-07-29 13:09:40 -0700 | [diff] [blame] | 1108 | if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 && |
| 1109 | mWallpaperControllerLocked.adjustWallpaperWindows()) { |
| 1110 | mService.mLayersController.assignLayersLocked(windows); |
| 1111 | displayContent.layoutNeeded = true; |
| 1112 | } |
| 1113 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1114 | final WindowState lowerWallpaperTarget = |
| 1115 | mWallpaperControllerLocked.getLowerWallpaperTarget(); |
| 1116 | final WindowState upperWallpaperTarget = |
| 1117 | mWallpaperControllerLocked.getUpperWallpaperTarget(); |
| 1118 | |
| 1119 | boolean openingAppHasWallpaper = false; |
| 1120 | boolean closingAppHasWallpaper = false; |
| 1121 | final AppWindowToken lowerWallpaperAppToken; |
| 1122 | final AppWindowToken upperWallpaperAppToken; |
| 1123 | if (lowerWallpaperTarget == null) { |
| 1124 | lowerWallpaperAppToken = upperWallpaperAppToken = null; |
| 1125 | } else { |
| 1126 | lowerWallpaperAppToken = lowerWallpaperTarget.mAppToken; |
| 1127 | upperWallpaperAppToken = upperWallpaperTarget.mAppToken; |
| 1128 | } |
| 1129 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1130 | // Do a first pass through the tokens for two |
| 1131 | // things: |
| 1132 | // (1) Determine if both the closing and opening |
| 1133 | // app token sets are wallpaper targets, in which |
| 1134 | // case special animations are needed |
| 1135 | // (since the wallpaper needs to stay static |
| 1136 | // behind them). |
| 1137 | // (2) Find the layout params of the top-most |
| 1138 | // application window in the tokens, which is |
| 1139 | // what will control the animation theme. |
| 1140 | final int closingAppsCount = mService.mClosingApps.size(); |
| 1141 | appsCount = closingAppsCount + mService.mOpeningApps.size(); |
| 1142 | for (i = 0; i < appsCount; i++) { |
| 1143 | final AppWindowToken wtoken; |
| 1144 | if (i < closingAppsCount) { |
| 1145 | wtoken = mService.mClosingApps.valueAt(i); |
| 1146 | if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) { |
| 1147 | closingAppHasWallpaper = true; |
| 1148 | } |
| 1149 | } else { |
| 1150 | wtoken = mService.mOpeningApps.valueAt(i - closingAppsCount); |
| 1151 | if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) { |
| 1152 | openingAppHasWallpaper = true; |
| 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | voiceInteraction |= wtoken.voiceInteraction; |
| 1157 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1158 | if (wtoken.fillsParent()) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1159 | WindowState ws = wtoken.findMainWindow(); |
| 1160 | if (ws != null) { |
| 1161 | animLp = ws.mAttrs; |
| 1162 | bestAnimLayer = ws.mLayer; |
| 1163 | fullscreenAnim = true; |
| 1164 | } |
| 1165 | } else if (!fullscreenAnim) { |
| 1166 | WindowState ws = wtoken.findMainWindow(); |
| 1167 | if (ws != null) { |
| 1168 | if (ws.mLayer > bestAnimLayer) { |
| 1169 | animLp = ws.mAttrs; |
| 1170 | bestAnimLayer = ws.mLayer; |
| 1171 | } |
| 1172 | } |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | transit = maybeUpdateTransitToWallpaper(transit, openingAppHasWallpaper, |
| 1177 | closingAppHasWallpaper, lowerWallpaperTarget, upperWallpaperTarget); |
| 1178 | |
| 1179 | // If all closing windows are obscured, then there is |
| 1180 | // no need to do an animation. This is the case, for |
| 1181 | // example, when this transition is being done behind |
| 1182 | // the lock screen. |
| 1183 | if (!mService.mPolicy.allowAppAnimationsLw()) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1184 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1185 | "Animations disallowed by keyguard or dream."); |
| 1186 | animLp = null; |
| 1187 | } |
| 1188 | |
| 1189 | processApplicationsAnimatingInPlace(transit); |
| 1190 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1191 | mTmpLayerAndToken.token = null; |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1192 | handleClosingApps(transit, animLp, voiceInteraction, mTmpLayerAndToken); |
| 1193 | final AppWindowToken topClosingApp = mTmpLayerAndToken.token; |
| 1194 | final int topClosingLayer = mTmpLayerAndToken.layer; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1195 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1196 | final AppWindowToken topOpeningApp = handleOpeningApps(transit, |
| 1197 | animLp, voiceInteraction, topClosingLayer); |
| 1198 | |
Chong Zhang | 1c93f6d | 2016-07-27 17:52:45 -0700 | [diff] [blame] | 1199 | mService.mAppTransition.setLastAppTransition(transit, topOpeningApp, topClosingApp); |
| 1200 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1201 | final AppWindowAnimator openingAppAnimator = (topOpeningApp == null) ? null : |
| 1202 | topOpeningApp.mAppAnimator; |
| 1203 | final AppWindowAnimator closingAppAnimator = (topClosingApp == null) ? null : |
| 1204 | topClosingApp.mAppAnimator; |
| 1205 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 1206 | mService.mAppTransition.goodToGo(openingAppAnimator, closingAppAnimator, |
| 1207 | mService.mOpeningApps, mService.mClosingApps); |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1208 | mService.mAppTransition.postAnimationCallback(); |
| 1209 | mService.mAppTransition.clear(); |
| 1210 | |
| 1211 | mService.mOpeningApps.clear(); |
| 1212 | mService.mClosingApps.clear(); |
| 1213 | |
| 1214 | // This has changed the visibility of windows, so perform |
| 1215 | // a new layout to get them all up-to-date. |
Chong Zhang | ec8299c | 2016-07-29 13:09:40 -0700 | [diff] [blame] | 1216 | displayContent.layoutNeeded = true; |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1217 | |
| 1218 | // TODO(multidisplay): IMEs are only supported on the default display. |
| 1219 | if (windows == mService.getDefaultWindowListLocked() |
| 1220 | && !mService.moveInputMethodWindowsIfNeededLocked(true)) { |
Filip Gruszczynski | 92e432c | 2015-12-15 19:17:09 -0800 | [diff] [blame] | 1221 | mService.mLayersController.assignLayersLocked(windows); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1222 | } |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1223 | mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, |
| 1224 | true /*updateInputWindows*/); |
| 1225 | mService.mFocusMayChange = false; |
| 1226 | mService.notifyActivityDrawnForKeyguard(); |
Chong Zhang | 8784be6 | 2016-06-28 15:25:07 -0700 | [diff] [blame] | 1227 | |
| 1228 | Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); |
| 1229 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1230 | return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG; |
| 1231 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1232 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1233 | private AppWindowToken handleOpeningApps(int transit, LayoutParams animLp, |
| 1234 | boolean voiceInteraction, int topClosingLayer) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1235 | AppWindowToken topOpeningApp = null; |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1236 | final int appsCount = mService.mOpeningApps.size(); |
| 1237 | for (int i = 0; i < appsCount; i++) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1238 | AppWindowToken wtoken = mService.mOpeningApps.valueAt(i); |
| 1239 | final AppWindowAnimator appAnimator = wtoken.mAppAnimator; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1240 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now opening app" + wtoken); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1241 | |
| 1242 | if (!appAnimator.usingTransferredAnimation) { |
| 1243 | appAnimator.clearThumbnail(); |
Chong Zhang | 65d15d0 | 2016-03-14 13:59:32 -0700 | [diff] [blame] | 1244 | appAnimator.setNullAnimation(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1245 | } |
Chong Zhang | eb22e8e | 2016-01-20 19:52:22 -0800 | [diff] [blame] | 1246 | |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1247 | if (!wtoken.setVisibility(animLp, true, transit, false, voiceInteraction)){ |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1248 | // This token isn't going to be animating. Add it to the list of tokens to |
| 1249 | // be notified of app transition complete since the notification will not be |
| 1250 | // sent be the app window animator. |
| 1251 | mService.mNoAnimationNotifyOnTransitionFinished.add(wtoken.token); |
| 1252 | } |
| 1253 | wtoken.updateReportedVisibilityLocked(); |
| 1254 | wtoken.waitingToShow = false; |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1255 | wtoken.setAllAppWinAnimators(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1256 | |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1257 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 974eb3d | 2015-10-23 17:33:11 -0700 | [diff] [blame] | 1258 | ">>> OPEN TRANSACTION handleAppTransitionReadyLocked()"); |
Robert Carr | 68e5c9e | 2016-09-14 10:50:09 -0700 | [diff] [blame^] | 1259 | mService.openSurfaceTransaction(); |
Filip Gruszczynski | 974eb3d | 2015-10-23 17:33:11 -0700 | [diff] [blame] | 1260 | try { |
Wale Ogunwale | 69cf50f | 2015-11-13 11:08:36 -0800 | [diff] [blame] | 1261 | mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked()); |
Filip Gruszczynski | 974eb3d | 2015-10-23 17:33:11 -0700 | [diff] [blame] | 1262 | } finally { |
Robert Carr | 68e5c9e | 2016-09-14 10:50:09 -0700 | [diff] [blame^] | 1263 | mService.closeSurfaceTransaction(); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1264 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
Filip Gruszczynski | 974eb3d | 2015-10-23 17:33:11 -0700 | [diff] [blame] | 1265 | "<<< CLOSE TRANSACTION handleAppTransitionReadyLocked()"); |
| 1266 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1267 | mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating(); |
| 1268 | |
| 1269 | int topOpeningLayer = 0; |
| 1270 | if (animLp != null) { |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1271 | final int layer = wtoken.getHighestAnimLayer(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1272 | if (topOpeningApp == null || layer > topOpeningLayer) { |
| 1273 | topOpeningApp = wtoken; |
| 1274 | topOpeningLayer = layer; |
| 1275 | } |
| 1276 | } |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1277 | if (mService.mAppTransition.isNextAppTransitionThumbnailUp()) { |
| 1278 | createThumbnailAppAnimator(transit, wtoken, topOpeningLayer, topClosingLayer); |
| 1279 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1280 | } |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1281 | return topOpeningApp; |
| 1282 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1283 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1284 | private void handleClosingApps(int transit, LayoutParams animLp, boolean voiceInteraction, |
| 1285 | LayerAndToken layerAndToken) { |
| 1286 | final int appsCount; |
| 1287 | appsCount = mService.mClosingApps.size(); |
| 1288 | for (int i = 0; i < appsCount; i++) { |
| 1289 | AppWindowToken wtoken = mService.mClosingApps.valueAt(i); |
Chong Zhang | f58631a | 2016-05-24 16:02:10 -0700 | [diff] [blame] | 1290 | |
| 1291 | // If we still have some windows animating with saved surfaces that's |
| 1292 | // either invisible or already removed, mark them exiting so that they |
| 1293 | // are disposed of after the exit animation. These are not supposed to |
| 1294 | // be shown, or are delayed removal until app is actually drawn (in which |
| 1295 | // case the window will be removed after the animation). |
| 1296 | wtoken.markSavedSurfaceExiting(); |
| 1297 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1298 | final AppWindowAnimator appAnimator = wtoken.mAppAnimator; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1299 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now closing app " + wtoken); |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1300 | appAnimator.clearThumbnail(); |
Chong Zhang | 65d15d0 | 2016-03-14 13:59:32 -0700 | [diff] [blame] | 1301 | appAnimator.setNullAnimation(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1302 | wtoken.setVisibility(animLp, false, transit, false, voiceInteraction); |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1303 | wtoken.updateReportedVisibilityLocked(); |
| 1304 | // Force the allDrawn flag, because we want to start |
| 1305 | // this guy's animations regardless of whether it's |
| 1306 | // gotten drawn. |
| 1307 | wtoken.allDrawn = true; |
| 1308 | wtoken.deferClearAllDrawn = false; |
| 1309 | // Ensure that apps that are mid-starting are also scheduled to have their |
| 1310 | // starting windows removed after the animation is complete |
Wale Ogunwale | c48a354 | 2016-02-19 15:18:45 -0800 | [diff] [blame] | 1311 | if (wtoken.startingWindow != null && !wtoken.startingWindow.mAnimatingExit) { |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1312 | mService.scheduleRemoveStartingWindowLocked(wtoken); |
| 1313 | } |
| 1314 | mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1315 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1316 | if (animLp != null) { |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 1317 | int layer = wtoken.getHighestAnimLayer(); |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1318 | if (layerAndToken.token == null || layer > layerAndToken.layer) { |
| 1319 | layerAndToken.token = wtoken; |
| 1320 | layerAndToken.layer = layer; |
| 1321 | } |
| 1322 | } |
| 1323 | if (mService.mAppTransition.isNextAppTransitionThumbnailDown()) { |
| 1324 | createThumbnailAppAnimator(transit, wtoken, 0, layerAndToken.layer); |
| 1325 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1326 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1327 | } |
| 1328 | |
| 1329 | private boolean transitionGoodToGo(int appsCount) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1330 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1331 | "Checking " + appsCount + " opening apps (frozen=" |
| 1332 | + mService.mDisplayFrozen + " timeout=" |
| 1333 | + mService.mAppTransition.isTimeout() + ")..."); |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1334 | int reason = APP_TRANSITION_TIMEOUT; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1335 | if (!mService.mAppTransition.isTimeout()) { |
| 1336 | for (int i = 0; i < appsCount; i++) { |
| 1337 | AppWindowToken wtoken = mService.mOpeningApps.valueAt(i); |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1338 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1339 | "Check opening app=" + wtoken + ": allDrawn=" |
| 1340 | + wtoken.allDrawn + " startingDisplayed=" |
| 1341 | + wtoken.startingDisplayed + " startingMoved=" |
Chong Zhang | d78ddb4 | 2016-03-02 17:01:14 -0800 | [diff] [blame] | 1342 | + wtoken.startingMoved + " isRelaunching()=" |
| 1343 | + wtoken.isRelaunching()); |
| 1344 | |
| 1345 | if (wtoken.isRelaunching()) { |
| 1346 | return false; |
| 1347 | } |
Chong Zhang | db20b5f | 2015-10-23 14:01:43 -0700 | [diff] [blame] | 1348 | |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1349 | final boolean drawnBeforeRestoring = wtoken.allDrawn; |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 1350 | wtoken.restoreSavedSurfaceForInterestingWindows(); |
Chong Zhang | bfc2f8f | 2016-01-29 15:50:34 -0800 | [diff] [blame] | 1351 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1352 | if (!wtoken.allDrawn && !wtoken.startingDisplayed && !wtoken.startingMoved) { |
| 1353 | return false; |
| 1354 | } |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1355 | if (wtoken.allDrawn) { |
| 1356 | reason = drawnBeforeRestoring ? APP_TRANSITION_WINDOWS_DRAWN |
| 1357 | : APP_TRANSITION_SAVED_SURFACE; |
| 1358 | } else { |
| 1359 | reason = APP_TRANSITION_STARTING_WINDOW; |
| 1360 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1361 | } |
| 1362 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1363 | // We also need to wait for the specs to be fetched, if needed. |
| 1364 | if (mService.mAppTransition.isFetchingAppTransitionsSpecs()) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1365 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "isFetchingAppTransitionSpecs=true"); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1366 | return false; |
| 1367 | } |
| 1368 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1369 | // If the wallpaper is visible, we need to check it's ready too. |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1370 | boolean wallpaperReady = !mWallpaperControllerLocked.isWallpaperVisible() || |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1371 | mWallpaperControllerLocked.wallpaperTransitionReady(); |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1372 | if (wallpaperReady) { |
| 1373 | mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING, reason, 0).sendToTarget(); |
| 1374 | return true; |
| 1375 | } |
| 1376 | return false; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1377 | } |
Jorim Jaggi | 275561a | 2016-02-23 10:11:02 -0500 | [diff] [blame] | 1378 | mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING, reason, 0).sendToTarget(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1379 | return true; |
| 1380 | } |
| 1381 | |
| 1382 | private int maybeUpdateTransitToWallpaper(int transit, boolean openingAppHasWallpaper, |
| 1383 | boolean closingAppHasWallpaper, WindowState lowerWallpaperTarget, |
| 1384 | WindowState upperWallpaperTarget) { |
| 1385 | // if wallpaper is animating in or out set oldWallpaper to null else to wallpaper |
| 1386 | final WindowState wallpaperTarget = mWallpaperControllerLocked.getWallpaperTarget(); |
| 1387 | final WindowState oldWallpaper = |
| 1388 | mWallpaperControllerLocked.isWallpaperTargetAnimating() |
| 1389 | ? null : wallpaperTarget; |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1390 | final ArraySet<AppWindowToken> openingApps = mService.mOpeningApps; |
| 1391 | final ArraySet<AppWindowToken> closingApps = mService.mClosingApps; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1392 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1393 | "New wallpaper target=" + wallpaperTarget |
| 1394 | + ", oldWallpaper=" + oldWallpaper |
| 1395 | + ", lower target=" + lowerWallpaperTarget |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1396 | + ", upper target=" + upperWallpaperTarget |
| 1397 | + ", openingApps=" + openingApps |
| 1398 | + ", closingApps=" + closingApps); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1399 | mService.mAnimateWallpaperWithTarget = false; |
| 1400 | if (closingAppHasWallpaper && openingAppHasWallpaper) { |
| 1401 | if (DEBUG_APP_TRANSITIONS) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1402 | Slog.v(TAG, "Wallpaper animation!"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1403 | switch (transit) { |
| 1404 | case AppTransition.TRANSIT_ACTIVITY_OPEN: |
| 1405 | case AppTransition.TRANSIT_TASK_OPEN: |
| 1406 | case AppTransition.TRANSIT_TASK_TO_FRONT: |
| 1407 | transit = AppTransition.TRANSIT_WALLPAPER_INTRA_OPEN; |
| 1408 | break; |
| 1409 | case AppTransition.TRANSIT_ACTIVITY_CLOSE: |
| 1410 | case AppTransition.TRANSIT_TASK_CLOSE: |
| 1411 | case AppTransition.TRANSIT_TASK_TO_BACK: |
| 1412 | transit = AppTransition.TRANSIT_WALLPAPER_INTRA_CLOSE; |
| 1413 | break; |
| 1414 | } |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1415 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1416 | "New transit: " + AppTransition.appTransitionToString(transit)); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1417 | } else if (oldWallpaper != null && !mService.mOpeningApps.isEmpty() |
| 1418 | && !openingApps.contains(oldWallpaper.mAppToken) |
| 1419 | && closingApps.contains(oldWallpaper.mAppToken)) { |
| 1420 | // We are transitioning from an activity with a wallpaper to one without. |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1421 | transit = AppTransition.TRANSIT_WALLPAPER_CLOSE; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1422 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1423 | "New transit away from wallpaper: " |
| 1424 | + AppTransition.appTransitionToString(transit)); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1425 | } else if (wallpaperTarget != null && wallpaperTarget.isVisibleLw() && |
| 1426 | openingApps.contains(wallpaperTarget.mAppToken)) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1427 | // We are transitioning from an activity without |
| 1428 | // a wallpaper to now showing the wallpaper |
| 1429 | transit = AppTransition.TRANSIT_WALLPAPER_OPEN; |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1430 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1431 | "New transit into wallpaper: " |
| 1432 | + AppTransition.appTransitionToString(transit)); |
| 1433 | } else { |
| 1434 | mService.mAnimateWallpaperWithTarget = true; |
| 1435 | } |
| 1436 | return transit; |
| 1437 | } |
| 1438 | |
| 1439 | /** |
| 1440 | * @param w WindowState this method is applied to. |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 1441 | * @param dispInfo info of the display that the window's obscuring state is checked against. |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1442 | */ |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 1443 | private void handleNotObscuredLocked(final WindowState w, final DisplayInfo dispInfo) { |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 1444 | final LayoutParams attrs = w.mAttrs; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1445 | final int attrFlags = attrs.flags; |
| 1446 | final boolean canBeSeen = w.isDisplayedLw(); |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 1447 | final int privateflags = attrs.privateFlags; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1448 | |
Chong Zhang | 0abb20f | 2015-11-19 14:17:31 -0800 | [diff] [blame] | 1449 | if (canBeSeen && w.isObscuringFullscreen(dispInfo)) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1450 | // This window completely covers everything behind it, |
| 1451 | // so we want to leave all of them as undimmed (for |
| 1452 | // performance reasons). |
Chong Zhang | 4ffc318 | 2016-05-04 15:06:02 -0700 | [diff] [blame] | 1453 | if (!mObscured) { |
| 1454 | mObsuringWindow = w; |
| 1455 | } |
| 1456 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1457 | mObscured = true; |
| 1458 | } |
| 1459 | |
Andrii Kulian | b20addbd | 2016-08-09 18:52:01 -0700 | [diff] [blame] | 1460 | if (w.mHasSurface && canBeSeen) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1461 | if ((attrFlags&FLAG_KEEP_SCREEN_ON) != 0) { |
| 1462 | mHoldScreen = w.mSession; |
Chong Zhang | 4ffc318 | 2016-05-04 15:06:02 -0700 | [diff] [blame] | 1463 | mHoldScreenWindow = w; |
| 1464 | } else if (DEBUG_KEEP_SCREEN_ON && w == mService.mLastWakeLockHoldingWindow) { |
| 1465 | Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked: " + w + " was holding " |
| 1466 | + "screen wakelock but no longer has FLAG_KEEP_SCREEN_ON!!! called by" |
| 1467 | + Debug.getCallers(10)); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1468 | } |
| 1469 | if (!mSyswin && w.mAttrs.screenBrightness >= 0 |
| 1470 | && mScreenBrightness < 0) { |
| 1471 | mScreenBrightness = w.mAttrs.screenBrightness; |
| 1472 | } |
| 1473 | if (!mSyswin && w.mAttrs.buttonBrightness >= 0 |
| 1474 | && mButtonBrightness < 0) { |
| 1475 | mButtonBrightness = w.mAttrs.buttonBrightness; |
| 1476 | } |
| 1477 | if (!mSyswin && w.mAttrs.userActivityTimeout >= 0 |
| 1478 | && mUserActivityTimeout < 0) { |
| 1479 | mUserActivityTimeout = w.mAttrs.userActivityTimeout; |
| 1480 | } |
| 1481 | |
| 1482 | final int type = attrs.type; |
Andrii Kulian | b20addbd | 2016-08-09 18:52:01 -0700 | [diff] [blame] | 1483 | if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR |
| 1484 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1485 | mSyswin = true; |
| 1486 | } |
| 1487 | |
Andrii Kulian | b20addbd | 2016-08-09 18:52:01 -0700 | [diff] [blame] | 1488 | // This function assumes that the contents of the default display are |
| 1489 | // processed first before secondary displays. |
| 1490 | final DisplayContent displayContent = w.getDisplayContent(); |
| 1491 | if (displayContent != null && displayContent.isDefaultDisplay) { |
| 1492 | // While a dream or keyguard is showing, obscure ordinary application |
| 1493 | // content on secondary displays (by forcibly enabling mirroring unless |
| 1494 | // there is other content we want to show) but still allow opaque |
| 1495 | // keyguard dialogs to be shown. |
| 1496 | if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
| 1497 | mObscureApplicationContentOnSecondaryDisplays = true; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1498 | } |
Andrii Kulian | b20addbd | 2016-08-09 18:52:01 -0700 | [diff] [blame] | 1499 | mDisplayHasContent = true; |
| 1500 | } else if (displayContent != null && |
| 1501 | (!mObscureApplicationContentOnSecondaryDisplays |
| 1502 | || (mObscured && type == TYPE_KEYGUARD_DIALOG))) { |
| 1503 | // Allow full screen keyguard presentation dialogs to be seen. |
| 1504 | mDisplayHasContent = true; |
| 1505 | } |
| 1506 | if (mPreferredRefreshRate == 0 |
| 1507 | && w.mAttrs.preferredRefreshRate != 0) { |
| 1508 | mPreferredRefreshRate = w.mAttrs.preferredRefreshRate; |
| 1509 | } |
| 1510 | if (mPreferredModeId == 0 |
| 1511 | && w.mAttrs.preferredDisplayModeId != 0) { |
| 1512 | mPreferredModeId = w.mAttrs.preferredDisplayModeId; |
| 1513 | } |
| 1514 | if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) { |
| 1515 | mSustainedPerformanceModeCurrent = true; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1516 | } |
| 1517 | } |
| 1518 | } |
| 1519 | |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1520 | private static int toBrightnessOverride(float value) { |
| 1521 | return (int)(value * PowerManager.BRIGHTNESS_ON); |
| 1522 | } |
| 1523 | |
| 1524 | private void processApplicationsAnimatingInPlace(int transit) { |
| 1525 | if (transit == AppTransition.TRANSIT_TASK_IN_PLACE) { |
| 1526 | // Find the focused window |
Wale Ogunwale | 63d4ecc | 2016-09-08 18:48:26 -0700 | [diff] [blame] | 1527 | final WindowState win = mService.getDefaultDisplayContentLocked().findFocusedWindow(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1528 | if (win != null) { |
| 1529 | final AppWindowToken wtoken = win.mAppToken; |
| 1530 | final AppWindowAnimator appAnimator = wtoken.mAppAnimator; |
| 1531 | if (DEBUG_APP_TRANSITIONS) |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1532 | Slog.v(TAG, "Now animating app in place " + wtoken); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1533 | appAnimator.clearThumbnail(); |
Chong Zhang | 65d15d0 | 2016-03-14 13:59:32 -0700 | [diff] [blame] | 1534 | appAnimator.setNullAnimation(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1535 | mService.updateTokenInPlaceLocked(wtoken, transit); |
| 1536 | wtoken.updateReportedVisibilityLocked(); |
Wale Ogunwale | 9f25bee | 2016-08-02 07:23:47 -0700 | [diff] [blame] | 1537 | wtoken.setAllAppWinAnimators(); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1538 | mService.mAnimator.mAppWindowAnimating |= appAnimator.isAnimating(); |
Wale Ogunwale | 69cf50f | 2015-11-13 11:08:36 -0800 | [diff] [blame] | 1539 | mService.mAnimator.orAnimating(appAnimator.showAllWindowsLocked()); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1540 | } |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | private void createThumbnailAppAnimator(int transit, AppWindowToken appToken, |
| 1545 | int openingLayer, int closingLayer) { |
| 1546 | AppWindowAnimator openingAppAnimator = (appToken == null) ? null : appToken.mAppAnimator; |
| 1547 | if (openingAppAnimator == null || openingAppAnimator.animation == null) { |
| 1548 | return; |
| 1549 | } |
| 1550 | final int taskId = appToken.mTask.mTaskId; |
| 1551 | Bitmap thumbnailHeader = mService.mAppTransition.getAppTransitionThumbnailHeader(taskId); |
| 1552 | if (thumbnailHeader == null || thumbnailHeader.getConfig() == Bitmap.Config.ALPHA_8) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1553 | if (DEBUG_APP_TRANSITIONS) Slog.d(TAG, "No thumbnail header bitmap for: " + taskId); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1554 | return; |
| 1555 | } |
| 1556 | // This thumbnail animation is very special, we need to have |
| 1557 | // an extra surface with the thumbnail included with the animation. |
| 1558 | Rect dirty = new Rect(0, 0, thumbnailHeader.getWidth(), thumbnailHeader.getHeight()); |
| 1559 | try { |
| 1560 | // TODO(multi-display): support other displays |
| 1561 | final DisplayContent displayContent = mService.getDefaultDisplayContentLocked(); |
| 1562 | final Display display = displayContent.getDisplay(); |
| 1563 | final DisplayInfo displayInfo = displayContent.getDisplayInfo(); |
| 1564 | |
| 1565 | // Create a new surface for the thumbnail |
| 1566 | SurfaceControl surfaceControl = new SurfaceControl(mService.mFxSession, |
| 1567 | "thumbnail anim", dirty.width(), dirty.height(), |
| 1568 | PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); |
| 1569 | surfaceControl.setLayerStack(display.getLayerStack()); |
| 1570 | if (SHOW_TRANSACTIONS) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1571 | Slog.i(TAG, " THUMBNAIL " + surfaceControl + ": CREATE"); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1572 | } |
| 1573 | |
| 1574 | // Draw the thumbnail onto the surface |
| 1575 | Surface drawSurface = new Surface(); |
| 1576 | drawSurface.copyFrom(surfaceControl); |
| 1577 | Canvas c = drawSurface.lockCanvas(dirty); |
| 1578 | c.drawBitmap(thumbnailHeader, 0, 0, null); |
| 1579 | drawSurface.unlockCanvasAndPost(c); |
| 1580 | drawSurface.release(); |
| 1581 | |
| 1582 | // Get the thumbnail animation |
| 1583 | Animation anim; |
| 1584 | if (mService.mAppTransition.isNextThumbnailTransitionAspectScaled()) { |
| 1585 | // If this is a multi-window scenario, we use the windows frame as |
| 1586 | // destination of the thumbnail header animation. If this is a full screen |
| 1587 | // window scenario, we use the whole display as the target. |
| 1588 | WindowState win = appToken.findMainWindow(); |
| 1589 | Rect appRect = win != null ? win.getContentFrameLw() : |
| 1590 | new Rect(0, 0, displayInfo.appWidth, displayInfo.appHeight); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 1591 | Rect insets = win != null ? win.mContentInsets : null; |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1592 | // For the new aspect-scaled transition, we want it to always show |
| 1593 | // above the animating opening/closing window, and we want to |
| 1594 | // synchronize its thumbnail surface with the surface for the |
| 1595 | // open/close animation (only on the way down) |
| 1596 | anim = mService.mAppTransition.createThumbnailAspectScaleAnimationLocked(appRect, |
Andrii Kulian | 8072d11 | 2016-09-16 11:11:01 -0700 | [diff] [blame] | 1597 | insets, thumbnailHeader, taskId, mService.mGlobalConfiguration.uiMode, |
| 1598 | mService.mGlobalConfiguration.orientation); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1599 | openingAppAnimator.thumbnailForceAboveLayer = Math.max(openingLayer, closingLayer); |
| 1600 | openingAppAnimator.deferThumbnailDestruction = |
| 1601 | !mService.mAppTransition.isNextThumbnailTransitionScaleUp(); |
| 1602 | } else { |
| 1603 | anim = mService.mAppTransition.createThumbnailScaleAnimationLocked( |
| 1604 | displayInfo.appWidth, displayInfo.appHeight, transit, thumbnailHeader); |
| 1605 | } |
| 1606 | anim.restrictDuration(MAX_ANIMATION_DURATION); |
| 1607 | anim.scaleCurrentDuration(mService.getTransitionAnimationScaleLocked()); |
| 1608 | |
| 1609 | openingAppAnimator.thumbnail = surfaceControl; |
| 1610 | openingAppAnimator.thumbnailLayer = openingLayer; |
| 1611 | openingAppAnimator.thumbnailAnimation = anim; |
| 1612 | mService.mAppTransition.getNextAppTransitionStartRect(taskId, mTmpStartRect); |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1613 | } catch (Surface.OutOfResourcesException e) { |
Filip Gruszczynski | ce4ec40 | 2016-01-22 11:22:47 -0800 | [diff] [blame] | 1614 | Slog.e(TAG, "Can't allocate thumbnail/Canvas surface w=" |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1615 | + dirty.width() + " h=" + dirty.height(), e); |
| 1616 | openingAppAnimator.clearThumbnail(); |
| 1617 | } |
| 1618 | } |
| 1619 | |
| 1620 | boolean copyAnimToLayoutParamsLocked() { |
| 1621 | boolean doRequest = false; |
| 1622 | |
| 1623 | final int bulkUpdateParams = mService.mAnimator.mBulkUpdateParams; |
| 1624 | if ((bulkUpdateParams & SET_UPDATE_ROTATION) != 0) { |
| 1625 | mUpdateRotation = true; |
| 1626 | doRequest = true; |
| 1627 | } |
| 1628 | if ((bulkUpdateParams & SET_WALLPAPER_MAY_CHANGE) != 0) { |
| 1629 | mWallpaperMayChange = true; |
| 1630 | doRequest = true; |
| 1631 | } |
| 1632 | if ((bulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0) { |
| 1633 | mWallpaperForceHidingChanged = true; |
| 1634 | doRequest = true; |
| 1635 | } |
| 1636 | if ((bulkUpdateParams & SET_ORIENTATION_CHANGE_COMPLETE) == 0) { |
| 1637 | mOrientationChangeComplete = false; |
| 1638 | } else { |
| 1639 | mOrientationChangeComplete = true; |
| 1640 | mLastWindowFreezeSource = mService.mAnimator.mLastWindowFreezeSource; |
| 1641 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 1642 | doRequest = true; |
| 1643 | } |
| 1644 | } |
| 1645 | if ((bulkUpdateParams & SET_TURN_ON_SCREEN) != 0) { |
| 1646 | mService.mTurnOnScreen = true; |
| 1647 | } |
| 1648 | if ((bulkUpdateParams & SET_WALLPAPER_ACTION_PENDING) != 0) { |
| 1649 | mWallpaperActionPending = true; |
| 1650 | } |
| 1651 | |
| 1652 | return doRequest; |
| 1653 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1654 | |
| 1655 | void requestTraversal() { |
| 1656 | if (!mTraversalScheduled) { |
| 1657 | mTraversalScheduled = true; |
| 1658 | mService.mH.sendEmptyMessage(DO_TRAVERSAL); |
| 1659 | } |
| 1660 | } |
| 1661 | |
Jorim Jaggi | 3dac63a | 2016-03-01 12:37:07 +0100 | [diff] [blame] | 1662 | /** |
| 1663 | * Puts the {@param surface} into a pending list to be destroyed after the current transaction |
| 1664 | * has been committed. |
| 1665 | */ |
| 1666 | void destroyAfterTransaction(SurfaceControl surface) { |
| 1667 | mPendingDestroyingSurfaces.add(surface); |
| 1668 | } |
| 1669 | |
| 1670 | /** |
| 1671 | * Destroys any surfaces that have been put into the pending list with |
| 1672 | * {@link #destroyAfterTransaction}. |
| 1673 | */ |
| 1674 | void destroyPendingSurfaces() { |
| 1675 | for (int i = mPendingDestroyingSurfaces.size() - 1; i >= 0; i--) { |
| 1676 | mPendingDestroyingSurfaces.get(i).destroy(); |
| 1677 | } |
| 1678 | mPendingDestroyingSurfaces.clear(); |
| 1679 | } |
| 1680 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1681 | public void dump(PrintWriter pw, String prefix) { |
| 1682 | pw.print(prefix); pw.print("mTraversalScheduled="); pw.println(mTraversalScheduled); |
Chong Zhang | 4ffc318 | 2016-05-04 15:06:02 -0700 | [diff] [blame] | 1683 | pw.print(prefix); pw.print("mHoldScreenWindow="); pw.println(mHoldScreenWindow); |
| 1684 | pw.print(prefix); pw.print("mObsuringWindow="); pw.println(mObsuringWindow); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1685 | } |
Filip Gruszczynski | 4501d23 | 2015-09-02 13:00:02 -0700 | [diff] [blame] | 1686 | } |