blob: 08f49f689323146b0c29beba7d9a339864be4306 [file] [log] [blame]
Robert Carre625fcf2017-09-01 12:36:28 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
Wale Ogunwalee05f5012016-09-16 16:27:29 -070016
Filip Gruszczynski4501d232015-09-02 13:00:02 -070017package com.android.server.wm;
18
Jorim Jaggi3878ca32017-02-02 17:13:05 -080019import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
Jorim Jaggi3878ca32017-02-02 17:13:05 -080020import static android.app.ActivityManagerInternal.APP_TRANSITION_SNAPSHOT;
21import static android.app.ActivityManagerInternal.APP_TRANSITION_SPLASH_SCREEN;
Jorim Jaggi275561a2016-02-23 10:11:02 -050022import static android.app.ActivityManagerInternal.APP_TRANSITION_WINDOWS_DRAWN;
Adrian Roose99bc052017-11-20 17:55:31 +010023import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
24import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -070025import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_CLOSE;
26import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_OPEN;
Jorim Jaggife762342016-10-13 14:33:27 +020027import static com.android.server.wm.AppTransition.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
28import static com.android.server.wm.AppTransition.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE;
29import static com.android.server.wm.AppTransition.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER;
30import static com.android.server.wm.AppTransition.TRANSIT_KEYGUARD_GOING_AWAY;
31import static com.android.server.wm.AppTransition.TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
Matthew Ng26a1cec2017-05-18 14:42:51 -070032import static com.android.server.wm.AppTransition.TRANSIT_NONE;
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -070033import static com.android.server.wm.AppTransition.TRANSIT_TASK_CLOSE;
34import static com.android.server.wm.AppTransition.TRANSIT_TASK_IN_PLACE;
35import static com.android.server.wm.AppTransition.TRANSIT_TASK_OPEN;
36import static com.android.server.wm.AppTransition.TRANSIT_TASK_TO_BACK;
37import static com.android.server.wm.AppTransition.TRANSIT_TASK_TO_FRONT;
38import static com.android.server.wm.AppTransition.TRANSIT_WALLPAPER_CLOSE;
39import static com.android.server.wm.AppTransition.TRANSIT_WALLPAPER_INTRA_CLOSE;
40import static com.android.server.wm.AppTransition.TRANSIT_WALLPAPER_INTRA_OPEN;
41import static com.android.server.wm.AppTransition.TRANSIT_WALLPAPER_OPEN;
Jorim Jaggia69243a2017-06-15 15:10:38 -040042import static com.android.server.wm.AppTransition.isKeyguardGoingAwayTransit;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080043import static com.android.server.wm.WindowManagerDebugConfig.DEBUG;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080044import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080045import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
46import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS;
Jorim Jaggi192086e2016-03-11 17:17:03 +010047import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080048import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Jorim Jaggi192086e2016-03-11 17:17:03 +010049import static com.android.server.wm.WindowManagerService.H.NOTIFY_APP_TRANSITION_STARTING;
Jorim Jaggi192086e2016-03-11 17:17:03 +010050import static com.android.server.wm.WindowManagerService.H.REPORT_WINDOWS_CHANGE;
Jorim Jaggi192086e2016-03-11 17:17:03 +010051import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
52import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070053import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070054
Andrii Kulian441e4492016-09-29 15:25:00 -070055import android.content.res.Configuration;
Winson Chungaa7fa012017-05-24 15:50:06 -070056import android.graphics.GraphicBuffer;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070057import android.graphics.PixelFormat;
58import android.graphics.Rect;
Bryce Leee6c25d42017-05-31 10:27:42 -070059import android.os.Binder;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070060import android.os.Debug;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070061import android.os.Trace;
Filip Gruszczynski49b80af2015-09-24 09:04:26 -070062import android.util.ArraySet;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070063import android.util.Slog;
Jorim Jaggi3878ca32017-02-02 17:13:05 -080064import android.util.SparseIntArray;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070065import android.view.Display;
66import android.view.DisplayInfo;
67import android.view.Surface;
68import android.view.SurfaceControl;
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -080069import android.view.WindowManager.LayoutParams;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070070import android.view.animation.Animation;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070071
Jorim Jaggid75962e2016-05-03 15:10:03 -070072import com.android.server.wm.WindowManagerService.H;
73
Filip Gruszczynski24966d42015-09-05 15:00:00 -070074import java.io.PrintWriter;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070075import java.util.ArrayList;
76
77/**
78 * Positions windows and their surfaces.
79 *
80 * It sets positions of windows by calculating their frames and then applies this by positioning
81 * surfaces according to these frames. Z layer is still assigned withing WindowManagerService.
82 */
83class WindowSurfacePlacer {
Filip Gruszczynskice4ec402016-01-22 11:22:47 -080084 private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowSurfacePlacer" : TAG_WM;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070085 private final WindowManagerService mService;
86 private final WallpaperController mWallpaperControllerLocked;
87
88 private boolean mInLayout = false;
89
90 /** Only do a maximum of 6 repeated layouts. After that quit */
91 private int mLayoutRepeatCount;
92
93 static final int SET_UPDATE_ROTATION = 1 << 0;
94 static final int SET_WALLPAPER_MAY_CHANGE = 1 << 1;
95 static final int SET_FORCE_HIDING_CHANGED = 1 << 2;
96 static final int SET_ORIENTATION_CHANGE_COMPLETE = 1 << 3;
97 static final int SET_TURN_ON_SCREEN = 1 << 4;
98 static final int SET_WALLPAPER_ACTION_PENDING = 1 << 5;
99
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700100 private boolean mTraversalScheduled;
Jorim Jaggic4025202015-10-22 16:43:34 +0200101 private int mDeferDepth = 0;
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700102
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800103 private static final class LayerAndToken {
104 public int layer;
105 public AppWindowToken token;
106 }
107 private final LayerAndToken mTmpLayerAndToken = new LayerAndToken();
108
Jorim Jaggi3dac63a2016-03-01 12:37:07 +0100109 private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>();
Jorim Jaggi3878ca32017-02-02 17:13:05 -0800110 private final SparseIntArray mTempTransitionReasons = new SparseIntArray();
Jorim Jaggi3dac63a2016-03-01 12:37:07 +0100111
Jorim Jaggied7993b2017-03-28 18:50:01 +0100112 private final Runnable mPerformSurfacePlacement;
113
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700114 public WindowSurfacePlacer(WindowManagerService service) {
115 mService = service;
Wale Ogunwale0303c572016-10-20 10:16:29 -0700116 mWallpaperControllerLocked = mService.mRoot.mWallpaperController;
Jorim Jaggied7993b2017-03-28 18:50:01 +0100117 mPerformSurfacePlacement = () -> {
118 synchronized (mService.mWindowMap) {
119 performSurfacePlacement();
120 }
121 };
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700122 }
123
Jorim Jaggic4025202015-10-22 16:43:34 +0200124 /**
125 * See {@link WindowManagerService#deferSurfaceLayout()}
126 */
127 void deferLayout() {
128 mDeferDepth++;
129 }
130
131 /**
132 * See {@link WindowManagerService#continueSurfaceLayout()}
133 */
134 void continueLayout() {
135 mDeferDepth--;
136 if (mDeferDepth <= 0) {
137 performSurfacePlacement();
138 }
139 }
140
Jorim Jaggi1f833082017-08-04 18:06:56 +0200141 boolean isLayoutDeferred() {
142 return mDeferDepth > 0;
143 }
144
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700145 final void performSurfacePlacement() {
Jorim Jaggi02886a82016-12-06 09:10:06 -0800146 performSurfacePlacement(false /* force */);
147 }
148
149 final void performSurfacePlacement(boolean force) {
150 if (mDeferDepth > 0 && !force) {
Jorim Jaggic4025202015-10-22 16:43:34 +0200151 return;
152 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700153 int loopCount = 6;
154 do {
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700155 mTraversalScheduled = false;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700156 performSurfacePlacementLoop();
Jorim Jaggied7993b2017-03-28 18:50:01 +0100157 mService.mAnimationHandler.removeCallbacks(mPerformSurfacePlacement);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700158 loopCount--;
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700159 } while (mTraversalScheduled && loopCount > 0);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700160 mService.mRoot.mWallpaperActionPending = false;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700161 }
162
163 private void performSurfacePlacementLoop() {
164 if (mInLayout) {
165 if (DEBUG) {
166 throw new RuntimeException("Recursive call!");
167 }
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800168 Slog.w(TAG, "performLayoutAndPlaceSurfacesLocked called while in layout. Callers="
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700169 + Debug.getCallers(3));
170 return;
171 }
172
173 if (mService.mWaitingForConfig) {
174 // Our configuration has changed (most likely rotation), but we
175 // don't yet have the complete configuration to report to
176 // applications. Don't do any window layout until we have it.
177 return;
178 }
179
180 if (!mService.mDisplayReady) {
181 // Not yet initialized, nothing to do.
182 return;
183 }
184
185 Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmLayout");
186 mInLayout = true;
187
188 boolean recoveringMemory = false;
189 if (!mService.mForceRemoves.isEmpty()) {
190 recoveringMemory = true;
191 // Wait a little bit for things to settle down, and off we go.
192 while (!mService.mForceRemoves.isEmpty()) {
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700193 final WindowState ws = mService.mForceRemoves.remove(0);
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800194 Slog.i(TAG, "Force removing: " + ws);
Wale Ogunwale571771c2016-08-26 13:18:50 -0700195 ws.removeImmediately();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700196 }
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800197 Slog.w(TAG, "Due to memory failure, waiting a bit for next layout");
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700198 Object tmp = new Object();
199 synchronized (tmp) {
200 try {
201 tmp.wait(250);
202 } catch (InterruptedException e) {
203 }
204 }
205 }
206
207 try {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700208 mService.mRoot.performSurfacePlacement(recoveringMemory);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700209
210 mInLayout = false;
211
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700212 if (mService.mRoot.isLayoutNeeded()) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700213 if (++mLayoutRepeatCount < 6) {
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700214 requestTraversal();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700215 } else {
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800216 Slog.e(TAG, "Performed 6 layouts in a row. Skipping");
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700217 mLayoutRepeatCount = 0;
218 }
219 } else {
220 mLayoutRepeatCount = 0;
221 }
222
223 if (mService.mWindowsChanged && !mService.mWindowChangeListeners.isEmpty()) {
224 mService.mH.removeMessages(REPORT_WINDOWS_CHANGE);
225 mService.mH.sendEmptyMessage(REPORT_WINDOWS_CHANGE);
226 }
227 } catch (RuntimeException e) {
228 mInLayout = false;
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800229 Slog.wtf(TAG, "Unhandled exception while laying out windows", e);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700230 }
231
232 Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
233 }
234
235 void debugLayoutRepeats(final String msg, int pendingLayoutChanges) {
236 if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) {
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800237 Slog.v(TAG, "Layouts looping: " + msg +
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700238 ", mPendingLayoutChanges = 0x" + Integer.toHexString(pendingLayoutChanges));
239 }
240 }
241
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700242 boolean isInLayout() {
243 return mInLayout;
244 }
245
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700246 /**
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700247 * @return bitmap indicating if another pass through layout must be made.
248 */
Wale Ogunwale0303c572016-10-20 10:16:29 -0700249 int handleAppTransitionReadyLocked() {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700250 int appsCount = mService.mOpeningApps.size();
Jorim Jaggidbaad382017-07-18 13:22:52 +0200251 if (!transitionGoodToGo(appsCount, mTempTransitionReasons)) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700252 return 0;
253 }
Chong Zhang8784be62016-06-28 15:25:07 -0700254 Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "AppTransitionReady");
255
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800256 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "**** GOOD TO GO");
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700257 int transit = mService.mAppTransition.getAppTransition();
Jorim Jaggia69243a2017-06-15 15:10:38 -0400258 if (mService.mSkipAppTransitionAnimation && !isKeyguardGoingAwayTransit(transit)) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700259 transit = AppTransition.TRANSIT_UNSET;
260 }
261 mService.mSkipAppTransitionAnimation = false;
262 mService.mNoAnimationNotifyOnTransitionFinished.clear();
263
Jorim Jaggid75962e2016-05-03 15:10:03 -0700264 mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700265
Wale Ogunwale9adfe572016-09-08 20:43:58 -0700266 final DisplayContent displayContent = mService.getDefaultDisplayContentLocked();
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000267 // TODO: Don't believe this is really needed...
268 //mService.mWindowsChanged = true;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700269
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700270 mService.mRoot.mWallpaperMayChange = false;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700271
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700272 // The top-most window will supply the layout params, and we will determine it below.
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800273 LayoutParams animLp = null;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700274 int bestAnimLayer = -1;
275 boolean fullscreenAnim = false;
276 boolean voiceInteraction = false;
277
Chong Zhangec8299c2016-07-29 13:09:40 -0700278 int i;
279 for (i = 0; i < appsCount; i++) {
280 final AppWindowToken wtoken = mService.mOpeningApps.valueAt(i);
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700281 // Clearing the mAnimatingExit flag before entering animation. It's set to true if app
282 // window is removed, or window relayout to invisible. This also affects window
283 // visibility. We need to clear it *before* maybeUpdateTransitToWallpaper() as the
284 // transition selection depends on wallpaper target visibility.
Chong Zhangec8299c2016-07-29 13:09:40 -0700285 wtoken.clearAnimatingFlags();
286
287 }
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700288
Chong Zhangec8299c2016-07-29 13:09:40 -0700289 // Adjust wallpaper before we pull the lower/upper target, since pending changes
290 // (like the clearAnimatingFlags() above) might affect wallpaper target result.
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700291 // Or, the opening app window should be a wallpaper target.
292 mWallpaperControllerLocked.adjustWallpaperWindowsForAppTransitionIfNeeded(displayContent,
Wale Ogunwale0303c572016-10-20 10:16:29 -0700293 mService.mOpeningApps);
Chong Zhangec8299c2016-07-29 13:09:40 -0700294
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800295 final WindowState wallpaperTarget = mWallpaperControllerLocked.getWallpaperTarget();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700296 boolean openingAppHasWallpaper = false;
297 boolean closingAppHasWallpaper = false;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700298
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700299 // Do a first pass through the tokens for two things:
300 // (1) Determine if both the closing and opening app token sets are wallpaper targets, in
301 // which case special animations are needed (since the wallpaper needs to stay static behind
302 // them).
303 // (2) Find the layout params of the top-most application window in the tokens, which is
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700304 // what will control the animation theme.
305 final int closingAppsCount = mService.mClosingApps.size();
306 appsCount = closingAppsCount + mService.mOpeningApps.size();
307 for (i = 0; i < appsCount; i++) {
308 final AppWindowToken wtoken;
309 if (i < closingAppsCount) {
310 wtoken = mService.mClosingApps.valueAt(i);
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800311 if (wallpaperTarget != null && wtoken.windowsCanBeWallpaperTarget()) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700312 closingAppHasWallpaper = true;
313 }
314 } else {
315 wtoken = mService.mOpeningApps.valueAt(i - closingAppsCount);
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800316 if (wallpaperTarget != null && wtoken.windowsCanBeWallpaperTarget()) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700317 openingAppHasWallpaper = true;
318 }
319 }
320
Wale Ogunwale72919d22016-12-08 18:58:50 -0800321 voiceInteraction |= wtoken.mVoiceInteraction;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700322
Wale Ogunwale51362492016-09-08 17:49:17 -0700323 if (wtoken.fillsParent()) {
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800324 final WindowState ws = wtoken.findMainWindow();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700325 if (ws != null) {
326 animLp = ws.mAttrs;
327 bestAnimLayer = ws.mLayer;
328 fullscreenAnim = true;
329 }
330 } else if (!fullscreenAnim) {
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800331 final WindowState ws = wtoken.findMainWindow();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700332 if (ws != null) {
333 if (ws.mLayer > bestAnimLayer) {
334 animLp = ws.mAttrs;
335 bestAnimLayer = ws.mLayer;
336 }
337 }
338 }
339 }
340
341 transit = maybeUpdateTransitToWallpaper(transit, openingAppHasWallpaper,
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800342 closingAppHasWallpaper);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700343
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700344 // If all closing windows are obscured, then there is no need to do an animation. This is
345 // the case, for example, when this transition is being done behind the lock screen.
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700346 if (!mService.mPolicy.allowAppAnimationsLw()) {
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800347 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700348 "Animations disallowed by keyguard or dream.");
349 animLp = null;
350 }
351
Jorim Jaggid6d97162018-01-05 18:28:36 +0100352 final int layoutRedo;
353 mService.mSurfaceAnimationRunner.deferStartingAnimations();
354 try {
355 processApplicationsAnimatingInPlace(transit);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700356
Jorim Jaggid6d97162018-01-05 18:28:36 +0100357 mTmpLayerAndToken.token = null;
358 handleClosingApps(transit, animLp, voiceInteraction, mTmpLayerAndToken);
359 final AppWindowToken topClosingApp = mTmpLayerAndToken.token;
360 final AppWindowToken topOpeningApp = handleOpeningApps(transit, animLp,
361 voiceInteraction);
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800362
Jorim Jaggid6d97162018-01-05 18:28:36 +0100363 mService.mAppTransition.setLastAppTransition(transit, topOpeningApp, topClosingApp);
Chong Zhang1c93f6d2016-07-27 17:52:45 -0700364
Jorim Jaggid6d97162018-01-05 18:28:36 +0100365 final int flags = mService.mAppTransition.getTransitFlags();
366 layoutRedo = mService.mAppTransition.goodToGo(transit, topOpeningApp,
367 topClosingApp, mService.mOpeningApps, mService.mClosingApps);
368 handleNonAppWindowsInTransition(transit, flags);
369 mService.mAppTransition.postAnimationCallback();
370 mService.mAppTransition.clear();
371 } finally {
372 mService.mSurfaceAnimationRunner.continueStartingAnimations();
373 }
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800374
Jorim Jaggi02886a82016-12-06 09:10:06 -0800375 mService.mTaskSnapshotController.onTransitionStarting();
376
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800377 mService.mOpeningApps.clear();
378 mService.mClosingApps.clear();
Jorim Jaggi5a108c22016-10-13 14:33:27 +0200379 mService.mUnknownAppVisibilityController.clear();
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800380
381 // This has changed the visibility of windows, so perform
382 // a new layout to get them all up-to-date.
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700383 displayContent.setLayoutNeeded();
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800384
385 // TODO(multidisplay): IMEs are only supported on the default display.
Wale Ogunwaleae9adbf2016-10-18 15:17:06 -0700386 final DisplayContent dc = mService.getDefaultDisplayContentLocked();
Wale Ogunwale6213caa2016-12-02 16:47:15 +0000387 dc.computeImeTarget(true /* updateImeTarget */);
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800388 mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,
389 true /*updateInputWindows*/);
390 mService.mFocusMayChange = false;
Chong Zhang8784be62016-06-28 15:25:07 -0700391
Jorim Jaggidbaad382017-07-18 13:22:52 +0200392 mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING,
393 mTempTransitionReasons.clone()).sendToTarget();
394
Chong Zhang8784be62016-06-28 15:25:07 -0700395 Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
396
Jorim Jaggife762342016-10-13 14:33:27 +0200397 return layoutRedo | FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG;
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800398 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700399
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800400 private AppWindowToken handleOpeningApps(int transit, LayoutParams animLp,
Matthew Ngb7e8a132017-09-29 10:27:24 -0700401 boolean voiceInteraction) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700402 AppWindowToken topOpeningApp = null;
Matthew Ngb7e8a132017-09-29 10:27:24 -0700403 int topOpeningLayer = Integer.MIN_VALUE;
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800404 final int appsCount = mService.mOpeningApps.size();
405 for (int i = 0; i < appsCount; i++) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700406 AppWindowToken wtoken = mService.mOpeningApps.valueAt(i);
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800407 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now opening app" + wtoken);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700408
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700409 if (!wtoken.setVisibility(animLp, true, transit, false, voiceInteraction)){
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700410 // This token isn't going to be animating. Add it to the list of tokens to
411 // be notified of app transition complete since the notification will not be
412 // sent be the app window animator.
413 mService.mNoAnimationNotifyOnTransitionFinished.add(wtoken.token);
414 }
415 wtoken.updateReportedVisibilityLocked();
416 wtoken.waitingToShow = false;
417
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800418 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
Filip Gruszczynski974eb3d2015-10-23 17:33:11 -0700419 ">>> OPEN TRANSACTION handleAppTransitionReadyLocked()");
Robert Carr68e5c9e2016-09-14 10:50:09 -0700420 mService.openSurfaceTransaction();
Filip Gruszczynski974eb3d2015-10-23 17:33:11 -0700421 try {
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200422 wtoken.showAllWindowsLocked();
Filip Gruszczynski974eb3d2015-10-23 17:33:11 -0700423 } finally {
Adrian Roos111aff92017-09-27 18:11:46 +0200424 mService.closeSurfaceTransaction("handleAppTransitionReadyLocked");
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800425 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
Filip Gruszczynski974eb3d2015-10-23 17:33:11 -0700426 "<<< CLOSE TRANSACTION handleAppTransitionReadyLocked()");
427 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700428
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700429 if (animLp != null) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700430 final int layer = wtoken.getHighestAnimLayer();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700431 if (topOpeningApp == null || layer > topOpeningLayer) {
432 topOpeningApp = wtoken;
433 topOpeningLayer = layer;
434 }
435 }
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800436 if (mService.mAppTransition.isNextAppTransitionThumbnailUp()) {
Jorim Jaggi988f6682017-11-17 17:46:43 +0100437 wtoken.attachThumbnailAnimation();
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800438 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700439 }
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800440 return topOpeningApp;
441 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700442
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800443 private void handleClosingApps(int transit, LayoutParams animLp, boolean voiceInteraction,
444 LayerAndToken layerAndToken) {
445 final int appsCount;
446 appsCount = mService.mClosingApps.size();
447 for (int i = 0; i < appsCount; i++) {
448 AppWindowToken wtoken = mService.mClosingApps.valueAt(i);
Chong Zhangf58631a2016-05-24 16:02:10 -0700449
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800450 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now closing app " + wtoken);
Winson Chung87e5d552017-04-05 11:49:38 -0700451 // TODO: Do we need to add to mNoAnimationNotifyOnTransitionFinished like above if not
452 // animating?
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700453 wtoken.setVisibility(animLp, false, transit, false, voiceInteraction);
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800454 wtoken.updateReportedVisibilityLocked();
455 // Force the allDrawn flag, because we want to start
456 // this guy's animations regardless of whether it's
457 // gotten drawn.
458 wtoken.allDrawn = true;
459 wtoken.deferClearAllDrawn = false;
460 // Ensure that apps that are mid-starting are also scheduled to have their
461 // starting windows removed after the animation is complete
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800462 if (wtoken.startingWindow != null && !wtoken.startingWindow.mAnimatingExit
463 && wtoken.getController() != null) {
464 wtoken.getController().removeStartingWindow();
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800465 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700466
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800467 if (animLp != null) {
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700468 int layer = wtoken.getHighestAnimLayer();
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800469 if (layerAndToken.token == null || layer > layerAndToken.layer) {
470 layerAndToken.token = wtoken;
471 layerAndToken.layer = layer;
472 }
473 }
474 if (mService.mAppTransition.isNextAppTransitionThumbnailDown()) {
Jorim Jaggi988f6682017-11-17 17:46:43 +0100475 wtoken.attachThumbnailAnimation();
Filip Gruszczynski4cbc3152015-12-07 11:50:57 -0800476 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700477 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700478 }
479
Jorim Jaggife762342016-10-13 14:33:27 +0200480 private void handleNonAppWindowsInTransition(int transit, int flags) {
481 if (transit == TRANSIT_KEYGUARD_GOING_AWAY) {
482 if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0
483 && (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) == 0) {
484 Animation anim = mService.mPolicy.createKeyguardWallpaperExit(
485 (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0);
486 if (anim != null) {
487 mService.getDefaultDisplayContentLocked().mWallpaperController
488 .startWallpaperAnimation(anim);
489 }
490 }
491 }
492 if (transit == TRANSIT_KEYGUARD_GOING_AWAY
493 || transit == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER) {
494 mService.getDefaultDisplayContentLocked().startKeyguardExitOnNonAppWindows(
495 transit == TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
496 (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0);
497 }
498 }
499
Jorim Jaggidbaad382017-07-18 13:22:52 +0200500 private boolean transitionGoodToGo(int appsCount, SparseIntArray outReasons) {
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800501 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700502 "Checking " + appsCount + " opening apps (frozen="
503 + mService.mDisplayFrozen + " timeout="
504 + mService.mAppTransition.isTimeout() + ")...");
Robert Carr42769ff2016-09-20 13:36:42 -0700505 final ScreenRotationAnimation screenRotationAnimation =
506 mService.mAnimator.getScreenRotationAnimationLocked(
507 Display.DEFAULT_DISPLAY);
508
Jorim Jaggidbaad382017-07-18 13:22:52 +0200509 outReasons.clear();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700510 if (!mService.mAppTransition.isTimeout()) {
Robert Carr42769ff2016-09-20 13:36:42 -0700511 // Imagine the case where we are changing orientation due to an app transition, but a previous
512 // orientation change is still in progress. We won't process the orientation change
513 // for our transition because we need to wait for the rotation animation to finish.
514 // If we start the app transition at this point, we will interrupt it halfway with a new rotation
515 // animation after the old one finally finishes. It's better to defer the
516 // app transition.
517 if (screenRotationAnimation != null && screenRotationAnimation.isAnimating() &&
518 mService.rotationNeedsUpdateLocked()) {
519 if (DEBUG_APP_TRANSITIONS) {
520 Slog.v(TAG, "Delaying app transition for screen rotation animation to finish");
521 }
522 return false;
523 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700524 for (int i = 0; i < appsCount; i++) {
525 AppWindowToken wtoken = mService.mOpeningApps.valueAt(i);
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800526 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700527 "Check opening app=" + wtoken + ": allDrawn="
528 + wtoken.allDrawn + " startingDisplayed="
529 + wtoken.startingDisplayed + " startingMoved="
Chong Zhangd78ddb42016-03-02 17:01:14 -0800530 + wtoken.startingMoved + " isRelaunching()="
531 + wtoken.isRelaunching());
532
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800533
Jorim Jaggi02886a82016-12-06 09:10:06 -0800534 final boolean allDrawn = wtoken.allDrawn && !wtoken.isRelaunching();
535 if (!allDrawn && !wtoken.startingDisplayed && !wtoken.startingMoved) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700536 return false;
537 }
Jorim Jaggi3878ca32017-02-02 17:13:05 -0800538 final TaskStack stack = wtoken.getStack();
539 final int stackId = stack != null ? stack.mStackId : INVALID_STACK_ID;
Jorim Jaggi02886a82016-12-06 09:10:06 -0800540 if (allDrawn) {
Jorim Jaggie7d2b852017-08-28 17:55:15 +0200541 outReasons.put(stackId, APP_TRANSITION_WINDOWS_DRAWN);
Jorim Jaggi275561a2016-02-23 10:11:02 -0500542 } else {
Jorim Jaggidbaad382017-07-18 13:22:52 +0200543 outReasons.put(stackId, wtoken.startingData instanceof SplashScreenStartingData
Jorim Jaggi3878ca32017-02-02 17:13:05 -0800544 ? APP_TRANSITION_SPLASH_SCREEN
545 : APP_TRANSITION_SNAPSHOT);
Jorim Jaggi275561a2016-02-23 10:11:02 -0500546 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700547 }
548
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100549 // We also need to wait for the specs to be fetched, if needed.
550 if (mService.mAppTransition.isFetchingAppTransitionsSpecs()) {
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800551 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "isFetchingAppTransitionSpecs=true");
Jorim Jaggi2f7d2922015-10-29 13:08:29 +0100552 return false;
553 }
554
Jorim Jaggi5a108c22016-10-13 14:33:27 +0200555 if (!mService.mUnknownAppVisibilityController.allResolved()) {
556 if (DEBUG_APP_TRANSITIONS) {
557 Slog.v(TAG, "unknownApps is not empty: "
558 + mService.mUnknownAppVisibilityController.getDebugMessage());
559 }
560 return false;
561 }
562
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700563 // If the wallpaper is visible, we need to check it's ready too.
Jorim Jaggi275561a2016-02-23 10:11:02 -0500564 boolean wallpaperReady = !mWallpaperControllerLocked.isWallpaperVisible() ||
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700565 mWallpaperControllerLocked.wallpaperTransitionReady();
Jorim Jaggi275561a2016-02-23 10:11:02 -0500566 if (wallpaperReady) {
Jorim Jaggi275561a2016-02-23 10:11:02 -0500567 return true;
568 }
569 return false;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700570 }
571 return true;
572 }
573
574 private int maybeUpdateTransitToWallpaper(int transit, boolean openingAppHasWallpaper,
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -0800575 boolean closingAppHasWallpaper) {
Matthew Ng26a1cec2017-05-18 14:42:51 -0700576 // Given no app transition pass it through instead of a wallpaper transition
577 if (transit == TRANSIT_NONE) {
578 return TRANSIT_NONE;
579 }
580
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700581 // if wallpaper is animating in or out set oldWallpaper to null else to wallpaper
582 final WindowState wallpaperTarget = mWallpaperControllerLocked.getWallpaperTarget();
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700583 final WindowState oldWallpaper = mWallpaperControllerLocked.isWallpaperTargetAnimating()
584 ? null : wallpaperTarget;
Filip Gruszczynski49b80af2015-09-24 09:04:26 -0700585 final ArraySet<AppWindowToken> openingApps = mService.mOpeningApps;
586 final ArraySet<AppWindowToken> closingApps = mService.mClosingApps;
Jorim Jaggife762342016-10-13 14:33:27 +0200587 boolean openingCanBeWallpaperTarget = canBeWallpaperTarget(openingApps);
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800588 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700589 "New wallpaper target=" + wallpaperTarget
590 + ", oldWallpaper=" + oldWallpaper
Filip Gruszczynski49b80af2015-09-24 09:04:26 -0700591 + ", openingApps=" + openingApps
592 + ", closingApps=" + closingApps);
Jorim Jaggia5e10572017-11-15 14:36:26 +0100593
Jorim Jaggia69243a2017-06-15 15:10:38 -0400594 if (openingCanBeWallpaperTarget && transit == TRANSIT_KEYGUARD_GOING_AWAY) {
Jorim Jaggife762342016-10-13 14:33:27 +0200595 transit = TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
596 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
597 "New transit: " + AppTransition.appTransitionToString(transit));
Jorim Jaggia69243a2017-06-15 15:10:38 -0400598 }
599 // We never want to change from a Keyguard transit to a non-Keyguard transit, as our logic
600 // relies on the fact that we always execute a Keyguard transition after preparing one.
601 else if (!isKeyguardGoingAwayTransit(transit)) {
602 if (closingAppHasWallpaper && openingAppHasWallpaper) {
603 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Wallpaper animation!");
604 switch (transit) {
605 case TRANSIT_ACTIVITY_OPEN:
606 case TRANSIT_TASK_OPEN:
607 case TRANSIT_TASK_TO_FRONT:
608 transit = TRANSIT_WALLPAPER_INTRA_OPEN;
609 break;
610 case TRANSIT_ACTIVITY_CLOSE:
611 case TRANSIT_TASK_CLOSE:
612 case TRANSIT_TASK_TO_BACK:
613 transit = TRANSIT_WALLPAPER_INTRA_CLOSE;
614 break;
615 }
616 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
617 "New transit: " + AppTransition.appTransitionToString(transit));
618 } else if (oldWallpaper != null && !mService.mOpeningApps.isEmpty()
619 && !openingApps.contains(oldWallpaper.mAppToken)
620 && closingApps.contains(oldWallpaper.mAppToken)) {
621 // We are transitioning from an activity with a wallpaper to one without.
622 transit = TRANSIT_WALLPAPER_CLOSE;
623 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "New transit away from wallpaper: "
624 + AppTransition.appTransitionToString(transit));
625 } else if (wallpaperTarget != null && wallpaperTarget.isVisibleLw() &&
626 openingApps.contains(wallpaperTarget.mAppToken)) {
627 // We are transitioning from an activity without
628 // a wallpaper to now showing the wallpaper
629 transit = TRANSIT_WALLPAPER_OPEN;
630 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "New transit into wallpaper: "
631 + AppTransition.appTransitionToString(transit));
Jorim Jaggia69243a2017-06-15 15:10:38 -0400632 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700633 }
634 return transit;
635 }
636
Jorim Jaggife762342016-10-13 14:33:27 +0200637 private boolean canBeWallpaperTarget(ArraySet<AppWindowToken> apps) {
638 for (int i = apps.size() - 1; i >= 0; i--) {
639 if (apps.valueAt(i).windowsCanBeWallpaperTarget()) {
640 return true;
641 }
642 }
643 return false;
644 }
645
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700646 private void processApplicationsAnimatingInPlace(int transit) {
Wale Ogunwale0c4a40ef2016-10-07 07:06:40 -0700647 if (transit == TRANSIT_TASK_IN_PLACE) {
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700648 // Find the focused window
Wale Ogunwale63d4ecc2016-09-08 18:48:26 -0700649 final WindowState win = mService.getDefaultDisplayContentLocked().findFocusedWindow();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700650 if (win != null) {
651 final AppWindowToken wtoken = win.mAppToken;
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700652 if (DEBUG_APP_TRANSITIONS)
Filip Gruszczynskice4ec402016-01-22 11:22:47 -0800653 Slog.v(TAG, "Now animating app in place " + wtoken);
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200654 wtoken.cancelAnimation();
655 wtoken.applyAnimationLocked(null, transit, false, false);
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700656 wtoken.updateReportedVisibilityLocked();
Jorim Jaggif5f9e122017-10-24 18:21:09 +0200657 wtoken.showAllWindowsLocked();
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700658 }
659 }
660 }
661
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700662 void requestTraversal() {
663 if (!mTraversalScheduled) {
664 mTraversalScheduled = true;
Jorim Jaggied7993b2017-03-28 18:50:01 +0100665 mService.mAnimationHandler.post(mPerformSurfacePlacement);
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700666 }
667 }
668
Jorim Jaggi3dac63a2016-03-01 12:37:07 +0100669 /**
670 * Puts the {@param surface} into a pending list to be destroyed after the current transaction
671 * has been committed.
672 */
673 void destroyAfterTransaction(SurfaceControl surface) {
674 mPendingDestroyingSurfaces.add(surface);
675 }
676
677 /**
678 * Destroys any surfaces that have been put into the pending list with
679 * {@link #destroyAfterTransaction}.
680 */
681 void destroyPendingSurfaces() {
682 for (int i = mPendingDestroyingSurfaces.size() - 1; i >= 0; i--) {
683 mPendingDestroyingSurfaces.get(i).destroy();
684 }
685 mPendingDestroyingSurfaces.clear();
686 }
687
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700688 public void dump(PrintWriter pw, String prefix) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700689 pw.println(prefix + "mTraversalScheduled=" + mTraversalScheduled);
690 pw.println(prefix + "mHoldScreenWindow=" + mService.mRoot.mHoldScreenWindow);
Wale Ogunwaled4a00a02016-10-10 11:29:17 -0700691 pw.println(prefix + "mObscuringWindow=" + mService.mRoot.mObscuringWindow);
Filip Gruszczynski24966d42015-09-05 15:00:00 -0700692 }
Filip Gruszczynski4501d232015-09-02 13:00:02 -0700693}