blob: b0653921caf19bc1e4869a6b47fe93896778cbf3 [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 Zhangf96cb3c2016-08-15 11:09:29 -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 Zhangf96cb3c2016-08-15 11:09:29 -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() {
Chong Zhangb0d26702016-08-12 16:03:29 -0700343 boolean wallpaperMightChange = false;
Chong Zhange05bcb12016-07-26 17:47:29 -0700344 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
345 final WindowState win = allAppWindows.get(i);
346 // We don't want to clear it out for windows that get replaced, because the
347 // animation depends on the flag to remove the replaced window.
348 //
349 // We also don't clear the mAnimatingExit flag for windows which have the
350 // mRemoveOnExit flag. This indicates an explicit remove request has been issued
351 // by the client. We should let animation proceed and not clear this flag or
352 // they won't eventually be removed by WindowStateAnimator#finishExit.
353 if (!win.mWillReplaceWindow && !win.mRemoveOnExit) {
Chong Zhange05bcb12016-07-26 17:47:29 -0700354 // 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.
Chong Zhangb0d26702016-08-12 16:03:29 -0700361 if (win.mAnimatingExit) {
362 win.mAnimatingExit = false;
363 wallpaperMightChange = true;
364 }
365 if (win.mWinAnimator.mAnimating) {
366 win.mWinAnimator.mAnimating = false;
367 wallpaperMightChange = true;
368 }
Chong Zhangf96cb3c2016-08-15 11:09:29 -0700369 if (win.mDestroying) {
370 win.mDestroying = false;
371 service.mDestroySurface.remove(win);
Chong Zhangb0d26702016-08-12 16:03:29 -0700372 wallpaperMightChange = true;
Chong Zhangf96cb3c2016-08-15 11:09:29 -0700373 }
Chong Zhange05bcb12016-07-26 17:47:29 -0700374 }
375 }
Chong Zhangb0d26702016-08-12 16:03:29 -0700376 if (wallpaperMightChange) {
377 requestUpdateWallpaperIfNeeded();
378 }
Chong Zhange05bcb12016-07-26 17:47:29 -0700379 }
380
Robert Carre12aece2016-02-02 22:43:27 -0800381 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700382 destroySurfaces(false /*cleanupOnResume*/);
383 }
384
385 /**
386 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
387 * the client has finished with them.
388 *
389 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
390 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
391 * others so that they are ready to be reused. If set to false (common case), destroy all
392 * surfaces that's eligible, if the app is already stopped.
393 */
394
395 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800396 final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone();
397 final DisplayContentList displayList = new DisplayContentList();
398 for (int i = allWindows.size() - 1; i >= 0; i--) {
399 final WindowState win = allWindows.get(i);
Chong Zhangeb665572016-05-09 18:28:27 -0700400
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700401 if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) {
Robert Carre12aece2016-02-02 22:43:27 -0800402 continue;
403 }
404
Chong Zhangeb665572016-05-09 18:28:27 -0700405 win.mWinAnimator.destroyPreservedSurfaceLocked();
406
407 if (!win.mDestroying) {
Chong Zhang5471e902016-02-12 15:34:10 -0800408 continue;
Robert Carre12aece2016-02-02 22:43:27 -0800409 }
410
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800411 if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win
412 + " destroySurfaces: mAppStopped=" + mAppStopped
413 + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed
414 + " win.mRemoveOnExit=" + win.mRemoveOnExit);
415
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700416 if (!cleanupOnResume || win.mRemoveOnExit) {
417 win.destroyOrSaveSurface();
418 }
Robert Carre12aece2016-02-02 22:43:27 -0800419 if (win.mRemoveOnExit) {
Robert Carre12aece2016-02-02 22:43:27 -0800420 service.removeWindowInnerLocked(win);
421 }
422 final DisplayContent displayContent = win.getDisplayContent();
423 if (displayContent != null && !displayList.contains(displayContent)) {
424 displayList.add(displayContent);
425 }
Chong Zhangf96cb3c2016-08-15 11:09:29 -0700426 if (cleanupOnResume) {
427 win.requestUpdateWallpaperIfNeeded();
428 }
Robert Carre12aece2016-02-02 22:43:27 -0800429 win.mDestroying = false;
430 }
431 for (int i = 0; i < displayList.size(); i++) {
432 final DisplayContent displayContent = displayList.get(i);
433 service.mLayersController.assignLayersLocked(displayContent.getWindowList());
434 displayContent.layoutNeeded = true;
435 }
436 }
437
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800438 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700439 * Notify that the app is now resumed, and it was not stopped before, perform a clean
440 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800441 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700442 void notifyAppResumed(boolean wasStopped) {
443 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this);
444 mAppStopped = false;
445 if (!wasStopped) {
446 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800447 }
Robert Carre12aece2016-02-02 22:43:27 -0800448 }
449
Chong Zhangbef461f2015-10-27 11:38:24 -0700450 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700451 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
452 * keeping alive in case they were still being used.
453 */
454 void notifyAppStopped() {
455 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
456 mAppStopped = true;
457 destroySurfaces();
458 // Remove any starting window that was added for this app if they are still around.
459 mTask.mService.scheduleRemoveStartingWindowLocked(this);
460 }
461
462 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700463 * Checks whether we should save surfaces for this app.
464 *
465 * @return true if the surfaces should be saved, false otherwise.
466 */
467 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800468 // We want to save surface if the app's windows are "allDrawn".
469 // (If we started entering animation early with saved surfaces, allDrawn
470 // should have been restored to true. So we'll save again in that case
471 // even if app didn't actually finish drawing.)
472 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800473 }
474
Chong Zhang92147042016-05-09 12:47:11 -0700475 boolean canRestoreSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700476 for (int i = allAppWindows.size() -1; i >= 0; i--) {
Chong Zhang92147042016-05-09 12:47:11 -0700477 final WindowState w = allAppWindows.get(i);
478 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800479 return true;
480 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700481 }
482 return false;
483 }
484
Chong Zhang92147042016-05-09 12:47:11 -0700485 void clearVisibleBeforeClientHidden() {
486 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
487 final WindowState w = allAppWindows.get(i);
488 w.clearVisibleBeforeClientHidden();
489 }
490 }
491
Chong Zhang8e4bda92016-05-04 15:08:18 -0700492 /**
493 * Whether the app has some window that is invisible in layout, but
494 * animating with saved surface.
495 */
496 boolean isAnimatingInvisibleWithSavedSurface() {
497 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
498 final WindowState w = allAppWindows.get(i);
499 if (w.isAnimatingInvisibleWithSavedSurface()) {
500 return true;
501 }
502 }
503 return false;
504 }
505
506 /**
507 * Hide all window surfaces that's still invisible in layout but animating
508 * with a saved surface, and mark them destroying.
509 */
510 void stopUsingSavedSurfaceLocked() {
511 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
512 final WindowState w = allAppWindows.get(i);
513 if (w.isAnimatingInvisibleWithSavedSurface()) {
514 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
515 "stopUsingSavedSurfaceLocked: " + w);
516 w.clearAnimatingWithSavedSurface();
517 w.mDestroying = true;
518 w.mWinAnimator.hide("stopUsingSavedSurfaceLocked");
519 w.mWinAnimator.mWallpaperControllerLocked.hideWallpapers(w);
520 }
521 }
522 destroySurfaces();
523 }
524
Chong Zhangf58631a2016-05-24 16:02:10 -0700525 void markSavedSurfaceExiting() {
526 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
527 final WindowState w = allAppWindows.get(i);
528 if (w.isAnimatingInvisibleWithSavedSurface()) {
529 w.mAnimatingExit = true;
530 w.mWinAnimator.mAnimating = true;
531 }
532 }
533 }
534
Chong Zhangbef461f2015-10-27 11:38:24 -0700535 void restoreSavedSurfaces() {
Chong Zhang92147042016-05-09 12:47:11 -0700536 if (!canRestoreSurfaces()) {
537 clearVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700538 return;
539 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800540 // Check if we have enough drawn windows to mark allDrawn= true.
541 int numInteresting = 0;
542 int numDrawn = 0;
Chong Zhangb7b4a562016-04-28 15:30:33 -0700543 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
544 WindowState w = allAppWindows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700545 if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800546 && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
547 numInteresting++;
Chong Zhang92147042016-05-09 12:47:11 -0700548 if (w.hasSavedSurface()) {
549 w.restoreSavedSurface();
550 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800551 if (w.isDrawnLw()) {
552 numDrawn++;
553 }
554 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700555 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800556
Chong Zhang92147042016-05-09 12:47:11 -0700557 if (!allDrawn) {
558 allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
559 if (allDrawn) {
560 service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
561 }
562 }
563 clearVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800564
565 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Chong Zhang92147042016-05-09 12:47:11 -0700566 "restoreSavedSurfaces: " + appWindowToken + " allDrawn=" + allDrawn
567 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700568 }
569
570 void destroySavedSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700571 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
572 WindowState win = allAppWindows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800573 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700574 }
Chong Zhang92147042016-05-09 12:47:11 -0700575 }
576
577 void clearAllDrawn() {
578 allDrawn = false;
579 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700580 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700581 }
582
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800583 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700584 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800585 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
586 // removeWindowLocked at bottom of loop may remove multiple entries from
587 // allAppWindows if the window to be removed has child windows. It also may
588 // not remove any windows from allAppWindows at all if win is exiting and
589 // currently animating away. This ensures that winNdx is monotonically decreasing
590 // and never beyond allAppWindows bounds.
591 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
592 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800593 if (DEBUG_WINDOW_MOVEMENT) {
594 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800595 }
596
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700597 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700598 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800599 allAppWindows.clear();
600 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700601 }
602
Chong Zhang112eb8c2015-11-02 11:17:00 -0800603 void removeAllDeadWindows() {
604 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700605 // removeWindowLocked at bottom of loop may remove multiple entries from
606 // allAppWindows if the window to be removed has child windows. It also may
607 // not remove any windows from allAppWindows at all if win is exiting and
608 // currently animating away. This ensures that winNdx is monotonically decreasing
609 // and never beyond allAppWindows bounds.
610 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800611 WindowState win = allAppWindows.get(winNdx);
612 if (win.mAppDied) {
Wale Ogunwale2728bf42016-03-03 11:03:26 -0800613 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800614 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800615 }
616 // Set mDestroying, we don't want any animation or delayed removal here.
617 win.mDestroying = true;
618 service.removeWindowLocked(win);
619 }
620 }
621 }
622
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700623 boolean hasWindowsAlive() {
624 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
625 if (!allAppWindows.get(i).mAppDied) {
626 return true;
627 }
628 }
629 return false;
630 }
631
Robert Carra1eb4392015-12-10 12:43:51 -0800632 void setReplacingWindows(boolean animate) {
633 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
634 + " with replacing windows.");
635
636 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
637 final WindowState w = allAppWindows.get(i);
638 w.setReplacing(animate);
639 }
640 if (animate) {
641 // Set-up dummy animation so we can start treating windows associated with this
642 // token like they are in transition before the new app window is ready for us to
643 // run the real transition animation.
644 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
645 "setReplacingWindow() Setting dummy animation on: " + this);
646 mAppAnimator.setDummyAnimation();
647 }
648 }
649
Robert Carr23fa16b2016-01-13 13:19:58 -0800650 void setReplacingChildren() {
651 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
652 + " with replacing child windows.");
653 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
654 final WindowState w = allAppWindows.get(i);
Robert Carrd1a010f2016-04-07 22:36:22 -0700655 if (w.shouldBeReplacedWithChildren()) {
Robert Carr23fa16b2016-01-13 13:19:58 -0800656 w.setReplacing(false /* animate */);
657 }
658 }
659 }
660
Chong Zhangf596cd52016-01-05 13:42:44 -0800661 void resetReplacingWindows() {
662 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Resetting app token " + appWindowToken
663 + " of replacing window marks.");
664
665 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
666 final WindowState w = allAppWindows.get(i);
667 w.resetReplacing();
668 }
669 }
670
Chong Zhang4d7369a2016-04-25 16:09:14 -0700671 void requestUpdateWallpaperIfNeeded() {
672 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
673 final WindowState w = allAppWindows.get(i);
674 w.requestUpdateWallpaperIfNeeded();
675 }
676 }
677
Chong Zhangd78ddb42016-03-02 17:01:14 -0800678 boolean isRelaunching() {
679 return mPendingRelaunchCount > 0;
680 }
681
682 void startRelaunching() {
683 if (canFreezeBounds()) {
684 freezeBounds();
685 }
686 mPendingRelaunchCount++;
687 }
688
689 void finishRelaunching() {
690 if (canFreezeBounds()) {
691 unfreezeBounds();
692 }
693 if (mPendingRelaunchCount > 0) {
694 mPendingRelaunchCount--;
695 }
696 }
697
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700698 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700699 if (mPendingRelaunchCount == 0) {
700 return;
701 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700702 if (canFreezeBounds()) {
703 unfreezeBounds();
704 }
705 mPendingRelaunchCount = 0;
706 }
707
Robert Carra1eb4392015-12-10 12:43:51 -0800708 void addWindow(WindowState w) {
709 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
710 WindowState candidate = allAppWindows.get(i);
711 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
Robert Carr8bc89072016-04-08 13:29:59 -0700712 candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) {
Robert Carra1eb4392015-12-10 12:43:51 -0800713 candidate.mReplacingWindow = w;
Robert Carrb439a632016-04-07 22:52:10 -0700714 w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
Chong Zhangf596cd52016-01-05 13:42:44 -0800715
716 // if we got a replacement window, reset the timeout to give drawing more time
Chong Zhang32de3652016-05-12 16:00:01 -0700717 service.scheduleReplacingWindowTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800718 }
719 }
720 allAppWindows.add(w);
721 }
722
723 boolean waitingForReplacement() {
724 for (int i = allAppWindows.size() -1; i >= 0; i--) {
725 WindowState candidate = allAppWindows.get(i);
726 if (candidate.mWillReplaceWindow) {
727 return true;
728 }
729 }
730 return false;
731 }
732
Chong Zhangf596cd52016-01-05 13:42:44 -0800733 void clearTimedoutReplacesLocked() {
Robert Carra1eb4392015-12-10 12:43:51 -0800734 for (int i = allAppWindows.size() - 1; i >= 0;
735 // removeWindowLocked at bottom of loop may remove multiple entries from
736 // allAppWindows if the window to be removed has child windows. It also may
737 // not remove any windows from allAppWindows at all if win is exiting and
738 // currently animating away. This ensures that winNdx is monotonically decreasing
739 // and never beyond allAppWindows bounds.
740 i = Math.min(i - 1, allAppWindows.size() - 1)) {
741 WindowState candidate = allAppWindows.get(i);
742 if (candidate.mWillReplaceWindow == false) {
743 continue;
744 }
745 candidate.mWillReplaceWindow = false;
Robert Carrb439a632016-04-07 22:52:10 -0700746 if (candidate.mReplacingWindow != null) {
747 candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false;
748 }
Chong Zhangf596cd52016-01-05 13:42:44 -0800749 // Since the window already timed out, remove it immediately now.
750 // Use removeWindowInnerLocked() instead of removeWindowLocked(), as the latter
751 // delays removal on certain conditions, which will leave the stale window in the
752 // stack and marked mWillReplaceWindow=false, so the window will never be removed.
753 service.removeWindowInnerLocked(candidate);
Robert Carra1eb4392015-12-10 12:43:51 -0800754 }
755 }
756
Chong Zhangd78ddb42016-03-02 17:01:14 -0800757 private boolean canFreezeBounds() {
758 // For freeform windows, we can't freeze the bounds at the moment because this would make
759 // the resizing unresponsive.
760 return mTask != null && !mTask.inFreeformWorkspace();
761 }
762
Jorim Jaggi0429f352015-12-22 16:29:16 +0100763 /**
764 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
765 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
766 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
767 * with a queue.
768 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800769 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100770 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700771
772 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
773 // We didn't call prepareFreezingBounds on the task, so use the current value.
774 final Configuration config = new Configuration(service.mCurConfiguration);
775 config.updateFrom(mTask.mOverrideConfig);
776 mFrozenMergedConfig.offer(config);
777 } else {
778 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
779 }
780 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100781 }
782
783 /**
784 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
785 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800786 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700787 if (!mFrozenBounds.isEmpty()) {
788 mFrozenBounds.remove();
789 }
790 if (!mFrozenMergedConfig.isEmpty()) {
791 mFrozenMergedConfig.remove();
792 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100793 for (int i = windows.size() - 1; i >= 0; i--) {
794 final WindowState win = windows.get(i);
Jorim Jaggi69abc192016-02-04 19:34:00 -0800795 if (!win.mHasSurface) {
796 continue;
797 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100798 win.mLayoutNeeded = true;
799 win.setDisplayLayoutNeeded();
800 if (!service.mResizingWindows.contains(win)) {
801 service.mResizingWindows.add(win);
802 }
803 }
804 service.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100805 }
806
Robert Carr91b228092016-06-28 17:32:37 -0700807 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
808 mSurfaceViewBackgrounds.add(background);
809 }
810
811 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
812 mSurfaceViewBackgrounds.remove(background);
813 updateSurfaceViewBackgroundVisibilities();
814 }
815
816 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
817 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
818 // below the main app window (as traditionally a SurfaceView which is never drawn
819 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
820 // the background for the SurfaceView with lowest Z order
821 void updateSurfaceViewBackgroundVisibilities() {
822 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
823 int bottomLayer = Integer.MAX_VALUE;
824 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
825 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
826 if (sc.mVisible && sc.mLayer < bottomLayer) {
827 bottomLayer = sc.mLayer;
828 bottom = sc;
829 }
830 }
831 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
832 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
833 sc.updateBackgroundVisibility(sc != bottom);
834 }
835 }
836
Craig Mautnerdbb79912012-03-01 18:59:14 -0800837 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800838 void dump(PrintWriter pw, String prefix) {
839 super.dump(pw, prefix);
840 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700841 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800842 }
843 if (allAppWindows.size() > 0) {
844 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
845 }
Craig Mautner83162a92015-01-26 14:43:30 -0800846 pw.print(prefix); pw.print("task="); pw.println(mTask);
847 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800848 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
849 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
850 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700851 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800852 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700853 if (paused) {
854 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800855 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800856 if (mAppStopped) {
857 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
858 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800859 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700860 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800861 pw.print(prefix); pw.print("numInterestingWindows=");
862 pw.print(numInterestingWindows);
863 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
864 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700865 pw.print(" allDrawn="); pw.print(allDrawn);
866 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
867 pw.println(")");
868 }
869 if (inPendingTransaction) {
870 pw.print(prefix); pw.print("inPendingTransaction=");
871 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800872 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800873 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800874 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
875 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800876 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800877 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800878 }
879 if (startingWindow != null || startingView != null
880 || startingDisplayed || startingMoved) {
881 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
882 pw.print(" startingView="); pw.print(startingView);
883 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800884 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800885 }
Jorim Jaggi0429f352015-12-22 16:29:16 +0100886 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -0800887 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700888 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -0800889 }
890 if (mPendingRelaunchCount != 0) {
891 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +0100892 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800893 }
894
895 @Override
896 public String toString() {
897 if (stringName == null) {
898 StringBuilder sb = new StringBuilder();
899 sb.append("AppWindowToken{");
900 sb.append(Integer.toHexString(System.identityHashCode(this)));
901 sb.append(" token="); sb.append(token); sb.append('}');
902 stringName = sb.toString();
903 }
904 return stringName;
905 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700906}