blob: f4bb47901f76171d1d3850dec322312dc266b1d6 [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 Zhang92147042016-05-09 12:47:11 -070029import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080030
Jeff Brown4532e612012-04-05 14:27:12 -070031import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080032import com.android.server.wm.WindowManagerService.H;
33
Filip Gruszczynskia590c992015-11-25 16:45:26 -080034import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080035import android.content.pm.ActivityInfo;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070036import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010037import android.graphics.Rect;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080038import android.os.Message;
39import android.os.RemoteException;
40import android.util.Slog;
41import android.view.IApplicationToken;
42import android.view.View;
43import android.view.WindowManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080044
45import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010046import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080047import java.util.ArrayList;
48
49class AppTokenList extends ArrayList<AppWindowToken> {
50}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080051
52/**
53 * Version of WindowToken that is specifically for a particular application (or
54 * really activity) that is displaying windows.
55 */
Craig Mautnere32c3072012-03-12 15:25:35 -070056class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080057 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
58
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080059 // Non-null only for application tokens.
60 final IApplicationToken appToken;
61
62 // All of the windows and child windows that are included in this
63 // application token. Note this list is NOT sorted!
Craig Mautner96868332012-12-04 14:29:11 -080064 final WindowList allAppWindows = new WindowList();
Filip Gruszczynskia590c992015-11-25 16:45:26 -080065 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070066
Dianne Hackborne30e02f2014-05-27 18:24:45 -070067 final boolean voiceInteraction;
68
Craig Mautner83162a92015-01-26 14:43:30 -080069 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080070 boolean appFullscreen;
71 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080072 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070073 boolean showForAllUsers;
Yorke Lee0e852472016-06-15 10:03:18 -070074 int targetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070075
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080076 // The input dispatching timeout for this application token in nanoseconds.
77 long inputDispatchingTimeoutNanos;
78
79 // These are used for determining when all windows associated with
80 // an activity have been drawn, so they can be made visible together
81 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070082 // initialize so that it doesn't match mTransactionSequence which is an int.
83 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080084 int numInterestingWindows;
85 int numDrawnWindows;
86 boolean inPendingTransaction;
87 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080088 // Set to true when this app creates a surface while in the middle of an animation. In that
89 // case do not clear allDrawn until the animation completes.
90 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080091
Chong Zhang8e4bda92016-05-04 15:08:18 -070092 // These are to track the app's real drawing status if there were no saved surfaces.
93 boolean allDrawnExcludingSaved;
94 int numInterestingWindowsExcludingSaved;
95 int numDrawnWindowsExclusingSaved;
96
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080097 // Is this window's surface needed? This is almost like hidden, except
98 // it will sometimes be true a little earlier: when the token has
99 // been shown, but is still waiting for its app transition to execute
100 // before making its windows shown.
101 boolean hiddenRequested;
102
103 // Have we told the window clients to hide themselves?
104 boolean clientHidden;
105
106 // Last visibility state we reported to the app token.
107 boolean reportedVisible;
108
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700109 // Last drawn state we reported to the app token.
110 boolean reportedDrawn;
111
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800112 // Set to true when the token has been removed from the window mgr.
113 boolean removed;
114
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800115 // Information about an application starting window if displayed.
116 StartingData startingData;
117 WindowState startingWindow;
118 View startingView;
119 boolean startingDisplayed;
120 boolean startingMoved;
121 boolean firstWindowDrawn;
122
123 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700124 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800125
Craig Mautner799bc1d2015-01-14 10:33:48 -0800126 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800127
Craig Mautnerbb742462014-07-07 15:28:55 -0700128 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700129 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700130
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800131 boolean mAlwaysFocusable;
132
Robert Carre12aece2016-02-02 22:43:27 -0800133 boolean mAppStopped;
Robert Carrfd10cd12016-06-29 16:41:50 -0700134 int mRotationAnimationHint;
Chong Zhangd78ddb42016-03-02 17:01:14 -0800135 int mPendingRelaunchCount;
Robert Carre12aece2016-02-02 22:43:27 -0800136
Robert Carr91b228092016-06-28 17:32:37 -0700137 private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds =
138 new ArrayList<WindowSurfaceController.SurfaceControlWithBackground>();
139
Jorim Jaggi0429f352015-12-22 16:29:16 +0100140 ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700141 ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100142
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700143 AppWindowToken(WindowManagerService _service, IApplicationToken _token,
144 boolean _voiceInteraction) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800145 super(_service, _token.asBinder(),
146 WindowManager.LayoutParams.TYPE_APPLICATION, true);
147 appWindowToken = this;
148 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700149 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800150 mInputApplicationHandle = new InputApplicationHandle(this);
Craig Mautner322e4032012-07-13 13:35:20 -0700151 mAppAnimator = new AppWindowAnimator(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800152 }
153
154 void sendAppVisibilityToClients() {
155 final int N = allAppWindows.size();
156 for (int i=0; i<N; i++) {
157 WindowState win = allAppWindows.get(i);
158 if (win == startingWindow && clientHidden) {
159 // Don't hide the starting window.
160 continue;
161 }
162 try {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800163 if (DEBUG_VISIBILITY) Slog.v(TAG,
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800164 "Setting visibility of " + win + ": " + (!clientHidden));
165 win.mClient.dispatchAppVisibility(!clientHidden);
166 } catch (RemoteException e) {
167 }
168 }
169 }
170
Chong Zhang92147042016-05-09 12:47:11 -0700171 void setVisibleBeforeClientHidden() {
172 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
173 final WindowState w = allAppWindows.get(i);
174 w.setVisibleBeforeClientHidden();
175 }
176 }
177
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800178 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
179 firstWindowDrawn = true;
180
181 // We now have a good window to show, remove dead placeholders
182 removeAllDeadWindows();
183
184 if (startingData != null) {
185 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
186 + win.mToken + ": first real window is shown, no animation");
187 // If this initial window is animating, stop it -- we will do an animation to reveal
188 // it from behind the starting window, so there is no need for it to also be doing its
189 // own stuff.
190 winAnimator.clearAnimation();
191 winAnimator.mService.mFinishedStarting.add(this);
192 winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
193 }
194 updateReportedVisibilityLocked();
195 }
196
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800197 void updateReportedVisibilityLocked() {
198 if (appToken == null) {
199 return;
200 }
201
202 int numInteresting = 0;
203 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700204 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800205 boolean nowGone = true;
206
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800207 if (DEBUG_VISIBILITY) Slog.v(TAG,
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700208 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800209 final int N = allAppWindows.size();
210 for (int i=0; i<N; i++) {
211 WindowState win = allAppWindows.get(i);
212 if (win == startingWindow || win.mAppFreezing
213 || win.mViewVisibility != View.VISIBLE
214 || win.mAttrs.type == TYPE_APPLICATION_STARTING
215 || win.mDestroying) {
216 continue;
217 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800218 if (DEBUG_VISIBILITY) {
219 Slog.v(TAG, "Win " + win + ": isDrawn="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800220 + win.isDrawnLw()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700221 + ", isAnimationSet=" + win.mWinAnimator.isAnimationSet());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800222 if (!win.isDrawnLw()) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800223 Slog.v(TAG, "Not displayed: s=" +
Robert Carre6a83512015-11-03 16:09:21 -0800224 win.mWinAnimator.mSurfaceController
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800225 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700226 + " mDrawState=" + win.mWinAnimator.mDrawState
Wale Ogunwale9d147902016-07-16 11:58:55 -0700227 + " ph=" + win.isParentWindowHidden()
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800228 + " th="
229 + (win.mAppToken != null
230 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700231 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800232 }
233 }
234 numInteresting++;
235 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700236 numDrawn++;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700237 if (!win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800238 numVisible++;
239 }
240 nowGone = false;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700241 } else if (win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800242 nowGone = false;
243 }
244 }
245
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700246 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800247 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700248 if (!nowGone) {
249 // If the app is not yet gone, then it can only become visible/drawn.
250 if (!nowDrawn) {
251 nowDrawn = reportedDrawn;
252 }
253 if (!nowVisible) {
254 nowVisible = reportedVisible;
255 }
256 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800257 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800258 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700259 if (nowDrawn != reportedDrawn) {
260 if (nowDrawn) {
261 Message m = service.mH.obtainMessage(
262 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
263 service.mH.sendMessage(m);
264 }
265 reportedDrawn = nowDrawn;
266 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800267 if (nowVisible != reportedVisible) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800268 if (DEBUG_VISIBILITY) Slog.v(
269 TAG, "Visibility changed in " + this
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800270 + ": vis=" + nowVisible);
271 reportedVisible = nowVisible;
272 Message m = service.mH.obtainMessage(
273 H.REPORT_APPLICATION_TOKEN_WINDOWS,
274 nowVisible ? 1 : 0,
275 nowGone ? 1 : 0,
276 this);
277 service.mH.sendMessage(m);
278 }
279 }
280
281 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700282 WindowState candidate = null;
Wale Ogunwale455fac52016-07-21 07:24:49 -0700283 int j = allAppWindows.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800284 while (j > 0) {
285 j--;
Wale Ogunwale455fac52016-07-21 07:24:49 -0700286 WindowState win = allAppWindows.get(j);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800287 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
288 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700289 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900290 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700291 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800292 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700293 candidate = win;
294 } else {
295 return win;
296 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800297 }
298 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700299 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800300 }
301
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800302 boolean windowsAreFocusable() {
303 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800304 }
305
Craig Mautner72669d12012-12-18 17:23:54 -0800306 boolean isVisible() {
307 final int N = allAppWindows.size();
Craig Mautner72669d12012-12-18 17:23:54 -0800308 for (int i=0; i<N; i++) {
309 WindowState win = allAppWindows.get(i);
Chong Zhangdb20b5f2015-10-23 14:01:43 -0700310 // If we're animating with a saved surface, we're already visible.
311 // Return true so that the alpha doesn't get cleared.
Craig Mautner72669d12012-12-18 17:23:54 -0800312 if (!win.mAppFreezing
Chong Zhang92147042016-05-09 12:47:11 -0700313 && (win.mViewVisibility == View.VISIBLE || win.isAnimatingWithSavedSurface()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700314 || (win.mWinAnimator.isAnimationSet()
Filip Gruszczynski57f76f12015-11-04 16:10:54 -0800315 && !service.mAppTransition.isTransitionSet()))
316 && !win.mDestroying
317 && win.isDrawnLw()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800318 return true;
319 }
320 }
321 return false;
322 }
323
Craig Mautnere3119b72015-01-20 15:02:36 -0800324 void removeAppFromTaskLocked() {
325 mIsExiting = false;
326 removeAllWindows();
327
Craig Mautner83162a92015-01-26 14:43:30 -0800328 // Use local variable because removeAppToken will null out mTask.
329 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800330 if (task != null) {
331 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800332 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800333 + " not found.");
334 }
335 task.mStack.mExitingAppTokens.remove(this);
336 }
337 }
338
Chong Zhange05bcb12016-07-26 17:47:29 -0700339 void clearAnimatingFlags() {
340 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
341 final WindowState win = allAppWindows.get(i);
342 // We don't want to clear it out for windows that get replaced, because the
343 // animation depends on the flag to remove the replaced window.
344 //
345 // We also don't clear the mAnimatingExit flag for windows which have the
346 // mRemoveOnExit flag. This indicates an explicit remove request has been issued
347 // by the client. We should let animation proceed and not clear this flag or
348 // they won't eventually be removed by WindowStateAnimator#finishExit.
349 if (!win.mWillReplaceWindow && !win.mRemoveOnExit) {
350 win.mAnimatingExit = false;
351 // Clear mAnimating flag together with mAnimatingExit. When animation
352 // changes from exiting to entering, we need to clear this flag until the
353 // new animation gets applied, so that isAnimationStarting() becomes true
354 // until then.
355 // Otherwise applySurfaceChangesTransaction will faill to skip surface
356 // placement for this window during this period, one or more frame will
357 // show up with wrong position or scale.
358 win.mWinAnimator.mAnimating = false;
359 }
360 }
361 }
362
Robert Carre12aece2016-02-02 22:43:27 -0800363 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700364 destroySurfaces(false /*cleanupOnResume*/);
365 }
366
367 /**
368 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
369 * the client has finished with them.
370 *
371 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
372 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
373 * others so that they are ready to be reused. If set to false (common case), destroy all
374 * surfaces that's eligible, if the app is already stopped.
375 */
376
377 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800378 final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone();
379 final DisplayContentList displayList = new DisplayContentList();
380 for (int i = allWindows.size() - 1; i >= 0; i--) {
381 final WindowState win = allWindows.get(i);
Chong Zhangeb665572016-05-09 18:28:27 -0700382
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700383 if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) {
Robert Carre12aece2016-02-02 22:43:27 -0800384 continue;
385 }
386
Chong Zhangeb665572016-05-09 18:28:27 -0700387 win.mWinAnimator.destroyPreservedSurfaceLocked();
388
389 if (!win.mDestroying) {
Chong Zhang5471e902016-02-12 15:34:10 -0800390 continue;
Robert Carre12aece2016-02-02 22:43:27 -0800391 }
392
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800393 if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win
394 + " destroySurfaces: mAppStopped=" + mAppStopped
395 + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed
396 + " win.mRemoveOnExit=" + win.mRemoveOnExit);
397
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700398 if (!cleanupOnResume || win.mRemoveOnExit) {
399 win.destroyOrSaveSurface();
400 }
Robert Carre12aece2016-02-02 22:43:27 -0800401 if (win.mRemoveOnExit) {
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700402 win.remove();
Robert Carre12aece2016-02-02 22:43:27 -0800403 }
404 final DisplayContent displayContent = win.getDisplayContent();
405 if (displayContent != null && !displayList.contains(displayContent)) {
406 displayList.add(displayContent);
407 }
408 win.mDestroying = false;
409 }
410 for (int i = 0; i < displayList.size(); i++) {
411 final DisplayContent displayContent = displayList.get(i);
412 service.mLayersController.assignLayersLocked(displayContent.getWindowList());
413 displayContent.layoutNeeded = true;
414 }
415 }
416
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800417 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700418 * Notify that the app is now resumed, and it was not stopped before, perform a clean
419 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800420 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700421 void notifyAppResumed(boolean wasStopped) {
422 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this);
423 mAppStopped = false;
424 if (!wasStopped) {
425 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800426 }
Robert Carre12aece2016-02-02 22:43:27 -0800427 }
428
Chong Zhangbef461f2015-10-27 11:38:24 -0700429 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700430 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
431 * keeping alive in case they were still being used.
432 */
433 void notifyAppStopped() {
434 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
435 mAppStopped = true;
436 destroySurfaces();
437 // Remove any starting window that was added for this app if they are still around.
438 mTask.mService.scheduleRemoveStartingWindowLocked(this);
439 }
440
441 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700442 * Checks whether we should save surfaces for this app.
443 *
444 * @return true if the surfaces should be saved, false otherwise.
445 */
446 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800447 // We want to save surface if the app's windows are "allDrawn".
448 // (If we started entering animation early with saved surfaces, allDrawn
449 // should have been restored to true. So we'll save again in that case
450 // even if app didn't actually finish drawing.)
451 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800452 }
453
Chong Zhang92147042016-05-09 12:47:11 -0700454 boolean canRestoreSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700455 for (int i = allAppWindows.size() -1; i >= 0; i--) {
Chong Zhang92147042016-05-09 12:47:11 -0700456 final WindowState w = allAppWindows.get(i);
457 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800458 return true;
459 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700460 }
461 return false;
462 }
463
Chong Zhang92147042016-05-09 12:47:11 -0700464 void clearVisibleBeforeClientHidden() {
465 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
466 final WindowState w = allAppWindows.get(i);
467 w.clearVisibleBeforeClientHidden();
468 }
469 }
470
Chong Zhang8e4bda92016-05-04 15:08:18 -0700471 /**
472 * Whether the app has some window that is invisible in layout, but
473 * animating with saved surface.
474 */
475 boolean isAnimatingInvisibleWithSavedSurface() {
476 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
477 final WindowState w = allAppWindows.get(i);
478 if (w.isAnimatingInvisibleWithSavedSurface()) {
479 return true;
480 }
481 }
482 return false;
483 }
484
485 /**
486 * Hide all window surfaces that's still invisible in layout but animating
487 * with a saved surface, and mark them destroying.
488 */
489 void stopUsingSavedSurfaceLocked() {
490 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
491 final WindowState w = allAppWindows.get(i);
492 if (w.isAnimatingInvisibleWithSavedSurface()) {
493 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
494 "stopUsingSavedSurfaceLocked: " + w);
495 w.clearAnimatingWithSavedSurface();
496 w.mDestroying = true;
497 w.mWinAnimator.hide("stopUsingSavedSurfaceLocked");
498 w.mWinAnimator.mWallpaperControllerLocked.hideWallpapers(w);
499 }
500 }
501 destroySurfaces();
502 }
503
Chong Zhangf58631a2016-05-24 16:02:10 -0700504 void markSavedSurfaceExiting() {
505 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
506 final WindowState w = allAppWindows.get(i);
507 if (w.isAnimatingInvisibleWithSavedSurface()) {
508 w.mAnimatingExit = true;
509 w.mWinAnimator.mAnimating = true;
510 }
511 }
512 }
513
Chong Zhangbef461f2015-10-27 11:38:24 -0700514 void restoreSavedSurfaces() {
Chong Zhang92147042016-05-09 12:47:11 -0700515 if (!canRestoreSurfaces()) {
516 clearVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700517 return;
518 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800519 // Check if we have enough drawn windows to mark allDrawn= true.
520 int numInteresting = 0;
521 int numDrawn = 0;
Chong Zhangb7b4a562016-04-28 15:30:33 -0700522 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
523 WindowState w = allAppWindows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700524 if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800525 && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
526 numInteresting++;
Chong Zhang92147042016-05-09 12:47:11 -0700527 if (w.hasSavedSurface()) {
528 w.restoreSavedSurface();
529 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800530 if (w.isDrawnLw()) {
531 numDrawn++;
532 }
533 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700534 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800535
Chong Zhang92147042016-05-09 12:47:11 -0700536 if (!allDrawn) {
537 allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
538 if (allDrawn) {
539 service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
540 }
541 }
542 clearVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800543
544 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Wale Ogunwale455fac52016-07-21 07:24:49 -0700545 "restoreSavedSurfaces: " + this + " allDrawn=" + allDrawn
Chong Zhang92147042016-05-09 12:47:11 -0700546 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700547 }
548
549 void destroySavedSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700550 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
551 WindowState win = allAppWindows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800552 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700553 }
Chong Zhang92147042016-05-09 12:47:11 -0700554 }
555
556 void clearAllDrawn() {
557 allDrawn = false;
558 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700559 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700560 }
561
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800562 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700563 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800564 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
565 // removeWindowLocked at bottom of loop may remove multiple entries from
566 // allAppWindows if the window to be removed has child windows. It also may
567 // not remove any windows from allAppWindows at all if win is exiting and
568 // currently animating away. This ensures that winNdx is monotonically decreasing
569 // and never beyond allAppWindows bounds.
570 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
571 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800572 if (DEBUG_WINDOW_MOVEMENT) {
573 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800574 }
575
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700576 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700577 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800578 allAppWindows.clear();
579 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700580 }
581
Chong Zhang112eb8c2015-11-02 11:17:00 -0800582 void removeAllDeadWindows() {
583 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700584 // removeWindowLocked at bottom of loop may remove multiple entries from
585 // allAppWindows if the window to be removed has child windows. It also may
586 // not remove any windows from allAppWindows at all if win is exiting and
587 // currently animating away. This ensures that winNdx is monotonically decreasing
588 // and never beyond allAppWindows bounds.
589 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800590 WindowState win = allAppWindows.get(winNdx);
591 if (win.mAppDied) {
Wale Ogunwale2728bf42016-03-03 11:03:26 -0800592 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800593 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800594 }
595 // Set mDestroying, we don't want any animation or delayed removal here.
596 win.mDestroying = true;
597 service.removeWindowLocked(win);
598 }
599 }
600 }
601
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700602 boolean hasWindowsAlive() {
603 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
604 if (!allAppWindows.get(i).mAppDied) {
605 return true;
606 }
607 }
608 return false;
609 }
610
Robert Carra1eb4392015-12-10 12:43:51 -0800611 void setReplacingWindows(boolean animate) {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700612 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
613 "Marking app token " + this + " with replacing windows.");
Robert Carra1eb4392015-12-10 12:43:51 -0800614
615 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
616 final WindowState w = allAppWindows.get(i);
617 w.setReplacing(animate);
618 }
619 if (animate) {
620 // Set-up dummy animation so we can start treating windows associated with this
621 // token like they are in transition before the new app window is ready for us to
622 // run the real transition animation.
623 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
624 "setReplacingWindow() Setting dummy animation on: " + this);
625 mAppAnimator.setDummyAnimation();
626 }
627 }
628
Robert Carr23fa16b2016-01-13 13:19:58 -0800629 void setReplacingChildren() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700630 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this
Robert Carr23fa16b2016-01-13 13:19:58 -0800631 + " with replacing child windows.");
632 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
633 final WindowState w = allAppWindows.get(i);
Robert Carrd1a010f2016-04-07 22:36:22 -0700634 if (w.shouldBeReplacedWithChildren()) {
Robert Carr23fa16b2016-01-13 13:19:58 -0800635 w.setReplacing(false /* animate */);
636 }
637 }
638 }
639
Chong Zhangf596cd52016-01-05 13:42:44 -0800640 void resetReplacingWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700641 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
642 "Resetting app token " + this + " of replacing window marks.");
Chong Zhangf596cd52016-01-05 13:42:44 -0800643
644 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
645 final WindowState w = allAppWindows.get(i);
646 w.resetReplacing();
647 }
648 }
649
Chong Zhang4d7369a2016-04-25 16:09:14 -0700650 void requestUpdateWallpaperIfNeeded() {
651 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
652 final WindowState w = allAppWindows.get(i);
653 w.requestUpdateWallpaperIfNeeded();
654 }
655 }
656
Chong Zhangd78ddb42016-03-02 17:01:14 -0800657 boolean isRelaunching() {
658 return mPendingRelaunchCount > 0;
659 }
660
661 void startRelaunching() {
662 if (canFreezeBounds()) {
663 freezeBounds();
664 }
665 mPendingRelaunchCount++;
666 }
667
668 void finishRelaunching() {
669 if (canFreezeBounds()) {
670 unfreezeBounds();
671 }
672 if (mPendingRelaunchCount > 0) {
673 mPendingRelaunchCount--;
674 }
675 }
676
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700677 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700678 if (mPendingRelaunchCount == 0) {
679 return;
680 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700681 if (canFreezeBounds()) {
682 unfreezeBounds();
683 }
684 mPendingRelaunchCount = 0;
685 }
686
Robert Carra1eb4392015-12-10 12:43:51 -0800687 void addWindow(WindowState w) {
688 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
689 WindowState candidate = allAppWindows.get(i);
690 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
Robert Carr8bc89072016-04-08 13:29:59 -0700691 candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) {
Robert Carra1eb4392015-12-10 12:43:51 -0800692 candidate.mReplacingWindow = w;
Robert Carrb439a632016-04-07 22:52:10 -0700693 w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
Chong Zhangf596cd52016-01-05 13:42:44 -0800694
695 // if we got a replacement window, reset the timeout to give drawing more time
Chong Zhang32de3652016-05-12 16:00:01 -0700696 service.scheduleReplacingWindowTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800697 }
698 }
699 allAppWindows.add(w);
700 }
701
702 boolean waitingForReplacement() {
703 for (int i = allAppWindows.size() -1; i >= 0; i--) {
704 WindowState candidate = allAppWindows.get(i);
705 if (candidate.mWillReplaceWindow) {
706 return true;
707 }
708 }
709 return false;
710 }
711
Chong Zhangf596cd52016-01-05 13:42:44 -0800712 void clearTimedoutReplacesLocked() {
Robert Carra1eb4392015-12-10 12:43:51 -0800713 for (int i = allAppWindows.size() - 1; i >= 0;
714 // removeWindowLocked at bottom of loop may remove multiple entries from
715 // allAppWindows if the window to be removed has child windows. It also may
716 // not remove any windows from allAppWindows at all if win is exiting and
717 // currently animating away. This ensures that winNdx is monotonically decreasing
718 // and never beyond allAppWindows bounds.
719 i = Math.min(i - 1, allAppWindows.size() - 1)) {
720 WindowState candidate = allAppWindows.get(i);
721 if (candidate.mWillReplaceWindow == false) {
722 continue;
723 }
724 candidate.mWillReplaceWindow = false;
Robert Carrb439a632016-04-07 22:52:10 -0700725 if (candidate.mReplacingWindow != null) {
726 candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false;
727 }
Chong Zhangf596cd52016-01-05 13:42:44 -0800728 // Since the window already timed out, remove it immediately now.
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700729 // Use WindowState#remove() instead of removeWindowLocked(), as the latter
Chong Zhangf596cd52016-01-05 13:42:44 -0800730 // delays removal on certain conditions, which will leave the stale window in the
731 // stack and marked mWillReplaceWindow=false, so the window will never be removed.
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700732 candidate.remove();
Robert Carra1eb4392015-12-10 12:43:51 -0800733 }
734 }
735
Chong Zhangd78ddb42016-03-02 17:01:14 -0800736 private boolean canFreezeBounds() {
737 // For freeform windows, we can't freeze the bounds at the moment because this would make
738 // the resizing unresponsive.
739 return mTask != null && !mTask.inFreeformWorkspace();
740 }
741
Jorim Jaggi0429f352015-12-22 16:29:16 +0100742 /**
743 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
744 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
745 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
746 * with a queue.
747 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800748 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100749 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700750
751 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
752 // We didn't call prepareFreezingBounds on the task, so use the current value.
753 final Configuration config = new Configuration(service.mCurConfiguration);
754 config.updateFrom(mTask.mOverrideConfig);
755 mFrozenMergedConfig.offer(config);
756 } else {
757 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
758 }
759 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100760 }
761
762 /**
763 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
764 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800765 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700766 if (!mFrozenBounds.isEmpty()) {
767 mFrozenBounds.remove();
768 }
769 if (!mFrozenMergedConfig.isEmpty()) {
770 mFrozenMergedConfig.remove();
771 }
Wale Ogunwale455fac52016-07-21 07:24:49 -0700772 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
773 final WindowState win = allAppWindows.get(i);
Jorim Jaggi69abc192016-02-04 19:34:00 -0800774 if (!win.mHasSurface) {
775 continue;
776 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100777 win.mLayoutNeeded = true;
778 win.setDisplayLayoutNeeded();
779 if (!service.mResizingWindows.contains(win)) {
780 service.mResizingWindows.add(win);
781 }
782 }
783 service.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100784 }
785
Robert Carr91b228092016-06-28 17:32:37 -0700786 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
787 mSurfaceViewBackgrounds.add(background);
788 }
789
790 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
791 mSurfaceViewBackgrounds.remove(background);
792 updateSurfaceViewBackgroundVisibilities();
793 }
794
795 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
796 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
797 // below the main app window (as traditionally a SurfaceView which is never drawn
798 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
799 // the background for the SurfaceView with lowest Z order
800 void updateSurfaceViewBackgroundVisibilities() {
801 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
802 int bottomLayer = Integer.MAX_VALUE;
803 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
804 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
805 if (sc.mVisible && sc.mLayer < bottomLayer) {
806 bottomLayer = sc.mLayer;
807 bottom = sc;
808 }
809 }
810 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
811 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
812 sc.updateBackgroundVisibility(sc != bottom);
813 }
814 }
815
Craig Mautnerdbb79912012-03-01 18:59:14 -0800816 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800817 void dump(PrintWriter pw, String prefix) {
818 super.dump(pw, prefix);
819 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700820 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800821 }
822 if (allAppWindows.size() > 0) {
823 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
824 }
Craig Mautner83162a92015-01-26 14:43:30 -0800825 pw.print(prefix); pw.print("task="); pw.println(mTask);
826 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800827 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
828 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
829 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700830 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800831 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700832 if (paused) {
833 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800834 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800835 if (mAppStopped) {
836 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
837 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800838 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700839 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800840 pw.print(prefix); pw.print("numInterestingWindows=");
841 pw.print(numInterestingWindows);
842 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
843 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700844 pw.print(" allDrawn="); pw.print(allDrawn);
845 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
846 pw.println(")");
847 }
848 if (inPendingTransaction) {
849 pw.print(prefix); pw.print("inPendingTransaction=");
850 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800851 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800852 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800853 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
854 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800855 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800856 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800857 }
858 if (startingWindow != null || startingView != null
859 || startingDisplayed || startingMoved) {
860 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
861 pw.print(" startingView="); pw.print(startingView);
862 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800863 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800864 }
Jorim Jaggi0429f352015-12-22 16:29:16 +0100865 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -0800866 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700867 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -0800868 }
869 if (mPendingRelaunchCount != 0) {
870 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +0100871 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800872 }
873
874 @Override
875 public String toString() {
876 if (stringName == null) {
877 StringBuilder sb = new StringBuilder();
878 sb.append("AppWindowToken{");
879 sb.append(Integer.toHexString(System.identityHashCode(this)));
880 sb.append(" token="); sb.append(token); sb.append('}');
881 stringName = sb.toString();
882 }
883 return stringName;
884 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700885}