blob: b49641fb6ab6822b80ac9d754bb17de03e10a8ba [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
19import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080020import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
21import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Robert Carra1eb4392015-12-10 12:43:51 -080022import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080023import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
24import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
25import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
26import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080027
Jeff Brown4532e612012-04-05 14:27:12 -070028import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080029import com.android.server.wm.WindowManagerService.H;
30
Filip Gruszczynskia590c992015-11-25 16:45:26 -080031import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080032import android.content.pm.ActivityInfo;
33import android.os.Message;
34import android.os.RemoteException;
35import android.util.Slog;
36import android.view.IApplicationToken;
37import android.view.View;
38import android.view.WindowManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080039
40import java.io.PrintWriter;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080041import java.util.ArrayList;
42
43class AppTokenList extends ArrayList<AppWindowToken> {
44}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080045
46/**
47 * Version of WindowToken that is specifically for a particular application (or
48 * really activity) that is displaying windows.
49 */
Craig Mautnere32c3072012-03-12 15:25:35 -070050class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080051 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
52
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080053 // Non-null only for application tokens.
54 final IApplicationToken appToken;
55
56 // All of the windows and child windows that are included in this
57 // application token. Note this list is NOT sorted!
Craig Mautner96868332012-12-04 14:29:11 -080058 final WindowList allAppWindows = new WindowList();
Filip Gruszczynskia590c992015-11-25 16:45:26 -080059 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070060
Dianne Hackborne30e02f2014-05-27 18:24:45 -070061 final boolean voiceInteraction;
62
Chong Zhangdb20b5f2015-10-23 14:01:43 -070063 // Whether we're performing an entering animation with a saved surface.
64 boolean mAnimatingWithSavedSurface;
65
Craig Mautner83162a92015-01-26 14:43:30 -080066 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080067 boolean appFullscreen;
68 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080069 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070070 boolean showForAllUsers;
Craig Mautnera2c77052012-03-26 12:14:43 -070071
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080072 // The input dispatching timeout for this application token in nanoseconds.
73 long inputDispatchingTimeoutNanos;
74
75 // These are used for determining when all windows associated with
76 // an activity have been drawn, so they can be made visible together
77 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070078 // initialize so that it doesn't match mTransactionSequence which is an int.
79 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080080 int numInterestingWindows;
81 int numDrawnWindows;
82 boolean inPendingTransaction;
83 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080084 // Set to true when this app creates a surface while in the middle of an animation. In that
85 // case do not clear allDrawn until the animation completes.
86 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080087
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080088 // Is this window's surface needed? This is almost like hidden, except
89 // it will sometimes be true a little earlier: when the token has
90 // been shown, but is still waiting for its app transition to execute
91 // before making its windows shown.
92 boolean hiddenRequested;
93
94 // Have we told the window clients to hide themselves?
95 boolean clientHidden;
96
97 // Last visibility state we reported to the app token.
98 boolean reportedVisible;
99
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700100 // Last drawn state we reported to the app token.
101 boolean reportedDrawn;
102
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800103 // Set to true when the token has been removed from the window mgr.
104 boolean removed;
105
Chong Zhang112eb8c2015-11-02 11:17:00 -0800106 boolean appDied;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800107 // Information about an application starting window if displayed.
108 StartingData startingData;
109 WindowState startingWindow;
110 View startingView;
111 boolean startingDisplayed;
112 boolean startingMoved;
113 boolean firstWindowDrawn;
114
115 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700116 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800117
Craig Mautner799bc1d2015-01-14 10:33:48 -0800118 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800119
Craig Mautnerbb742462014-07-07 15:28:55 -0700120 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700121 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700122
Wale Ogunwale61b009e2015-09-16 15:43:05 -0700123 // True if the windows associated with this token should be cropped to their stack bounds.
124 boolean mCropWindowsToStack;
125
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700126 AppWindowToken(WindowManagerService _service, IApplicationToken _token,
127 boolean _voiceInteraction) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800128 super(_service, _token.asBinder(),
129 WindowManager.LayoutParams.TYPE_APPLICATION, true);
130 appWindowToken = this;
131 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700132 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800133 mInputApplicationHandle = new InputApplicationHandle(this);
Craig Mautner322e4032012-07-13 13:35:20 -0700134 mAppAnimator = new AppWindowAnimator(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800135 }
136
137 void sendAppVisibilityToClients() {
138 final int N = allAppWindows.size();
139 for (int i=0; i<N; i++) {
140 WindowState win = allAppWindows.get(i);
141 if (win == startingWindow && clientHidden) {
142 // Don't hide the starting window.
143 continue;
144 }
145 try {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800146 if (DEBUG_VISIBILITY) Slog.v(TAG,
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800147 "Setting visibility of " + win + ": " + (!clientHidden));
148 win.mClient.dispatchAppVisibility(!clientHidden);
149 } catch (RemoteException e) {
150 }
151 }
152 }
153
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800154 void updateReportedVisibilityLocked() {
155 if (appToken == null) {
156 return;
157 }
158
159 int numInteresting = 0;
160 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700161 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800162 boolean nowGone = true;
163
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800164 if (DEBUG_VISIBILITY) Slog.v(TAG,
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700165 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800166 final int N = allAppWindows.size();
167 for (int i=0; i<N; i++) {
168 WindowState win = allAppWindows.get(i);
169 if (win == startingWindow || win.mAppFreezing
170 || win.mViewVisibility != View.VISIBLE
171 || win.mAttrs.type == TYPE_APPLICATION_STARTING
172 || win.mDestroying) {
173 continue;
174 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800175 if (DEBUG_VISIBILITY) {
176 Slog.v(TAG, "Win " + win + ": isDrawn="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800177 + win.isDrawnLw()
Craig Mautnera2c77052012-03-26 12:14:43 -0700178 + ", isAnimating=" + win.mWinAnimator.isAnimating());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800179 if (!win.isDrawnLw()) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800180 Slog.v(TAG, "Not displayed: s=" +
Robert Carre6a83512015-11-03 16:09:21 -0800181 win.mWinAnimator.mSurfaceController
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800182 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700183 + " mDrawState=" + win.mWinAnimator.mDrawState
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800184 + " ah=" + win.mAttachedHidden
185 + " th="
186 + (win.mAppToken != null
187 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700188 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800189 }
190 }
191 numInteresting++;
192 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700193 numDrawn++;
Craig Mautnera2c77052012-03-26 12:14:43 -0700194 if (!win.mWinAnimator.isAnimating()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800195 numVisible++;
196 }
197 nowGone = false;
Craig Mautnera2c77052012-03-26 12:14:43 -0700198 } else if (win.mWinAnimator.isAnimating()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800199 nowGone = false;
200 }
201 }
202
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700203 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800204 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700205 if (!nowGone) {
206 // If the app is not yet gone, then it can only become visible/drawn.
207 if (!nowDrawn) {
208 nowDrawn = reportedDrawn;
209 }
210 if (!nowVisible) {
211 nowVisible = reportedVisible;
212 }
213 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800214 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800215 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700216 if (nowDrawn != reportedDrawn) {
217 if (nowDrawn) {
218 Message m = service.mH.obtainMessage(
219 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
220 service.mH.sendMessage(m);
221 }
222 reportedDrawn = nowDrawn;
223 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800224 if (nowVisible != reportedVisible) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800225 if (DEBUG_VISIBILITY) Slog.v(
226 TAG, "Visibility changed in " + this
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800227 + ": vis=" + nowVisible);
228 reportedVisible = nowVisible;
229 Message m = service.mH.obtainMessage(
230 H.REPORT_APPLICATION_TOKEN_WINDOWS,
231 nowVisible ? 1 : 0,
232 nowGone ? 1 : 0,
233 this);
234 service.mH.sendMessage(m);
235 }
236 }
237
238 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700239 WindowState candidate = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800240 int j = windows.size();
241 while (j > 0) {
242 j--;
243 WindowState win = windows.get(j);
244 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
245 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700246 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900247 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700248 // constructing the animation, we want the new window, not the exiting one.
249 if (win.mExiting) {
250 candidate = win;
251 } else {
252 return win;
253 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800254 }
255 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700256 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800257 }
258
Wale Ogunwaled045c822015-12-02 09:14:28 -0800259 boolean stackCanReceiveKeys() {
260 return (windows.size() > 0) ? windows.get(windows.size() - 1).stackCanReceiveKeys() : false;
261 }
262
Craig Mautner72669d12012-12-18 17:23:54 -0800263 boolean isVisible() {
264 final int N = allAppWindows.size();
Craig Mautner72669d12012-12-18 17:23:54 -0800265 for (int i=0; i<N; i++) {
266 WindowState win = allAppWindows.get(i);
Chong Zhangdb20b5f2015-10-23 14:01:43 -0700267 // If we're animating with a saved surface, we're already visible.
268 // Return true so that the alpha doesn't get cleared.
Craig Mautner72669d12012-12-18 17:23:54 -0800269 if (!win.mAppFreezing
Filip Gruszczynski57f76f12015-11-04 16:10:54 -0800270 && (win.mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface
271 || (win.mWinAnimator.isAnimating()
272 && !service.mAppTransition.isTransitionSet()))
273 && !win.mDestroying
274 && win.isDrawnLw()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800275 return true;
276 }
277 }
278 return false;
279 }
280
Craig Mautnere3119b72015-01-20 15:02:36 -0800281 void removeAppFromTaskLocked() {
282 mIsExiting = false;
283 removeAllWindows();
284
Craig Mautner83162a92015-01-26 14:43:30 -0800285 // Use local variable because removeAppToken will null out mTask.
286 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800287 if (task != null) {
288 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800289 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800290 + " not found.");
291 }
292 task.mStack.mExitingAppTokens.remove(this);
293 }
294 }
295
Chong Zhangbef461f2015-10-27 11:38:24 -0700296 /**
297 * Checks whether we should save surfaces for this app.
298 *
299 * @return true if the surfaces should be saved, false otherwise.
300 */
301 boolean shouldSaveSurface() {
302 // We want to save surface if the app's windows are "allDrawn", or if we're
303 // currently animating with save surfaces. (If the app didn't even finish
304 // drawing when the user exits, but we have a saved surface from last time,
305 // we still want to keep that surface.)
Robert Carr13f7be9e2015-12-02 18:39:45 -0800306 return allDrawn || mAnimatingWithSavedSurface;
307 }
308
309 boolean hasSavedSurface() {
310 for (int i = windows.size() -1; i >= 0; i--) {
311 final WindowState ws = windows.get(i);
312 if (ws.hasSavedSurface()) {
313 return true;
314 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700315 }
316 return false;
317 }
318
319 void restoreSavedSurfaces() {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800320 if (!hasSavedSurface()) {
Chong Zhangbef461f2015-10-27 11:38:24 -0700321 return;
322 }
323
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800324 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG_WM,
Chong Zhangbef461f2015-10-27 11:38:24 -0700325 "Restoring saved surfaces: " + this + ", allDrawn=" + allDrawn);
326
Chong Zhangbef461f2015-10-27 11:38:24 -0700327 mAnimatingWithSavedSurface = true;
328 for (int i = windows.size() - 1; i >= 0; i--) {
329 WindowState ws = windows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800330 ws.restoreSavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700331 }
332 }
333
334 void destroySavedSurfaces() {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800335 for (int i = windows.size() - 1; i >= 0; i--) {
336 WindowState win = windows.get(i);
337 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700338 }
339 }
340
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800341 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700342 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800343 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
344 // removeWindowLocked at bottom of loop may remove multiple entries from
345 // allAppWindows if the window to be removed has child windows. It also may
346 // not remove any windows from allAppWindows at all if win is exiting and
347 // currently animating away. This ensures that winNdx is monotonically decreasing
348 // and never beyond allAppWindows bounds.
349 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
350 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800351 if (DEBUG_WINDOW_MOVEMENT) {
352 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800353 }
354
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700355 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700356 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800357 allAppWindows.clear();
358 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700359 }
360
Chong Zhang112eb8c2015-11-02 11:17:00 -0800361 void removeAllDeadWindows() {
362 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
363 // removeWindowLocked at bottom of loop may remove multiple entries from
364 // allAppWindows if the window to be removed has child windows. It also may
365 // not remove any windows from allAppWindows at all if win is exiting and
366 // currently animating away. This ensures that winNdx is monotonically decreasing
367 // and never beyond allAppWindows bounds.
368 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
369 WindowState win = allAppWindows.get(winNdx);
370 if (win.mAppDied) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800371 if (DEBUG_WINDOW_MOVEMENT) {
372 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800373 }
374 // Set mDestroying, we don't want any animation or delayed removal here.
375 win.mDestroying = true;
376 service.removeWindowLocked(win);
377 }
378 }
379 }
380
Robert Carra1eb4392015-12-10 12:43:51 -0800381 void setReplacingWindows(boolean animate) {
382 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
383 + " with replacing windows.");
384
385 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
386 final WindowState w = allAppWindows.get(i);
387 w.setReplacing(animate);
388 }
389 if (animate) {
390 // Set-up dummy animation so we can start treating windows associated with this
391 // token like they are in transition before the new app window is ready for us to
392 // run the real transition animation.
393 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
394 "setReplacingWindow() Setting dummy animation on: " + this);
395 mAppAnimator.setDummyAnimation();
396 }
397 }
398
399 void addWindow(WindowState w) {
400 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
401 WindowState candidate = allAppWindows.get(i);
402 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
403 candidate.getWindowTag().equals(w.getWindowTag().toString())) {
404 candidate.mReplacingWindow = w;
405 }
406 }
407 allAppWindows.add(w);
408 }
409
410 boolean waitingForReplacement() {
411 for (int i = allAppWindows.size() -1; i >= 0; i--) {
412 WindowState candidate = allAppWindows.get(i);
413 if (candidate.mWillReplaceWindow) {
414 return true;
415 }
416 }
417 return false;
418 }
419
420 void clearTimedoutReplaceesLocked() {
421 for (int i = allAppWindows.size() - 1; i >= 0;
422 // removeWindowLocked at bottom of loop may remove multiple entries from
423 // allAppWindows if the window to be removed has child windows. It also may
424 // not remove any windows from allAppWindows at all if win is exiting and
425 // currently animating away. This ensures that winNdx is monotonically decreasing
426 // and never beyond allAppWindows bounds.
427 i = Math.min(i - 1, allAppWindows.size() - 1)) {
428 WindowState candidate = allAppWindows.get(i);
429 if (candidate.mWillReplaceWindow == false) {
430 continue;
431 }
432 candidate.mWillReplaceWindow = false;
433 service.removeWindowLocked(candidate);
434 }
435 }
436
Craig Mautnerdbb79912012-03-01 18:59:14 -0800437 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800438 void dump(PrintWriter pw, String prefix) {
439 super.dump(pw, prefix);
440 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700441 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800442 }
443 if (allAppWindows.size() > 0) {
444 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
445 }
Craig Mautner83162a92015-01-26 14:43:30 -0800446 pw.print(prefix); pw.print("task="); pw.println(mTask);
447 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800448 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
449 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
450 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700451 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800452 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700453 if (paused) {
454 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800455 }
456 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700457 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800458 pw.print(prefix); pw.print("numInterestingWindows=");
459 pw.print(numInterestingWindows);
460 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
461 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700462 pw.print(" allDrawn="); pw.print(allDrawn);
463 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
464 pw.println(")");
465 }
466 if (inPendingTransaction) {
467 pw.print(prefix); pw.print("inPendingTransaction=");
468 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800469 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800470 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800471 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
472 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800473 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800474 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800475 }
476 if (startingWindow != null || startingView != null
477 || startingDisplayed || startingMoved) {
478 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
479 pw.print(" startingView="); pw.print(startingView);
480 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
481 pw.print(" startingMoved"); pw.println(startingMoved);
482 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800483 }
484
485 @Override
486 public String toString() {
487 if (stringName == null) {
488 StringBuilder sb = new StringBuilder();
489 sb.append("AppWindowToken{");
490 sb.append(Integer.toHexString(System.identityHashCode(this)));
491 sb.append(" token="); sb.append(token); sb.append('}');
492 stringName = sb.toString();
493 }
494 return stringName;
495 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700496}