blob: 9b9f14bee98294a9e663a92f6076c5418255968b [file] [log] [blame]
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.wm;
18
Wale Ogunwale6cae7652015-12-26 07:36:26 -080019import static android.app.ActivityManager.StackId;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080020import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080021import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
22import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Robert Carra1eb4392015-12-10 12:43:51 -080023import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080024import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
25import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
26import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
27import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080028
Jeff Brown4532e612012-04-05 14:27:12 -070029import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080030import com.android.server.wm.WindowManagerService.H;
31
Filip Gruszczynskia590c992015-11-25 16:45:26 -080032import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080033import android.content.pm.ActivityInfo;
34import android.os.Message;
35import android.os.RemoteException;
36import android.util.Slog;
37import android.view.IApplicationToken;
38import android.view.View;
39import android.view.WindowManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080040
41import java.io.PrintWriter;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080042import java.util.ArrayList;
43
44class AppTokenList extends ArrayList<AppWindowToken> {
45}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080046
47/**
48 * Version of WindowToken that is specifically for a particular application (or
49 * really activity) that is displaying windows.
50 */
Craig Mautnere32c3072012-03-12 15:25:35 -070051class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080052 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
53
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080054 // Non-null only for application tokens.
55 final IApplicationToken appToken;
56
57 // All of the windows and child windows that are included in this
58 // application token. Note this list is NOT sorted!
Craig Mautner96868332012-12-04 14:29:11 -080059 final WindowList allAppWindows = new WindowList();
Filip Gruszczynskia590c992015-11-25 16:45:26 -080060 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070061
Dianne Hackborne30e02f2014-05-27 18:24:45 -070062 final boolean voiceInteraction;
63
Chong Zhangdb20b5f2015-10-23 14:01:43 -070064 // Whether we're performing an entering animation with a saved surface.
65 boolean mAnimatingWithSavedSurface;
66
Craig Mautner83162a92015-01-26 14:43:30 -080067 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080068 boolean appFullscreen;
69 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080070 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070071 boolean showForAllUsers;
Craig Mautnera2c77052012-03-26 12:14:43 -070072
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080073 // The input dispatching timeout for this application token in nanoseconds.
74 long inputDispatchingTimeoutNanos;
75
76 // These are used for determining when all windows associated with
77 // an activity have been drawn, so they can be made visible together
78 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070079 // initialize so that it doesn't match mTransactionSequence which is an int.
80 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080081 int numInterestingWindows;
82 int numDrawnWindows;
83 boolean inPendingTransaction;
84 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080085 // Set to true when this app creates a surface while in the middle of an animation. In that
86 // case do not clear allDrawn until the animation completes.
87 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080088
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080089 // Is this window's surface needed? This is almost like hidden, except
90 // it will sometimes be true a little earlier: when the token has
91 // been shown, but is still waiting for its app transition to execute
92 // before making its windows shown.
93 boolean hiddenRequested;
94
95 // Have we told the window clients to hide themselves?
96 boolean clientHidden;
97
98 // Last visibility state we reported to the app token.
99 boolean reportedVisible;
100
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700101 // Last drawn state we reported to the app token.
102 boolean reportedDrawn;
103
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800104 // Set to true when the token has been removed from the window mgr.
105 boolean removed;
106
Chong Zhang112eb8c2015-11-02 11:17:00 -0800107 boolean appDied;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800108 // Information about an application starting window if displayed.
109 StartingData startingData;
110 WindowState startingWindow;
111 View startingView;
112 boolean startingDisplayed;
113 boolean startingMoved;
114 boolean firstWindowDrawn;
115
116 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700117 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800118
Craig Mautner799bc1d2015-01-14 10:33:48 -0800119 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800120
Craig Mautnerbb742462014-07-07 15:28:55 -0700121 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700122 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700123
Wale Ogunwale61b009e2015-09-16 15:43:05 -0700124 // True if the windows associated with this token should be cropped to their stack bounds.
125 boolean mCropWindowsToStack;
126
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800127 boolean mAlwaysFocusable;
128
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700129 AppWindowToken(WindowManagerService _service, IApplicationToken _token,
130 boolean _voiceInteraction) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800131 super(_service, _token.asBinder(),
132 WindowManager.LayoutParams.TYPE_APPLICATION, true);
133 appWindowToken = this;
134 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700135 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800136 mInputApplicationHandle = new InputApplicationHandle(this);
Craig Mautner322e4032012-07-13 13:35:20 -0700137 mAppAnimator = new AppWindowAnimator(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800138 }
139
140 void sendAppVisibilityToClients() {
141 final int N = allAppWindows.size();
142 for (int i=0; i<N; i++) {
143 WindowState win = allAppWindows.get(i);
144 if (win == startingWindow && clientHidden) {
145 // Don't hide the starting window.
146 continue;
147 }
148 try {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800149 if (DEBUG_VISIBILITY) Slog.v(TAG,
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800150 "Setting visibility of " + win + ": " + (!clientHidden));
151 win.mClient.dispatchAppVisibility(!clientHidden);
152 } catch (RemoteException e) {
153 }
154 }
155 }
156
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800157 void updateReportedVisibilityLocked() {
158 if (appToken == null) {
159 return;
160 }
161
162 int numInteresting = 0;
163 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700164 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800165 boolean nowGone = true;
166
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800167 if (DEBUG_VISIBILITY) Slog.v(TAG,
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700168 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800169 final int N = allAppWindows.size();
170 for (int i=0; i<N; i++) {
171 WindowState win = allAppWindows.get(i);
172 if (win == startingWindow || win.mAppFreezing
173 || win.mViewVisibility != View.VISIBLE
174 || win.mAttrs.type == TYPE_APPLICATION_STARTING
175 || win.mDestroying) {
176 continue;
177 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800178 if (DEBUG_VISIBILITY) {
179 Slog.v(TAG, "Win " + win + ": isDrawn="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800180 + win.isDrawnLw()
Craig Mautnera2c77052012-03-26 12:14:43 -0700181 + ", isAnimating=" + win.mWinAnimator.isAnimating());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800182 if (!win.isDrawnLw()) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800183 Slog.v(TAG, "Not displayed: s=" +
Robert Carre6a83512015-11-03 16:09:21 -0800184 win.mWinAnimator.mSurfaceController
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800185 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700186 + " mDrawState=" + win.mWinAnimator.mDrawState
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800187 + " ah=" + win.mAttachedHidden
188 + " th="
189 + (win.mAppToken != null
190 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700191 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800192 }
193 }
194 numInteresting++;
195 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700196 numDrawn++;
Craig Mautnera2c77052012-03-26 12:14:43 -0700197 if (!win.mWinAnimator.isAnimating()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800198 numVisible++;
199 }
200 nowGone = false;
Craig Mautnera2c77052012-03-26 12:14:43 -0700201 } else if (win.mWinAnimator.isAnimating()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800202 nowGone = false;
203 }
204 }
205
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700206 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800207 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700208 if (!nowGone) {
209 // If the app is not yet gone, then it can only become visible/drawn.
210 if (!nowDrawn) {
211 nowDrawn = reportedDrawn;
212 }
213 if (!nowVisible) {
214 nowVisible = reportedVisible;
215 }
216 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800217 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800218 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700219 if (nowDrawn != reportedDrawn) {
220 if (nowDrawn) {
221 Message m = service.mH.obtainMessage(
222 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
223 service.mH.sendMessage(m);
224 }
225 reportedDrawn = nowDrawn;
226 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800227 if (nowVisible != reportedVisible) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800228 if (DEBUG_VISIBILITY) Slog.v(
229 TAG, "Visibility changed in " + this
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800230 + ": vis=" + nowVisible);
231 reportedVisible = nowVisible;
232 Message m = service.mH.obtainMessage(
233 H.REPORT_APPLICATION_TOKEN_WINDOWS,
234 nowVisible ? 1 : 0,
235 nowGone ? 1 : 0,
236 this);
237 service.mH.sendMessage(m);
238 }
239 }
240
241 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700242 WindowState candidate = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800243 int j = windows.size();
244 while (j > 0) {
245 j--;
246 WindowState win = windows.get(j);
247 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
248 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700249 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900250 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700251 // constructing the animation, we want the new window, not the exiting one.
252 if (win.mExiting) {
253 candidate = win;
254 } else {
255 return win;
256 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800257 }
258 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700259 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800260 }
261
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800262 boolean windowsAreFocusable() {
263 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800264 }
265
Craig Mautner72669d12012-12-18 17:23:54 -0800266 boolean isVisible() {
267 final int N = allAppWindows.size();
Craig Mautner72669d12012-12-18 17:23:54 -0800268 for (int i=0; i<N; i++) {
269 WindowState win = allAppWindows.get(i);
Chong Zhangdb20b5f2015-10-23 14:01:43 -0700270 // If we're animating with a saved surface, we're already visible.
271 // Return true so that the alpha doesn't get cleared.
Craig Mautner72669d12012-12-18 17:23:54 -0800272 if (!win.mAppFreezing
Filip Gruszczynski57f76f12015-11-04 16:10:54 -0800273 && (win.mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface
274 || (win.mWinAnimator.isAnimating()
275 && !service.mAppTransition.isTransitionSet()))
276 && !win.mDestroying
277 && win.isDrawnLw()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800278 return true;
279 }
280 }
281 return false;
282 }
283
Craig Mautnere3119b72015-01-20 15:02:36 -0800284 void removeAppFromTaskLocked() {
285 mIsExiting = false;
286 removeAllWindows();
287
Craig Mautner83162a92015-01-26 14:43:30 -0800288 // Use local variable because removeAppToken will null out mTask.
289 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800290 if (task != null) {
291 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800292 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800293 + " not found.");
294 }
295 task.mStack.mExitingAppTokens.remove(this);
296 }
297 }
298
Chong Zhangbef461f2015-10-27 11:38:24 -0700299 /**
300 * Checks whether we should save surfaces for this app.
301 *
302 * @return true if the surfaces should be saved, false otherwise.
303 */
304 boolean shouldSaveSurface() {
305 // We want to save surface if the app's windows are "allDrawn", or if we're
306 // currently animating with save surfaces. (If the app didn't even finish
307 // drawing when the user exits, but we have a saved surface from last time,
308 // we still want to keep that surface.)
Robert Carr13f7be9e2015-12-02 18:39:45 -0800309 return allDrawn || mAnimatingWithSavedSurface;
310 }
311
312 boolean hasSavedSurface() {
313 for (int i = windows.size() -1; i >= 0; i--) {
314 final WindowState ws = windows.get(i);
315 if (ws.hasSavedSurface()) {
316 return true;
317 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700318 }
319 return false;
320 }
321
322 void restoreSavedSurfaces() {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800323 if (!hasSavedSurface()) {
Chong Zhangbef461f2015-10-27 11:38:24 -0700324 return;
325 }
326
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800327 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG_WM,
Chong Zhangbef461f2015-10-27 11:38:24 -0700328 "Restoring saved surfaces: " + this + ", allDrawn=" + allDrawn);
329
Chong Zhangbef461f2015-10-27 11:38:24 -0700330 mAnimatingWithSavedSurface = true;
331 for (int i = windows.size() - 1; i >= 0; i--) {
332 WindowState ws = windows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800333 ws.restoreSavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700334 }
335 }
336
337 void destroySavedSurfaces() {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800338 for (int i = windows.size() - 1; i >= 0; i--) {
339 WindowState win = windows.get(i);
340 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700341 }
342 }
343
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800344 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700345 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800346 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
347 // removeWindowLocked at bottom of loop may remove multiple entries from
348 // allAppWindows if the window to be removed has child windows. It also may
349 // not remove any windows from allAppWindows at all if win is exiting and
350 // currently animating away. This ensures that winNdx is monotonically decreasing
351 // and never beyond allAppWindows bounds.
352 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
353 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800354 if (DEBUG_WINDOW_MOVEMENT) {
355 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800356 }
357
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700358 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700359 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800360 allAppWindows.clear();
361 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700362 }
363
Chong Zhang112eb8c2015-11-02 11:17:00 -0800364 void removeAllDeadWindows() {
365 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
366 // removeWindowLocked at bottom of loop may remove multiple entries from
367 // allAppWindows if the window to be removed has child windows. It also may
368 // not remove any windows from allAppWindows at all if win is exiting and
369 // currently animating away. This ensures that winNdx is monotonically decreasing
370 // and never beyond allAppWindows bounds.
371 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
372 WindowState win = allAppWindows.get(winNdx);
373 if (win.mAppDied) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800374 if (DEBUG_WINDOW_MOVEMENT) {
375 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800376 }
377 // Set mDestroying, we don't want any animation or delayed removal here.
378 win.mDestroying = true;
379 service.removeWindowLocked(win);
380 }
381 }
382 }
383
Robert Carra1eb4392015-12-10 12:43:51 -0800384 void setReplacingWindows(boolean animate) {
385 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
386 + " with replacing windows.");
387
388 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
389 final WindowState w = allAppWindows.get(i);
390 w.setReplacing(animate);
391 }
392 if (animate) {
393 // Set-up dummy animation so we can start treating windows associated with this
394 // token like they are in transition before the new app window is ready for us to
395 // run the real transition animation.
396 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
397 "setReplacingWindow() Setting dummy animation on: " + this);
398 mAppAnimator.setDummyAnimation();
399 }
400 }
401
402 void addWindow(WindowState w) {
403 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
404 WindowState candidate = allAppWindows.get(i);
405 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
406 candidate.getWindowTag().equals(w.getWindowTag().toString())) {
407 candidate.mReplacingWindow = w;
408 }
409 }
410 allAppWindows.add(w);
411 }
412
413 boolean waitingForReplacement() {
414 for (int i = allAppWindows.size() -1; i >= 0; i--) {
415 WindowState candidate = allAppWindows.get(i);
416 if (candidate.mWillReplaceWindow) {
417 return true;
418 }
419 }
420 return false;
421 }
422
423 void clearTimedoutReplaceesLocked() {
424 for (int i = allAppWindows.size() - 1; i >= 0;
425 // removeWindowLocked at bottom of loop may remove multiple entries from
426 // allAppWindows if the window to be removed has child windows. It also may
427 // not remove any windows from allAppWindows at all if win is exiting and
428 // currently animating away. This ensures that winNdx is monotonically decreasing
429 // and never beyond allAppWindows bounds.
430 i = Math.min(i - 1, allAppWindows.size() - 1)) {
431 WindowState candidate = allAppWindows.get(i);
432 if (candidate.mWillReplaceWindow == false) {
433 continue;
434 }
435 candidate.mWillReplaceWindow = false;
436 service.removeWindowLocked(candidate);
437 }
438 }
439
Craig Mautnerdbb79912012-03-01 18:59:14 -0800440 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800441 void dump(PrintWriter pw, String prefix) {
442 super.dump(pw, prefix);
443 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700444 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800445 }
446 if (allAppWindows.size() > 0) {
447 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
448 }
Craig Mautner83162a92015-01-26 14:43:30 -0800449 pw.print(prefix); pw.print("task="); pw.println(mTask);
450 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800451 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
452 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
453 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700454 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800455 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -0700456 if (paused) {
457 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800458 }
459 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -0700460 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800461 pw.print(prefix); pw.print("numInterestingWindows=");
462 pw.print(numInterestingWindows);
463 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
464 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -0700465 pw.print(" allDrawn="); pw.print(allDrawn);
466 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
467 pw.println(")");
468 }
469 if (inPendingTransaction) {
470 pw.print(prefix); pw.print("inPendingTransaction=");
471 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800472 }
Craig Mautner799bc1d2015-01-14 10:33:48 -0800473 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800474 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
475 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -0800476 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -0800477 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800478 }
479 if (startingWindow != null || startingView != null
480 || startingDisplayed || startingMoved) {
481 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
482 pw.print(" startingView="); pw.print(startingView);
483 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
484 pw.print(" startingMoved"); pw.println(startingMoved);
485 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800486 }
487
488 @Override
489 public String toString() {
490 if (stringName == null) {
491 StringBuilder sb = new StringBuilder();
492 sb.append("AppWindowToken{");
493 sb.append(Integer.toHexString(System.identityHashCode(this)));
494 sb.append(" token="); sb.append(token); sb.append('}');
495 stringName = sb.toString();
496 }
497 return stringName;
498 }
Jeff Browne9bdb312012-04-05 15:30:10 -0700499}