blob: 66fa976433ba48ecc00a2324e02ee4b28dc19507 [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;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080023import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
24import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Robert Carra1eb4392015-12-10 12:43:51 -080025import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070026import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
27import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
Wale Ogunwale9017ec02016-02-25 08:55:25 -080028import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080029import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
30import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
31import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
32import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Chong Zhang92147042016-05-09 12:47:11 -070033import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
Jorim Jaggi6626f542016-08-22 13:08:44 -070034import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070035import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070036import static com.android.server.wm.WindowManagerService.logWithStack;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080037
Jeff Brown4532e612012-04-05 14:27:12 -070038import com.android.server.input.InputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080039import com.android.server.wm.WindowManagerService.H;
40
Filip Gruszczynskia590c992015-11-25 16:45:26 -080041import android.annotation.NonNull;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080042import android.content.pm.ActivityInfo;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070043import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010044import android.graphics.Rect;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070045import android.os.Binder;
46import android.os.IBinder;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080047import android.os.Message;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070048import android.os.SystemClock;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080049import android.util.Slog;
50import android.view.IApplicationToken;
51import android.view.View;
52import android.view.WindowManager;
Jorim Jaggi6626f542016-08-22 13:08:44 -070053import android.view.animation.Animation;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080054
55import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010056import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080057import java.util.ArrayList;
58
59class AppTokenList extends ArrayList<AppWindowToken> {
60}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080061
62/**
63 * Version of WindowToken that is specifically for a particular application (or
64 * really activity) that is displaying windows.
65 */
Craig Mautnere32c3072012-03-12 15:25:35 -070066class AppWindowToken extends WindowToken {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080067 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
68
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080069 // Non-null only for application tokens.
70 final IApplicationToken appToken;
71
Filip Gruszczynskia590c992015-11-25 16:45:26 -080072 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070073
Dianne Hackborne30e02f2014-05-27 18:24:45 -070074 final boolean voiceInteraction;
75
Craig Mautner83162a92015-01-26 14:43:30 -080076 Task mTask;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080077 boolean appFullscreen;
78 int requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Craig Mautner4c5eb222013-11-18 12:59:05 -080079 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070080 boolean showForAllUsers;
Yorke Lee0e852472016-06-15 10:03:18 -070081 int targetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070082
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080083 // The input dispatching timeout for this application token in nanoseconds.
84 long inputDispatchingTimeoutNanos;
85
86 // These are used for determining when all windows associated with
87 // an activity have been drawn, so they can be made visible together
88 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070089 // initialize so that it doesn't match mTransactionSequence which is an int.
90 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080091 int numInterestingWindows;
92 int numDrawnWindows;
93 boolean inPendingTransaction;
94 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080095 // Set to true when this app creates a surface while in the middle of an animation. In that
96 // case do not clear allDrawn until the animation completes.
97 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080098
Chong Zhang8e4bda92016-05-04 15:08:18 -070099 // These are to track the app's real drawing status if there were no saved surfaces.
100 boolean allDrawnExcludingSaved;
101 int numInterestingWindowsExcludingSaved;
102 int numDrawnWindowsExclusingSaved;
103
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800104 // Is this window's surface needed? This is almost like hidden, except
105 // it will sometimes be true a little earlier: when the token has
106 // been shown, but is still waiting for its app transition to execute
107 // before making its windows shown.
108 boolean hiddenRequested;
109
110 // Have we told the window clients to hide themselves?
111 boolean clientHidden;
112
113 // Last visibility state we reported to the app token.
114 boolean reportedVisible;
115
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700116 // Last drawn state we reported to the app token.
117 boolean reportedDrawn;
118
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800119 // Set to true when the token has been removed from the window mgr.
120 boolean removed;
121
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800122 // Information about an application starting window if displayed.
123 StartingData startingData;
124 WindowState startingWindow;
125 View startingView;
126 boolean startingDisplayed;
127 boolean startingMoved;
128 boolean firstWindowDrawn;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700129 private final WindowState.UpdateReportedVisibilityResults mReportedVisibilityResults =
130 new WindowState.UpdateReportedVisibilityResults();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800131
132 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700133 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800134
Craig Mautner799bc1d2015-01-14 10:33:48 -0800135 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800136
Craig Mautnerbb742462014-07-07 15:28:55 -0700137 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700138 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700139
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800140 boolean mAlwaysFocusable;
141
Robert Carre12aece2016-02-02 22:43:27 -0800142 boolean mAppStopped;
Robert Carrfd10cd12016-06-29 16:41:50 -0700143 int mRotationAnimationHint;
Chong Zhangd78ddb42016-03-02 17:01:14 -0800144 int mPendingRelaunchCount;
Robert Carre12aece2016-02-02 22:43:27 -0800145
Robert Carr91b228092016-06-28 17:32:37 -0700146 private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds =
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700147 new ArrayList<>();
Robert Carr91b228092016-06-28 17:32:37 -0700148
Jorim Jaggi0429f352015-12-22 16:29:16 +0100149 ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700150 ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100151
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700152 AppWindowToken(WindowManagerService service, IApplicationToken _token, boolean _voiceInteraction) {
153 super(service, _token.asBinder(), WindowManager.LayoutParams.TYPE_APPLICATION, true);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800154 appToken = _token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700155 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800156 mInputApplicationHandle = new InputApplicationHandle(this);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700157 mAppAnimator = new AppWindowAnimator(this, service);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800158 }
159
160 void sendAppVisibilityToClients() {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700161 final int count = windows.size();
162 for (int i = 0; i < count; i++) {
163 final WindowState win = windows.get(i);
164 win.sendAppVisibilityToClients(clientHidden);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800165 }
166 }
167
Chong Zhang92147042016-05-09 12:47:11 -0700168 void setVisibleBeforeClientHidden() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700169 for (int i = windows.size() - 1; i >= 0; i--) {
170 final WindowState w = windows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700171 w.setVisibleBeforeClientHidden();
172 }
173 }
174
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800175 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
176 firstWindowDrawn = true;
177
178 // We now have a good window to show, remove dead placeholders
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700179 removeDeadWindows();
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800180
181 if (startingData != null) {
182 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
183 + win.mToken + ": first real window is shown, no animation");
184 // If this initial window is animating, stop it -- we will do an animation to reveal
185 // it from behind the starting window, so there is no need for it to also be doing its
186 // own stuff.
187 winAnimator.clearAnimation();
188 winAnimator.mService.mFinishedStarting.add(this);
189 winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
190 }
191 updateReportedVisibilityLocked();
192 }
193
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800194 void updateReportedVisibilityLocked() {
195 if (appToken == null) {
196 return;
197 }
198
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700199 if (DEBUG_VISIBILITY) Slog.v(TAG, "Update reported visibility: " + this);
200 final int count = windows.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800201
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700202 mReportedVisibilityResults.reset();
203
204 for (int i = 0; i < count; i++) {
205 final WindowState win = windows.get(i);
206 win.updateReportedVisibility(mReportedVisibilityResults);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800207 }
208
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700209 int numInteresting = mReportedVisibilityResults.numInteresting;
210 int numVisible = mReportedVisibilityResults.numVisible;
211 int numDrawn = mReportedVisibilityResults.numDrawn;
212 boolean nowGone = mReportedVisibilityResults.nowGone;
213
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700214 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800215 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700216 if (!nowGone) {
217 // If the app is not yet gone, then it can only become visible/drawn.
218 if (!nowDrawn) {
219 nowDrawn = reportedDrawn;
220 }
221 if (!nowVisible) {
222 nowVisible = reportedVisible;
223 }
224 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800225 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800226 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700227 if (nowDrawn != reportedDrawn) {
228 if (nowDrawn) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700229 mService.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_DRAWN, this).sendToTarget();
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700230 }
231 reportedDrawn = nowDrawn;
232 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800233 if (nowVisible != reportedVisible) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700234 if (DEBUG_VISIBILITY) Slog.v(TAG,
235 "Visibility changed in " + this + ": vis=" + nowVisible);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800236 reportedVisible = nowVisible;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700237 mService.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_WINDOWS,
238 nowVisible ? 1 : 0, nowGone ? 1 : 0, this).sendToTarget();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800239 }
240 }
241
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700242 boolean setVisibility(WindowManager.LayoutParams lp,
243 boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) {
244
245 boolean delayed = false;
246 inPendingTransaction = false;
247
248 if (clientHidden == visible) {
249 clientHidden = !visible;
250 sendAppVisibilityToClients();
251 }
252
253 // Allow for state changes and animation to be applied if:
254 // * token is transitioning visibility state
255 // * or the token was marked as hidden and is exiting before we had a chance to play the
256 // transition animation
257 // * or this is an opening app and windows are being replaced.
258 boolean visibilityChanged = false;
259 if (hidden == visible || (hidden && mIsExiting) || (visible && waitingForReplacement())) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700260 final AccessibilityController accessibilityController = mService.mAccessibilityController;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700261 boolean changed = false;
262 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
263 "Changing app " + this + " hidden=" + hidden + " performLayout=" + performLayout);
264
265 boolean runningAppAnimation = false;
266
267 if (transit != AppTransition.TRANSIT_UNSET) {
268 if (mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) {
269 mAppAnimator.setNullAnimation();
270 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700271 if (mService.applyAnimationLocked(this, lp, transit, visible, isVoiceInteraction)) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700272 delayed = runningAppAnimation = true;
273 }
274 final WindowState window = findMainWindow();
275 //TODO (multidisplay): Magnification is supported only for the default display.
276 if (window != null && accessibilityController != null
277 && window.getDisplayId() == DEFAULT_DISPLAY) {
278 accessibilityController.onAppWindowTransitionLocked(window, transit);
279 }
280 changed = true;
281 }
282
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700283 final int windowsCount = windows.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700284 for (int i = 0; i < windowsCount; i++) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700285 final WindowState win = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700286 changed |= win.onAppVisibilityChanged(visible, runningAppAnimation);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700287 }
288
289 hidden = hiddenRequested = !visible;
290 visibilityChanged = true;
291 if (!visible) {
292 stopFreezingScreen(true, true);
293 } else {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700294 // If we are being set visible, and the starting window is not yet displayed,
295 // then make sure it doesn't get displayed.
296 if (startingWindow != null && !startingWindow.isDrawnLw()) {
297 startingWindow.mPolicyVisibility = false;
298 startingWindow.mPolicyVisibilityAfterAnim = false;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700299 }
300 }
301
302 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this
303 + ": hidden=" + hidden + " hiddenRequested=" + hiddenRequested);
304
305 if (changed) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700306 mService.mInputMonitor.setUpdateInputWindowsNeededLw();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700307 if (performLayout) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700308 mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700309 false /*updateInputWindows*/);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700310 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700311 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700312 mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700313 }
314 }
315
316 if (mAppAnimator.animation != null) {
317 delayed = true;
318 }
319
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700320 for (int i = windows.size() - 1; i >= 0 && !delayed; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700321 if (windows.get(i).isWindowAnimationSet()) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700322 delayed = true;
323 }
324 }
325
326 if (visibilityChanged) {
327 if (visible && !delayed) {
328 // The token was made immediately visible, there will be no entrance animation.
329 // We need to inform the client the enter animation was finished.
330 mEnteringAnimation = true;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700331 mService.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700332 }
333
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700334 if (!mService.mClosingApps.contains(this) && !mService.mOpeningApps.contains(this)) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700335 // The token is not closing nor opening, so even if there is an animation set, that
336 // doesn't mean that it goes through the normal app transition cycle so we have
337 // to inform the docked controller about visibility change.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700338 mService.getDefaultDisplayContentLocked().getDockedDividerController()
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700339 .notifyAppVisibilityChanged();
340 }
341 }
342
343 return delayed;
344 }
345
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800346 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700347 WindowState candidate = null;
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700348 int j = windows.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800349 while (j > 0) {
350 j--;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700351 final WindowState win = windows.get(j);
352 final int type = win.mAttrs.type;
353 // No need to loop through child window as base application and starting types can't be
354 // child windows.
355 if (type == TYPE_BASE_APPLICATION || type == TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700356 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900357 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700358 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800359 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700360 candidate = win;
361 } else {
362 return win;
363 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800364 }
365 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700366 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800367 }
368
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800369 boolean windowsAreFocusable() {
370 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800371 }
372
Craig Mautner72669d12012-12-18 17:23:54 -0800373 boolean isVisible() {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700374 final int count = windows.size();
375 for (int i = 0; i < count; i++) {
376 final WindowState win = windows.get(i);
377 if (win.isVisible()) {
Craig Mautner72669d12012-12-18 17:23:54 -0800378 return true;
379 }
380 }
381 return false;
382 }
383
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700384 boolean canBeVisibleForCurrentUser() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700385 for (int j = windows.size() - 1; j >= 0; j--) {
386 final WindowState w = windows.get(j);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700387 if (!w.isHiddenFromUserLocked()) {
388 return true;
389 }
390 }
391 return false;
392 }
393
Craig Mautnere3119b72015-01-20 15:02:36 -0800394 void removeAppFromTaskLocked() {
395 mIsExiting = false;
396 removeAllWindows();
397
Craig Mautner83162a92015-01-26 14:43:30 -0800398 // Use local variable because removeAppToken will null out mTask.
399 final Task task = mTask;
Craig Mautnere3119b72015-01-20 15:02:36 -0800400 if (task != null) {
401 if (!task.removeAppToken(this)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800402 Slog.e(TAG, "removeAppFromTaskLocked: token=" + this
Craig Mautnere3119b72015-01-20 15:02:36 -0800403 + " not found.");
404 }
405 task.mStack.mExitingAppTokens.remove(this);
406 }
407 }
408
Chong Zhange05bcb12016-07-26 17:47:29 -0700409 void clearAnimatingFlags() {
Chong Zhangb0d26702016-08-12 16:03:29 -0700410 boolean wallpaperMightChange = false;
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700411 for (int i = windows.size() - 1; i >= 0; i--) {
412 final WindowState win = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700413 wallpaperMightChange |= win.clearAnimatingFlags();
Chong Zhange05bcb12016-07-26 17:47:29 -0700414 }
Chong Zhangb0d26702016-08-12 16:03:29 -0700415 if (wallpaperMightChange) {
416 requestUpdateWallpaperIfNeeded();
417 }
Chong Zhange05bcb12016-07-26 17:47:29 -0700418 }
419
Robert Carre12aece2016-02-02 22:43:27 -0800420 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700421 destroySurfaces(false /*cleanupOnResume*/);
422 }
423
424 /**
425 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
426 * the client has finished with them.
427 *
428 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
429 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
430 * others so that they are ready to be reused. If set to false (common case), destroy all
431 * surfaces that's eligible, if the app is already stopped.
432 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700433 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800434 final DisplayContentList displayList = new DisplayContentList();
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700435 for (int i = windows.size() - 1; i >= 0; i--) {
436 final WindowState win = windows.get(i);
437 final boolean destroyed = win.destroySurface(cleanupOnResume, mAppStopped);
Chong Zhangeb665572016-05-09 18:28:27 -0700438
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700439 if (destroyed) {
440 final DisplayContent displayContent = win.getDisplayContent();
441 if (displayContent != null && !displayList.contains(displayContent)) {
442 displayList.add(displayContent);
443 }
Robert Carre12aece2016-02-02 22:43:27 -0800444 }
Robert Carre12aece2016-02-02 22:43:27 -0800445 }
446 for (int i = 0; i < displayList.size(); i++) {
447 final DisplayContent displayContent = displayList.get(i);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700448 mService.mLayersController.assignLayersLocked(displayContent.getWindowList());
Robert Carre12aece2016-02-02 22:43:27 -0800449 displayContent.layoutNeeded = true;
450 }
451 }
452
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800453 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700454 * Notify that the app is now resumed, and it was not stopped before, perform a clean
455 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800456 */
Chong Zhangad24f962016-08-25 12:12:33 -0700457 void notifyAppResumed(boolean wasStopped, boolean allowSavedSurface) {
458 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped
459 + " allowSavedSurface=" + allowSavedSurface + " " + this);
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700460 mAppStopped = false;
461 if (!wasStopped) {
462 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800463 }
Chong Zhangad24f962016-08-25 12:12:33 -0700464 if (!allowSavedSurface) {
465 destroySavedSurfaces();
466 }
Robert Carre12aece2016-02-02 22:43:27 -0800467 }
468
Chong Zhangbef461f2015-10-27 11:38:24 -0700469 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700470 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
471 * keeping alive in case they were still being used.
472 */
473 void notifyAppStopped() {
474 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
475 mAppStopped = true;
476 destroySurfaces();
477 // Remove any starting window that was added for this app if they are still around.
478 mTask.mService.scheduleRemoveStartingWindowLocked(this);
479 }
480
481 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700482 * Checks whether we should save surfaces for this app.
483 *
484 * @return true if the surfaces should be saved, false otherwise.
485 */
486 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800487 // We want to save surface if the app's windows are "allDrawn".
488 // (If we started entering animation early with saved surfaces, allDrawn
489 // should have been restored to true. So we'll save again in that case
490 // even if app didn't actually finish drawing.)
491 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800492 }
493
Chong Zhang92147042016-05-09 12:47:11 -0700494 boolean canRestoreSurfaces() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700495 for (int i = windows.size() -1; i >= 0; i--) {
496 final WindowState w = windows.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700497 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800498 return true;
499 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700500 }
501 return false;
502 }
503
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700504 void clearWasVisibleBeforeClientHidden() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700505 for (int i = windows.size() - 1; i >= 0; i--) {
506 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700507 w.clearWasVisibleBeforeClientHidden();
Chong Zhang92147042016-05-09 12:47:11 -0700508 }
509 }
510
Chong Zhang8e4bda92016-05-04 15:08:18 -0700511 /**
512 * Whether the app has some window that is invisible in layout, but
513 * animating with saved surface.
514 */
515 boolean isAnimatingInvisibleWithSavedSurface() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700516 for (int i = windows.size() - 1; i >= 0; i--) {
517 final WindowState w = windows.get(i);
Chong Zhang8e4bda92016-05-04 15:08:18 -0700518 if (w.isAnimatingInvisibleWithSavedSurface()) {
519 return true;
520 }
521 }
522 return false;
523 }
524
525 /**
526 * Hide all window surfaces that's still invisible in layout but animating
527 * with a saved surface, and mark them destroying.
528 */
529 void stopUsingSavedSurfaceLocked() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700530 for (int i = windows.size() - 1; i >= 0; i--) {
531 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700532 w.stopUsingSavedSurface();
Chong Zhang8e4bda92016-05-04 15:08:18 -0700533 }
534 destroySurfaces();
535 }
536
Chong Zhangf58631a2016-05-24 16:02:10 -0700537 void markSavedSurfaceExiting() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700538 for (int i = windows.size() - 1; i >= 0; i--) {
539 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700540 w.markSavedSurfaceExiting();
Chong Zhangf58631a2016-05-24 16:02:10 -0700541 }
542 }
543
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700544 void restoreSavedSurfaceForInterestingWindows() {
Chong Zhang92147042016-05-09 12:47:11 -0700545 if (!canRestoreSurfaces()) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700546 clearWasVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700547 return;
548 }
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700549
550 // Check if all interesting windows are drawn and we can mark allDrawn=true.
551 int interestingNotDrawn = -1;
552
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700553 for (int i = windows.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700554 final WindowState w = windows.get(i);
555 interestingNotDrawn = w.restoreSavedSurfaceForInterestingWindow();
Chong Zhangbef461f2015-10-27 11:38:24 -0700556 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800557
Chong Zhang92147042016-05-09 12:47:11 -0700558 if (!allDrawn) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700559 allDrawn = (interestingNotDrawn == 0);
Chong Zhang92147042016-05-09 12:47:11 -0700560 if (allDrawn) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700561 mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
Chong Zhang92147042016-05-09 12:47:11 -0700562 }
563 }
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700564 clearWasVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800565
566 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700567 "restoreSavedSurfaceForInterestingWindows: " + this + " allDrawn=" + allDrawn
568 + " interestingNotDrawn=" + interestingNotDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700569 }
570
571 void destroySavedSurfaces() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700572 for (int i = windows.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700573 final WindowState win = windows.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800574 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700575 }
Chong Zhang92147042016-05-09 12:47:11 -0700576 }
577
578 void clearAllDrawn() {
579 allDrawn = false;
580 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700581 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700582 }
583
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800584 @Override
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700585 void removeWindow(WindowState win) {
586 super.removeWindow(win);
587
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700588 // TODO: Something smells about the code below...Is there a better way?
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700589 if (startingWindow == win) {
590 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Notify removed startingWindow " + win);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700591 mService.scheduleRemoveStartingWindowLocked(this);
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700592 } else if (windows.size() == 0 && startingData != null) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700593 // If this is the last window and we had requested a starting transition window,
594 // well there is no point now.
595 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Nulling last startingWindow");
596 startingData = null;
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700597 } else if (windows.size() == 1 && startingView != null) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700598 // If this is the last window except for a starting transition window,
599 // we need to get rid of the starting transition.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700600 mService.scheduleRemoveStartingWindowLocked(this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700601 }
602 }
603
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700604 void removeDeadWindows() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700605 for (int winNdx = windows.size() - 1; winNdx >= 0;
606 // WindowState#removeIfPossible() at bottom of loop may remove multiple entries from
607 // windows if the window to be removed has child windows. It also may
608 // not remove any windows from windows at all if win is exiting and
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700609 // currently animating away. This ensures that winNdx is monotonically decreasing
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700610 // and never beyond windows bounds.
611 winNdx = Math.min(winNdx - 1, windows.size() - 1)) {
612 WindowState win = windows.get(winNdx);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800613 if (win.mAppDied) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700614 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.w(TAG,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700615 "removeDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800616 // Set mDestroying, we don't want any animation or delayed removal here.
617 win.mDestroying = true;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700618 // Also removes child windows.
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700619 win.removeIfPossible();
Chong Zhang112eb8c2015-11-02 11:17:00 -0800620 }
621 }
622 }
623
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700624 boolean hasWindowsAlive() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700625 for (int i = windows.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700626 // No need to loop through child windows as the answer should be the same as that of the
627 // parent window.
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700628 if (!windows.get(i).mAppDied) {
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700629 return true;
630 }
631 }
632 return false;
633 }
634
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700635 void setWillReplaceWindows(boolean animate) {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700636 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
637 "Marking app token " + this + " with replacing windows.");
Robert Carra1eb4392015-12-10 12:43:51 -0800638
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700639 for (int i = windows.size() - 1; i >= 0; i--) {
640 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700641 w.setWillReplaceWindow(animate);
Robert Carra1eb4392015-12-10 12:43:51 -0800642 }
643 if (animate) {
644 // Set-up dummy animation so we can start treating windows associated with this
645 // token like they are in transition before the new app window is ready for us to
646 // run the real transition animation.
647 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700648 "setWillReplaceWindow() Setting dummy animation on: " + this);
Robert Carra1eb4392015-12-10 12:43:51 -0800649 mAppAnimator.setDummyAnimation();
650 }
651 }
652
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700653 void setWillReplaceChildWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700654 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this
Robert Carr23fa16b2016-01-13 13:19:58 -0800655 + " with replacing child windows.");
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700656 for (int i = windows.size() - 1; i >= 0; i--) {
657 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700658 w.setWillReplaceChildWindows();
Robert Carr23fa16b2016-01-13 13:19:58 -0800659 }
660 }
661
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700662 void clearWillReplaceWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700663 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
664 "Resetting app token " + this + " of replacing window marks.");
Chong Zhangf596cd52016-01-05 13:42:44 -0800665
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700666 for (int i = windows.size() - 1; i >= 0; i--) {
667 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700668 w.clearWillReplaceWindow();
Chong Zhangf596cd52016-01-05 13:42:44 -0800669 }
670 }
671
Chong Zhang4d7369a2016-04-25 16:09:14 -0700672 void requestUpdateWallpaperIfNeeded() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700673 for (int i = windows.size() - 1; i >= 0; i--) {
674 final WindowState w = windows.get(i);
Chong Zhang4d7369a2016-04-25 16:09:14 -0700675 w.requestUpdateWallpaperIfNeeded();
676 }
677 }
678
Chong Zhangd78ddb42016-03-02 17:01:14 -0800679 boolean isRelaunching() {
680 return mPendingRelaunchCount > 0;
681 }
682
683 void startRelaunching() {
684 if (canFreezeBounds()) {
685 freezeBounds();
686 }
687 mPendingRelaunchCount++;
688 }
689
690 void finishRelaunching() {
691 if (canFreezeBounds()) {
692 unfreezeBounds();
693 }
694 if (mPendingRelaunchCount > 0) {
695 mPendingRelaunchCount--;
696 }
697 }
698
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700699 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700700 if (mPendingRelaunchCount == 0) {
701 return;
702 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700703 if (canFreezeBounds()) {
704 unfreezeBounds();
705 }
706 mPendingRelaunchCount = 0;
707 }
708
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700709 @Override
Robert Carra1eb4392015-12-10 12:43:51 -0800710 void addWindow(WindowState w) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700711 super.addWindow(w);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700712
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700713 boolean gotReplacementWindow = false;
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700714 for (int i = windows.size() - 1; i >= 0; i--) {
715 final WindowState candidate = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700716 gotReplacementWindow |= candidate.setReplacementWindowIfNeeded(w);
717 }
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700718
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700719 // if we got a replacement window, reset the timeout to give drawing more time
720 if (gotReplacementWindow) {
721 mService.scheduleWindowReplacementTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800722 }
Robert Carra1eb4392015-12-10 12:43:51 -0800723 }
724
725 boolean waitingForReplacement() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700726 for (int i = windows.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700727 final WindowState candidate = windows.get(i);
728 if (candidate.waitingForReplacement()) {
Robert Carra1eb4392015-12-10 12:43:51 -0800729 return true;
730 }
731 }
732 return false;
733 }
734
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700735 void onWindowReplacementTimeout() {
736 for (int i = windows.size() - 1; i >= 0; --i) {
737 windows.get(i).onWindowReplacementTimeout();
Robert Carra1eb4392015-12-10 12:43:51 -0800738 }
739 }
740
Chong Zhangd78ddb42016-03-02 17:01:14 -0800741 private boolean canFreezeBounds() {
742 // For freeform windows, we can't freeze the bounds at the moment because this would make
743 // the resizing unresponsive.
744 return mTask != null && !mTask.inFreeformWorkspace();
745 }
746
Jorim Jaggi0429f352015-12-22 16:29:16 +0100747 /**
748 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
749 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
750 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
751 * with a queue.
752 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800753 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100754 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700755
756 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
757 // We didn't call prepareFreezingBounds on the task, so use the current value.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700758 final Configuration config = new Configuration(mService.mCurConfiguration);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700759 config.updateFrom(mTask.mOverrideConfig);
760 mFrozenMergedConfig.offer(config);
761 } else {
762 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
763 }
764 mTask.mPreparedFrozenMergedConfig.setToDefaults();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100765 }
766
767 /**
768 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
769 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800770 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700771 if (!mFrozenBounds.isEmpty()) {
772 mFrozenBounds.remove();
773 }
774 if (!mFrozenMergedConfig.isEmpty()) {
775 mFrozenMergedConfig.remove();
776 }
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700777 for (int i = windows.size() - 1; i >= 0; i--) {
778 final WindowState win = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700779 win.onUnfreezeBounds();
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100780 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700781 mService.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100782 }
783
Robert Carr91b228092016-06-28 17:32:37 -0700784 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
785 mSurfaceViewBackgrounds.add(background);
786 }
787
788 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
789 mSurfaceViewBackgrounds.remove(background);
790 updateSurfaceViewBackgroundVisibilities();
791 }
792
793 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
794 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
795 // below the main app window (as traditionally a SurfaceView which is never drawn
796 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
797 // the background for the SurfaceView with lowest Z order
798 void updateSurfaceViewBackgroundVisibilities() {
799 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
800 int bottomLayer = Integer.MAX_VALUE;
801 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
802 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
803 if (sc.mVisible && sc.mLayer < bottomLayer) {
804 bottomLayer = sc.mLayer;
805 bottom = sc;
806 }
807 }
808 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
809 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
810 sc.updateBackgroundVisibility(sc != bottom);
811 }
812 }
813
Jorim Jaggi6626f542016-08-22 13:08:44 -0700814 /**
815 * See {@link WindowManagerService#overridePlayingAppAnimationsLw}
816 */
817 void overridePlayingAppAnimations(Animation a) {
818 if (mAppAnimator.isAnimating()) {
819 final WindowState win = findMainWindow();
820 final int width = win.mContainingFrame.width();
821 final int height = win.mContainingFrame.height();
822 mAppAnimator.setAnimation(a, width, height, false, STACK_CLIP_NONE);
823 }
824 }
825
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700826 void resetJustMovedInStack() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700827 for (int i = windows.size() - 1; i >= 0; i--) {
828 windows.get(i).resetJustMovedInStack();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700829 }
830 }
831
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700832 void setWaitingForDrawnIfResizingChanged() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700833 for (int i = windows.size() - 1; i >= 0; --i) {
834 final WindowState win = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700835 win.setWaitingForDrawnIfResizingChanged();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700836 }
837 }
838
839 void resizeWindows() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700840 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
841 final WindowState win = windows.get(winNdx);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700842 win.addToResizingList();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700843 }
844 }
845
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700846 void setMovedByResize() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700847 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
848 final WindowState win = windows.get(winNdx);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700849 win.setMovedByResize();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700850 }
851 }
852
853 void notifyMovedInStack() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700854 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
855 final WindowState win = windows.get(winNdx);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700856 win.notifyMovedInStack();
857 }
858 }
859
860 void resetDragResizingChangeReported() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700861 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
862 final WindowState win = windows.get(winNdx);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700863 win.resetDragResizingChangeReported();
864 }
865 }
866
867 void detachDisplay() {
868 boolean doAnotherLayoutPass = false;
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700869 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700870 // We are in the middle of changing the state of displays/stacks/tasks. We need
871 // to finish that, before we let layout interfere with it.
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700872 // Also removes child windows.
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700873 windows.get(winNdx).removeIfPossible();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700874 doAnotherLayoutPass = true;
875 }
876 if (doAnotherLayoutPass) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700877 mService.mWindowPlacerLocked.requestTraversal();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700878 }
879 }
880
881 void forceWindowsScaleableInTransaction(boolean force) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700882 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700883 windows.get(winNdx).forceWindowsScaleableInTransaction(force);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700884 }
885 }
886
887 boolean isAnimating() {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700888 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700889 if (windows.get(winNdx).isAnimating()) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700890 return true;
891 }
892 }
893 return false;
894 }
895
896 void setAppLayoutChanges(int changes, String reason, int displayId) {
897 final WindowAnimator windowAnimator = mAppAnimator.mAnimator;
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700898 for (int i = windows.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700899 // Child windows will be on the same display as their parents.
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700900 if (displayId == windows.get(i).getDisplayId()) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700901 windowAnimator.setPendingLayoutChanges(displayId, changes);
902 if (DEBUG_LAYOUT_REPEATS) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700903 mService.mWindowPlacerLocked.debugLayoutRepeats(
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700904 reason, windowAnimator.getPendingLayoutChanges(displayId));
905 }
906 break;
907 }
908 }
909 }
910
911 void removeReplacedWindowIfNeeded(WindowState replacement) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700912 for (int i = windows.size() - 1; i >= 0; i--) {
913 final WindowState win = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700914 if (win.removeReplacedWindowIfNeeded(replacement)) {
915 return;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700916 }
917 }
918 }
919
920 void startFreezingScreen() {
921 if (DEBUG_ORIENTATION) logWithStack(TAG, "Set freezing of " + appToken + ": hidden="
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700922 + hidden + " freezing=" + mAppAnimator.freezingScreen + " hiddenRequested="
923 + hiddenRequested);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700924 if (!hiddenRequested) {
925 if (!mAppAnimator.freezingScreen) {
926 mAppAnimator.freezingScreen = true;
927 mAppAnimator.lastFreezeDuration = 0;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700928 mService.mAppsFreezingScreen++;
929 if (mService.mAppsFreezingScreen == 1) {
930 mService.startFreezingDisplayLocked(false, 0, 0);
931 mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
932 mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700933 }
934 }
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700935 final int count = windows.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700936 for (int i = 0; i < count; i++) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700937 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700938 w.onStartFreezingScreen();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700939 }
940 }
941 }
942
943 void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) {
944 if (!mAppAnimator.freezingScreen) {
945 return;
946 }
947 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Clear freezing of " + this + " force=" + force);
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700948 final int count = windows.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700949 boolean unfrozeWindows = false;
950 for (int i = 0; i < count; i++) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700951 final WindowState w = windows.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700952 unfrozeWindows |= w.onStopFreezingScreen();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700953 }
954 if (force || unfrozeWindows) {
955 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this);
956 mAppAnimator.freezingScreen = false;
957 mAppAnimator.lastFreezeDuration =
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700958 (int)(SystemClock.elapsedRealtime() - mService.mDisplayFreezeTime);
959 mService.mAppsFreezingScreen--;
960 mService.mLastFinishedFreezeSource = this;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700961 }
962 if (unfreezeSurfaceNow) {
963 if (unfrozeWindows) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700964 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700965 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700966 mService.stopFreezingDisplayLocked();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700967 }
968 }
969
970 boolean transferStartingWindow(IBinder transferFrom) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700971 final AppWindowToken fromToken = mService.findAppWindowToken(transferFrom);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700972 if (fromToken == null) {
973 return false;
974 }
975
976 final WindowState tStartingWindow = fromToken.startingWindow;
977 if (tStartingWindow != null && fromToken.startingView != null) {
978 // In this case, the starting icon has already been displayed, so start
979 // letting windows get shown immediately without any more transitions.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700980 mService.mSkipAppTransitionAnimation = true;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700981
982 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Moving existing starting " + tStartingWindow
983 + " from " + fromToken + " to " + this);
984
985 final long origId = Binder.clearCallingIdentity();
986
987 // Transfer the starting window over to the new token.
988 startingData = fromToken.startingData;
989 startingView = fromToken.startingView;
990 startingDisplayed = fromToken.startingDisplayed;
991 fromToken.startingDisplayed = false;
992 startingWindow = tStartingWindow;
993 reportedVisible = fromToken.reportedVisible;
994 fromToken.startingData = null;
995 fromToken.startingView = null;
996 fromToken.startingWindow = null;
997 fromToken.startingMoved = true;
998 tStartingWindow.mToken = this;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700999 tStartingWindow.mAppToken = this;
1000
1001 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
1002 "Removing starting window: " + tStartingWindow);
1003 tStartingWindow.getWindowList().remove(tStartingWindow);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001004 mService.mWindowsChanged = true;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001005 if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
1006 "Removing starting " + tStartingWindow + " from " + fromToken);
1007 fromToken.removeWindow(tStartingWindow);
Wale Ogunwale92fc3722016-08-05 12:19:08 -07001008 addWindow(tStartingWindow);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001009
1010 // Propagate other interesting state between the tokens. If the old token is displayed,
1011 // we should immediately force the new one to be displayed. If it is animating, we need
1012 // to move that animation to the new one.
1013 if (fromToken.allDrawn) {
1014 allDrawn = true;
1015 deferClearAllDrawn = fromToken.deferClearAllDrawn;
1016 }
1017 if (fromToken.firstWindowDrawn) {
1018 firstWindowDrawn = true;
1019 }
1020 if (!fromToken.hidden) {
1021 hidden = false;
1022 hiddenRequested = false;
1023 }
1024 if (clientHidden != fromToken.clientHidden) {
1025 clientHidden = fromToken.clientHidden;
1026 sendAppVisibilityToClients();
1027 }
1028 fromToken.mAppAnimator.transferCurrentAnimation(
1029 mAppAnimator, tStartingWindow.mWinAnimator);
1030
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001031 mService.updateFocusedWindowLocked(
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001032 UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001033 mService.getDefaultDisplayContentLocked().layoutNeeded = true;
1034 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001035 Binder.restoreCallingIdentity(origId);
1036 return true;
1037 } else if (fromToken.startingData != null) {
1038 // The previous app was getting ready to show a
1039 // starting window, but hasn't yet done so. Steal it!
1040 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
1041 "Moving pending starting from " + fromToken + " to " + this);
1042 startingData = fromToken.startingData;
1043 fromToken.startingData = null;
1044 fromToken.startingMoved = true;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001045 final Message m = mService.mH.obtainMessage(H.ADD_STARTING, this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001046 // Note: we really want to do sendMessageAtFrontOfQueue() because we want to process the
1047 // message ASAP, before any other queued messages.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001048 mService.mH.sendMessageAtFrontOfQueue(m);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001049 return true;
1050 }
1051
1052 final AppWindowAnimator tAppAnimator = fromToken.mAppAnimator;
1053 final AppWindowAnimator wAppAnimator = mAppAnimator;
1054 if (tAppAnimator.thumbnail != null) {
1055 // The old token is animating with a thumbnail, transfer that to the new token.
1056 if (wAppAnimator.thumbnail != null) {
1057 wAppAnimator.thumbnail.destroy();
1058 }
1059 wAppAnimator.thumbnail = tAppAnimator.thumbnail;
1060 wAppAnimator.thumbnailLayer = tAppAnimator.thumbnailLayer;
1061 wAppAnimator.thumbnailAnimation = tAppAnimator.thumbnailAnimation;
1062 tAppAnimator.thumbnail = null;
1063 }
1064 return false;
1065 }
1066
Wale Ogunwale9bc47732016-08-10 14:44:22 -07001067 boolean isLastWindow(WindowState win) {
1068 return windows.size() == 1 && windows.get(0) == win;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001069 }
1070
1071 void setAllAppWinAnimators() {
1072 final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators;
1073 allAppWinAnimators.clear();
1074
Wale Ogunwale92fc3722016-08-05 12:19:08 -07001075 final int windowsCount = windows.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001076 for (int j = 0; j < windowsCount; j++) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -07001077 windows.get(j).addWinAnimatorToList(allAppWinAnimators);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001078 }
1079 }
1080
Craig Mautnerdbb79912012-03-01 18:59:14 -08001081 @Override
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001082 AppWindowToken asAppWindowToken() {
1083 // I am an app window token!
1084 return this;
1085 }
1086
1087 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001088 void dump(PrintWriter pw, String prefix) {
1089 super.dump(pw, prefix);
1090 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001091 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001092 }
Craig Mautner83162a92015-01-26 14:43:30 -08001093 pw.print(prefix); pw.print("task="); pw.println(mTask);
1094 pw.print(prefix); pw.print(" appFullscreen="); pw.print(appFullscreen);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001095 pw.print(" requestedOrientation="); pw.println(requestedOrientation);
1096 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
1097 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -07001098 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001099 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -07001100 if (paused) {
1101 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001102 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001103 if (mAppStopped) {
1104 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
1105 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001106 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -07001107 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001108 pw.print(prefix); pw.print("numInterestingWindows=");
1109 pw.print(numInterestingWindows);
1110 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
1111 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -07001112 pw.print(" allDrawn="); pw.print(allDrawn);
1113 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
1114 pw.println(")");
1115 }
1116 if (inPendingTransaction) {
1117 pw.print(prefix); pw.print("inPendingTransaction=");
1118 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001119 }
Craig Mautner799bc1d2015-01-14 10:33:48 -08001120 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001121 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
1122 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -08001123 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -08001124 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001125 }
1126 if (startingWindow != null || startingView != null
1127 || startingDisplayed || startingMoved) {
1128 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
1129 pw.print(" startingView="); pw.print(startingView);
1130 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001131 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001132 }
Jorim Jaggi0429f352015-12-22 16:29:16 +01001133 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -08001134 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -07001135 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -08001136 }
1137 if (mPendingRelaunchCount != 0) {
1138 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +01001139 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001140 }
1141
1142 @Override
1143 public String toString() {
1144 if (stringName == null) {
1145 StringBuilder sb = new StringBuilder();
1146 sb.append("AppWindowToken{");
1147 sb.append(Integer.toHexString(System.identityHashCode(this)));
1148 sb.append(" token="); sb.append(token); sb.append('}');
1149 stringName = sb.toString();
1150 }
1151 return stringName;
1152 }
Jeff Browne9bdb312012-04-05 15:30:10 -07001153}