blob: bbd6fd74351c3c958b2f132f6409204ca7caabe9 [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;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070020import static android.view.Display.DEFAULT_DISPLAY;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080021import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070022import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
23import static android.view.WindowManagerPolicy.TRANSIT_ENTER;
24import static android.view.WindowManagerPolicy.TRANSIT_EXIT;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080025import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
26import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Robert Carra1eb4392015-12-10 12:43:51 -080027import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070028import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYERS;
29import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
30import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
31import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RESIZE;
Wale Ogunwale9017ec02016-02-25 08:55:25 -080032import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080033import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
34import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
35import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
36import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Chong Zhang92147042016-05-09 12:47:11 -070037import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070038import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
39import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_TIMEOUT;
40import static com.android.server.wm.WindowManagerService.logWithStack;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080041
Jeff Brown4532e612012-04-05 14:27:12 -070042import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080043import com.android.server.wm.WindowManagerService.H;
44
Filip Gruszczynskia590c992015-11-25 16:45:26 -080045import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080046import android.content.pm.ActivityInfo;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070047import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010048import android.graphics.Rect;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070049import android.os.Binder;
50import android.os.IBinder;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080051import android.os.Message;
52import android.os.RemoteException;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070053import android.os.SystemClock;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080054import android.util.Slog;
55import android.view.IApplicationToken;
56import android.view.View;
57import android.view.WindowManager;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080058
59import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010060import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080061import java.util.ArrayList;
62
63class AppTokenList extends ArrayList<AppWindowToken> {
64}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080065
66/**
67 * Version of WindowToken that is specifically for a particular application (or
68 * really activity) that is displaying windows.
69 */
Craig Mautnere32c3072012-03-12 15:25:35 -070070class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080071 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
72
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080073 // Non-null only for application tokens.
74 final IApplicationToken appToken;
75
76 // All of the windows and child windows that are included in this
77 // application token. Note this list is NOT sorted!
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070078 private final WindowList allAppWindows = new WindowList();
Filip Gruszczynskia590c992015-11-25 16:45:26 -080079 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070080
Dianne Hackborne30e02f2014-05-27 18:24:45 -070081 final boolean voiceInteraction;
82
Craig Mautner83162a92015-01-26 14:43:30 -080083 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080084 boolean appFullscreen;
85 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080086 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070087 boolean showForAllUsers;
Yorke Lee0e852472016-06-15 10:03:18 -070088 int targetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070089
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080090 // The input dispatching timeout for this application token in nanoseconds.
91 long inputDispatchingTimeoutNanos;
92
93 // These are used for determining when all windows associated with
94 // an activity have been drawn, so they can be made visible together
95 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070096 // initialize so that it doesn't match mTransactionSequence which is an int.
97 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080098 int numInterestingWindows;
99 int numDrawnWindows;
100 boolean inPendingTransaction;
101 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -0800102 // Set to true when this app creates a surface while in the middle of an animation. In that
103 // case do not clear allDrawn until the animation completes.
104 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800105
Chong Zhang8e4bda92016-05-04 15:08:18 -0700106 // These are to track the app's real drawing status if there were no saved surfaces.
107 boolean allDrawnExcludingSaved;
108 int numInterestingWindowsExcludingSaved;
109 int numDrawnWindowsExclusingSaved;
110
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800111 // Is this window's surface needed? This is almost like hidden, except
112 // it will sometimes be true a little earlier: when the token has
113 // been shown, but is still waiting for its app transition to execute
114 // before making its windows shown.
115 boolean hiddenRequested;
116
117 // Have we told the window clients to hide themselves?
118 boolean clientHidden;
119
120 // Last visibility state we reported to the app token.
121 boolean reportedVisible;
122
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700123 // Last drawn state we reported to the app token.
124 boolean reportedDrawn;
125
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800126 // Set to true when the token has been removed from the window mgr.
127 boolean removed;
128
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800129 // Information about an application starting window if displayed.
130 StartingData startingData;
131 WindowState startingWindow;
132 View startingView;
133 boolean startingDisplayed;
134 boolean startingMoved;
135 boolean firstWindowDrawn;
136
137 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700138 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800139
Craig Mautner799bc1d2015-01-14 10:33:48 -0800140 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800141
Craig Mautnerbb742462014-07-07 15:28:55 -0700142 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700143 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700144
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800145 boolean mAlwaysFocusable;
146
Robert Carre12aece2016-02-02 22:43:27 -0800147 boolean mAppStopped;
Robert Carrfd10cd12016-06-29 16:41:50 -0700148 int mRotationAnimationHint;
Chong Zhangd78ddb42016-03-02 17:01:14 -0800149 int mPendingRelaunchCount;
Robert Carre12aece2016-02-02 22:43:27 -0800150
Robert Carr91b228092016-06-28 17:32:37 -0700151 private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds =
152 new ArrayList<WindowSurfaceController.SurfaceControlWithBackground>();
153
Jorim Jaggi0429f352015-12-22 16:29:16 +0100154 ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700155 ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100156
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700157 AppWindowToken(WindowManagerService _service, IApplicationToken _token,
158 boolean _voiceInteraction) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800159 super(_service, _token.asBinder(),
160 WindowManager.LayoutParams.TYPE_APPLICATION, true);
161 appWindowToken = this;
162 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700163 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800164 mInputApplicationHandle = new InputApplicationHandle(this);
Craig Mautner322e4032012-07-13 13:35:20 -0700165 mAppAnimator = new AppWindowAnimator(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800166 }
167
168 void sendAppVisibilityToClients() {
169 final int N = allAppWindows.size();
170 for (int i=0; i<N; i++) {
171 WindowState win = allAppWindows.get(i);
172 if (win == startingWindow && clientHidden) {
173 // Don't hide the starting window.
174 continue;
175 }
176 try {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800177 if (DEBUG_VISIBILITY) Slog.v(TAG,
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800178 "Setting visibility of " + win + ": " + (!clientHidden));
179 win.mClient.dispatchAppVisibility(!clientHidden);
180 } catch (RemoteException e) {
181 }
182 }
183 }
184
Chong Zhang92147042016-05-09 12:47:11 -0700185 void setVisibleBeforeClientHidden() {
186 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
187 final WindowState w = allAppWindows.get(i);
188 w.setVisibleBeforeClientHidden();
189 }
190 }
191
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800192 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
193 firstWindowDrawn = true;
194
195 // We now have a good window to show, remove dead placeholders
196 removeAllDeadWindows();
197
198 if (startingData != null) {
199 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
200 + win.mToken + ": first real window is shown, no animation");
201 // If this initial window is animating, stop it -- we will do an animation to reveal
202 // it from behind the starting window, so there is no need for it to also be doing its
203 // own stuff.
204 winAnimator.clearAnimation();
205 winAnimator.mService.mFinishedStarting.add(this);
206 winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
207 }
208 updateReportedVisibilityLocked();
209 }
210
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800211 void updateReportedVisibilityLocked() {
212 if (appToken == null) {
213 return;
214 }
215
216 int numInteresting = 0;
217 int numVisible = 0;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700218 int numDrawn = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800219 boolean nowGone = true;
220
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800221 if (DEBUG_VISIBILITY) Slog.v(TAG,
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700222 "Update reported visibility: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800223 final int N = allAppWindows.size();
224 for (int i=0; i<N; i++) {
225 WindowState win = allAppWindows.get(i);
226 if (win == startingWindow || win.mAppFreezing
227 || win.mViewVisibility != View.VISIBLE
228 || win.mAttrs.type == TYPE_APPLICATION_STARTING
229 || win.mDestroying) {
230 continue;
231 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800232 if (DEBUG_VISIBILITY) {
233 Slog.v(TAG, "Win " + win + ": isDrawn="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800234 + win.isDrawnLw()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700235 + ", isAnimationSet=" + win.mWinAnimator.isAnimationSet());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800236 if (!win.isDrawnLw()) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800237 Slog.v(TAG, "Not displayed: s=" +
Robert Carre6a83512015-11-03 16:09:21 -0800238 win.mWinAnimator.mSurfaceController
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800239 + " pv=" + win.mPolicyVisibility
Craig Mautner749a7bb2012-04-02 13:49:53 -0700240 + " mDrawState=" + win.mWinAnimator.mDrawState
Wale Ogunwale9d147902016-07-16 11:58:55 -0700241 + " ph=" + win.isParentWindowHidden()
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800242 + " th="
243 + (win.mAppToken != null
244 ? win.mAppToken.hiddenRequested : false)
Craig Mautnera2c77052012-03-26 12:14:43 -0700245 + " a=" + win.mWinAnimator.mAnimating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800246 }
247 }
248 numInteresting++;
249 if (win.isDrawnLw()) {
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700250 numDrawn++;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700251 if (!win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800252 numVisible++;
253 }
254 nowGone = false;
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700255 } else if (win.mWinAnimator.isAnimationSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800256 nowGone = false;
257 }
258 }
259
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700260 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800261 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700262 if (!nowGone) {
263 // If the app is not yet gone, then it can only become visible/drawn.
264 if (!nowDrawn) {
265 nowDrawn = reportedDrawn;
266 }
267 if (!nowVisible) {
268 nowVisible = reportedVisible;
269 }
270 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800271 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800272 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700273 if (nowDrawn != reportedDrawn) {
274 if (nowDrawn) {
275 Message m = service.mH.obtainMessage(
276 H.REPORT_APPLICATION_TOKEN_DRAWN, this);
277 service.mH.sendMessage(m);
278 }
279 reportedDrawn = nowDrawn;
280 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800281 if (nowVisible != reportedVisible) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800282 if (DEBUG_VISIBILITY) Slog.v(
283 TAG, "Visibility changed in " + this
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800284 + ": vis=" + nowVisible);
285 reportedVisible = nowVisible;
286 Message m = service.mH.obtainMessage(
287 H.REPORT_APPLICATION_TOKEN_WINDOWS,
288 nowVisible ? 1 : 0,
289 nowGone ? 1 : 0,
290 this);
291 service.mH.sendMessage(m);
292 }
293 }
294
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700295 boolean setVisibility(WindowManager.LayoutParams lp,
296 boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) {
297
298 boolean delayed = false;
299 inPendingTransaction = false;
300
301 if (clientHidden == visible) {
302 clientHidden = !visible;
303 sendAppVisibilityToClients();
304 }
305
306 // Allow for state changes and animation to be applied if:
307 // * token is transitioning visibility state
308 // * or the token was marked as hidden and is exiting before we had a chance to play the
309 // transition animation
310 // * or this is an opening app and windows are being replaced.
311 boolean visibilityChanged = false;
312 if (hidden == visible || (hidden && mIsExiting) || (visible && waitingForReplacement())) {
313 final AccessibilityController accessibilityController = service.mAccessibilityController;
314 boolean changed = false;
315 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
316 "Changing app " + this + " hidden=" + hidden + " performLayout=" + performLayout);
317
318 boolean runningAppAnimation = false;
319
320 if (transit != AppTransition.TRANSIT_UNSET) {
321 if (mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) {
322 mAppAnimator.setNullAnimation();
323 }
324 if (service.applyAnimationLocked(this, lp, transit, visible, isVoiceInteraction)) {
325 delayed = runningAppAnimation = true;
326 }
327 final WindowState window = findMainWindow();
328 //TODO (multidisplay): Magnification is supported only for the default display.
329 if (window != null && accessibilityController != null
330 && window.getDisplayId() == DEFAULT_DISPLAY) {
331 accessibilityController.onAppWindowTransitionLocked(window, transit);
332 }
333 changed = true;
334 }
335
336 final int windowsCount = allAppWindows.size();
337 for (int i = 0; i < windowsCount; i++) {
338 final WindowState win = allAppWindows.get(i);
339 if (win == startingWindow) {
340 // Starting window that's exiting will be removed when the animation finishes.
341 // Mark all relevant flags for that onExitAnimationDone will proceed all the way
342 // to actually remove it.
343 if (!visible && win.isVisibleNow() && mAppAnimator.isAnimating()) {
344 win.mAnimatingExit = true;
345 win.mRemoveOnExit = true;
346 win.mWindowRemovalAllowed = true;
347 }
348 continue;
349 }
350
351 //Slog.i(TAG_WM, "Window " + win + ": vis=" + win.isVisible());
352 //win.dump(" ");
353 if (visible) {
354 if (!win.isVisibleNow()) {
355 if (!runningAppAnimation) {
356 win.mWinAnimator.applyAnimationLocked(TRANSIT_ENTER, true);
357 //TODO (multidisplay): Magnification is supported only for the default
358 if (accessibilityController != null
359 && win.getDisplayId() == DEFAULT_DISPLAY) {
360 accessibilityController.onWindowTransitionLocked(win, TRANSIT_ENTER);
361 }
362 }
363 changed = true;
364 win.setDisplayLayoutNeeded();
365 }
366 } else if (win.isVisibleNow()) {
367 if (!runningAppAnimation) {
368 win.mWinAnimator.applyAnimationLocked(TRANSIT_EXIT, false);
369 //TODO (multidisplay): Magnification is supported only for the default
370 if (accessibilityController != null
371 && win.getDisplayId() == DEFAULT_DISPLAY) {
372 accessibilityController.onWindowTransitionLocked(win,TRANSIT_EXIT);
373 }
374 }
375 changed = true;
376 win.setDisplayLayoutNeeded();
377 }
378 }
379
380 hidden = hiddenRequested = !visible;
381 visibilityChanged = true;
382 if (!visible) {
383 stopFreezingScreen(true, true);
384 } else {
385 // If we are being set visible, and the starting window is
386 // not yet displayed, then make sure it doesn't get displayed.
387 WindowState swin = startingWindow;
388 if (swin != null && !swin.isDrawnLw()) {
389 swin.mPolicyVisibility = false;
390 swin.mPolicyVisibilityAfterAnim = false;
391 }
392 }
393
394 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this
395 + ": hidden=" + hidden + " hiddenRequested=" + hiddenRequested);
396
397 if (changed) {
398 service.mInputMonitor.setUpdateInputWindowsNeededLw();
399 if (performLayout) {
400 service.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
401 false /*updateInputWindows*/);
402 service.mWindowPlacerLocked.performSurfacePlacement();
403 }
404 service.mInputMonitor.updateInputWindowsLw(false /*force*/);
405 }
406 }
407
408 if (mAppAnimator.animation != null) {
409 delayed = true;
410 }
411
412 for (int i = allAppWindows.size() - 1; i >= 0 && !delayed; i--) {
413 if (allAppWindows.get(i).mWinAnimator.isWindowAnimationSet()) {
414 delayed = true;
415 }
416 }
417
418 if (visibilityChanged) {
419 if (visible && !delayed) {
420 // The token was made immediately visible, there will be no entrance animation.
421 // We need to inform the client the enter animation was finished.
422 mEnteringAnimation = true;
423 service.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token);
424 }
425
426 if (!service.mClosingApps.contains(this) && !service.mOpeningApps.contains(this)) {
427 // The token is not closing nor opening, so even if there is an animation set, that
428 // doesn't mean that it goes through the normal app transition cycle so we have
429 // to inform the docked controller about visibility change.
430 service.getDefaultDisplayContentLocked().getDockedDividerController()
431 .notifyAppVisibilityChanged();
432 }
433 }
434
435 return delayed;
436 }
437
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800438 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700439 WindowState candidate = null;
Wale Ogunwale455fac52016-07-21 07:24:49 -0700440 int j = allAppWindows.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800441 while (j > 0) {
442 j--;
Wale Ogunwale455fac52016-07-21 07:24:49 -0700443 WindowState win = allAppWindows.get(j);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800444 if (win.mAttrs.type == WindowManager.LayoutParams.TYPE_BASE_APPLICATION
445 || win.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700446 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900447 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700448 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800449 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700450 candidate = win;
451 } else {
452 return win;
453 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800454 }
455 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700456 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800457 }
458
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800459 boolean windowsAreFocusable() {
460 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800461 }
462
Craig Mautner72669d12012-12-18 17:23:54 -0800463 boolean isVisible() {
464 final int N = allAppWindows.size();
Craig Mautner72669d12012-12-18 17:23:54 -0800465 for (int i=0; i<N; i++) {
466 WindowState win = allAppWindows.get(i);
Chong Zhangdb20b5f2015-10-23 14:01:43 -0700467 // If we're animating with a saved surface, we're already visible.
468 // Return true so that the alpha doesn't get cleared.
Craig Mautner72669d12012-12-18 17:23:54 -0800469 if (!win.mAppFreezing
Chong Zhang92147042016-05-09 12:47:11 -0700470 && (win.mViewVisibility == View.VISIBLE || win.isAnimatingWithSavedSurface()
Jorim Jaggi5c80c412016-04-19 20:03:47 -0700471 || (win.mWinAnimator.isAnimationSet()
Filip Gruszczynski57f76f12015-11-04 16:10:54 -0800472 && !service.mAppTransition.isTransitionSet()))
473 && !win.mDestroying
474 && win.isDrawnLw()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800475 return true;
476 }
477 }
478 return false;
479 }
480
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700481 boolean isVisibleForUser() {
482 for (int j = allAppWindows.size() - 1; j >= 0; j--) {
483 final WindowState w = allAppWindows.get(j);
484 if (!w.isHiddenFromUserLocked()) {
485 return true;
486 }
487 }
488 return false;
489 }
490
Craig Mautnere3119b72015-01-20 15:02:36 -0800491 void removeAppFromTaskLocked() {
492 mIsExiting = false;
493 removeAllWindows();
494
Craig Mautner83162a92015-01-26 14:43:30 -0800495 // Use local variable because removeAppToken will null out mTask.
496 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800497 if (task != null) {
498 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800499 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800500 + " not found.");
501 }
502 task.mStack.mExitingAppTokens.remove(this);
503 }
504 }
505
Chong Zhange05bcb12016-07-26 17:47:29 -0700506 void clearAnimatingFlags() {
507 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
508 final WindowState win = allAppWindows.get(i);
509 // We don't want to clear it out for windows that get replaced, because the
510 // animation depends on the flag to remove the replaced window.
511 //
512 // We also don't clear the mAnimatingExit flag for windows which have the
513 // mRemoveOnExit flag. This indicates an explicit remove request has been issued
514 // by the client. We should let animation proceed and not clear this flag or
515 // they won't eventually be removed by WindowStateAnimator#finishExit.
516 if (!win.mWillReplaceWindow && !win.mRemoveOnExit) {
517 win.mAnimatingExit = false;
518 // Clear mAnimating flag together with mAnimatingExit. When animation
519 // changes from exiting to entering, we need to clear this flag until the
520 // new animation gets applied, so that isAnimationStarting() becomes true
521 // until then.
522 // Otherwise applySurfaceChangesTransaction will faill to skip surface
523 // placement for this window during this period, one or more frame will
524 // show up with wrong position or scale.
525 win.mWinAnimator.mAnimating = false;
526 }
527 }
Chong Zhangec8299c2016-07-29 13:09:40 -0700528 requestUpdateWallpaperIfNeeded();
Chong Zhange05bcb12016-07-26 17:47:29 -0700529 }
530
Robert Carre12aece2016-02-02 22:43:27 -0800531 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700532 destroySurfaces(false /*cleanupOnResume*/);
533 }
534
535 /**
536 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
537 * the client has finished with them.
538 *
539 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
540 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
541 * others so that they are ready to be reused. If set to false (common case), destroy all
542 * surfaces that's eligible, if the app is already stopped.
543 */
544
545 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800546 final ArrayList<WindowState> allWindows = (ArrayList<WindowState>) allAppWindows.clone();
547 final DisplayContentList displayList = new DisplayContentList();
548 for (int i = allWindows.size() - 1; i >= 0; i--) {
549 final WindowState win = allWindows.get(i);
Chong Zhangeb665572016-05-09 18:28:27 -0700550
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700551 if (!(mAppStopped || win.mWindowRemovalAllowed || cleanupOnResume)) {
Robert Carre12aece2016-02-02 22:43:27 -0800552 continue;
553 }
554
Chong Zhangeb665572016-05-09 18:28:27 -0700555 win.mWinAnimator.destroyPreservedSurfaceLocked();
556
557 if (!win.mDestroying) {
Chong Zhang5471e902016-02-12 15:34:10 -0800558 continue;
Robert Carre12aece2016-02-02 22:43:27 -0800559 }
560
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800561 if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + win
562 + " destroySurfaces: mAppStopped=" + mAppStopped
563 + " win.mWindowRemovalAllowed=" + win.mWindowRemovalAllowed
564 + " win.mRemoveOnExit=" + win.mRemoveOnExit);
565
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700566 if (!cleanupOnResume || win.mRemoveOnExit) {
567 win.destroyOrSaveSurface();
568 }
Robert Carre12aece2016-02-02 22:43:27 -0800569 if (win.mRemoveOnExit) {
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700570 win.remove();
Robert Carre12aece2016-02-02 22:43:27 -0800571 }
572 final DisplayContent displayContent = win.getDisplayContent();
573 if (displayContent != null && !displayList.contains(displayContent)) {
574 displayList.add(displayContent);
575 }
Chong Zhangec8299c2016-07-29 13:09:40 -0700576 if (cleanupOnResume) {
577 win.requestUpdateWallpaperIfNeeded();
578 }
Robert Carre12aece2016-02-02 22:43:27 -0800579 win.mDestroying = false;
580 }
581 for (int i = 0; i < displayList.size(); i++) {
582 final DisplayContent displayContent = displayList.get(i);
583 service.mLayersController.assignLayersLocked(displayContent.getWindowList());
584 displayContent.layoutNeeded = true;
585 }
586 }
587
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800588 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700589 * Notify that the app is now resumed, and it was not stopped before, perform a clean
590 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800591 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700592 void notifyAppResumed(boolean wasStopped) {
593 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped + " " + this);
594 mAppStopped = false;
595 if (!wasStopped) {
596 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800597 }
Robert Carre12aece2016-02-02 22:43:27 -0800598 }
599
Chong Zhangbef461f2015-10-27 11:38:24 -0700600 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700601 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
602 * keeping alive in case they were still being used.
603 */
604 void notifyAppStopped() {
605 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
606 mAppStopped = true;
607 destroySurfaces();
608 // Remove any starting window that was added for this app if they are still around.
609 mTask.mService.scheduleRemoveStartingWindowLocked(this);
610 }
611
612 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700613 * Checks whether we should save surfaces for this app.
614 *
615 * @return true if the surfaces should be saved, false otherwise.
616 */
617 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800618 // We want to save surface if the app's windows are "allDrawn".
619 // (If we started entering animation early with saved surfaces, allDrawn
620 // should have been restored to true. So we'll save again in that case
621 // even if app didn't actually finish drawing.)
622 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800623 }
624
Chong Zhang92147042016-05-09 12:47:11 -0700625 boolean canRestoreSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700626 for (int i = allAppWindows.size() -1; i >= 0; i--) {
Chong Zhang92147042016-05-09 12:47:11 -0700627 final WindowState w = allAppWindows.get(i);
628 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800629 return true;
630 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700631 }
632 return false;
633 }
634
Chong Zhang92147042016-05-09 12:47:11 -0700635 void clearVisibleBeforeClientHidden() {
636 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
637 final WindowState w = allAppWindows.get(i);
638 w.clearVisibleBeforeClientHidden();
639 }
640 }
641
Chong Zhang8e4bda92016-05-04 15:08:18 -0700642 /**
643 * Whether the app has some window that is invisible in layout, but
644 * animating with saved surface.
645 */
646 boolean isAnimatingInvisibleWithSavedSurface() {
647 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
648 final WindowState w = allAppWindows.get(i);
649 if (w.isAnimatingInvisibleWithSavedSurface()) {
650 return true;
651 }
652 }
653 return false;
654 }
655
656 /**
657 * Hide all window surfaces that's still invisible in layout but animating
658 * with a saved surface, and mark them destroying.
659 */
660 void stopUsingSavedSurfaceLocked() {
661 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
662 final WindowState w = allAppWindows.get(i);
663 if (w.isAnimatingInvisibleWithSavedSurface()) {
664 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
665 "stopUsingSavedSurfaceLocked: " + w);
666 w.clearAnimatingWithSavedSurface();
667 w.mDestroying = true;
668 w.mWinAnimator.hide("stopUsingSavedSurfaceLocked");
Wale Ogunwalee4da0c12016-07-29 12:47:02 -0700669 service.mWallpaperControllerLocked.hideWallpapers(w);
Chong Zhang8e4bda92016-05-04 15:08:18 -0700670 }
671 }
672 destroySurfaces();
673 }
674
Chong Zhangf58631a2016-05-24 16:02:10 -0700675 void markSavedSurfaceExiting() {
676 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
677 final WindowState w = allAppWindows.get(i);
678 if (w.isAnimatingInvisibleWithSavedSurface()) {
679 w.mAnimatingExit = true;
680 w.mWinAnimator.mAnimating = true;
681 }
682 }
683 }
684
Chong Zhangbef461f2015-10-27 11:38:24 -0700685 void restoreSavedSurfaces() {
Chong Zhang92147042016-05-09 12:47:11 -0700686 if (!canRestoreSurfaces()) {
687 clearVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700688 return;
689 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800690 // Check if we have enough drawn windows to mark allDrawn= true.
691 int numInteresting = 0;
692 int numDrawn = 0;
Chong Zhangb7b4a562016-04-28 15:30:33 -0700693 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
694 WindowState w = allAppWindows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700695 if (w != startingWindow && !w.mAppDied && w.wasVisibleBeforeClientHidden()
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800696 && (!mAppAnimator.freezingScreen || !w.mAppFreezing)) {
697 numInteresting++;
Chong Zhang92147042016-05-09 12:47:11 -0700698 if (w.hasSavedSurface()) {
699 w.restoreSavedSurface();
700 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800701 if (w.isDrawnLw()) {
702 numDrawn++;
703 }
704 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700705 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800706
Chong Zhang92147042016-05-09 12:47:11 -0700707 if (!allDrawn) {
708 allDrawn = (numInteresting > 0) && (numInteresting == numDrawn);
709 if (allDrawn) {
710 service.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
711 }
712 }
713 clearVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800714
715 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Wale Ogunwale455fac52016-07-21 07:24:49 -0700716 "restoreSavedSurfaces: " + this + " allDrawn=" + allDrawn
Chong Zhang92147042016-05-09 12:47:11 -0700717 + " numInteresting=" + numInteresting + " numDrawn=" + numDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700718 }
719
720 void destroySavedSurfaces() {
Chong Zhangb7b4a562016-04-28 15:30:33 -0700721 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
722 WindowState win = allAppWindows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800723 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700724 }
Chong Zhang92147042016-05-09 12:47:11 -0700725 }
726
727 void clearAllDrawn() {
728 allDrawn = false;
729 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700730 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700731 }
732
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800733 @Override
Craig Mautner7c9ee192014-08-14 16:08:26 -0700734 void removeAllWindows() {
Craig Mautner7b4655d2014-11-20 12:13:22 -0800735 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
736 // removeWindowLocked at bottom of loop may remove multiple entries from
737 // allAppWindows if the window to be removed has child windows. It also may
738 // not remove any windows from allAppWindows at all if win is exiting and
739 // currently animating away. This ensures that winNdx is monotonically decreasing
740 // and never beyond allAppWindows bounds.
741 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
742 WindowState win = allAppWindows.get(winNdx);
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800743 if (DEBUG_WINDOW_MOVEMENT) {
744 Slog.w(TAG, "removeAllWindows: removing win=" + win);
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800745 }
746
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -0700747 service.removeWindowLocked(win);
Craig Mautner7c9ee192014-08-14 16:08:26 -0700748 }
Craig Mautnere3119b72015-01-20 15:02:36 -0800749 allAppWindows.clear();
750 windows.clear();
Craig Mautner7c9ee192014-08-14 16:08:26 -0700751 }
752
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700753 @Override
754 void removeWindow(WindowState win) {
755 super.removeWindow(win);
756
757 allAppWindows.remove(win);
758
759 if (startingWindow == win) {
760 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Notify removed startingWindow " + win);
761 service.scheduleRemoveStartingWindowLocked(this);
762 } else if (allAppWindows.size() == 0 && startingData != null) {
763 // If this is the last window and we had requested a starting transition window,
764 // well there is no point now.
765 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Nulling last startingWindow");
766 startingData = null;
767 } else if (allAppWindows.size() == 1 && startingView != null) {
768 // If this is the last window except for a starting transition window,
769 // we need to get rid of the starting transition.
770 service.scheduleRemoveStartingWindowLocked(this);
771 }
772 }
773
Chong Zhang112eb8c2015-11-02 11:17:00 -0800774 void removeAllDeadWindows() {
775 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0;
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700776 // removeWindowLocked at bottom of loop may remove multiple entries from
777 // allAppWindows if the window to be removed has child windows. It also may
778 // not remove any windows from allAppWindows at all if win is exiting and
779 // currently animating away. This ensures that winNdx is monotonically decreasing
780 // and never beyond allAppWindows bounds.
781 winNdx = Math.min(winNdx - 1, allAppWindows.size() - 1)) {
Chong Zhang112eb8c2015-11-02 11:17:00 -0800782 WindowState win = allAppWindows.get(winNdx);
783 if (win.mAppDied) {
Wale Ogunwale2728bf42016-03-03 11:03:26 -0800784 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800785 Slog.w(TAG, "removeAllDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800786 }
787 // Set mDestroying, we don't want any animation or delayed removal here.
788 win.mDestroying = true;
789 service.removeWindowLocked(win);
790 }
791 }
792 }
793
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700794 boolean hasWindowsAlive() {
795 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
796 if (!allAppWindows.get(i).mAppDied) {
797 return true;
798 }
799 }
800 return false;
801 }
802
Robert Carra1eb4392015-12-10 12:43:51 -0800803 void setReplacingWindows(boolean animate) {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700804 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
805 "Marking app token " + this + " with replacing windows.");
Robert Carra1eb4392015-12-10 12:43:51 -0800806
807 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
808 final WindowState w = allAppWindows.get(i);
809 w.setReplacing(animate);
810 }
811 if (animate) {
812 // Set-up dummy animation so we can start treating windows associated with this
813 // token like they are in transition before the new app window is ready for us to
814 // run the real transition animation.
815 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
816 "setReplacingWindow() Setting dummy animation on: " + this);
817 mAppAnimator.setDummyAnimation();
818 }
819 }
820
Robert Carr23fa16b2016-01-13 13:19:58 -0800821 void setReplacingChildren() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700822 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this
Robert Carr23fa16b2016-01-13 13:19:58 -0800823 + " with replacing child windows.");
824 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
825 final WindowState w = allAppWindows.get(i);
Robert Carrd1a010f2016-04-07 22:36:22 -0700826 if (w.shouldBeReplacedWithChildren()) {
Robert Carr23fa16b2016-01-13 13:19:58 -0800827 w.setReplacing(false /* animate */);
828 }
829 }
830 }
831
Chong Zhangf596cd52016-01-05 13:42:44 -0800832 void resetReplacingWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700833 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
834 "Resetting app token " + this + " of replacing window marks.");
Chong Zhangf596cd52016-01-05 13:42:44 -0800835
836 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
837 final WindowState w = allAppWindows.get(i);
838 w.resetReplacing();
839 }
840 }
841
Chong Zhang4d7369a2016-04-25 16:09:14 -0700842 void requestUpdateWallpaperIfNeeded() {
843 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
844 final WindowState w = allAppWindows.get(i);
845 w.requestUpdateWallpaperIfNeeded();
846 }
847 }
848
Chong Zhangd78ddb42016-03-02 17:01:14 -0800849 boolean isRelaunching() {
850 return mPendingRelaunchCount > 0;
851 }
852
853 void startRelaunching() {
854 if (canFreezeBounds()) {
855 freezeBounds();
856 }
857 mPendingRelaunchCount++;
858 }
859
860 void finishRelaunching() {
861 if (canFreezeBounds()) {
862 unfreezeBounds();
863 }
864 if (mPendingRelaunchCount > 0) {
865 mPendingRelaunchCount--;
866 }
867 }
868
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700869 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700870 if (mPendingRelaunchCount == 0) {
871 return;
872 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700873 if (canFreezeBounds()) {
874 unfreezeBounds();
875 }
876 mPendingRelaunchCount = 0;
877 }
878
Robert Carra1eb4392015-12-10 12:43:51 -0800879 void addWindow(WindowState w) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700880 if (allAppWindows.contains(w)) {
881 return;
882 }
883
Robert Carra1eb4392015-12-10 12:43:51 -0800884 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
885 WindowState candidate = allAppWindows.get(i);
886 if (candidate.mWillReplaceWindow && candidate.mReplacingWindow == null &&
Robert Carr8bc89072016-04-08 13:29:59 -0700887 candidate.getWindowTag().toString().equals(w.getWindowTag().toString())) {
Robert Carra1eb4392015-12-10 12:43:51 -0800888 candidate.mReplacingWindow = w;
Robert Carrb439a632016-04-07 22:52:10 -0700889 w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
Chong Zhangf596cd52016-01-05 13:42:44 -0800890
891 // if we got a replacement window, reset the timeout to give drawing more time
Chong Zhang32de3652016-05-12 16:00:01 -0700892 service.scheduleReplacingWindowTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800893 }
894 }
895 allAppWindows.add(w);
896 }
897
898 boolean waitingForReplacement() {
899 for (int i = allAppWindows.size() -1; i >= 0; i--) {
900 WindowState candidate = allAppWindows.get(i);
901 if (candidate.mWillReplaceWindow) {
902 return true;
903 }
904 }
905 return false;
906 }
907
Chong Zhangf596cd52016-01-05 13:42:44 -0800908 void clearTimedoutReplacesLocked() {
Robert Carra1eb4392015-12-10 12:43:51 -0800909 for (int i = allAppWindows.size() - 1; i >= 0;
910 // removeWindowLocked at bottom of loop may remove multiple entries from
911 // allAppWindows if the window to be removed has child windows. It also may
912 // not remove any windows from allAppWindows at all if win is exiting and
913 // currently animating away. This ensures that winNdx is monotonically decreasing
914 // and never beyond allAppWindows bounds.
915 i = Math.min(i - 1, allAppWindows.size() - 1)) {
916 WindowState candidate = allAppWindows.get(i);
917 if (candidate.mWillReplaceWindow == false) {
918 continue;
919 }
920 candidate.mWillReplaceWindow = false;
Robert Carrb439a632016-04-07 22:52:10 -0700921 if (candidate.mReplacingWindow != null) {
922 candidate.mReplacingWindow.mSkipEnterAnimationForSeamlessReplacement = false;
923 }
Chong Zhangf596cd52016-01-05 13:42:44 -0800924 // Since the window already timed out, remove it immediately now.
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700925 // Use WindowState#remove() instead of removeWindowLocked(), as the latter
Chong Zhangf596cd52016-01-05 13:42:44 -0800926 // delays removal on certain conditions, which will leave the stale window in the
927 // stack and marked mWillReplaceWindow=false, so the window will never be removed.
Wale Ogunwalee4343ef2016-07-19 08:00:46 -0700928 candidate.remove();
Robert Carra1eb4392015-12-10 12:43:51 -0800929 }
930 }
931
Chong Zhangd78ddb42016-03-02 17:01:14 -0800932 private boolean canFreezeBounds() {
933 // For freeform windows, we can't freeze the bounds at the moment because this would make
934 // the resizing unresponsive.
935 return mTask != null && !mTask.inFreeformWorkspace();
936 }
937
Jorim Jaggi0429f352015-12-22 16:29:16 +0100938 /**
939 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
940 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
941 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
942 * with a queue.
943 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800944 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100945 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700946
947 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
948 // We didn't call prepareFreezingBounds on the task, so use the current value.
949 final Configuration config = new Configuration(service.mCurConfiguration);
950 config.updateFrom(mTask.mOverrideConfig);
951 mFrozenMergedConfig.offer(config);
952 } else {
953 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
954 }
955 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100956 }
957
958 /**
959 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
960 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800961 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700962 if (!mFrozenBounds.isEmpty()) {
963 mFrozenBounds.remove();
964 }
965 if (!mFrozenMergedConfig.isEmpty()) {
966 mFrozenMergedConfig.remove();
967 }
Wale Ogunwale455fac52016-07-21 07:24:49 -0700968 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
969 final WindowState win = allAppWindows.get(i);
Jorim Jaggi69abc192016-02-04 19:34:00 -0800970 if (!win.mHasSurface) {
971 continue;
972 }
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100973 win.mLayoutNeeded = true;
974 win.setDisplayLayoutNeeded();
975 if (!service.mResizingWindows.contains(win)) {
976 service.mResizingWindows.add(win);
977 }
978 }
979 service.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100980 }
981
Robert Carr91b228092016-06-28 17:32:37 -0700982 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
983 mSurfaceViewBackgrounds.add(background);
984 }
985
986 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
987 mSurfaceViewBackgrounds.remove(background);
988 updateSurfaceViewBackgroundVisibilities();
989 }
990
991 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
992 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
993 // below the main app window (as traditionally a SurfaceView which is never drawn
994 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
995 // the background for the SurfaceView with lowest Z order
996 void updateSurfaceViewBackgroundVisibilities() {
997 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
998 int bottomLayer = Integer.MAX_VALUE;
999 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
1000 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
1001 if (sc.mVisible && sc.mLayer < bottomLayer) {
1002 bottomLayer = sc.mLayer;
1003 bottom = sc;
1004 }
1005 }
1006 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
1007 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
1008 sc.updateBackgroundVisibility(sc != bottom);
1009 }
1010 }
1011
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001012 void resetJustMovedInStack() {
1013 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
1014 allAppWindows.get(i).resetJustMovedInStack();
1015 }
1016 }
1017
1018 @Override
1019 int adjustAnimLayer(int adj) {
1020 int highestAnimLayer = super.adjustAnimLayer(adj);
1021
1022 final int windowCount = allAppWindows.size();
1023
1024 for (int i = 0; i < windowCount; i++) {
1025 final WindowState w = allAppWindows.get(i);
1026 w.adjustAnimLayer(adj);
1027
1028 final int animLayer = w.mWinAnimator.mAnimLayer;
1029 if (DEBUG_LAYERS) Slog.v(TAG, "Updating layer " + w + ": " + animLayer);
1030 if (animLayer > highestAnimLayer) {
1031 highestAnimLayer = animLayer;
1032 }
1033 if (w == service.mInputMethodTarget && !service.mInputMethodTargetWaitingAnim) {
1034 service.mLayersController.setInputMethodAnimLayerAdjustment(adj);
1035 }
1036 }
1037
1038 return highestAnimLayer;
1039 }
1040
1041 @Override
1042 int getHighestAnimLayer() {
1043 int layer = super.getHighestAnimLayer();
1044 for (int j = 0; j < allAppWindows.size(); j++) {
1045 final WindowState win = allAppWindows.get(j);
1046 if (win.mWinAnimator.mAnimLayer > layer) {
1047 layer = win.mWinAnimator.mAnimLayer;
1048 }
1049 }
1050 return layer;
1051 }
1052
1053 void setWaitingForDrawnIfResizingChanged() {
1054 for (int i = allAppWindows.size() - 1; i >= 0; --i) {
1055 final WindowState win = allAppWindows.get(i);
1056 if (win.isDragResizeChanged()) {
1057 service.mWaitingForDrawn.add(win);
1058 }
1059 }
1060 }
1061
1062 void resizeWindows() {
1063 final ArrayList<WindowState> resizingWindows = service.mResizingWindows;
1064 // Some windows won't go through the resizing process, if they don't have a surface, so
1065 // destroy all saved surfaces here.
1066 destroySavedSurfaces();
1067
1068 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
1069 final WindowState win = allAppWindows.get(winNdx);
1070 if (win.mHasSurface && !resizingWindows.contains(win)) {
1071 if (DEBUG_RESIZE) Slog.d(TAG, "resizeWindows: Resizing " + win);
1072 resizingWindows.add(win);
1073
1074 // If we are not drag resizing, force recreating of a new surface so updating
1075 // the content and positioning that surface will be in sync.
1076 //
1077 // As we use this flag as a hint to freeze surface boundary updates,
1078 // we'd like to only apply this to TYPE_BASE_APPLICATION,
1079 // windows of TYPE_APPLICATION like dialogs, could appear
1080 // to not be drag resizing while they resize, but we'd
1081 // still like to manipulate their frame to update crop, etc...
1082 //
1083 // Anyway we don't need to synchronize position and content updates for these
1084 // windows since they aren't at the base layer and could be moved around anyway.
1085 if (!win.computeDragResizing() && win.mAttrs.type == TYPE_BASE_APPLICATION &&
1086 !mTask.mStack.getBoundsAnimating() && !win.isGoneForLayoutLw() &&
1087 !mTask.inPinnedWorkspace()) {
1088 win.setResizedWhileNotDragResizing(true);
1089 }
1090 }
1091 if (win.isGoneForLayoutLw()) {
1092 win.mResizedWhileGone = true;
1093 }
1094 }
1095 }
1096
1097 void moveWindows() {
1098 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
1099 final WindowState win = allAppWindows.get(winNdx);
1100 if (DEBUG_RESIZE) Slog.d(TAG, "moveWindows: Moving " + win);
1101 win.mMovedByResize = true;
1102 }
1103 }
1104
1105 void notifyMovedInStack() {
1106 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
1107 final WindowState win = allAppWindows.get(winNdx);
1108 win.notifyMovedInStack();
1109 }
1110 }
1111
1112 void resetDragResizingChangeReported() {
1113 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
1114 final WindowState win = allAppWindows.get(winNdx);
1115 win.resetDragResizingChangeReported();
1116 }
1117 }
1118
1119 void detachDisplay() {
1120 boolean doAnotherLayoutPass = false;
1121 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
1122 // We are in the middle of changing the state of displays/stacks/tasks. We need
1123 // to finish that, before we let layout interfere with it.
1124 service.removeWindowLocked(allAppWindows.get(winNdx));
1125 doAnotherLayoutPass = true;
1126 }
1127 if (doAnotherLayoutPass) {
1128 service.mWindowPlacerLocked.requestTraversal();
1129 }
1130 }
1131
1132 void forceWindowsScaleableInTransaction(boolean force) {
1133 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
1134 final WindowStateAnimator winAnimator = allAppWindows.get(winNdx).mWinAnimator;
1135 if (winAnimator == null || !winAnimator.hasSurface()) {
1136 continue;
1137 }
1138 winAnimator.mSurfaceController.forceScaleableInTransaction(force);
1139 }
1140 }
1141
1142 boolean isAnimating() {
1143 for (int winNdx = allAppWindows.size() - 1; winNdx >= 0; --winNdx) {
1144 final WindowStateAnimator winAnimator = allAppWindows.get(winNdx).mWinAnimator;
1145 if (winAnimator.isAnimationSet() || winAnimator.mWin.mAnimatingExit) {
1146 return true;
1147 }
1148 }
1149 return false;
1150 }
1151
1152 void setAppLayoutChanges(int changes, String reason, int displayId) {
1153 final WindowAnimator windowAnimator = mAppAnimator.mAnimator;
1154 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
1155 if (displayId == allAppWindows.get(i).getDisplayId()) {
1156 windowAnimator.setPendingLayoutChanges(displayId, changes);
1157 if (DEBUG_LAYOUT_REPEATS) {
1158 service.mWindowPlacerLocked.debugLayoutRepeats(
1159 reason, windowAnimator.getPendingLayoutChanges(displayId));
1160 }
1161 break;
1162 }
1163 }
1164 }
1165
1166 void removeReplacedWindowIfNeeded(WindowState replacement) {
1167 for (int i = allAppWindows.size() - 1; i >= 0; i--) {
1168 final WindowState win = allAppWindows.get(i);
1169 if (win.mWillReplaceWindow && win.mReplacingWindow == replacement
1170 && replacement.hasDrawnLw()) {
1171 replacement.mSkipEnterAnimationForSeamlessReplacement = false;
1172 win.removeReplacedWindow();
1173 }
1174 }
1175 }
1176
1177 void startFreezingScreen() {
1178 if (DEBUG_ORIENTATION) logWithStack(TAG, "Set freezing of " + appToken + ": hidden="
1179 + hidden + " freezing=" + mAppAnimator.freezingScreen);
1180 if (!hiddenRequested) {
1181 if (!mAppAnimator.freezingScreen) {
1182 mAppAnimator.freezingScreen = true;
1183 mAppAnimator.lastFreezeDuration = 0;
1184 service.mAppsFreezingScreen++;
1185 if (service.mAppsFreezingScreen == 1) {
1186 service.startFreezingDisplayLocked(false, 0, 0);
1187 service.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
1188 service.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
1189 }
1190 }
1191 final int count = allAppWindows.size();
1192 for (int i = 0; i < count; i++) {
1193 final WindowState w = allAppWindows.get(i);
1194 w.mAppFreezing = true;
1195 }
1196 }
1197 }
1198
1199 void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) {
1200 if (!mAppAnimator.freezingScreen) {
1201 return;
1202 }
1203 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Clear freezing of " + this + " force=" + force);
1204 final int count = allAppWindows.size();
1205 boolean unfrozeWindows = false;
1206 for (int i = 0; i < count; i++) {
1207 final WindowState w = allAppWindows.get(i);
1208 if (w.mAppFreezing) {
1209 w.mAppFreezing = false;
1210 if (w.mHasSurface && !w.mOrientationChanging
1211 && service.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
1212 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "set mOrientationChanging of " + w);
1213 w.mOrientationChanging = true;
1214 service.mWindowPlacerLocked.mOrientationChangeComplete = false;
1215 }
1216 w.mLastFreezeDuration = 0;
1217 unfrozeWindows = true;
1218 w.setDisplayLayoutNeeded();
1219 }
1220 }
1221 if (force || unfrozeWindows) {
1222 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this);
1223 mAppAnimator.freezingScreen = false;
1224 mAppAnimator.lastFreezeDuration =
1225 (int)(SystemClock.elapsedRealtime() - service.mDisplayFreezeTime);
1226 service.mAppsFreezingScreen--;
1227 service.mLastFinishedFreezeSource = this;
1228 }
1229 if (unfreezeSurfaceNow) {
1230 if (unfrozeWindows) {
1231 service.mWindowPlacerLocked.performSurfacePlacement();
1232 }
1233 service.stopFreezingDisplayLocked();
1234 }
1235 }
1236
1237 boolean transferStartingWindow(IBinder transferFrom) {
1238 final AppWindowToken fromToken = service.findAppWindowToken(transferFrom);
1239 if (fromToken == null) {
1240 return false;
1241 }
1242
1243 final WindowState tStartingWindow = fromToken.startingWindow;
1244 if (tStartingWindow != null && fromToken.startingView != null) {
1245 // In this case, the starting icon has already been displayed, so start
1246 // letting windows get shown immediately without any more transitions.
1247 service.mSkipAppTransitionAnimation = true;
1248
1249 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Moving existing starting " + tStartingWindow
1250 + " from " + fromToken + " to " + this);
1251
1252 final long origId = Binder.clearCallingIdentity();
1253
1254 // Transfer the starting window over to the new token.
1255 startingData = fromToken.startingData;
1256 startingView = fromToken.startingView;
1257 startingDisplayed = fromToken.startingDisplayed;
1258 fromToken.startingDisplayed = false;
1259 startingWindow = tStartingWindow;
1260 reportedVisible = fromToken.reportedVisible;
1261 fromToken.startingData = null;
1262 fromToken.startingView = null;
1263 fromToken.startingWindow = null;
1264 fromToken.startingMoved = true;
1265 tStartingWindow.mToken = this;
1266 tStartingWindow.mRootToken = this;
1267 tStartingWindow.mAppToken = this;
1268
1269 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
1270 "Removing starting window: " + tStartingWindow);
1271 tStartingWindow.getWindowList().remove(tStartingWindow);
1272 service.mWindowsChanged = true;
1273 if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
1274 "Removing starting " + tStartingWindow + " from " + fromToken);
1275 fromToken.removeWindow(tStartingWindow);
1276 fromToken.allAppWindows.remove(tStartingWindow);
1277 addWindowToList(tStartingWindow);
1278
1279 // Propagate other interesting state between the tokens. If the old token is displayed,
1280 // we should immediately force the new one to be displayed. If it is animating, we need
1281 // to move that animation to the new one.
1282 if (fromToken.allDrawn) {
1283 allDrawn = true;
1284 deferClearAllDrawn = fromToken.deferClearAllDrawn;
1285 }
1286 if (fromToken.firstWindowDrawn) {
1287 firstWindowDrawn = true;
1288 }
1289 if (!fromToken.hidden) {
1290 hidden = false;
1291 hiddenRequested = false;
1292 }
1293 if (clientHidden != fromToken.clientHidden) {
1294 clientHidden = fromToken.clientHidden;
1295 sendAppVisibilityToClients();
1296 }
1297 fromToken.mAppAnimator.transferCurrentAnimation(
1298 mAppAnimator, tStartingWindow.mWinAnimator);
1299
1300 service.updateFocusedWindowLocked(
1301 UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/);
1302 service.getDefaultDisplayContentLocked().layoutNeeded = true;
1303 service.mWindowPlacerLocked.performSurfacePlacement();
1304 Binder.restoreCallingIdentity(origId);
1305 return true;
1306 } else if (fromToken.startingData != null) {
1307 // The previous app was getting ready to show a
1308 // starting window, but hasn't yet done so. Steal it!
1309 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
1310 "Moving pending starting from " + fromToken + " to " + this);
1311 startingData = fromToken.startingData;
1312 fromToken.startingData = null;
1313 fromToken.startingMoved = true;
1314 final Message m = service.mH.obtainMessage(H.ADD_STARTING, this);
1315 // Note: we really want to do sendMessageAtFrontOfQueue() because we want to process the
1316 // message ASAP, before any other queued messages.
1317 service.mH.sendMessageAtFrontOfQueue(m);
1318 return true;
1319 }
1320
1321 final AppWindowAnimator tAppAnimator = fromToken.mAppAnimator;
1322 final AppWindowAnimator wAppAnimator = mAppAnimator;
1323 if (tAppAnimator.thumbnail != null) {
1324 // The old token is animating with a thumbnail, transfer that to the new token.
1325 if (wAppAnimator.thumbnail != null) {
1326 wAppAnimator.thumbnail.destroy();
1327 }
1328 wAppAnimator.thumbnail = tAppAnimator.thumbnail;
1329 wAppAnimator.thumbnailLayer = tAppAnimator.thumbnailLayer;
1330 wAppAnimator.thumbnailAnimation = tAppAnimator.thumbnailAnimation;
1331 tAppAnimator.thumbnail = null;
1332 }
1333 return false;
1334 }
1335
1336 int getWindowsCount() {
1337 return allAppWindows.size();
1338 }
1339
1340 void setAllAppWinAnimators() {
1341 final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators;
1342 allAppWinAnimators.clear();
1343
1344 final int windowsCount = allAppWindows.size();
1345 for (int j = 0; j < windowsCount; j++) {
1346 allAppWinAnimators.add(allAppWindows.get(j).mWinAnimator);
1347 }
1348 }
1349
1350 /** Returns true if the app token windows list is empty. */
1351 @Override
1352 boolean isEmpty() {
1353 return allAppWindows.isEmpty();
1354 }
1355
Craig Mautnerdbb79912012-03-01 18:59:14 -08001356 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001357 void dump(PrintWriter pw, String prefix) {
1358 super.dump(pw, prefix);
1359 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001360 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001361 }
1362 if (allAppWindows.size() > 0) {
1363 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
1364 }
Craig Mautner83162a92015-01-26 14:43:30 -08001365 pw.print(prefix); pw.print("task="); pw.println(mTask);
1366 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001367 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
1368 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
1369 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -07001370 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001371 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -07001372 if (paused) {
1373 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001374 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001375 if (mAppStopped) {
1376 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
1377 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001378 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -07001379 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001380 pw.print(prefix); pw.print("numInterestingWindows=");
1381 pw.print(numInterestingWindows);
1382 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
1383 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -07001384 pw.print(" allDrawn="); pw.print(allDrawn);
1385 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
1386 pw.println(")");
1387 }
1388 if (inPendingTransaction) {
1389 pw.print(prefix); pw.print("inPendingTransaction=");
1390 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001391 }
Craig Mautner799bc1d2015-01-14 10:33:48 -08001392 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001393 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
1394 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -08001395 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -08001396 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001397 }
1398 if (startingWindow != null || startingView != null
1399 || startingDisplayed || startingMoved) {
1400 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
1401 pw.print(" startingView="); pw.print(startingView);
1402 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001403 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001404 }
Jorim Jaggi0429f352015-12-22 16:29:16 +01001405 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -08001406 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -07001407 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -08001408 }
1409 if (mPendingRelaunchCount != 0) {
1410 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +01001411 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001412 }
1413
1414 @Override
1415 public String toString() {
1416 if (stringName == null) {
1417 StringBuilder sb = new StringBuilder();
1418 sb.append("AppWindowToken{");
1419 sb.append(Integer.toHexString(System.identityHashCode(this)));
1420 sb.append(" token="); sb.append(token); sb.append('}');
1421 stringName = sb.toString();
1422 }
1423 return stringName;
1424 }
Jeff Browne9bdb312012-04-05 15:30:10 -07001425}