blob: a9624cfaba955b726ec3ba0324794f91142e025d [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
Chong Zhange05bcb12016-07-26 17:47:29 -0700340 void clearAnimatingFlags() {
341 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
342 final WindowState win = allAppWindows.get(i);
343 // We don't want to clear it out for windows that get replaced, because the
344 // animation depends on the flag to remove the replaced window.
345 //
346 // We also don't clear the mAnimatingExit flag for windows which have the
347 // mRemoveOnExit flag. This indicates an explicit remove request has been issued
348 // by the client. We should let animation proceed and not clear this flag or
349 // they won't eventually be removed by WindowStateAnimator#finishExit.
350 if (!win.mWillReplaceWindow && !win.mRemoveOnExit) {
351 win.mAnimatingExit = false;
352 // Clear mAnimating flag together with mAnimatingExit. When animation
353 // changes from exiting to entering, we need to clear this flag until the
354 // new animation gets applied, so that isAnimationStarting() becomes true
355 // until then.
356 // Otherwise applySurfaceChangesTransaction will faill to skip surface
357 // placement for this window during this period, one or more frame will
358 // show up with wrong position or scale.
359 win.mWinAnimator.mAnimating = false;
360 }
361 }
362 }
363
Robert Carre12aece2016-02-02 22:43:27 -0800364 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700365 destroySurfaces(false /*cleanupOnResume*/);
366 }
367
368 /**
369 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
370 * the client has finished with them.
371 *
372 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
373 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
374 * others so that they are ready to be reused. If set to false (common case), destroy all
375 * surfaces that's eligible, if the app is already stopped.
376 */
377
378 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800379 final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone();
380 final DisplayContentList displayList = new DisplayContentList();
381 for (int i = allWindows.size() - 1; i >= 0; i--) {
382 final WindowState win = allWindows.get(i);
Chong Zhangeb665572016-05-09 18:28:27 -0700383
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700384 if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) {
Robert Carre12aece2016-02-02 22:43:27 -0800385 continue;
386 }
387
Chong Zhangeb665572016-05-09 18:28:27 -0700388 win.mWinAnimator.destroyPreservedSurfaceLocked();
389
390 if (!win.mDestroying) {
Chong Zhang5471e902016-02-12 15:34:10 -0800391 continue;
Robert Carre12aece2016-02-02 22:43:27 -0800392 }
393
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800394 if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win
395 + " destroySurfaces: mAppStopped=" + mAppStopped
396 + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed
397 + " win.mRemoveOnExit=" + win.mRemoveOnExit);
398
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700399 if (!cleanupOnResume || win.mRemoveOnExit) {
400 win.destroyOrSaveSurface();
401 }
Robert Carre12aece2016-02-02 22:43:27 -0800402 if (win.mRemoveOnExit) {
Robert Carre12aece2016-02-02 22:43:27 -0800403 service.removeWindowInnerLocked(win);
404 }
405 final DisplayContent displayContent = win.getDisplayContent();
406 if (displayContent != null && !displayList.contains(displayContent)) {
407 displayList.add(displayContent);
408 }
409 win.mDestroying = false;
410 }
411 for (int i = 0; i < displayList.size(); i++) {
412 final DisplayContent displayContent = displayList.get(i);
413 service.mLayersController.assignLayersLocked(displayContent.getWindowList());
414 displayContent.layoutNeeded = true;
415 }
416 }
417
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800418 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700419 * Notify that the app is now resumed, and it was not stopped before, perform a clean
420 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800421 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700422 void notifyAppResumed(boolean wasStopped) {
423 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this);
424 mAppStopped = false;
425 if (!wasStopped) {
426 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800427 }
Robert Carre12aece2016-02-02 22:43:27 -0800428 }
429
Chong Zhangbef461f2015-10-27 11:38:24 -0700430 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700431 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
432 * keeping alive in case they were still being used.
433 */
434 void notifyAppStopped() {
435 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
436 mAppStopped = true;
437 destroySurfaces();
438 // Remove any starting window that was added for this app if they are still around.
439 mTask.mService.scheduleRemoveStartingWindowLocked(this);
440 }
441
442 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700443 * Checks whether we should save surfaces for this app.
444 *
445 * @return true if the surfaces should be saved, false otherwise.
446 */
447 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800448 // We want to save surface if the app's windows are "allDrawn".
449 // (If we started entering animation early with saved surfaces, allDrawn
450 // should have been restored to true. So we'll save again in that case
451 // even if app didn't actually finish drawing.)
452 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800453 }
454
Chong Zhang92147042016-05-09 12:47:11 -0700455 boolean canRestoreSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700456 for (int i = allAppWindows.size() -1; i >= 0; i--) {
Chong Zhang92147042016-05-09 12:47:11 -0700457 final WindowState w = allAppWindows.get(i);
458 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800459 return true;
460 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700461 }
462 return false;
463 }
464
Chong Zhang92147042016-05-09 12:47:11 -0700465 void clearVisibleBeforeClientHidden() {
466 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
467 final WindowState w = allAppWindows.get(i);
468 w.clearVisibleBeforeClientHidden();
469 }
470 }
471
Chong Zhang8e4bda92016-05-04 15:08:18 -0700472 /**
473 * Whether the app has some window that is invisible in layout, but
474 * animating with saved surface.
475 */
476 boolean isAnimatingInvisibleWithSavedSurface() {
477 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
478 final WindowState w = allAppWindows.get(i);
479 if (w.isAnimatingInvisibleWithSavedSurface()) {
480 return true;
481 }
482 }
483 return false;
484 }
485
486 /**
487 * Hide all window surfaces that's still invisible in layout but animating
488 * with a saved surface, and mark them destroying.
489 */
490 void stopUsingSavedSurfaceLocked() {
491 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
492 final WindowState w = allAppWindows.get(i);
493 if (w.isAnimatingInvisibleWithSavedSurface()) {
494 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
495 "stopUsingSavedSurfaceLocked: " + w);
496 w.clearAnimatingWithSavedSurface();
497 w.mDestroying = true;
498 w.mWinAnimator.hide("stopUsingSavedSurfaceLocked");
499 w.mWinAnimator.mWallpaperControllerLocked.hideWallpapers(w);
500 }
501 }
502 destroySurfaces();
503 }
504
Chong Zhangf58631a2016-05-24 16:02:10 -0700505 void markSavedSurfaceExiting() {
506 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
507 final WindowState w = allAppWindows.get(i);
508 if (w.isAnimatingInvisibleWithSavedSurface()) {
509 w.mAnimatingExit = true;
510 w.mWinAnimator.mAnimating = true;
511 }
512 }
513 }
514
Chong Zhangbef461f2015-10-27 11:38:24 -0700515 void restoreSavedSurfaces() {
Chong Zhang92147042016-05-09 12:47:11 -0700516 if (!canRestoreSurfaces()) {
517 clearVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700518 return;
519 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800520 // Check if we have enough drawn windows to mark allDrawn= true.
521 int numInteresting = 0;
522 int numDrawn = 0;
Chong Zhangb7b4a562016-04-28 15:30:33 -0700523 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
524 WindowState w = allAppWindows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700525 if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800526 && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
527 numInteresting++;
Chong Zhang92147042016-05-09 12:47:11 -0700528 if (w.hasSavedSurface()) {
529 w.restoreSavedSurface();
530 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800531 if (w.isDrawnLw()) {
532 numDrawn++;
533 }
534 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700535 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800536
Chong Zhang92147042016-05-09 12:47:11 -0700537 if (!allDrawn) {
538 allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
539 if (allDrawn) {
540 service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
541 }
542 }
543 clearVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800544
545 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Chong Zhang92147042016-05-09 12:47:11 -0700546 "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn
547 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700548 }
549
550 void destroySavedSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700551 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
552 WindowState win = allAppWindows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800553 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700554 }
Chong Zhang92147042016-05-09 12:47:11 -0700555 }
556
557 void clearAllDrawn() {
558 allDrawn = false;
559 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700560 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700561 }
562
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800563 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700564 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800565 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
566 // removeWindowLocked at bottom of loop may remove multiple entries from
567 // allAppWindows if the window to be removed has child windows. It also may
568 // not remove any windows from allAppWindows at all if win is exiting and
569 // currently animating away. This ensures that winNdx is monotonically decreasing
570 // and never beyond allAppWindows bounds.
571 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
572 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800573 if (DEBUG_WINDOW_MOVEMENT) {
574 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800575 }
576
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700577 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700578 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800579 allAppWindows.clear();
580 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700581 }
582
Chong Zhang112eb8c2015-11-02 11:17:00 -0800583 void removeAllDeadWindows() {
584 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700585 // removeWindowLocked at bottom of loop may remove multiple entries from
586 // allAppWindows if the window to be removed has child windows. It also may
587 // not remove any windows from allAppWindows at all if win is exiting and
588 // currently animating away. This ensures that winNdx is monotonically decreasing
589 // and never beyond allAppWindows bounds.
590 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800591 WindowState win = allAppWindows.get(winNdx);
592 if (win.mAppDied) {
Wale Ogunwale2728bf42016-03-03 11:03:26 -0800593 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800594 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800595 }
596 // Set mDestroying, we don't want any animation or delayed removal here.
597 win.mDestroying = true;
598 service.removeWindowLocked(win);
599 }
600 }
601 }
602
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700603 boolean hasWindowsAlive() {
604 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
605 if (!allAppWindows.get(i).mAppDied) {
606 return true;
607 }
608 }
609 return false;
610 }
611
Robert Carra1eb4392015-12-10 12:43:51 -0800612 void setReplacingWindows(boolean animate) {
613 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
614 + " with replacing windows.");
615
616 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
617 final WindowState w = allAppWindows.get(i);
618 w.setReplacing(animate);
619 }
620 if (animate) {
621 // Set-up dummy animation so we can start treating windows associated with this
622 // token like they are in transition before the new app window is ready for us to
623 // run the real transition animation.
624 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
625 "setReplacingWindow() Setting dummy animation on: " + this);
626 mAppAnimator.setDummyAnimation();
627 }
628 }
629
Robert Carr23fa16b2016-01-13 13:19:58 -0800630 void setReplacingChildren() {
631 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
632 + " with replacing child windows.");
633 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
634 final WindowState w = allAppWindows.get(i);
Robert Carrd1a010f2016-04-07 22:36:22 -0700635 if (w.shouldBeReplacedWithChildren()) {
Robert Carr23fa16b2016-01-13 13:19:58 -0800636 w.setReplacing(false /* animate */);
637 }
638 }
639 }
640
Chong Zhangf596cd52016-01-05 13:42:44 -0800641 void resetReplacingWindows() {
642 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Resetting app token " + appWindowToken
643 + " of replacing window marks.");
644
645 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
646 final WindowState w = allAppWindows.get(i);
647 w.resetReplacing();
648 }
649 }
650
Chong Zhang4d7369a2016-04-25 16:09:14 -0700651 void requestUpdateWallpaperIfNeeded() {
652 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
653 final WindowState w = allAppWindows.get(i);
654 w.requestUpdateWallpaperIfNeeded();
655 }
656 }
657
Chong Zhangd78ddb42016-03-02 17:01:14 -0800658 boolean isRelaunching() {
659 return mPendingRelaunchCount > 0;
660 }
661
662 void startRelaunching() {
663 if (canFreezeBounds()) {
664 freezeBounds();
665 }
666 mPendingRelaunchCount++;
667 }
668
669 void finishRelaunching() {
670 if (canFreezeBounds()) {
671 unfreezeBounds();
672 }
673 if (mPendingRelaunchCount > 0) {
674 mPendingRelaunchCount--;
675 }
676 }
677
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700678 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700679 if (mPendingRelaunchCount == 0) {
680 return;
681 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700682 if (canFreezeBounds()) {
683 unfreezeBounds();
684 }
685 mPendingRelaunchCount = 0;
686 }
687
Robert Carra1eb4392015-12-10 12:43:51 -0800688 void addWindow(WindowState w) {
689 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
690 WindowState candidate = allAppWindows.get(i);
691 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
Robert Carr8bc89072016-04-08 13:29:59 -0700692 candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) {
Robert Carra1eb4392015-12-10 12:43:51 -0800693 candidate.mReplacingWindow = w;
Robert Carrb439a632016-04-07 22:52:10 -0700694 w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
Chong Zhangf596cd52016-01-05 13:42:44 -0800695
696 // if we got a replacement window, reset the timeout to give drawing more time
Chong Zhang32de3652016-05-12 16:00:01 -0700697 service.scheduleReplacingWindowTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800698 }
699 }
700 allAppWindows.add(w);
701 }
702
703 boolean waitingForReplacement() {
704 for (int i = allAppWindows.size() -1; i >= 0; i--) {
705 WindowState candidate = allAppWindows.get(i);
706 if (candidate.mWillReplaceWindow) {
707 return true;
708 }
709 }
710 return false;
711 }
712
Chong Zhangf596cd52016-01-05 13:42:44 -0800713 void clearTimedoutReplacesLocked() {
Robert Carra1eb4392015-12-10 12:43:51 -0800714 for (int i = allAppWindows.size() - 1; i >= 0;
715 // removeWindowLocked at bottom of loop may remove multiple entries from
716 // allAppWindows if the window to be removed has child windows. It also may
717 // not remove any windows from allAppWindows at all if win is exiting and
718 // currently animating away. This ensures that winNdx is monotonically decreasing
719 // and never beyond allAppWindows bounds.
720 i = Math.min(i - 1, allAppWindows.size() - 1)) {
721 WindowState candidate = allAppWindows.get(i);
722 if (candidate.mWillReplaceWindow == false) {
723 continue;
724 }
725 candidate.mWillReplaceWindow = false;
Robert Carrb439a632016-04-07 22:52:10 -0700726 if (candidate.mReplacingWindow != null) {
727 candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false;
728 }
Chong Zhangf596cd52016-01-05 13:42:44 -0800729 // Since the window already timed out, remove it immediately now.
730 // Use removeWindowInnerLocked() instead of removeWindowLocked(), as the latter
731 // delays removal on certain conditions, which will leave the stale window in the
732 // stack and marked mWillReplaceWindow=false, so the window will never be removed.
733 service.removeWindowInnerLocked(candidate);
Robert Carra1eb4392015-12-10 12:43:51 -0800734 }
735 }
736
Chong Zhangd78ddb42016-03-02 17:01:14 -0800737 private boolean canFreezeBounds() {
738 // For freeform windows, we can't freeze the bounds at the moment because this would make
739 // the resizing unresponsive.
740 return mTask != null && !mTask.inFreeformWorkspace();
741 }
742
Jorim Jaggi0429f352015-12-22 16:29:16 +0100743 /**
744 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
745 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
746 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
747 * with a queue.
748 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800749 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100750 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700751
752 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
753 // We didn't call prepareFreezingBounds on the task, so use the current value.
754 final Configuration config = new Configuration(service.mCurConfiguration);
755 config.updateFrom(mTask.mOverrideConfig);
756 mFrozenMergedConfig.offer(config);
757 } else {
758 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
759 }
760 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100761 }
762
763 /**
764 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
765 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800766 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700767 if (!mFrozenBounds.isEmpty()) {
768 mFrozenBounds.remove();
769 }
770 if (!mFrozenMergedConfig.isEmpty()) {
771 mFrozenMergedConfig.remove();
772 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100773 for (int i = windows.size() - 1; i >= 0; i--) {
774 final WindowState win = windows.get(i);
Jorim Jaggi69abc192016-02-04 19:34:00 -0800775 if (!win.mHasSurface) {
776 continue;
777 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100778 win.mLayoutNeeded = true;
779 win.setDisplayLayoutNeeded();
780 if (!service.mResizingWindows.contains(win)) {
781 service.mResizingWindows.add(win);
782 }
783 }
784 service.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100785 }
786
Robert Carr91b228092016-06-28 17:32:37 -0700787 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
788 mSurfaceViewBackgrounds.add(background);
789 }
790
791 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
792 mSurfaceViewBackgrounds.remove(background);
793 updateSurfaceViewBackgroundVisibilities();
794 }
795
796 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
797 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
798 // below the main app window (as traditionally a SurfaceView which is never drawn
799 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
800 // the background for the SurfaceView with lowest Z order
801 void updateSurfaceViewBackgroundVisibilities() {
802 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
803 int bottomLayer = Integer.MAX_VALUE;
804 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
805 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
806 if (sc.mVisible && sc.mLayer < bottomLayer) {
807 bottomLayer = sc.mLayer;
808 bottom = sc;
809 }
810 }
811 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
812 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
813 sc.updateBackgroundVisibility(sc != bottom);
814 }
815 }
816
Craig Mautnerdbb79912012-03-01 18:59:14 -0800817 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800818 void dump(PrintWriter pw, String prefix) {
819 super.dump(pw, prefix);
820 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700821 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800822 }
823 if (allAppWindows.size() > 0) {
824 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
825 }
Craig Mautner83162a92015-01-26 14:43:30 -0800826 pw.print(prefix); pw.print("task="); pw.println(mTask);
827 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800828 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
829 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
830 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700831 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800832 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700833 if (paused) {
834 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800835 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800836 if (mAppStopped) {
837 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
838 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800839 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700840 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800841 pw.print(prefix); pw.print("numInterestingWindows=");
842 pw.print(numInterestingWindows);
843 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
844 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700845 pw.print(" allDrawn="); pw.print(allDrawn);
846 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
847 pw.println(")");
848 }
849 if (inPendingTransaction) {
850 pw.print(prefix); pw.print("inPendingTransaction=");
851 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800852 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800853 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800854 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
855 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800856 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800857 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800858 }
859 if (startingWindow != null || startingView != null
860 || startingDisplayed || startingMoved) {
861 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
862 pw.print(" startingView="); pw.print(startingView);
863 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800864 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800865 }
Jorim Jaggi0429f352015-12-22 16:29:16 +0100866 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -0800867 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700868 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -0800869 }
870 if (mPendingRelaunchCount != 0) {
871 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +0100872 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800873 }
874
875 @Override
876 public String toString() {
877 if (stringName == null) {
878 StringBuilder sb = new StringBuilder();
879 sb.append("AppWindowToken{");
880 sb.append(Integer.toHexString(System.identityHashCode(this)));
881 sb.append(" token="); sb.append(token); sb.append('}');
882 stringName = sb.toString();
883 }
884 return stringName;
885 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700886}