blob: eac72b01c8f9c70f1d915d2b90fdba1b74d3a82e [file] [log] [blame]
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001/*
2 * Copyright (C) 2011 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 */
16
17package com.android.server.wm;
18
Wale Ogunwale6cae7652015-12-26 07:36:26 -080019import static android.app.ActivityManager.StackId;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080020import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080021import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
22import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Robert Carra1eb4392015-12-10 12:43:51 -080023import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Wale Ogunwale9017ec02016-02-25 08:55:25 -080024import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080025import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
26import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
27import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
28import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Chong Zhangf596cd52016-01-05 13:42:44 -080029import static com.android.server.wm.WindowManagerService.WINDOW_REPLACEMENT_TIMEOUT_DURATION;
Chong Zhang92147042016-05-09 12:47:11 -070030import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080031
Jeff Brown4532e612012-04-05 14:27:12 -070032import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080033import com.android.server.wm.WindowManagerService.H;
34
Filip Gruszczynskia590c992015-11-25 16:45:26 -080035import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080036import android.content.pm.ActivityInfo;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070037import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010038import android.graphics.Rect;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080039import android.os.Message;
40import android.os.RemoteException;
41import android.util.Slog;
42import android.view.IApplicationToken;
43import android.view.View;
44import android.view.WindowManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080045
46import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010047import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080048import java.util.ArrayList;
49
50class AppTokenList extends ArrayList<AppWindowToken> {
51}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080052
53/**
54 * Version of WindowToken that is specifically for a particular application (or
55 * really activity) that is displaying windows.
56 */
Craig Mautnere32c3072012-03-12 15:25:35 -070057class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080058 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
59
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080060 // Non-null only for application tokens.
61 final IApplicationToken appToken;
62
63 // All of the windows and child windows that are included in this
64 // application token. Note this list is NOT sorted!
Craig Mautner96868332012-12-04 14:29:11 -080065 final WindowList allAppWindows = new WindowList();
Filip Gruszczynskia590c992015-11-25 16:45:26 -080066 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070067
Dianne Hackborne30e02f2014-05-27 18:24:45 -070068 final boolean voiceInteraction;
69
Craig Mautner83162a92015-01-26 14:43:30 -080070 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080071 boolean appFullscreen;
72 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080073 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070074 boolean showForAllUsers;
Yorke Lee0e852472016-06-15 10:03:18 -070075 int targetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070076
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080077 // The input dispatching timeout for this application token in nanoseconds.
78 long inputDispatchingTimeoutNanos;
79
80 // These are used for determining when all windows associated with
81 // an activity have been drawn, so they can be made visible together
82 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070083 // initialize so that it doesn't match mTransactionSequence which is an int.
84 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080085 int numInterestingWindows;
86 int numDrawnWindows;
87 boolean inPendingTransaction;
88 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080089 // Set to true when this app creates a surface while in the middle of an animation. In that
90 // case do not clear allDrawn until the animation completes.
91 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080092
Chong Zhang8e4bda92016-05-04 15:08:18 -070093 // These are to track the app's real drawing status if there were no saved surfaces.
94 boolean allDrawnExcludingSaved;
95 int numInterestingWindowsExcludingSaved;
96 int numDrawnWindowsExclusingSaved;
97
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080098 // Is this window's surface needed? This is almost like hidden, except
99 // it will sometimes be true a little earlier: when the token has
100 // been shown, but is still waiting for its app transition to execute
101 // before making its windows shown.
102 boolean hiddenRequested;
103
104 // Have we told the window clients to hide themselves?
105 boolean clientHidden;
106
107 // Last visibility state we reported to the app token.
108 boolean reportedVisible;
109
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700110 // Last drawn state we reported to the app token.
111 boolean reportedDrawn;
112
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800113 // Set to true when the token has been removed from the window mgr.
114 boolean removed;
115
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800116 // Information about an application starting window if displayed.
117 StartingData startingData;
118 WindowState startingWindow;
119 View startingView;
120 boolean startingDisplayed;
121 boolean startingMoved;
122 boolean firstWindowDrawn;
123
124 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700125 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800126
Craig Mautner799bc1d2015-01-14 10:33:48 -0800127 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800128
Craig Mautnerbb742462014-07-07 15:28:55 -0700129 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700130 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700131
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800132 boolean mAlwaysFocusable;
133
Robert Carre12aece2016-02-02 22:43:27 -0800134 boolean mAppStopped;
Robert Carrfd10cd12016-06-29 16:41:50 -0700135 int mRotationAnimationHint;
Chong Zhangd78ddb42016-03-02 17:01:14 -0800136 int mPendingRelaunchCount;
Robert Carre12aece2016-02-02 22:43:27 -0800137
Robert Carr91b228092016-06-28 17:32:37 -0700138 private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds =
139 new ArrayList<WindowSurfaceController.SurfaceControlWithBackground>();
140
Jorim Jaggi0429f352015-12-22 16:29:16 +0100141 ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700142 ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100143
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700144 AppWindowToken(WindowManagerService _service, IApplicationToken _token,
145 boolean _voiceInteraction) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800146 super(_service, _token.asBinder(),
147 WindowManager.LayoutParams.TYPE_APPLICATION, true);
148 appWindowToken = this;
149 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700150 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800151 mInputApplicationHandle = new InputApplicationHandle(this);
Craig Mautner322e4032012-07-13 13:35:20 -0700152 mAppAnimator = new AppWindowAnimator(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800153 }
154
155 void sendAppVisibilityToClients() {
156 final int N = allAppWindows.size();
157 for (int i=0; i<N; i++) {
158 WindowState win = allAppWindows.get(i);
159 if (win == startingWindow && clientHidden) {
160 // Don't hide the starting window.
161 continue;
162 }
163 try {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800164 if (DEBUG_VISIBILITY) Slog.v(TAG,
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800165 "Setting visibility of " + win + ": " + (!clientHidden));
166 win.mClient.dispatchAppVisibility(!clientHidden);
167 } catch (RemoteException e) {
168 }
169 }
170 }
171
Chong Zhang92147042016-05-09 12:47:11 -0700172 void setVisibleBeforeClientHidden() {
173 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
174 final WindowState w = allAppWindows.get(i);
175 w.setVisibleBeforeClientHidden();
176 }
177 }
178
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800179 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
180 firstWindowDrawn = true;
181
182 // We now have a good window to show, remove dead placeholders
183 removeAllDeadWindows();
184
185 if (startingData != null) {
186 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
187 + win.mToken + ": first real window is shown, no animation");
188 // If this initial window is animating, stop it -- we will do an animation to reveal
189 // it from behind the starting window, so there is no need for it to also be doing its
190 // own stuff.
191 winAnimator.clearAnimation();
192 winAnimator.mService.mFinishedStarting.add(this);
193 winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
194 }
195 updateReportedVisibilityLocked();
196 }
197
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800198 void updateReportedVisibilityLocked() {
199 if (appToken == null) {
200 return;
201 }
202
203 int numInteresting = 0;
204 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700205 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800206 boolean nowGone = true;
207
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800208 if (DEBUG_VISIBILITY) Slog.v(TAG,
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700209 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800210 final int N = allAppWindows.size();
211 for (int i=0; i<N; i++) {
212 WindowState win = allAppWindows.get(i);
213 if (win == startingWindow || win.mAppFreezing
214 || win.mViewVisibility != View.VISIBLE
215 || win.mAttrs.type == TYPE_APPLICATION_STARTING
216 || win.mDestroying) {
217 continue;
218 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800219 if (DEBUG_VISIBILITY) {
220 Slog.v(TAG, "Win " + win + ": isDrawn="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800221 + win.isDrawnLw()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700222 + ", isAnimationSet=" + win.mWinAnimator.isAnimationSet());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800223 if (!win.isDrawnLw()) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800224 Slog.v(TAG, "Not displayed: s=" +
Robert Carre6a83512015-11-03 16:09:21 -0800225 win.mWinAnimator.mSurfaceController
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800226 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700227 + " mDrawState=" + win.mWinAnimator.mDrawState
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800228 + " ah=" + win.mAttachedHidden
229 + " th="
230 + (win.mAppToken != null
231 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700232 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800233 }
234 }
235 numInteresting++;
236 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700237 numDrawn++;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700238 if (!win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800239 numVisible++;
240 }
241 nowGone = false;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700242 } else if (win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800243 nowGone = false;
244 }
245 }
246
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700247 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800248 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700249 if (!nowGone) {
250 // If the app is not yet gone, then it can only become visible/drawn.
251 if (!nowDrawn) {
252 nowDrawn = reportedDrawn;
253 }
254 if (!nowVisible) {
255 nowVisible = reportedVisible;
256 }
257 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800258 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800259 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700260 if (nowDrawn != reportedDrawn) {
261 if (nowDrawn) {
262 Message m = service.mH.obtainMessage(
263 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
264 service.mH.sendMessage(m);
265 }
266 reportedDrawn = nowDrawn;
267 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800268 if (nowVisible != reportedVisible) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800269 if (DEBUG_VISIBILITY) Slog.v(
270 TAG, "Visibility changed in " + this
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800271 + ": vis=" + nowVisible);
272 reportedVisible = nowVisible;
273 Message m = service.mH.obtainMessage(
274 H.REPORT_APPLICATION_TOKEN_WINDOWS,
275 nowVisible ? 1 : 0,
276 nowGone ? 1 : 0,
277 this);
278 service.mH.sendMessage(m);
279 }
280 }
281
282 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700283 WindowState candidate = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800284 int j = windows.size();
285 while (j > 0) {
286 j--;
287 WindowState win = windows.get(j);
288 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
289 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700290 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900291 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700292 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800293 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700294 candidate = win;
295 } else {
296 return win;
297 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800298 }
299 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700300 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800301 }
302
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800303 boolean windowsAreFocusable() {
304 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800305 }
306
Craig Mautner72669d12012-12-18 17:23:54 -0800307 boolean isVisible() {
308 final int N = allAppWindows.size();
Craig Mautner72669d12012-12-18 17:23:54 -0800309 for (int i=0; i<N; i++) {
310 WindowState win = allAppWindows.get(i);
Chong Zhangdb20b5f2015-10-23 14:01:43 -0700311 // If we're animating with a saved surface, we're already visible.
312 // Return true so that the alpha doesn't get cleared.
Craig Mautner72669d12012-12-18 17:23:54 -0800313 if (!win.mAppFreezing
Chong Zhang92147042016-05-09 12:47:11 -0700314 && (win.mViewVisibility == View.VISIBLE || win.isAnimatingWithSavedSurface()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700315 || (win.mWinAnimator.isAnimationSet()
Filip Gruszczynski57f76f12015-11-04 16:10:54 -0800316 && !service.mAppTransition.isTransitionSet()))
317 && !win.mDestroying
318 && win.isDrawnLw()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800319 return true;
320 }
321 }
322 return false;
323 }
324
Craig Mautnere3119b72015-01-20 15:02:36 -0800325 void removeAppFromTaskLocked() {
326 mIsExiting = false;
327 removeAllWindows();
328
Craig Mautner83162a92015-01-26 14:43:30 -0800329 // Use local variable because removeAppToken will null out mTask.
330 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800331 if (task != null) {
332 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800333 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800334 + " not found.");
335 }
336 task.mStack.mExitingAppTokens.remove(this);
337 }
338 }
339
Robert Carre12aece2016-02-02 22:43:27 -0800340 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700341 destroySurfaces(false /*cleanupOnResume*/);
342 }
343
344 /**
345 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
346 * the client has finished with them.
347 *
348 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
349 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
350 * others so that they are ready to be reused. If set to false (common case), destroy all
351 * surfaces that's eligible, if the app is already stopped.
352 */
353
354 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800355 final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone();
356 final DisplayContentList displayList = new DisplayContentList();
357 for (int i = allWindows.size() - 1; i >= 0; i--) {
358 final WindowState win = allWindows.get(i);
Chong Zhangeb665572016-05-09 18:28:27 -0700359
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700360 if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) {
Robert Carre12aece2016-02-02 22:43:27 -0800361 continue;
362 }
363
Chong Zhangeb665572016-05-09 18:28:27 -0700364 win.mWinAnimator.destroyPreservedSurfaceLocked();
365
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700366 if (cleanupOnResume) {
367 // If the window has an unfinished exit animation, consider that animation
368 // done and mark the window destroying so that it goes through the cleanup.
369 if (win.mAnimatingExit) {
370 win.mDestroying = true;
371 win.mAnimatingExit = false;
372 }
373 }
374
Chong Zhangeb665572016-05-09 18:28:27 -0700375 if (!win.mDestroying) {
Chong Zhang5471e902016-02-12 15:34:10 -0800376 continue;
Robert Carre12aece2016-02-02 22:43:27 -0800377 }
378
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800379 if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win
380 + " destroySurfaces: mAppStopped=" + mAppStopped
381 + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed
382 + " win.mRemoveOnExit=" + win.mRemoveOnExit);
383
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700384 if (!cleanupOnResume || win.mRemoveOnExit) {
385 win.destroyOrSaveSurface();
386 }
Robert Carre12aece2016-02-02 22:43:27 -0800387 if (win.mRemoveOnExit) {
Robert Carre12aece2016-02-02 22:43:27 -0800388 service.removeWindowInnerLocked(win);
389 }
390 final DisplayContent displayContent = win.getDisplayContent();
391 if (displayContent != null && !displayList.contains(displayContent)) {
392 displayList.add(displayContent);
393 }
394 win.mDestroying = false;
395 }
396 for (int i = 0; i < displayList.size(); i++) {
397 final DisplayContent displayContent = displayList.get(i);
398 service.mLayersController.assignLayersLocked(displayContent.getWindowList());
399 displayContent.layoutNeeded = true;
400 }
401 }
402
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800403 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700404 * Notify that the app is now resumed, and it was not stopped before, perform a clean
405 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800406 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700407 void notifyAppResumed(boolean wasStopped) {
408 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this);
409 mAppStopped = false;
410 if (!wasStopped) {
411 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800412 }
Robert Carre12aece2016-02-02 22:43:27 -0800413 }
414
Chong Zhangbef461f2015-10-27 11:38:24 -0700415 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700416 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
417 * keeping alive in case they were still being used.
418 */
419 void notifyAppStopped() {
420 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
421 mAppStopped = true;
422 destroySurfaces();
423 // Remove any starting window that was added for this app if they are still around.
424 mTask.mService.scheduleRemoveStartingWindowLocked(this);
425 }
426
427 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700428 * Checks whether we should save surfaces for this app.
429 *
430 * @return true if the surfaces should be saved, false otherwise.
431 */
432 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800433 // We want to save surface if the app's windows are "allDrawn".
434 // (If we started entering animation early with saved surfaces, allDrawn
435 // should have been restored to true. So we'll save again in that case
436 // even if app didn't actually finish drawing.)
437 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800438 }
439
Chong Zhang92147042016-05-09 12:47:11 -0700440 boolean canRestoreSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700441 for (int i = allAppWindows.size() -1; i >= 0; i--) {
Chong Zhang92147042016-05-09 12:47:11 -0700442 final WindowState w = allAppWindows.get(i);
443 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800444 return true;
445 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700446 }
447 return false;
448 }
449
Chong Zhang92147042016-05-09 12:47:11 -0700450 void clearVisibleBeforeClientHidden() {
451 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
452 final WindowState w = allAppWindows.get(i);
453 w.clearVisibleBeforeClientHidden();
454 }
455 }
456
Chong Zhang8e4bda92016-05-04 15:08:18 -0700457 /**
458 * Whether the app has some window that is invisible in layout, but
459 * animating with saved surface.
460 */
461 boolean isAnimatingInvisibleWithSavedSurface() {
462 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
463 final WindowState w = allAppWindows.get(i);
464 if (w.isAnimatingInvisibleWithSavedSurface()) {
465 return true;
466 }
467 }
468 return false;
469 }
470
471 /**
472 * Hide all window surfaces that's still invisible in layout but animating
473 * with a saved surface, and mark them destroying.
474 */
475 void stopUsingSavedSurfaceLocked() {
476 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
477 final WindowState w = allAppWindows.get(i);
478 if (w.isAnimatingInvisibleWithSavedSurface()) {
479 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
480 "stopUsingSavedSurfaceLocked: " + w);
481 w.clearAnimatingWithSavedSurface();
482 w.mDestroying = true;
483 w.mWinAnimator.hide("stopUsingSavedSurfaceLocked");
484 w.mWinAnimator.mWallpaperControllerLocked.hideWallpapers(w);
485 }
486 }
487 destroySurfaces();
488 }
489
Chong Zhangf58631a2016-05-24 16:02:10 -0700490 void markSavedSurfaceExiting() {
491 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
492 final WindowState w = allAppWindows.get(i);
493 if (w.isAnimatingInvisibleWithSavedSurface()) {
494 w.mAnimatingExit = true;
495 w.mWinAnimator.mAnimating = true;
496 }
497 }
498 }
499
Chong Zhangbef461f2015-10-27 11:38:24 -0700500 void restoreSavedSurfaces() {
Chong Zhang92147042016-05-09 12:47:11 -0700501 if (!canRestoreSurfaces()) {
502 clearVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700503 return;
504 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800505 // Check if we have enough drawn windows to mark allDrawn= true.
506 int numInteresting = 0;
507 int numDrawn = 0;
Chong Zhangb7b4a562016-04-28 15:30:33 -0700508 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
509 WindowState w = allAppWindows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700510 if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800511 && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
512 numInteresting++;
Chong Zhang92147042016-05-09 12:47:11 -0700513 if (w.hasSavedSurface()) {
514 w.restoreSavedSurface();
515 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800516 if (w.isDrawnLw()) {
517 numDrawn++;
518 }
519 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700520 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800521
Chong Zhang92147042016-05-09 12:47:11 -0700522 if (!allDrawn) {
523 allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
524 if (allDrawn) {
525 service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
526 }
527 }
528 clearVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800529
530 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Chong Zhang92147042016-05-09 12:47:11 -0700531 "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn
532 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700533 }
534
535 void destroySavedSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700536 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
537 WindowState win = allAppWindows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800538 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700539 }
Chong Zhang92147042016-05-09 12:47:11 -0700540 }
541
542 void clearAllDrawn() {
543 allDrawn = false;
544 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700545 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700546 }
547
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800548 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700549 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800550 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
551 // removeWindowLocked at bottom of loop may remove multiple entries from
552 // allAppWindows if the window to be removed has child windows. It also may
553 // not remove any windows from allAppWindows at all if win is exiting and
554 // currently animating away. This ensures that winNdx is monotonically decreasing
555 // and never beyond allAppWindows bounds.
556 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
557 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800558 if (DEBUG_WINDOW_MOVEMENT) {
559 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800560 }
561
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700562 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700563 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800564 allAppWindows.clear();
565 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700566 }
567
Chong Zhang112eb8c2015-11-02 11:17:00 -0800568 void removeAllDeadWindows() {
569 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700570 // removeWindowLocked at bottom of loop may remove multiple entries from
571 // allAppWindows if the window to be removed has child windows. It also may
572 // not remove any windows from allAppWindows at all if win is exiting and
573 // currently animating away. This ensures that winNdx is monotonically decreasing
574 // and never beyond allAppWindows bounds.
575 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800576 WindowState win = allAppWindows.get(winNdx);
577 if (win.mAppDied) {
Wale Ogunwale2728bf42016-03-03 11:03:26 -0800578 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800579 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800580 }
581 // Set mDestroying, we don't want any animation or delayed removal here.
582 win.mDestroying = true;
583 service.removeWindowLocked(win);
584 }
585 }
586 }
587
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700588 boolean hasWindowsAlive() {
589 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
590 if (!allAppWindows.get(i).mAppDied) {
591 return true;
592 }
593 }
594 return false;
595 }
596
Robert Carra1eb4392015-12-10 12:43:51 -0800597 void setReplacingWindows(boolean animate) {
598 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
599 + " with replacing windows.");
600
601 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
602 final WindowState w = allAppWindows.get(i);
603 w.setReplacing(animate);
604 }
605 if (animate) {
606 // Set-up dummy animation so we can start treating windows associated with this
607 // token like they are in transition before the new app window is ready for us to
608 // run the real transition animation.
609 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
610 "setReplacingWindow() Setting dummy animation on: " + this);
611 mAppAnimator.setDummyAnimation();
612 }
613 }
614
Robert Carr23fa16b2016-01-13 13:19:58 -0800615 void setReplacingChildren() {
616 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
617 + " with replacing child windows.");
618 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
619 final WindowState w = allAppWindows.get(i);
Robert Carrd1a010f2016-04-07 22:36:22 -0700620 if (w.shouldBeReplacedWithChildren()) {
Robert Carr23fa16b2016-01-13 13:19:58 -0800621 w.setReplacing(false /* animate */);
622 }
623 }
624 }
625
Chong Zhangf596cd52016-01-05 13:42:44 -0800626 void resetReplacingWindows() {
627 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Resetting app token " + appWindowToken
628 + " of replacing window marks.");
629
630 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
631 final WindowState w = allAppWindows.get(i);
632 w.resetReplacing();
633 }
634 }
635
Chong Zhang4d7369a2016-04-25 16:09:14 -0700636 void requestUpdateWallpaperIfNeeded() {
637 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
638 final WindowState w = allAppWindows.get(i);
639 w.requestUpdateWallpaperIfNeeded();
640 }
641 }
642
Chong Zhangd78ddb42016-03-02 17:01:14 -0800643 boolean isRelaunching() {
644 return mPendingRelaunchCount > 0;
645 }
646
647 void startRelaunching() {
648 if (canFreezeBounds()) {
649 freezeBounds();
650 }
651 mPendingRelaunchCount++;
652 }
653
654 void finishRelaunching() {
655 if (canFreezeBounds()) {
656 unfreezeBounds();
657 }
658 if (mPendingRelaunchCount > 0) {
659 mPendingRelaunchCount--;
660 }
661 }
662
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700663 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700664 if (mPendingRelaunchCount == 0) {
665 return;
666 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700667 if (canFreezeBounds()) {
668 unfreezeBounds();
669 }
670 mPendingRelaunchCount = 0;
671 }
672
Robert Carra1eb4392015-12-10 12:43:51 -0800673 void addWindow(WindowState w) {
674 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
675 WindowState candidate = allAppWindows.get(i);
676 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
Robert Carr8bc89072016-04-08 13:29:59 -0700677 candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) {
Robert Carra1eb4392015-12-10 12:43:51 -0800678 candidate.mReplacingWindow = w;
Robert Carrb439a632016-04-07 22:52:10 -0700679 w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
Chong Zhangf596cd52016-01-05 13:42:44 -0800680
681 // if we got a replacement window, reset the timeout to give drawing more time
Chong Zhang32de3652016-05-12 16:00:01 -0700682 service.scheduleReplacingWindowTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800683 }
684 }
685 allAppWindows.add(w);
686 }
687
688 boolean waitingForReplacement() {
689 for (int i = allAppWindows.size() -1; i >= 0; i--) {
690 WindowState candidate = allAppWindows.get(i);
691 if (candidate.mWillReplaceWindow) {
692 return true;
693 }
694 }
695 return false;
696 }
697
Chong Zhangf596cd52016-01-05 13:42:44 -0800698 void clearTimedoutReplacesLocked() {
Robert Carra1eb4392015-12-10 12:43:51 -0800699 for (int i = allAppWindows.size() - 1; i >= 0;
700 // removeWindowLocked at bottom of loop may remove multiple entries from
701 // allAppWindows if the window to be removed has child windows. It also may
702 // not remove any windows from allAppWindows at all if win is exiting and
703 // currently animating away. This ensures that winNdx is monotonically decreasing
704 // and never beyond allAppWindows bounds.
705 i = Math.min(i - 1, allAppWindows.size() - 1)) {
706 WindowState candidate = allAppWindows.get(i);
707 if (candidate.mWillReplaceWindow == false) {
708 continue;
709 }
710 candidate.mWillReplaceWindow = false;
Robert Carrb439a632016-04-07 22:52:10 -0700711 if (candidate.mReplacingWindow != null) {
712 candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false;
713 }
Chong Zhangf596cd52016-01-05 13:42:44 -0800714 // Since the window already timed out, remove it immediately now.
715 // Use removeWindowInnerLocked() instead of removeWindowLocked(), as the latter
716 // delays removal on certain conditions, which will leave the stale window in the
717 // stack and marked mWillReplaceWindow=false, so the window will never be removed.
718 service.removeWindowInnerLocked(candidate);
Robert Carra1eb4392015-12-10 12:43:51 -0800719 }
720 }
721
Chong Zhangd78ddb42016-03-02 17:01:14 -0800722 private boolean canFreezeBounds() {
723 // For freeform windows, we can't freeze the bounds at the moment because this would make
724 // the resizing unresponsive.
725 return mTask != null && !mTask.inFreeformWorkspace();
726 }
727
Jorim Jaggi0429f352015-12-22 16:29:16 +0100728 /**
729 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
730 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
731 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
732 * with a queue.
733 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800734 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100735 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700736
737 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
738 // We didn't call prepareFreezingBounds on the task, so use the current value.
739 final Configuration config = new Configuration(service.mCurConfiguration);
740 config.updateFrom(mTask.mOverrideConfig);
741 mFrozenMergedConfig.offer(config);
742 } else {
743 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
744 }
745 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100746 }
747
748 /**
749 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
750 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800751 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700752 if (!mFrozenBounds.isEmpty()) {
753 mFrozenBounds.remove();
754 }
755 if (!mFrozenMergedConfig.isEmpty()) {
756 mFrozenMergedConfig.remove();
757 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100758 for (int i = windows.size() - 1; i >= 0; i--) {
759 final WindowState win = windows.get(i);
Jorim Jaggi69abc192016-02-04 19:34:00 -0800760 if (!win.mHasSurface) {
761 continue;
762 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100763 win.mLayoutNeeded = true;
764 win.setDisplayLayoutNeeded();
765 if (!service.mResizingWindows.contains(win)) {
766 service.mResizingWindows.add(win);
767 }
768 }
769 service.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100770 }
771
Robert Carr91b228092016-06-28 17:32:37 -0700772 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
773 mSurfaceViewBackgrounds.add(background);
774 }
775
776 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
777 mSurfaceViewBackgrounds.remove(background);
778 updateSurfaceViewBackgroundVisibilities();
779 }
780
781 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
782 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
783 // below the main app window (as traditionally a SurfaceView which is never drawn
784 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
785 // the background for the SurfaceView with lowest Z order
786 void updateSurfaceViewBackgroundVisibilities() {
787 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
788 int bottomLayer = Integer.MAX_VALUE;
789 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
790 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
791 if (sc.mVisible && sc.mLayer < bottomLayer) {
792 bottomLayer = sc.mLayer;
793 bottom = sc;
794 }
795 }
796 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
797 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
798 sc.updateBackgroundVisibility(sc != bottom);
799 }
800 }
801
Craig Mautnerdbb79912012-03-01 18:59:14 -0800802 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800803 void dump(PrintWriter pw, String prefix) {
804 super.dump(pw, prefix);
805 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700806 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800807 }
808 if (allAppWindows.size() > 0) {
809 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
810 }
Craig Mautner83162a92015-01-26 14:43:30 -0800811 pw.print(prefix); pw.print("task="); pw.println(mTask);
812 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800813 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
814 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
815 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700816 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800817 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700818 if (paused) {
819 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800820 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800821 if (mAppStopped) {
822 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
823 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800824 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700825 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800826 pw.print(prefix); pw.print("numInterestingWindows=");
827 pw.print(numInterestingWindows);
828 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
829 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700830 pw.print(" allDrawn="); pw.print(allDrawn);
831 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
832 pw.println(")");
833 }
834 if (inPendingTransaction) {
835 pw.print(prefix); pw.print("inPendingTransaction=");
836 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800837 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800838 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800839 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
840 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800841 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800842 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800843 }
844 if (startingWindow != null || startingView != null
845 || startingDisplayed || startingMoved) {
846 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
847 pw.print(" startingView="); pw.print(startingView);
848 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800849 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800850 }
Jorim Jaggi0429f352015-12-22 16:29:16 +0100851 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -0800852 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700853 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -0800854 }
855 if (mPendingRelaunchCount != 0) {
856 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +0100857 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800858 }
859
860 @Override
861 public String toString() {
862 if (stringName == null) {
863 StringBuilder sb = new StringBuilder();
864 sb.append("AppWindowToken{");
865 sb.append(Integer.toHexString(System.identityHashCode(this)));
866 sb.append(" token="); sb.append(token); sb.append('}');
867 stringName = sb.toString();
868 }
869 return stringName;
870 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700871}