blob: 01be4c8f4642071ed061c2f7732fe67936bcf8d9 [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 Zhangec8299c2016-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 Zhangec8299c2016-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 Zhang92147042016-05-09 12:47:11 -070031import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080032
Jeff Brown4532e612012-04-05 14:27:12 -070033import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080034import com.android.server.wm.WindowManagerService.H;
35
Filip Gruszczynskia590c992015-11-25 16:45:26 -080036import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080037import android.content.pm.ActivityInfo;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070038import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010039import android.graphics.Rect;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080040import android.os.Message;
41import android.os.RemoteException;
42import android.util.Slog;
43import android.view.IApplicationToken;
44import android.view.View;
45import android.view.WindowManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080046
47import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010048import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080049import java.util.ArrayList;
50
51class AppTokenList extends ArrayList<AppWindowToken> {
52}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080053
54/**
55 * Version of WindowToken that is specifically for a particular application (or
56 * really activity) that is displaying windows.
57 */
Craig Mautnere32c3072012-03-12 15:25:35 -070058class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080059 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
60
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080061 // Non-null only for application tokens.
62 final IApplicationToken appToken;
63
64 // All of the windows and child windows that are included in this
65 // application token. Note this list is NOT sorted!
Craig Mautner96868332012-12-04 14:29:11 -080066 final WindowList allAppWindows = new WindowList();
Filip Gruszczynskia590c992015-11-25 16:45:26 -080067 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070068
Dianne Hackborne30e02f2014-05-27 18:24:45 -070069 final boolean voiceInteraction;
70
Craig Mautner83162a92015-01-26 14:43:30 -080071 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080072 boolean appFullscreen;
73 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080074 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070075 boolean showForAllUsers;
Yorke Lee0e852472016-06-15 10:03:18 -070076 int targetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070077
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080078 // The input dispatching timeout for this application token in nanoseconds.
79 long inputDispatchingTimeoutNanos;
80
81 // These are used for determining when all windows associated with
82 // an activity have been drawn, so they can be made visible together
83 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070084 // initialize so that it doesn't match mTransactionSequence which is an int.
85 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080086 int numInterestingWindows;
87 int numDrawnWindows;
88 boolean inPendingTransaction;
89 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080090 // Set to true when this app creates a surface while in the middle of an animation. In that
91 // case do not clear allDrawn until the animation completes.
92 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080093
Chong Zhang8e4bda92016-05-04 15:08:18 -070094 // These are to track the app's real drawing status if there were no saved surfaces.
95 boolean allDrawnExcludingSaved;
96 int numInterestingWindowsExcludingSaved;
97 int numDrawnWindowsExclusingSaved;
98
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080099 // Is this window's surface needed? This is almost like hidden, except
100 // it will sometimes be true a little earlier: when the token has
101 // been shown, but is still waiting for its app transition to execute
102 // before making its windows shown.
103 boolean hiddenRequested;
104
105 // Have we told the window clients to hide themselves?
106 boolean clientHidden;
107
108 // Last visibility state we reported to the app token.
109 boolean reportedVisible;
110
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700111 // Last drawn state we reported to the app token.
112 boolean reportedDrawn;
113
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800114 // Set to true when the token has been removed from the window mgr.
115 boolean removed;
116
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800117 // Information about an application starting window if displayed.
118 StartingData startingData;
119 WindowState startingWindow;
120 View startingView;
121 boolean startingDisplayed;
122 boolean startingMoved;
123 boolean firstWindowDrawn;
124
125 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700126 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800127
Craig Mautner799bc1d2015-01-14 10:33:48 -0800128 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800129
Craig Mautnerbb742462014-07-07 15:28:55 -0700130 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700131 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700132
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800133 boolean mAlwaysFocusable;
134
Robert Carre12aece2016-02-02 22:43:27 -0800135 boolean mAppStopped;
Robert Carrfd10cd12016-06-29 16:41:50 -0700136 int mRotationAnimationHint;
Chong Zhangd78ddb42016-03-02 17:01:14 -0800137 int mPendingRelaunchCount;
Robert Carre12aece2016-02-02 22:43:27 -0800138
Robert Carr91b228092016-06-28 17:32:37 -0700139 private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds =
140 new ArrayList<WindowSurfaceController.SurfaceControlWithBackground>();
141
Jorim Jaggi0429f352015-12-22 16:29:16 +0100142 ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700143 ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100144
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700145 AppWindowToken(WindowManagerService _service, IApplicationToken _token,
146 boolean _voiceInteraction) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800147 super(_service, _token.asBinder(),
148 WindowManager.LayoutParams.TYPE_APPLICATION, true);
149 appWindowToken = this;
150 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700151 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800152 mInputApplicationHandle = new InputApplicationHandle(this);
Craig Mautner322e4032012-07-13 13:35:20 -0700153 mAppAnimator = new AppWindowAnimator(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800154 }
155
156 void sendAppVisibilityToClients() {
157 final int N = allAppWindows.size();
158 for (int i=0; i<N; i++) {
159 WindowState win = allAppWindows.get(i);
160 if (win == startingWindow && clientHidden) {
161 // Don't hide the starting window.
162 continue;
163 }
164 try {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800165 if (DEBUG_VISIBILITY) Slog.v(TAG,
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800166 "Setting visibility of " + win + ": " + (!clientHidden));
167 win.mClient.dispatchAppVisibility(!clientHidden);
168 } catch (RemoteException e) {
169 }
170 }
171 }
172
Chong Zhang92147042016-05-09 12:47:11 -0700173 void setVisibleBeforeClientHidden() {
174 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
175 final WindowState w = allAppWindows.get(i);
176 w.setVisibleBeforeClientHidden();
177 }
178 }
179
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800180 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
181 firstWindowDrawn = true;
182
183 // We now have a good window to show, remove dead placeholders
184 removeAllDeadWindows();
185
186 if (startingData != null) {
187 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
188 + win.mToken + ": first real window is shown, no animation");
189 // If this initial window is animating, stop it -- we will do an animation to reveal
190 // it from behind the starting window, so there is no need for it to also be doing its
191 // own stuff.
192 winAnimator.clearAnimation();
193 winAnimator.mService.mFinishedStarting.add(this);
194 winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
195 }
196 updateReportedVisibilityLocked();
197 }
198
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800199 void updateReportedVisibilityLocked() {
200 if (appToken == null) {
201 return;
202 }
203
204 int numInteresting = 0;
205 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700206 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800207 boolean nowGone = true;
208
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800209 if (DEBUG_VISIBILITY) Slog.v(TAG,
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700210 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800211 final int N = allAppWindows.size();
212 for (int i=0; i<N; i++) {
213 WindowState win = allAppWindows.get(i);
214 if (win == startingWindow || win.mAppFreezing
215 || win.mViewVisibility != View.VISIBLE
216 || win.mAttrs.type == TYPE_APPLICATION_STARTING
217 || win.mDestroying) {
218 continue;
219 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800220 if (DEBUG_VISIBILITY) {
221 Slog.v(TAG, "Win " + win + ": isDrawn="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800222 + win.isDrawnLw()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700223 + ", isAnimationSet=" + win.mWinAnimator.isAnimationSet());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800224 if (!win.isDrawnLw()) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800225 Slog.v(TAG, "Not displayed: s=" +
Robert Carre6a83512015-11-03 16:09:21 -0800226 win.mWinAnimator.mSurfaceController
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800227 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700228 + " mDrawState=" + win.mWinAnimator.mDrawState
Wale Ogunwale9d147902016-07-16 11:58:55 -0700229 + " ph=" + win.isParentWindowHidden()
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800230 + " th="
231 + (win.mAppToken != null
232 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700233 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800234 }
235 }
236 numInteresting++;
237 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700238 numDrawn++;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700239 if (!win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800240 numVisible++;
241 }
242 nowGone = false;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700243 } else if (win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800244 nowGone = false;
245 }
246 }
247
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700248 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800249 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700250 if (!nowGone) {
251 // If the app is not yet gone, then it can only become visible/drawn.
252 if (!nowDrawn) {
253 nowDrawn = reportedDrawn;
254 }
255 if (!nowVisible) {
256 nowVisible = reportedVisible;
257 }
258 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800259 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800260 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700261 if (nowDrawn != reportedDrawn) {
262 if (nowDrawn) {
263 Message m = service.mH.obtainMessage(
264 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
265 service.mH.sendMessage(m);
266 }
267 reportedDrawn = nowDrawn;
268 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800269 if (nowVisible != reportedVisible) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800270 if (DEBUG_VISIBILITY) Slog.v(
271 TAG, "Visibility changed in " + this
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800272 + ": vis=" + nowVisible);
273 reportedVisible = nowVisible;
274 Message m = service.mH.obtainMessage(
275 H.REPORT_APPLICATION_TOKEN_WINDOWS,
276 nowVisible ? 1 : 0,
277 nowGone ? 1 : 0,
278 this);
279 service.mH.sendMessage(m);
280 }
281 }
282
283 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700284 WindowState candidate = null;
Wale Ogunwale455fac52016-07-21 07:24:49 -0700285 int j = allAppWindows.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800286 while (j > 0) {
287 j--;
Wale Ogunwale455fac52016-07-21 07:24:49 -0700288 WindowState win = allAppWindows.get(j);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800289 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
290 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700291 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900292 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700293 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800294 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700295 candidate = win;
296 } else {
297 return win;
298 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800299 }
300 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700301 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800302 }
303
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800304 boolean windowsAreFocusable() {
305 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800306 }
307
Craig Mautner72669d12012-12-18 17:23:54 -0800308 boolean isVisible() {
309 final int N = allAppWindows.size();
Craig Mautner72669d12012-12-18 17:23:54 -0800310 for (int i=0; i<N; i++) {
311 WindowState win = allAppWindows.get(i);
Chong Zhangdb20b5f2015-10-23 14:01:43 -0700312 // If we're animating with a saved surface, we're already visible.
313 // Return true so that the alpha doesn't get cleared.
Craig Mautner72669d12012-12-18 17:23:54 -0800314 if (!win.mAppFreezing
Chong Zhang92147042016-05-09 12:47:11 -0700315 && (win.mViewVisibility == View.VISIBLE || win.isAnimatingWithSavedSurface()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700316 || (win.mWinAnimator.isAnimationSet()
Filip Gruszczynski57f76f12015-11-04 16:10:54 -0800317 && !service.mAppTransition.isTransitionSet()))
318 && !win.mDestroying
319 && win.isDrawnLw()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800320 return true;
321 }
322 }
323 return false;
324 }
325
Craig Mautnere3119b72015-01-20 15:02:36 -0800326 void removeAppFromTaskLocked() {
327 mIsExiting = false;
328 removeAllWindows();
329
Craig Mautner83162a92015-01-26 14:43:30 -0800330 // Use local variable because removeAppToken will null out mTask.
331 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800332 if (task != null) {
333 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800334 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800335 + " not found.");
336 }
337 task.mStack.mExitingAppTokens.remove(this);
338 }
339 }
340
Chong Zhange05bcb12016-07-26 17:47:29 -0700341 void clearAnimatingFlags() {
342 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
343 final WindowState win = allAppWindows.get(i);
344 // We don't want to clear it out for windows that get replaced, because the
345 // animation depends on the flag to remove the replaced window.
346 //
347 // We also don't clear the mAnimatingExit flag for windows which have the
348 // mRemoveOnExit flag. This indicates an explicit remove request has been issued
349 // by the client. We should let animation proceed and not clear this flag or
350 // they won't eventually be removed by WindowStateAnimator#finishExit.
351 if (!win.mWillReplaceWindow && !win.mRemoveOnExit) {
352 win.mAnimatingExit = false;
353 // Clear mAnimating flag together with mAnimatingExit. When animation
354 // changes from exiting to entering, we need to clear this flag until the
355 // new animation gets applied, so that isAnimationStarting() becomes true
356 // until then.
357 // Otherwise applySurfaceChangesTransaction will faill to skip surface
358 // placement for this window during this period, one or more frame will
359 // show up with wrong position or scale.
360 win.mWinAnimator.mAnimating = false;
361 }
362 }
Chong Zhangec8299c2016-07-29 13:09:40 -0700363 requestUpdateWallpaperIfNeeded();
Chong Zhange05bcb12016-07-26 17:47:29 -0700364 }
365
Robert Carre12aece2016-02-02 22:43:27 -0800366 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700367 destroySurfaces(false /*cleanupOnResume*/);
368 }
369
370 /**
371 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
372 * the client has finished with them.
373 *
374 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
375 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
376 * others so that they are ready to be reused. If set to false (common case), destroy all
377 * surfaces that's eligible, if the app is already stopped.
378 */
379
380 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800381 final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone();
382 final DisplayContentList displayList = new DisplayContentList();
383 for (int i = allWindows.size() - 1; i >= 0; i--) {
384 final WindowState win = allWindows.get(i);
Chong Zhangeb665572016-05-09 18:28:27 -0700385
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700386 if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) {
Robert Carre12aece2016-02-02 22:43:27 -0800387 continue;
388 }
389
Chong Zhangeb665572016-05-09 18:28:27 -0700390 win.mWinAnimator.destroyPreservedSurfaceLocked();
391
392 if (!win.mDestroying) {
Chong Zhang5471e902016-02-12 15:34:10 -0800393 continue;
Robert Carre12aece2016-02-02 22:43:27 -0800394 }
395
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800396 if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win
397 + " destroySurfaces: mAppStopped=" + mAppStopped
398 + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed
399 + " win.mRemoveOnExit=" + win.mRemoveOnExit);
400
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700401 if (!cleanupOnResume || win.mRemoveOnExit) {
402 win.destroyOrSaveSurface();
403 }
Robert Carre12aece2016-02-02 22:43:27 -0800404 if (win.mRemoveOnExit) {
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700405 win.remove();
Robert Carre12aece2016-02-02 22:43:27 -0800406 }
407 final DisplayContent displayContent = win.getDisplayContent();
408 if (displayContent != null && !displayList.contains(displayContent)) {
409 displayList.add(displayContent);
410 }
Chong Zhangec8299c2016-07-29 13:09:40 -0700411 if (cleanupOnResume) {
412 win.requestUpdateWallpaperIfNeeded();
413 }
Robert Carre12aece2016-02-02 22:43:27 -0800414 win.mDestroying = false;
415 }
416 for (int i = 0; i < displayList.size(); i++) {
417 final DisplayContent displayContent = displayList.get(i);
418 service.mLayersController.assignLayersLocked(displayContent.getWindowList());
419 displayContent.layoutNeeded = true;
420 }
421 }
422
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800423 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700424 * Notify that the app is now resumed, and it was not stopped before, perform a clean
425 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800426 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700427 void notifyAppResumed(boolean wasStopped) {
428 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this);
429 mAppStopped = false;
430 if (!wasStopped) {
431 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800432 }
Robert Carre12aece2016-02-02 22:43:27 -0800433 }
434
Chong Zhangbef461f2015-10-27 11:38:24 -0700435 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700436 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
437 * keeping alive in case they were still being used.
438 */
439 void notifyAppStopped() {
440 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
441 mAppStopped = true;
442 destroySurfaces();
443 // Remove any starting window that was added for this app if they are still around.
444 mTask.mService.scheduleRemoveStartingWindowLocked(this);
445 }
446
447 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700448 * Checks whether we should save surfaces for this app.
449 *
450 * @return true if the surfaces should be saved, false otherwise.
451 */
452 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800453 // We want to save surface if the app's windows are "allDrawn".
454 // (If we started entering animation early with saved surfaces, allDrawn
455 // should have been restored to true. So we'll save again in that case
456 // even if app didn't actually finish drawing.)
457 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800458 }
459
Chong Zhang92147042016-05-09 12:47:11 -0700460 boolean canRestoreSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700461 for (int i = allAppWindows.size() -1; i >= 0; i--) {
Chong Zhang92147042016-05-09 12:47:11 -0700462 final WindowState w = allAppWindows.get(i);
463 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800464 return true;
465 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700466 }
467 return false;
468 }
469
Chong Zhang92147042016-05-09 12:47:11 -0700470 void clearVisibleBeforeClientHidden() {
471 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
472 final WindowState w = allAppWindows.get(i);
473 w.clearVisibleBeforeClientHidden();
474 }
475 }
476
Chong Zhang8e4bda92016-05-04 15:08:18 -0700477 /**
478 * Whether the app has some window that is invisible in layout, but
479 * animating with saved surface.
480 */
481 boolean isAnimatingInvisibleWithSavedSurface() {
482 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
483 final WindowState w = allAppWindows.get(i);
484 if (w.isAnimatingInvisibleWithSavedSurface()) {
485 return true;
486 }
487 }
488 return false;
489 }
490
491 /**
492 * Hide all window surfaces that's still invisible in layout but animating
493 * with a saved surface, and mark them destroying.
494 */
495 void stopUsingSavedSurfaceLocked() {
496 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
497 final WindowState w = allAppWindows.get(i);
498 if (w.isAnimatingInvisibleWithSavedSurface()) {
499 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
500 "stopUsingSavedSurfaceLocked: " + w);
501 w.clearAnimatingWithSavedSurface();
502 w.mDestroying = true;
503 w.mWinAnimator.hide("stopUsingSavedSurfaceLocked");
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700504 service.mWallpaperControllerLocked.hideWallpapers(w);
Chong Zhang8e4bda92016-05-04 15:08:18 -0700505 }
506 }
507 destroySurfaces();
508 }
509
Chong Zhangf58631a2016-05-24 16:02:10 -0700510 void markSavedSurfaceExiting() {
511 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
512 final WindowState w = allAppWindows.get(i);
513 if (w.isAnimatingInvisibleWithSavedSurface()) {
514 w.mAnimatingExit = true;
515 w.mWinAnimator.mAnimating = true;
516 }
517 }
518 }
519
Chong Zhangbef461f2015-10-27 11:38:24 -0700520 void restoreSavedSurfaces() {
Chong Zhang92147042016-05-09 12:47:11 -0700521 if (!canRestoreSurfaces()) {
522 clearVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700523 return;
524 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800525 // Check if we have enough drawn windows to mark allDrawn= true.
526 int numInteresting = 0;
527 int numDrawn = 0;
Chong Zhangb7b4a562016-04-28 15:30:33 -0700528 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
529 WindowState w = allAppWindows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700530 if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800531 && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
532 numInteresting++;
Chong Zhang92147042016-05-09 12:47:11 -0700533 if (w.hasSavedSurface()) {
534 w.restoreSavedSurface();
535 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800536 if (w.isDrawnLw()) {
537 numDrawn++;
538 }
539 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700540 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800541
Chong Zhang92147042016-05-09 12:47:11 -0700542 if (!allDrawn) {
543 allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
544 if (allDrawn) {
545 service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
546 }
547 }
548 clearVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800549
550 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Wale Ogunwale455fac52016-07-21 07:24:49 -0700551 "restoreSavedSurfaces: " + this + " allDrawn=" + allDrawn
Chong Zhang92147042016-05-09 12:47:11 -0700552 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700553 }
554
555 void destroySavedSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700556 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
557 WindowState win = allAppWindows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800558 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700559 }
Chong Zhang92147042016-05-09 12:47:11 -0700560 }
561
562 void clearAllDrawn() {
563 allDrawn = false;
564 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700565 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700566 }
567
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800568 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700569 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800570 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
571 // removeWindowLocked at bottom of loop may remove multiple entries from
572 // allAppWindows if the window to be removed has child windows. It also may
573 // not remove any windows from allAppWindows at all if win is exiting and
574 // currently animating away. This ensures that winNdx is monotonically decreasing
575 // and never beyond allAppWindows bounds.
576 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
577 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800578 if (DEBUG_WINDOW_MOVEMENT) {
579 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800580 }
581
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700582 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700583 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800584 allAppWindows.clear();
585 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700586 }
587
Chong Zhang112eb8c2015-11-02 11:17:00 -0800588 void removeAllDeadWindows() {
589 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700590 // removeWindowLocked at bottom of loop may remove multiple entries from
591 // allAppWindows if the window to be removed has child windows. It also may
592 // not remove any windows from allAppWindows at all if win is exiting and
593 // currently animating away. This ensures that winNdx is monotonically decreasing
594 // and never beyond allAppWindows bounds.
595 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800596 WindowState win = allAppWindows.get(winNdx);
597 if (win.mAppDied) {
Wale Ogunwale2728bf42016-03-03 11:03:26 -0800598 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800599 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800600 }
601 // Set mDestroying, we don't want any animation or delayed removal here.
602 win.mDestroying = true;
603 service.removeWindowLocked(win);
604 }
605 }
606 }
607
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700608 boolean hasWindowsAlive() {
609 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
610 if (!allAppWindows.get(i).mAppDied) {
611 return true;
612 }
613 }
614 return false;
615 }
616
Robert Carra1eb4392015-12-10 12:43:51 -0800617 void setReplacingWindows(boolean animate) {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700618 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
619 "Marking app token " + this + " with replacing windows.");
Robert Carra1eb4392015-12-10 12:43:51 -0800620
621 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
622 final WindowState w = allAppWindows.get(i);
623 w.setReplacing(animate);
624 }
625 if (animate) {
626 // Set-up dummy animation so we can start treating windows associated with this
627 // token like they are in transition before the new app window is ready for us to
628 // run the real transition animation.
629 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
630 "setReplacingWindow() Setting dummy animation on: " + this);
631 mAppAnimator.setDummyAnimation();
632 }
633 }
634
Robert Carr23fa16b2016-01-13 13:19:58 -0800635 void setReplacingChildren() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700636 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this
Robert Carr23fa16b2016-01-13 13:19:58 -0800637 + " with replacing child windows.");
638 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
639 final WindowState w = allAppWindows.get(i);
Robert Carrd1a010f2016-04-07 22:36:22 -0700640 if (w.shouldBeReplacedWithChildren()) {
Robert Carr23fa16b2016-01-13 13:19:58 -0800641 w.setReplacing(false /* animate */);
642 }
643 }
644 }
645
Chong Zhangf596cd52016-01-05 13:42:44 -0800646 void resetReplacingWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700647 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
648 "Resetting app token " + this + " of replacing window marks.");
Chong Zhangf596cd52016-01-05 13:42:44 -0800649
650 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
651 final WindowState w = allAppWindows.get(i);
652 w.resetReplacing();
653 }
654 }
655
Chong Zhang4d7369a2016-04-25 16:09:14 -0700656 void requestUpdateWallpaperIfNeeded() {
657 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
658 final WindowState w = allAppWindows.get(i);
659 w.requestUpdateWallpaperIfNeeded();
660 }
661 }
662
Chong Zhangd78ddb42016-03-02 17:01:14 -0800663 boolean isRelaunching() {
664 return mPendingRelaunchCount > 0;
665 }
666
667 void startRelaunching() {
668 if (canFreezeBounds()) {
669 freezeBounds();
670 }
671 mPendingRelaunchCount++;
672 }
673
674 void finishRelaunching() {
675 if (canFreezeBounds()) {
676 unfreezeBounds();
677 }
678 if (mPendingRelaunchCount > 0) {
679 mPendingRelaunchCount--;
680 }
681 }
682
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700683 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700684 if (mPendingRelaunchCount == 0) {
685 return;
686 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700687 if (canFreezeBounds()) {
688 unfreezeBounds();
689 }
690 mPendingRelaunchCount = 0;
691 }
692
Robert Carra1eb4392015-12-10 12:43:51 -0800693 void addWindow(WindowState w) {
694 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
695 WindowState candidate = allAppWindows.get(i);
696 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
Robert Carr8bc89072016-04-08 13:29:59 -0700697 candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) {
Robert Carra1eb4392015-12-10 12:43:51 -0800698 candidate.mReplacingWindow = w;
Robert Carrb439a632016-04-07 22:52:10 -0700699 w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
Chong Zhangf596cd52016-01-05 13:42:44 -0800700
701 // if we got a replacement window, reset the timeout to give drawing more time
Chong Zhang32de3652016-05-12 16:00:01 -0700702 service.scheduleReplacingWindowTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800703 }
704 }
705 allAppWindows.add(w);
706 }
707
708 boolean waitingForReplacement() {
709 for (int i = allAppWindows.size() -1; i >= 0; i--) {
710 WindowState candidate = allAppWindows.get(i);
711 if (candidate.mWillReplaceWindow) {
712 return true;
713 }
714 }
715 return false;
716 }
717
Chong Zhangf596cd52016-01-05 13:42:44 -0800718 void clearTimedoutReplacesLocked() {
Robert Carra1eb4392015-12-10 12:43:51 -0800719 for (int i = allAppWindows.size() - 1; i >= 0;
720 // removeWindowLocked at bottom of loop may remove multiple entries from
721 // allAppWindows if the window to be removed has child windows. It also may
722 // not remove any windows from allAppWindows at all if win is exiting and
723 // currently animating away. This ensures that winNdx is monotonically decreasing
724 // and never beyond allAppWindows bounds.
725 i = Math.min(i - 1, allAppWindows.size() - 1)) {
726 WindowState candidate = allAppWindows.get(i);
727 if (candidate.mWillReplaceWindow == false) {
728 continue;
729 }
730 candidate.mWillReplaceWindow = false;
Robert Carrb439a632016-04-07 22:52:10 -0700731 if (candidate.mReplacingWindow != null) {
732 candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false;
733 }
Chong Zhangf596cd52016-01-05 13:42:44 -0800734 // Since the window already timed out, remove it immediately now.
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700735 // Use WindowState#remove() instead of removeWindowLocked(), as the latter
Chong Zhangf596cd52016-01-05 13:42:44 -0800736 // delays removal on certain conditions, which will leave the stale window in the
737 // stack and marked mWillReplaceWindow=false, so the window will never be removed.
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700738 candidate.remove();
Robert Carra1eb4392015-12-10 12:43:51 -0800739 }
740 }
741
Chong Zhangd78ddb42016-03-02 17:01:14 -0800742 private boolean canFreezeBounds() {
743 // For freeform windows, we can't freeze the bounds at the moment because this would make
744 // the resizing unresponsive.
745 return mTask != null && !mTask.inFreeformWorkspace();
746 }
747
Jorim Jaggi0429f352015-12-22 16:29:16 +0100748 /**
749 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
750 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
751 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
752 * with a queue.
753 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800754 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100755 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700756
757 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
758 // We didn't call prepareFreezingBounds on the task, so use the current value.
759 final Configuration config = new Configuration(service.mCurConfiguration);
760 config.updateFrom(mTask.mOverrideConfig);
761 mFrozenMergedConfig.offer(config);
762 } else {
763 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
764 }
765 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100766 }
767
768 /**
769 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
770 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800771 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700772 if (!mFrozenBounds.isEmpty()) {
773 mFrozenBounds.remove();
774 }
775 if (!mFrozenMergedConfig.isEmpty()) {
776 mFrozenMergedConfig.remove();
777 }
Wale Ogunwale455fac52016-07-21 07:24:49 -0700778 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
779 final WindowState win = allAppWindows.get(i);
Jorim Jaggi69abc192016-02-04 19:34:00 -0800780 if (!win.mHasSurface) {
781 continue;
782 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100783 win.mLayoutNeeded = true;
784 win.setDisplayLayoutNeeded();
785 if (!service.mResizingWindows.contains(win)) {
786 service.mResizingWindows.add(win);
787 }
788 }
789 service.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100790 }
791
Robert Carr91b228092016-06-28 17:32:37 -0700792 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
793 mSurfaceViewBackgrounds.add(background);
794 }
795
796 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
797 mSurfaceViewBackgrounds.remove(background);
798 updateSurfaceViewBackgroundVisibilities();
799 }
800
801 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
802 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
803 // below the main app window (as traditionally a SurfaceView which is never drawn
804 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
805 // the background for the SurfaceView with lowest Z order
806 void updateSurfaceViewBackgroundVisibilities() {
807 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
808 int bottomLayer = Integer.MAX_VALUE;
809 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
810 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
811 if (sc.mVisible && sc.mLayer < bottomLayer) {
812 bottomLayer = sc.mLayer;
813 bottom = sc;
814 }
815 }
816 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
817 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
818 sc.updateBackgroundVisibility(sc != bottom);
819 }
820 }
821
Craig Mautnerdbb79912012-03-01 18:59:14 -0800822 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800823 void dump(PrintWriter pw, String prefix) {
824 super.dump(pw, prefix);
825 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700826 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800827 }
828 if (allAppWindows.size() > 0) {
829 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
830 }
Craig Mautner83162a92015-01-26 14:43:30 -0800831 pw.print(prefix); pw.print("task="); pw.println(mTask);
832 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800833 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
834 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
835 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700836 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800837 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700838 if (paused) {
839 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800840 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800841 if (mAppStopped) {
842 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
843 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800844 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700845 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800846 pw.print(prefix); pw.print("numInterestingWindows=");
847 pw.print(numInterestingWindows);
848 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
849 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700850 pw.print(" allDrawn="); pw.print(allDrawn);
851 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
852 pw.println(")");
853 }
854 if (inPendingTransaction) {
855 pw.print(prefix); pw.print("inPendingTransaction=");
856 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800857 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800858 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800859 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
860 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800861 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800862 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800863 }
864 if (startingWindow != null || startingView != null
865 || startingDisplayed || startingMoved) {
866 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
867 pw.print(" startingView="); pw.print(startingView);
868 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800869 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800870 }
Jorim Jaggi0429f352015-12-22 16:29:16 +0100871 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -0800872 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700873 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -0800874 }
875 if (mPendingRelaunchCount != 0) {
876 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +0100877 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800878 }
879
880 @Override
881 public String toString() {
882 if (stringName == null) {
883 StringBuilder sb = new StringBuilder();
884 sb.append("AppWindowToken{");
885 sb.append(Integer.toHexString(System.identityHashCode(this)));
886 sb.append(" token="); sb.append(token); sb.append('}');
887 stringName = sb.toString();
888 }
889 return stringName;
890 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700891}