blob: 1f385dfac5a5538992f9d363f0d6fb8e5c4c97f0 [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;
Chong Zhang808621c2016-07-29 13:09:40 -070020import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080021import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Chong Zhang808621c2016-07-29 13:09:40 -070022import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080023import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
24import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Robert Carra1eb4392015-12-10 12:43:51 -080025import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Wale Ogunwale9017ec02016-02-25 08:55:25 -080026import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080027import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
28import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
29import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
30import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Chong Zhangf596cd52016-01-05 13:42:44 -080031import static com.android.server.wm.WindowManagerService.WINDOW_REPLACEMENT_TIMEOUT_DURATION;
Chong Zhang92147042016-05-09 12:47:11 -070032import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080033
Jeff Brown4532e612012-04-05 14:27:12 -070034import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080035import com.android.server.wm.WindowManagerService.H;
36
Filip Gruszczynskia590c992015-11-25 16:45:26 -080037import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080038import android.content.pm.ActivityInfo;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070039import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010040import android.graphics.Rect;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080041import android.os.Message;
42import android.os.RemoteException;
43import android.util.Slog;
44import android.view.IApplicationToken;
45import android.view.View;
46import android.view.WindowManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080047
48import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010049import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080050import java.util.ArrayList;
51
52class AppTokenList extends ArrayList<AppWindowToken> {
53}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080054
55/**
56 * Version of WindowToken that is specifically for a particular application (or
57 * really activity) that is displaying windows.
58 */
Craig Mautnere32c3072012-03-12 15:25:35 -070059class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080060 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
61
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080062 // Non-null only for application tokens.
63 final IApplicationToken appToken;
64
65 // All of the windows and child windows that are included in this
66 // application token. Note this list is NOT sorted!
Craig Mautner96868332012-12-04 14:29:11 -080067 final WindowList allAppWindows = new WindowList();
Filip Gruszczynskia590c992015-11-25 16:45:26 -080068 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070069
Dianne Hackborne30e02f2014-05-27 18:24:45 -070070 final boolean voiceInteraction;
71
Craig Mautner83162a92015-01-26 14:43:30 -080072 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080073 boolean appFullscreen;
74 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080075 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070076 boolean showForAllUsers;
Yorke Lee0e852472016-06-15 10:03:18 -070077 int targetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070078
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080079 // The input dispatching timeout for this application token in nanoseconds.
80 long inputDispatchingTimeoutNanos;
81
82 // These are used for determining when all windows associated with
83 // an activity have been drawn, so they can be made visible together
84 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070085 // initialize so that it doesn't match mTransactionSequence which is an int.
86 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080087 int numInterestingWindows;
88 int numDrawnWindows;
89 boolean inPendingTransaction;
90 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080091 // Set to true when this app creates a surface while in the middle of an animation. In that
92 // case do not clear allDrawn until the animation completes.
93 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080094
Chong Zhang8e4bda92016-05-04 15:08:18 -070095 // These are to track the app's real drawing status if there were no saved surfaces.
96 boolean allDrawnExcludingSaved;
97 int numInterestingWindowsExcludingSaved;
98 int numDrawnWindowsExclusingSaved;
99
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800100 // Is this window's surface needed? This is almost like hidden, except
101 // it will sometimes be true a little earlier: when the token has
102 // been shown, but is still waiting for its app transition to execute
103 // before making its windows shown.
104 boolean hiddenRequested;
105
106 // Have we told the window clients to hide themselves?
107 boolean clientHidden;
108
109 // Last visibility state we reported to the app token.
110 boolean reportedVisible;
111
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700112 // Last drawn state we reported to the app token.
113 boolean reportedDrawn;
114
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800115 // Set to true when the token has been removed from the window mgr.
116 boolean removed;
117
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800118 // Information about an application starting window if displayed.
119 StartingData startingData;
120 WindowState startingWindow;
121 View startingView;
122 boolean startingDisplayed;
123 boolean startingMoved;
124 boolean firstWindowDrawn;
125
126 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700127 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800128
Craig Mautner799bc1d2015-01-14 10:33:48 -0800129 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800130
Craig Mautnerbb742462014-07-07 15:28:55 -0700131 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700132 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700133
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800134 boolean mAlwaysFocusable;
135
Robert Carre12aece2016-02-02 22:43:27 -0800136 boolean mAppStopped;
Robert Carrfd10cd12016-06-29 16:41:50 -0700137 int mRotationAnimationHint;
Chong Zhangd78ddb42016-03-02 17:01:14 -0800138 int mPendingRelaunchCount;
Robert Carre12aece2016-02-02 22:43:27 -0800139
Robert Carr91b228092016-06-28 17:32:37 -0700140 private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds =
141 new ArrayList<WindowSurfaceController.SurfaceControlWithBackground>();
142
Jorim Jaggi0429f352015-12-22 16:29:16 +0100143 ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700144 ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100145
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700146 AppWindowToken(WindowManagerService _service, IApplicationToken _token,
147 boolean _voiceInteraction) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800148 super(_service, _token.asBinder(),
149 WindowManager.LayoutParams.TYPE_APPLICATION, true);
150 appWindowToken = this;
151 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700152 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800153 mInputApplicationHandle = new InputApplicationHandle(this);
Craig Mautner322e4032012-07-13 13:35:20 -0700154 mAppAnimator = new AppWindowAnimator(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800155 }
156
157 void sendAppVisibilityToClients() {
158 final int N = allAppWindows.size();
159 for (int i=0; i<N; i++) {
160 WindowState win = allAppWindows.get(i);
161 if (win == startingWindow && clientHidden) {
162 // Don't hide the starting window.
163 continue;
164 }
165 try {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800166 if (DEBUG_VISIBILITY) Slog.v(TAG,
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800167 "Setting visibility of " + win + ": " + (!clientHidden));
168 win.mClient.dispatchAppVisibility(!clientHidden);
169 } catch (RemoteException e) {
170 }
171 }
172 }
173
Chong Zhang92147042016-05-09 12:47:11 -0700174 void setVisibleBeforeClientHidden() {
175 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
176 final WindowState w = allAppWindows.get(i);
177 w.setVisibleBeforeClientHidden();
178 }
179 }
180
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800181 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
182 firstWindowDrawn = true;
183
184 // We now have a good window to show, remove dead placeholders
185 removeAllDeadWindows();
186
187 if (startingData != null) {
188 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
189 + win.mToken + ": first real window is shown, no animation");
190 // If this initial window is animating, stop it -- we will do an animation to reveal
191 // it from behind the starting window, so there is no need for it to also be doing its
192 // own stuff.
193 winAnimator.clearAnimation();
194 winAnimator.mService.mFinishedStarting.add(this);
195 winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
196 }
197 updateReportedVisibilityLocked();
198 }
199
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800200 void updateReportedVisibilityLocked() {
201 if (appToken == null) {
202 return;
203 }
204
205 int numInteresting = 0;
206 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700207 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800208 boolean nowGone = true;
209
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800210 if (DEBUG_VISIBILITY) Slog.v(TAG,
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700211 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800212 final int N = allAppWindows.size();
213 for (int i=0; i<N; i++) {
214 WindowState win = allAppWindows.get(i);
215 if (win == startingWindow || win.mAppFreezing
216 || win.mViewVisibility != View.VISIBLE
217 || win.mAttrs.type == TYPE_APPLICATION_STARTING
218 || win.mDestroying) {
219 continue;
220 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800221 if (DEBUG_VISIBILITY) {
222 Slog.v(TAG, "Win " + win + ": isDrawn="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800223 + win.isDrawnLw()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700224 + ", isAnimationSet=" + win.mWinAnimator.isAnimationSet());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800225 if (!win.isDrawnLw()) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800226 Slog.v(TAG, "Not displayed: s=" +
Robert Carre6a83512015-11-03 16:09:21 -0800227 win.mWinAnimator.mSurfaceController
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800228 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700229 + " mDrawState=" + win.mWinAnimator.mDrawState
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800230 + " ah=" + win.mAttachedHidden
231 + " th="
232 + (win.mAppToken != null
233 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700234 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800235 }
236 }
237 numInteresting++;
238 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700239 numDrawn++;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700240 if (!win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800241 numVisible++;
242 }
243 nowGone = false;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700244 } else if (win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800245 nowGone = false;
246 }
247 }
248
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700249 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800250 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700251 if (!nowGone) {
252 // If the app is not yet gone, then it can only become visible/drawn.
253 if (!nowDrawn) {
254 nowDrawn = reportedDrawn;
255 }
256 if (!nowVisible) {
257 nowVisible = reportedVisible;
258 }
259 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800260 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800261 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700262 if (nowDrawn != reportedDrawn) {
263 if (nowDrawn) {
264 Message m = service.mH.obtainMessage(
265 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
266 service.mH.sendMessage(m);
267 }
268 reportedDrawn = nowDrawn;
269 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800270 if (nowVisible != reportedVisible) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800271 if (DEBUG_VISIBILITY) Slog.v(
272 TAG, "Visibility changed in " + this
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800273 + ": vis=" + nowVisible);
274 reportedVisible = nowVisible;
275 Message m = service.mH.obtainMessage(
276 H.REPORT_APPLICATION_TOKEN_WINDOWS,
277 nowVisible ? 1 : 0,
278 nowGone ? 1 : 0,
279 this);
280 service.mH.sendMessage(m);
281 }
282 }
283
284 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700285 WindowState candidate = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800286 int j = windows.size();
287 while (j > 0) {
288 j--;
289 WindowState win = windows.get(j);
290 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
291 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700292 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900293 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700294 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800295 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700296 candidate = win;
297 } else {
298 return win;
299 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800300 }
301 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700302 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800303 }
304
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800305 boolean windowsAreFocusable() {
306 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800307 }
308
Craig Mautner72669d12012-12-18 17:23:54 -0800309 boolean isVisible() {
310 final int N = allAppWindows.size();
Craig Mautner72669d12012-12-18 17:23:54 -0800311 for (int i=0; i<N; i++) {
312 WindowState win = allAppWindows.get(i);
Chong Zhangdb20b5f2015-10-23 14:01:43 -0700313 // If we're animating with a saved surface, we're already visible.
314 // Return true so that the alpha doesn't get cleared.
Craig Mautner72669d12012-12-18 17:23:54 -0800315 if (!win.mAppFreezing
Chong Zhang92147042016-05-09 12:47:11 -0700316 && (win.mViewVisibility == View.VISIBLE || win.isAnimatingWithSavedSurface()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700317 || (win.mWinAnimator.isAnimationSet()
Filip Gruszczynski57f76f12015-11-04 16:10:54 -0800318 && !service.mAppTransition.isTransitionSet()))
319 && !win.mDestroying
320 && win.isDrawnLw()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800321 return true;
322 }
323 }
324 return false;
325 }
326
Craig Mautnere3119b72015-01-20 15:02:36 -0800327 void removeAppFromTaskLocked() {
328 mIsExiting = false;
329 removeAllWindows();
330
Craig Mautner83162a92015-01-26 14:43:30 -0800331 // Use local variable because removeAppToken will null out mTask.
332 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800333 if (task != null) {
334 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800335 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800336 + " not found.");
337 }
338 task.mStack.mExitingAppTokens.remove(this);
339 }
340 }
341
Chong Zhange05bcb12016-07-26 17:47:29 -0700342 void clearAnimatingFlags() {
343 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
344 final WindowState win = allAppWindows.get(i);
345 // We don't want to clear it out for windows that get replaced, because the
346 // animation depends on the flag to remove the replaced window.
347 //
348 // We also don't clear the mAnimatingExit flag for windows which have the
349 // mRemoveOnExit flag. This indicates an explicit remove request has been issued
350 // by the client. We should let animation proceed and not clear this flag or
351 // they won't eventually be removed by WindowStateAnimator#finishExit.
352 if (!win.mWillReplaceWindow && !win.mRemoveOnExit) {
353 win.mAnimatingExit = false;
354 // Clear mAnimating flag together with mAnimatingExit. When animation
355 // changes from exiting to entering, we need to clear this flag until the
356 // new animation gets applied, so that isAnimationStarting() becomes true
357 // until then.
358 // Otherwise applySurfaceChangesTransaction will faill to skip surface
359 // placement for this window during this period, one or more frame will
360 // show up with wrong position or scale.
361 win.mWinAnimator.mAnimating = false;
Wale Ogunwale3c0d44e2016-08-11 09:34:45 -0700362
363 if (win.mDestroying) {
364 win.mDestroying = false;
365 service.mDestroySurface.remove(win);
366 }
Chong Zhange05bcb12016-07-26 17:47:29 -0700367 }
368 }
Chong Zhang808621c2016-07-29 13:09:40 -0700369 requestUpdateWallpaperIfNeeded();
Chong Zhange05bcb12016-07-26 17:47:29 -0700370 }
371
Robert Carre12aece2016-02-02 22:43:27 -0800372 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700373 destroySurfaces(false /*cleanupOnResume*/);
374 }
375
376 /**
377 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
378 * the client has finished with them.
379 *
380 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
381 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
382 * others so that they are ready to be reused. If set to false (common case), destroy all
383 * surfaces that's eligible, if the app is already stopped.
384 */
385
386 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800387 final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone();
388 final DisplayContentList displayList = new DisplayContentList();
389 for (int i = allWindows.size() - 1; i >= 0; i--) {
390 final WindowState win = allWindows.get(i);
Chong Zhangeb665572016-05-09 18:28:27 -0700391
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700392 if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) {
Robert Carre12aece2016-02-02 22:43:27 -0800393 continue;
394 }
395
Chong Zhangeb665572016-05-09 18:28:27 -0700396 win.mWinAnimator.destroyPreservedSurfaceLocked();
397
398 if (!win.mDestroying) {
Chong Zhang5471e902016-02-12 15:34:10 -0800399 continue;
Robert Carre12aece2016-02-02 22:43:27 -0800400 }
401
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800402 if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win
403 + " destroySurfaces: mAppStopped=" + mAppStopped
404 + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed
405 + " win.mRemoveOnExit=" + win.mRemoveOnExit);
406
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700407 if (!cleanupOnResume || win.mRemoveOnExit) {
408 win.destroyOrSaveSurface();
409 }
Robert Carre12aece2016-02-02 22:43:27 -0800410 if (win.mRemoveOnExit) {
Robert Carre12aece2016-02-02 22:43:27 -0800411 service.removeWindowInnerLocked(win);
412 }
413 final DisplayContent displayContent = win.getDisplayContent();
414 if (displayContent != null && !displayList.contains(displayContent)) {
415 displayList.add(displayContent);
416 }
Chong Zhang808621c2016-07-29 13:09:40 -0700417 if (cleanupOnResume) {
418 win.requestUpdateWallpaperIfNeeded();
419 }
Robert Carre12aece2016-02-02 22:43:27 -0800420 win.mDestroying = false;
421 }
422 for (int i = 0; i < displayList.size(); i++) {
423 final DisplayContent displayContent = displayList.get(i);
424 service.mLayersController.assignLayersLocked(displayContent.getWindowList());
425 displayContent.layoutNeeded = true;
426 }
427 }
428
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800429 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700430 * Notify that the app is now resumed, and it was not stopped before, perform a clean
431 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800432 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700433 void notifyAppResumed(boolean wasStopped) {
434 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this);
435 mAppStopped = false;
436 if (!wasStopped) {
437 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800438 }
Robert Carre12aece2016-02-02 22:43:27 -0800439 }
440
Chong Zhangbef461f2015-10-27 11:38:24 -0700441 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700442 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
443 * keeping alive in case they were still being used.
444 */
445 void notifyAppStopped() {
446 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
447 mAppStopped = true;
448 destroySurfaces();
449 // Remove any starting window that was added for this app if they are still around.
450 mTask.mService.scheduleRemoveStartingWindowLocked(this);
451 }
452
453 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700454 * Checks whether we should save surfaces for this app.
455 *
456 * @return true if the surfaces should be saved, false otherwise.
457 */
458 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800459 // We want to save surface if the app's windows are "allDrawn".
460 // (If we started entering animation early with saved surfaces, allDrawn
461 // should have been restored to true. So we'll save again in that case
462 // even if app didn't actually finish drawing.)
463 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800464 }
465
Chong Zhang92147042016-05-09 12:47:11 -0700466 boolean canRestoreSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700467 for (int i = allAppWindows.size() -1; i >= 0; i--) {
Chong Zhang92147042016-05-09 12:47:11 -0700468 final WindowState w = allAppWindows.get(i);
469 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800470 return true;
471 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700472 }
473 return false;
474 }
475
Chong Zhang92147042016-05-09 12:47:11 -0700476 void clearVisibleBeforeClientHidden() {
477 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
478 final WindowState w = allAppWindows.get(i);
479 w.clearVisibleBeforeClientHidden();
480 }
481 }
482
Chong Zhang8e4bda92016-05-04 15:08:18 -0700483 /**
484 * Whether the app has some window that is invisible in layout, but
485 * animating with saved surface.
486 */
487 boolean isAnimatingInvisibleWithSavedSurface() {
488 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
489 final WindowState w = allAppWindows.get(i);
490 if (w.isAnimatingInvisibleWithSavedSurface()) {
491 return true;
492 }
493 }
494 return false;
495 }
496
497 /**
498 * Hide all window surfaces that's still invisible in layout but animating
499 * with a saved surface, and mark them destroying.
500 */
501 void stopUsingSavedSurfaceLocked() {
502 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
503 final WindowState w = allAppWindows.get(i);
504 if (w.isAnimatingInvisibleWithSavedSurface()) {
505 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
506 "stopUsingSavedSurfaceLocked: " + w);
507 w.clearAnimatingWithSavedSurface();
508 w.mDestroying = true;
509 w.mWinAnimator.hide("stopUsingSavedSurfaceLocked");
510 w.mWinAnimator.mWallpaperControllerLocked.hideWallpapers(w);
511 }
512 }
513 destroySurfaces();
514 }
515
Chong Zhangf58631a2016-05-24 16:02:10 -0700516 void markSavedSurfaceExiting() {
517 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
518 final WindowState w = allAppWindows.get(i);
519 if (w.isAnimatingInvisibleWithSavedSurface()) {
520 w.mAnimatingExit = true;
521 w.mWinAnimator.mAnimating = true;
522 }
523 }
524 }
525
Chong Zhangbef461f2015-10-27 11:38:24 -0700526 void restoreSavedSurfaces() {
Chong Zhang92147042016-05-09 12:47:11 -0700527 if (!canRestoreSurfaces()) {
528 clearVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700529 return;
530 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800531 // Check if we have enough drawn windows to mark allDrawn= true.
532 int numInteresting = 0;
533 int numDrawn = 0;
Chong Zhangb7b4a562016-04-28 15:30:33 -0700534 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
535 WindowState w = allAppWindows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700536 if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800537 && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
538 numInteresting++;
Chong Zhang92147042016-05-09 12:47:11 -0700539 if (w.hasSavedSurface()) {
540 w.restoreSavedSurface();
541 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800542 if (w.isDrawnLw()) {
543 numDrawn++;
544 }
545 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700546 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800547
Chong Zhang92147042016-05-09 12:47:11 -0700548 if (!allDrawn) {
549 allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
550 if (allDrawn) {
551 service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
552 }
553 }
554 clearVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800555
556 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Chong Zhang92147042016-05-09 12:47:11 -0700557 "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn
558 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700559 }
560
561 void destroySavedSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700562 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
563 WindowState win = allAppWindows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800564 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700565 }
Chong Zhang92147042016-05-09 12:47:11 -0700566 }
567
568 void clearAllDrawn() {
569 allDrawn = false;
570 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700571 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700572 }
573
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800574 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700575 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800576 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
577 // removeWindowLocked at bottom of loop may remove multiple entries from
578 // allAppWindows if the window to be removed has child windows. It also may
579 // not remove any windows from allAppWindows at all if win is exiting and
580 // currently animating away. This ensures that winNdx is monotonically decreasing
581 // and never beyond allAppWindows bounds.
582 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
583 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800584 if (DEBUG_WINDOW_MOVEMENT) {
585 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800586 }
587
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700588 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700589 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800590 allAppWindows.clear();
591 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700592 }
593
Chong Zhang112eb8c2015-11-02 11:17:00 -0800594 void removeAllDeadWindows() {
595 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700596 // removeWindowLocked at bottom of loop may remove multiple entries from
597 // allAppWindows if the window to be removed has child windows. It also may
598 // not remove any windows from allAppWindows at all if win is exiting and
599 // currently animating away. This ensures that winNdx is monotonically decreasing
600 // and never beyond allAppWindows bounds.
601 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800602 WindowState win = allAppWindows.get(winNdx);
603 if (win.mAppDied) {
Wale Ogunwale2728bf42016-03-03 11:03:26 -0800604 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800605 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800606 }
607 // Set mDestroying, we don't want any animation or delayed removal here.
608 win.mDestroying = true;
609 service.removeWindowLocked(win);
610 }
611 }
612 }
613
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700614 boolean hasWindowsAlive() {
615 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
616 if (!allAppWindows.get(i).mAppDied) {
617 return true;
618 }
619 }
620 return false;
621 }
622
Robert Carra1eb4392015-12-10 12:43:51 -0800623 void setReplacingWindows(boolean animate) {
624 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
625 + " with replacing windows.");
626
627 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
628 final WindowState w = allAppWindows.get(i);
629 w.setReplacing(animate);
630 }
631 if (animate) {
632 // Set-up dummy animation so we can start treating windows associated with this
633 // token like they are in transition before the new app window is ready for us to
634 // run the real transition animation.
635 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
636 "setReplacingWindow() Setting dummy animation on: " + this);
637 mAppAnimator.setDummyAnimation();
638 }
639 }
640
Robert Carr23fa16b2016-01-13 13:19:58 -0800641 void setReplacingChildren() {
642 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
643 + " with replacing child windows.");
644 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
645 final WindowState w = allAppWindows.get(i);
Robert Carrd1a010f2016-04-07 22:36:22 -0700646 if (w.shouldBeReplacedWithChildren()) {
Robert Carr23fa16b2016-01-13 13:19:58 -0800647 w.setReplacing(false /* animate */);
648 }
649 }
650 }
651
Chong Zhangf596cd52016-01-05 13:42:44 -0800652 void resetReplacingWindows() {
653 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Resetting app token " + appWindowToken
654 + " of replacing window marks.");
655
656 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
657 final WindowState w = allAppWindows.get(i);
658 w.resetReplacing();
659 }
660 }
661
Chong Zhang4d7369a2016-04-25 16:09:14 -0700662 void requestUpdateWallpaperIfNeeded() {
663 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
664 final WindowState w = allAppWindows.get(i);
665 w.requestUpdateWallpaperIfNeeded();
666 }
667 }
668
Chong Zhangd78ddb42016-03-02 17:01:14 -0800669 boolean isRelaunching() {
670 return mPendingRelaunchCount > 0;
671 }
672
673 void startRelaunching() {
674 if (canFreezeBounds()) {
675 freezeBounds();
676 }
677 mPendingRelaunchCount++;
678 }
679
680 void finishRelaunching() {
681 if (canFreezeBounds()) {
682 unfreezeBounds();
683 }
684 if (mPendingRelaunchCount > 0) {
685 mPendingRelaunchCount--;
686 }
687 }
688
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700689 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700690 if (mPendingRelaunchCount == 0) {
691 return;
692 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700693 if (canFreezeBounds()) {
694 unfreezeBounds();
695 }
696 mPendingRelaunchCount = 0;
697 }
698
Robert Carra1eb4392015-12-10 12:43:51 -0800699 void addWindow(WindowState w) {
700 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
701 WindowState candidate = allAppWindows.get(i);
702 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
Robert Carr8bc89072016-04-08 13:29:59 -0700703 candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) {
Robert Carra1eb4392015-12-10 12:43:51 -0800704 candidate.mReplacingWindow = w;
Robert Carrb439a632016-04-07 22:52:10 -0700705 w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
Chong Zhangf596cd52016-01-05 13:42:44 -0800706
707 // if we got a replacement window, reset the timeout to give drawing more time
Chong Zhang32de3652016-05-12 16:00:01 -0700708 service.scheduleReplacingWindowTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800709 }
710 }
711 allAppWindows.add(w);
712 }
713
714 boolean waitingForReplacement() {
715 for (int i = allAppWindows.size() -1; i >= 0; i--) {
716 WindowState candidate = allAppWindows.get(i);
717 if (candidate.mWillReplaceWindow) {
718 return true;
719 }
720 }
721 return false;
722 }
723
Chong Zhangf596cd52016-01-05 13:42:44 -0800724 void clearTimedoutReplacesLocked() {
Robert Carra1eb4392015-12-10 12:43:51 -0800725 for (int i = allAppWindows.size() - 1; i >= 0;
726 // removeWindowLocked at bottom of loop may remove multiple entries from
727 // allAppWindows if the window to be removed has child windows. It also may
728 // not remove any windows from allAppWindows at all if win is exiting and
729 // currently animating away. This ensures that winNdx is monotonically decreasing
730 // and never beyond allAppWindows bounds.
731 i = Math.min(i - 1, allAppWindows.size() - 1)) {
732 WindowState candidate = allAppWindows.get(i);
733 if (candidate.mWillReplaceWindow == false) {
734 continue;
735 }
736 candidate.mWillReplaceWindow = false;
Robert Carrb439a632016-04-07 22:52:10 -0700737 if (candidate.mReplacingWindow != null) {
738 candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false;
739 }
Chong Zhangf596cd52016-01-05 13:42:44 -0800740 // Since the window already timed out, remove it immediately now.
741 // Use removeWindowInnerLocked() instead of removeWindowLocked(), as the latter
742 // delays removal on certain conditions, which will leave the stale window in the
743 // stack and marked mWillReplaceWindow=false, so the window will never be removed.
744 service.removeWindowInnerLocked(candidate);
Robert Carra1eb4392015-12-10 12:43:51 -0800745 }
746 }
747
Chong Zhangd78ddb42016-03-02 17:01:14 -0800748 private boolean canFreezeBounds() {
749 // For freeform windows, we can't freeze the bounds at the moment because this would make
750 // the resizing unresponsive.
751 return mTask != null && !mTask.inFreeformWorkspace();
752 }
753
Jorim Jaggi0429f352015-12-22 16:29:16 +0100754 /**
755 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
756 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
757 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
758 * with a queue.
759 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800760 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100761 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700762
763 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
764 // We didn't call prepareFreezingBounds on the task, so use the current value.
765 final Configuration config = new Configuration(service.mCurConfiguration);
766 config.updateFrom(mTask.mOverrideConfig);
767 mFrozenMergedConfig.offer(config);
768 } else {
769 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
770 }
771 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100772 }
773
774 /**
775 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
776 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800777 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700778 if (!mFrozenBounds.isEmpty()) {
779 mFrozenBounds.remove();
780 }
781 if (!mFrozenMergedConfig.isEmpty()) {
782 mFrozenMergedConfig.remove();
783 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100784 for (int i = windows.size() - 1; i >= 0; i--) {
785 final WindowState win = windows.get(i);
Jorim Jaggi69abc192016-02-04 19:34:00 -0800786 if (!win.mHasSurface) {
787 continue;
788 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100789 win.mLayoutNeeded = true;
790 win.setDisplayLayoutNeeded();
791 if (!service.mResizingWindows.contains(win)) {
792 service.mResizingWindows.add(win);
793 }
794 }
795 service.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100796 }
797
Robert Carr91b228092016-06-28 17:32:37 -0700798 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
799 mSurfaceViewBackgrounds.add(background);
800 }
801
802 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
803 mSurfaceViewBackgrounds.remove(background);
804 updateSurfaceViewBackgroundVisibilities();
805 }
806
807 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
808 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
809 // below the main app window (as traditionally a SurfaceView which is never drawn
810 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
811 // the background for the SurfaceView with lowest Z order
812 void updateSurfaceViewBackgroundVisibilities() {
813 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
814 int bottomLayer = Integer.MAX_VALUE;
815 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
816 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
817 if (sc.mVisible && sc.mLayer < bottomLayer) {
818 bottomLayer = sc.mLayer;
819 bottom = sc;
820 }
821 }
822 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
823 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
824 sc.updateBackgroundVisibility(sc != bottom);
825 }
826 }
827
Craig Mautnerdbb79912012-03-01 18:59:14 -0800828 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800829 void dump(PrintWriter pw, String prefix) {
830 super.dump(pw, prefix);
831 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700832 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800833 }
834 if (allAppWindows.size() > 0) {
835 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
836 }
Craig Mautner83162a92015-01-26 14:43:30 -0800837 pw.print(prefix); pw.print("task="); pw.println(mTask);
838 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800839 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
840 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
841 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700842 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800843 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700844 if (paused) {
845 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800846 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800847 if (mAppStopped) {
848 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
849 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800850 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700851 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800852 pw.print(prefix); pw.print("numInterestingWindows=");
853 pw.print(numInterestingWindows);
854 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
855 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700856 pw.print(" allDrawn="); pw.print(allDrawn);
857 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
858 pw.println(")");
859 }
860 if (inPendingTransaction) {
861 pw.print(prefix); pw.print("inPendingTransaction=");
862 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800863 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800864 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800865 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
866 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800867 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800868 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800869 }
870 if (startingWindow != null || startingView != null
871 || startingDisplayed || startingMoved) {
872 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
873 pw.print(" startingView="); pw.print(startingView);
874 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800875 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800876 }
Jorim Jaggi0429f352015-12-22 16:29:16 +0100877 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -0800878 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700879 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -0800880 }
881 if (mPendingRelaunchCount != 0) {
882 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +0100883 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800884 }
885
886 @Override
887 public String toString() {
888 if (stringName == null) {
889 StringBuilder sb = new StringBuilder();
890 sb.append("AppWindowToken{");
891 sb.append(Integer.toHexString(System.identityHashCode(this)));
892 sb.append(" token="); sb.append(token); sb.append('}');
893 stringName = sb.toString();
894 }
895 return stringName;
896 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700897}