blob: f9aa66b825fc184d922d26d6007d786ff9f21e8f [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 Ogunwale51362492016-09-08 17:49:17 -070020import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070021import static android.view.Display.DEFAULT_DISPLAY;
Wale Ogunwaled1c37912016-08-16 03:19:39 -070022import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080023import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070024import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
Wale Ogunwale3f4433d2016-08-18 20:42:42 -070025import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
26import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080027import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
28import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Robert Carra1eb4392015-12-10 12:43:51 -080029import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070030import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
31import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
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;
Jorim Jaggi6626f542016-08-22 13:08:44 -070038import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070039import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070040import 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;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070046import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010047import android.graphics.Rect;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070048import android.os.Binder;
49import android.os.IBinder;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080050import android.os.Message;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070051import android.os.SystemClock;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080052import android.util.Slog;
53import android.view.IApplicationToken;
54import android.view.View;
55import android.view.WindowManager;
Jorim Jaggi6626f542016-08-22 13:08:44 -070056import android.view.animation.Animation;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080057
58import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010059import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080060import java.util.ArrayList;
61
62class AppTokenList extends ArrayList<AppWindowToken> {
63}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080064
65/**
66 * Version of WindowToken that is specifically for a particular application (or
67 * really activity) that is displaying windows.
68 */
Wale Ogunwale3f4433d2016-08-18 20:42:42 -070069class AppWindowToken extends WindowToken implements WindowManagerService.AppFreezeListener {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080070 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
71
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080072 // Non-null only for application tokens.
73 final IApplicationToken appToken;
74
Filip Gruszczynskia590c992015-11-25 16:45:26 -080075 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070076
Dianne Hackborne30e02f2014-05-27 18:24:45 -070077 final boolean voiceInteraction;
78
Wale Ogunwalef6192862016-09-10 13:42:30 -070079 // TODO: Use getParent instead?
Craig Mautner83162a92015-01-26 14:43:30 -080080 Task mTask;
Wale Ogunwale51362492016-09-08 17:49:17 -070081 /** @see WindowContainer#fillsParent() */
82 private boolean mFillsParent;
Craig Mautner4c5eb222013-11-18 12:59:05 -080083 boolean layoutConfigChanges;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070084 boolean showForAllUsers;
Yorke Lee0e852472016-06-15 10:03:18 -070085 int targetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070086
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080087 // The input dispatching timeout for this application token in nanoseconds.
88 long inputDispatchingTimeoutNanos;
89
90 // These are used for determining when all windows associated with
91 // an activity have been drawn, so they can be made visible together
92 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -070093 // initialize so that it doesn't match mTransactionSequence which is an int.
94 long lastTransactionSequence = Long.MIN_VALUE;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080095 int numInterestingWindows;
96 int numDrawnWindows;
97 boolean inPendingTransaction;
98 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -080099 // Set to true when this app creates a surface while in the middle of an animation. In that
100 // case do not clear allDrawn until the animation completes.
101 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800102
Chong Zhang8e4bda92016-05-04 15:08:18 -0700103 // These are to track the app's real drawing status if there were no saved surfaces.
104 boolean allDrawnExcludingSaved;
105 int numInterestingWindowsExcludingSaved;
Wale Ogunwale571771c2016-08-26 13:18:50 -0700106 int numDrawnWindowsExcludingSaved;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700107
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800108 // Is this window's surface needed? This is almost like hidden, except
109 // it will sometimes be true a little earlier: when the token has
110 // been shown, but is still waiting for its app transition to execute
111 // before making its windows shown.
112 boolean hiddenRequested;
113
114 // Have we told the window clients to hide themselves?
115 boolean clientHidden;
116
117 // Last visibility state we reported to the app token.
118 boolean reportedVisible;
119
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700120 // Last drawn state we reported to the app token.
121 boolean reportedDrawn;
122
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800123 // Set to true when the token has been removed from the window mgr.
124 boolean removed;
125
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800126 // Information about an application starting window if displayed.
127 StartingData startingData;
128 WindowState startingWindow;
129 View startingView;
130 boolean startingDisplayed;
131 boolean startingMoved;
132 boolean firstWindowDrawn;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700133 private final WindowState.UpdateReportedVisibilityResults mReportedVisibilityResults =
134 new WindowState.UpdateReportedVisibilityResults();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800135
136 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700137 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800138
Wale Ogunwale571771c2016-08-26 13:18:50 -0700139 // TODO: Have a WindowContainer state for tracking exiting/deferred removal.
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 =
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700152 new ArrayList<>();
Robert Carr91b228092016-06-28 17:32:37 -0700153
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
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700157 AppWindowToken(WindowManagerService service, IApplicationToken token, boolean _voiceInteraction) {
158 super(service, token != null ? token.asBinder() : null, TYPE_APPLICATION, true);
159 appToken = token;
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700160 voiceInteraction = _voiceInteraction;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800161 mInputApplicationHandle = new InputApplicationHandle(this);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700162 mAppAnimator = new AppWindowAnimator(this, service);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800163 }
164
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800165 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
166 firstWindowDrawn = true;
167
168 // We now have a good window to show, remove dead placeholders
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700169 removeDeadWindows();
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800170
171 if (startingData != null) {
172 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
173 + win.mToken + ": first real window is shown, no animation");
174 // If this initial window is animating, stop it -- we will do an animation to reveal
175 // it from behind the starting window, so there is no need for it to also be doing its
176 // own stuff.
177 winAnimator.clearAnimation();
178 winAnimator.mService.mFinishedStarting.add(this);
179 winAnimator.mService.mH.sendEmptyMessage(H.FINISHED_STARTING);
180 }
181 updateReportedVisibilityLocked();
182 }
183
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800184 void updateReportedVisibilityLocked() {
185 if (appToken == null) {
186 return;
187 }
188
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700189 if (DEBUG_VISIBILITY) Slog.v(TAG, "Update reported visibility: " + this);
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700190 final int count = mChildren.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800191
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700192 mReportedVisibilityResults.reset();
193
194 for (int i = 0; i < count; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700195 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700196 win.updateReportedVisibility(mReportedVisibilityResults);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800197 }
198
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700199 int numInteresting = mReportedVisibilityResults.numInteresting;
200 int numVisible = mReportedVisibilityResults.numVisible;
201 int numDrawn = mReportedVisibilityResults.numDrawn;
202 boolean nowGone = mReportedVisibilityResults.nowGone;
203
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700204 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800205 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700206 if (!nowGone) {
207 // If the app is not yet gone, then it can only become visible/drawn.
208 if (!nowDrawn) {
209 nowDrawn = reportedDrawn;
210 }
211 if (!nowVisible) {
212 nowVisible = reportedVisible;
213 }
214 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800215 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800216 + numInteresting + " visible=" + numVisible);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700217 if (nowDrawn != reportedDrawn) {
218 if (nowDrawn) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700219 mService.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_DRAWN, this).sendToTarget();
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700220 }
221 reportedDrawn = nowDrawn;
222 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800223 if (nowVisible != reportedVisible) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700224 if (DEBUG_VISIBILITY) Slog.v(TAG,
225 "Visibility changed in " + this + ": vis=" + nowVisible);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800226 reportedVisible = nowVisible;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700227 mService.mH.obtainMessage(H.REPORT_APPLICATION_TOKEN_WINDOWS,
228 nowVisible ? 1 : 0, nowGone ? 1 : 0, this).sendToTarget();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800229 }
230 }
231
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700232 boolean setVisibility(WindowManager.LayoutParams lp,
233 boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) {
234
235 boolean delayed = false;
236 inPendingTransaction = false;
237
238 if (clientHidden == visible) {
239 clientHidden = !visible;
240 sendAppVisibilityToClients();
241 }
242
243 // Allow for state changes and animation to be applied if:
244 // * token is transitioning visibility state
245 // * or the token was marked as hidden and is exiting before we had a chance to play the
246 // transition animation
247 // * or this is an opening app and windows are being replaced.
248 boolean visibilityChanged = false;
249 if (hidden == visible || (hidden && mIsExiting) || (visible && waitingForReplacement())) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700250 final AccessibilityController accessibilityController = mService.mAccessibilityController;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700251 boolean changed = false;
252 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
253 "Changing app " + this + " hidden=" + hidden + " performLayout=" + performLayout);
254
255 boolean runningAppAnimation = false;
256
257 if (transit != AppTransition.TRANSIT_UNSET) {
258 if (mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) {
259 mAppAnimator.setNullAnimation();
260 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700261 if (mService.applyAnimationLocked(this, lp, transit, visible, isVoiceInteraction)) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700262 delayed = runningAppAnimation = true;
263 }
264 final WindowState window = findMainWindow();
265 //TODO (multidisplay): Magnification is supported only for the default display.
266 if (window != null && accessibilityController != null
267 && window.getDisplayId() == DEFAULT_DISPLAY) {
268 accessibilityController.onAppWindowTransitionLocked(window, transit);
269 }
270 changed = true;
271 }
272
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700273 final int windowsCount = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700274 for (int i = 0; i < windowsCount; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700275 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700276 changed |= win.onAppVisibilityChanged(visible, runningAppAnimation);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700277 }
278
279 hidden = hiddenRequested = !visible;
280 visibilityChanged = true;
281 if (!visible) {
282 stopFreezingScreen(true, true);
283 } else {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700284 // If we are being set visible, and the starting window is not yet displayed,
285 // then make sure it doesn't get displayed.
286 if (startingWindow != null && !startingWindow.isDrawnLw()) {
287 startingWindow.mPolicyVisibility = false;
288 startingWindow.mPolicyVisibilityAfterAnim = false;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700289 }
290 }
291
292 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this
293 + ": hidden=" + hidden + " hiddenRequested=" + hiddenRequested);
294
295 if (changed) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700296 mService.mInputMonitor.setUpdateInputWindowsNeededLw();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700297 if (performLayout) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700298 mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700299 false /*updateInputWindows*/);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700300 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700301 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700302 mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700303 }
304 }
305
306 if (mAppAnimator.animation != null) {
307 delayed = true;
308 }
309
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700310 for (int i = mChildren.size() - 1; i >= 0 && !delayed; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700311 if ((mChildren.get(i)).isWindowAnimationSet()) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700312 delayed = true;
313 }
314 }
315
316 if (visibilityChanged) {
317 if (visible && !delayed) {
318 // The token was made immediately visible, there will be no entrance animation.
319 // We need to inform the client the enter animation was finished.
320 mEnteringAnimation = true;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700321 mService.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700322 }
323
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700324 if (!mService.mClosingApps.contains(this) && !mService.mOpeningApps.contains(this)) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700325 // The token is not closing nor opening, so even if there is an animation set, that
326 // doesn't mean that it goes through the normal app transition cycle so we have
327 // to inform the docked controller about visibility change.
Andrii Kulian1e32e022016-09-16 15:29:34 -0700328 // TODO(multi-display): notify docked divider on all displays where visibility was
329 // affected.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700330 mService.getDefaultDisplayContentLocked().getDockedDividerController()
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700331 .notifyAppVisibilityChanged();
332 }
333 }
334
335 return delayed;
336 }
337
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800338 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700339 WindowState candidate = null;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700340 int j = mChildren.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800341 while (j > 0) {
342 j--;
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700343 final WindowState win = mChildren.get(j);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700344 final int type = win.mAttrs.type;
345 // No need to loop through child window as base application and starting types can't be
346 // child windows.
347 if (type == TYPE_BASE_APPLICATION || type == TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700348 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900349 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700350 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800351 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700352 candidate = win;
353 } else {
354 return win;
355 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800356 }
357 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700358 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800359 }
360
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800361 boolean windowsAreFocusable() {
362 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800363 }
364
Wale Ogunwale571771c2016-08-26 13:18:50 -0700365 @Override
Wale Ogunwale44f21802016-09-02 12:49:48 -0700366 boolean isVisible() {
367 if (hidden) {
368 // TODO: Should this be checking hiddenRequested instead of hidden?
369 return false;
370 }
371 return super.isVisible();
372 }
373
374 @Override
Wale Ogunwale571771c2016-08-26 13:18:50 -0700375 void removeIfPossible() {
Craig Mautnere3119b72015-01-20 15:02:36 -0800376 mIsExiting = false;
377 removeAllWindows();
Wale Ogunwale571771c2016-08-26 13:18:50 -0700378 if (mTask != null) {
Wale Ogunwalef6192862016-09-10 13:42:30 -0700379 mTask.mStack.mExitingAppTokens.remove(this);
380 mTask.removeChild(this);
Craig Mautnere3119b72015-01-20 15:02:36 -0800381 }
382 }
383
Wale Ogunwale3f4433d2016-08-18 20:42:42 -0700384 @Override
385 boolean checkCompleteDeferredRemoval() {
386 if (mIsExiting) {
387 removeIfPossible();
388 }
389 return super.checkCompleteDeferredRemoval();
390 }
391
Chong Zhange05bcb12016-07-26 17:47:29 -0700392 void clearAnimatingFlags() {
Chong Zhangb0d26702016-08-12 16:03:29 -0700393 boolean wallpaperMightChange = false;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700394 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700395 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700396 wallpaperMightChange |= win.clearAnimatingFlags();
Chong Zhange05bcb12016-07-26 17:47:29 -0700397 }
Chong Zhangb0d26702016-08-12 16:03:29 -0700398 if (wallpaperMightChange) {
399 requestUpdateWallpaperIfNeeded();
400 }
Chong Zhange05bcb12016-07-26 17:47:29 -0700401 }
402
Robert Carre12aece2016-02-02 22:43:27 -0800403 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700404 destroySurfaces(false /*cleanupOnResume*/);
405 }
406
407 /**
408 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
409 * the client has finished with them.
410 *
411 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
412 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
413 * others so that they are ready to be reused. If set to false (common case), destroy all
414 * surfaces that's eligible, if the app is already stopped.
415 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700416 private void destroySurfaces(boolean cleanupOnResume) {
Robert Carre12aece2016-02-02 22:43:27 -0800417 final DisplayContentList displayList = new DisplayContentList();
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700418 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700419 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700420 final boolean destroyed = win.destroySurface(cleanupOnResume, mAppStopped);
Chong Zhangeb665572016-05-09 18:28:27 -0700421
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700422 if (destroyed) {
423 final DisplayContent displayContent = win.getDisplayContent();
424 if (displayContent != null && !displayList.contains(displayContent)) {
425 displayList.add(displayContent);
426 }
Robert Carre12aece2016-02-02 22:43:27 -0800427 }
Robert Carre12aece2016-02-02 22:43:27 -0800428 }
429 for (int i = 0; i < displayList.size(); i++) {
430 final DisplayContent displayContent = displayList.get(i);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700431 mService.mLayersController.assignLayersLocked(displayContent.getWindowList());
Robert Carre12aece2016-02-02 22:43:27 -0800432 displayContent.layoutNeeded = true;
433 }
434 }
435
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800436 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700437 * Notify that the app is now resumed, and it was not stopped before, perform a clean
438 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800439 */
Chong Zhangad24f962016-08-25 12:12:33 -0700440 void notifyAppResumed(boolean wasStopped, boolean allowSavedSurface) {
441 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped
442 + " allowSavedSurface=" + allowSavedSurface + " " + this);
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700443 mAppStopped = false;
444 if (!wasStopped) {
445 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800446 }
Chong Zhangad24f962016-08-25 12:12:33 -0700447 if (!allowSavedSurface) {
448 destroySavedSurfaces();
449 }
Robert Carre12aece2016-02-02 22:43:27 -0800450 }
451
Chong Zhangbef461f2015-10-27 11:38:24 -0700452 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700453 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
454 * keeping alive in case they were still being used.
455 */
456 void notifyAppStopped() {
457 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
458 mAppStopped = true;
459 destroySurfaces();
460 // Remove any starting window that was added for this app if they are still around.
461 mTask.mService.scheduleRemoveStartingWindowLocked(this);
462 }
463
464 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700465 * Checks whether we should save surfaces for this app.
466 *
467 * @return true if the surfaces should be saved, false otherwise.
468 */
469 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800470 // We want to save surface if the app's windows are "allDrawn".
471 // (If we started entering animation early with saved surfaces, allDrawn
472 // should have been restored to true. So we'll save again in that case
473 // even if app didn't actually finish drawing.)
474 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800475 }
476
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700477 private boolean canRestoreSurfaces() {
478 for (int i = mChildren.size() -1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700479 final WindowState w = mChildren.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700480 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800481 return true;
482 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700483 }
484 return false;
485 }
486
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700487 private void clearWasVisibleBeforeClientHidden() {
488 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700489 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700490 w.clearWasVisibleBeforeClientHidden();
Chong Zhang92147042016-05-09 12:47:11 -0700491 }
492 }
493
Chong Zhang8e4bda92016-05-04 15:08:18 -0700494 /**
495 * Whether the app has some window that is invisible in layout, but
496 * animating with saved surface.
497 */
498 boolean isAnimatingInvisibleWithSavedSurface() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700499 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700500 final WindowState w = mChildren.get(i);
Chong Zhang8e4bda92016-05-04 15:08:18 -0700501 if (w.isAnimatingInvisibleWithSavedSurface()) {
502 return true;
503 }
504 }
505 return false;
506 }
507
508 /**
509 * Hide all window surfaces that's still invisible in layout but animating
510 * with a saved surface, and mark them destroying.
511 */
512 void stopUsingSavedSurfaceLocked() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700513 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700514 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700515 w.stopUsingSavedSurface();
Chong Zhang8e4bda92016-05-04 15:08:18 -0700516 }
517 destroySurfaces();
518 }
519
Chong Zhangf58631a2016-05-24 16:02:10 -0700520 void markSavedSurfaceExiting() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700521 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700522 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700523 w.markSavedSurfaceExiting();
Chong Zhangf58631a2016-05-24 16:02:10 -0700524 }
525 }
526
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700527 void restoreSavedSurfaceForInterestingWindows() {
Chong Zhang92147042016-05-09 12:47:11 -0700528 if (!canRestoreSurfaces()) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700529 clearWasVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700530 return;
531 }
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700532
533 // Check if all interesting windows are drawn and we can mark allDrawn=true.
534 int interestingNotDrawn = -1;
535
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700536 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700537 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700538 interestingNotDrawn = w.restoreSavedSurfaceForInterestingWindow();
Chong Zhangbef461f2015-10-27 11:38:24 -0700539 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800540
Chong Zhang92147042016-05-09 12:47:11 -0700541 if (!allDrawn) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700542 allDrawn = (interestingNotDrawn == 0);
Chong Zhang92147042016-05-09 12:47:11 -0700543 if (allDrawn) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700544 mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
Chong Zhang92147042016-05-09 12:47:11 -0700545 }
546 }
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700547 clearWasVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800548
549 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700550 "restoreSavedSurfaceForInterestingWindows: " + this + " allDrawn=" + allDrawn
551 + " interestingNotDrawn=" + interestingNotDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700552 }
553
554 void destroySavedSurfaces() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700555 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700556 final WindowState win = mChildren.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800557 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700558 }
Chong Zhang92147042016-05-09 12:47:11 -0700559 }
560
561 void clearAllDrawn() {
562 allDrawn = false;
563 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700564 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700565 }
566
Wale Ogunwale98e70d02014-11-10 12:12:27 -0800567 @Override
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700568 void removeWindow(WindowState win) {
569 super.removeWindow(win);
570
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700571 // TODO: Something smells about the code below...Is there a better way?
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700572 if (startingWindow == win) {
573 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Notify removed startingWindow " + win);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700574 mService.scheduleRemoveStartingWindowLocked(this);
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700575 } else if (mChildren.size() == 0 && startingData != null) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700576 // If this is the last window and we had requested a starting transition window,
577 // well there is no point now.
578 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Nulling last startingWindow");
579 startingData = null;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700580 } else if (mChildren.size() == 1 && startingView != null) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700581 // If this is the last window except for a starting transition window,
582 // we need to get rid of the starting transition.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700583 mService.scheduleRemoveStartingWindowLocked(this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700584 }
585 }
586
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700587 void removeDeadWindows() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700588 for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700589 WindowState win = mChildren.get(winNdx);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800590 if (win.mAppDied) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700591 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.w(TAG,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700592 "removeDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800593 // Set mDestroying, we don't want any animation or delayed removal here.
594 win.mDestroying = true;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700595 // Also removes child windows.
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700596 win.removeIfPossible();
Chong Zhang112eb8c2015-11-02 11:17:00 -0800597 }
598 }
599 }
600
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700601 boolean hasWindowsAlive() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700602 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700603 // No need to loop through child windows as the answer should be the same as that of the
604 // parent window.
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700605 if (!(mChildren.get(i)).mAppDied) {
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700606 return true;
607 }
608 }
609 return false;
610 }
611
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700612 void setWillReplaceWindows(boolean animate) {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700613 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
614 "Marking app token " + this + " with replacing windows.");
Robert Carra1eb4392015-12-10 12:43:51 -0800615
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700616 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700617 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700618 w.setWillReplaceWindow(animate);
Robert Carra1eb4392015-12-10 12:43:51 -0800619 }
620 if (animate) {
621 // Set-up dummy animation so we can start treating windows associated with this
622 // token like they are in transition before the new app window is ready for us to
623 // run the real transition animation.
624 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700625 "setWillReplaceWindow() Setting dummy animation on: " + this);
Robert Carra1eb4392015-12-10 12:43:51 -0800626 mAppAnimator.setDummyAnimation();
627 }
628 }
629
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700630 void setWillReplaceChildWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700631 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this
Robert Carr23fa16b2016-01-13 13:19:58 -0800632 + " with replacing child windows.");
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700633 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700634 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700635 w.setWillReplaceChildWindows();
Robert Carr23fa16b2016-01-13 13:19:58 -0800636 }
637 }
638
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700639 void clearWillReplaceWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700640 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
641 "Resetting app token " + this + " of replacing window marks.");
Chong Zhangf596cd52016-01-05 13:42:44 -0800642
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700643 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700644 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700645 w.clearWillReplaceWindow();
Chong Zhangf596cd52016-01-05 13:42:44 -0800646 }
647 }
648
Chong Zhang4d7369a2016-04-25 16:09:14 -0700649 void requestUpdateWallpaperIfNeeded() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700650 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700651 final WindowState w = mChildren.get(i);
Chong Zhang4d7369a2016-04-25 16:09:14 -0700652 w.requestUpdateWallpaperIfNeeded();
653 }
654 }
655
Chong Zhangd78ddb42016-03-02 17:01:14 -0800656 boolean isRelaunching() {
657 return mPendingRelaunchCount > 0;
658 }
659
660 void startRelaunching() {
661 if (canFreezeBounds()) {
662 freezeBounds();
663 }
664 mPendingRelaunchCount++;
665 }
666
667 void finishRelaunching() {
668 if (canFreezeBounds()) {
669 unfreezeBounds();
670 }
671 if (mPendingRelaunchCount > 0) {
672 mPendingRelaunchCount--;
673 }
674 }
675
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700676 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700677 if (mPendingRelaunchCount == 0) {
678 return;
679 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700680 if (canFreezeBounds()) {
681 unfreezeBounds();
682 }
683 mPendingRelaunchCount = 0;
684 }
685
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700686 @Override
Robert Carra1eb4392015-12-10 12:43:51 -0800687 void addWindow(WindowState w) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700688 super.addWindow(w);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700689
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700690 boolean gotReplacementWindow = false;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700691 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700692 final WindowState candidate = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700693 gotReplacementWindow |= candidate.setReplacementWindowIfNeeded(w);
694 }
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700695
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700696 // if we got a replacement window, reset the timeout to give drawing more time
697 if (gotReplacementWindow) {
698 mService.scheduleWindowReplacementTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800699 }
Robert Carra1eb4392015-12-10 12:43:51 -0800700 }
701
702 boolean waitingForReplacement() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700703 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700704 final WindowState candidate = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700705 if (candidate.waitingForReplacement()) {
Robert Carra1eb4392015-12-10 12:43:51 -0800706 return true;
707 }
708 }
709 return false;
710 }
711
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700712 void onWindowReplacementTimeout() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700713 for (int i = mChildren.size() - 1; i >= 0; --i) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700714 (mChildren.get(i)).onWindowReplacementTimeout();
Robert Carra1eb4392015-12-10 12:43:51 -0800715 }
716 }
717
Chong Zhangd78ddb42016-03-02 17:01:14 -0800718 private boolean canFreezeBounds() {
719 // For freeform windows, we can't freeze the bounds at the moment because this would make
720 // the resizing unresponsive.
721 return mTask != null && !mTask.inFreeformWorkspace();
722 }
723
Jorim Jaggi0429f352015-12-22 16:29:16 +0100724 /**
725 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
726 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
727 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
728 * with a queue.
729 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800730 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100731 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700732
733 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
734 // We didn't call prepareFreezingBounds on the task, so use the current value.
Andrii Kulian8072d112016-09-16 11:11:01 -0700735 final Configuration config = new Configuration(mService.mGlobalConfiguration);
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700736 config.updateFrom(mTask.mOverrideConfig);
737 mFrozenMergedConfig.offer(config);
738 } else {
739 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
740 }
Andrii Kulianb10330d2016-09-16 13:51:46 -0700741 // Calling unset() to make it equal to Configuration.EMPTY.
742 mTask.mPreparedFrozenMergedConfig.unset();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100743 }
744
745 /**
746 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
747 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800748 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700749 if (!mFrozenBounds.isEmpty()) {
750 mFrozenBounds.remove();
751 }
752 if (!mFrozenMergedConfig.isEmpty()) {
753 mFrozenMergedConfig.remove();
754 }
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700755 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700756 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700757 win.onUnfreezeBounds();
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100758 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700759 mService.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100760 }
761
Robert Carr91b228092016-06-28 17:32:37 -0700762 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
763 mSurfaceViewBackgrounds.add(background);
764 }
765
766 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
767 mSurfaceViewBackgrounds.remove(background);
768 updateSurfaceViewBackgroundVisibilities();
769 }
770
771 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
772 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
773 // below the main app window (as traditionally a SurfaceView which is never drawn
774 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
775 // the background for the SurfaceView with lowest Z order
776 void updateSurfaceViewBackgroundVisibilities() {
777 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
778 int bottomLayer = Integer.MAX_VALUE;
779 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
780 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
781 if (sc.mVisible && sc.mLayer < bottomLayer) {
782 bottomLayer = sc.mLayer;
783 bottom = sc;
784 }
785 }
786 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
787 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
788 sc.updateBackgroundVisibility(sc != bottom);
789 }
790 }
791
Jorim Jaggi6626f542016-08-22 13:08:44 -0700792 /**
793 * See {@link WindowManagerService#overridePlayingAppAnimationsLw}
794 */
795 void overridePlayingAppAnimations(Animation a) {
796 if (mAppAnimator.isAnimating()) {
797 final WindowState win = findMainWindow();
798 final int width = win.mContainingFrame.width();
799 final int height = win.mContainingFrame.height();
800 mAppAnimator.setAnimation(a, width, height, false, STACK_CLIP_NONE);
801 }
802 }
803
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700804 void resetJustMovedInStack() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700805 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700806 (mChildren.get(i)).resetJustMovedInStack();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700807 }
808 }
809
810 void notifyMovedInStack() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700811 for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700812 final WindowState win = mChildren.get(winNdx);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700813 win.notifyMovedInStack();
814 }
815 }
816
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700817 void setAppLayoutChanges(int changes, String reason, int displayId) {
818 final WindowAnimator windowAnimator = mAppAnimator.mAnimator;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700819 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700820 // Child windows will be on the same display as their parents.
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700821 if (displayId == (mChildren.get(i)).getDisplayId()) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700822 windowAnimator.setPendingLayoutChanges(displayId, changes);
823 if (DEBUG_LAYOUT_REPEATS) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700824 mService.mWindowPlacerLocked.debugLayoutRepeats(
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700825 reason, windowAnimator.getPendingLayoutChanges(displayId));
826 }
827 break;
828 }
829 }
830 }
831
832 void removeReplacedWindowIfNeeded(WindowState replacement) {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700833 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700834 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700835 if (win.removeReplacedWindowIfNeeded(replacement)) {
836 return;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700837 }
838 }
839 }
840
841 void startFreezingScreen() {
842 if (DEBUG_ORIENTATION) logWithStack(TAG, "Set freezing of " + appToken + ": hidden="
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700843 + hidden + " freezing=" + mAppAnimator.freezingScreen + " hiddenRequested="
844 + hiddenRequested);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700845 if (!hiddenRequested) {
846 if (!mAppAnimator.freezingScreen) {
847 mAppAnimator.freezingScreen = true;
Wale Ogunwale3f4433d2016-08-18 20:42:42 -0700848 mService.registerAppFreezeListener(this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700849 mAppAnimator.lastFreezeDuration = 0;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700850 mService.mAppsFreezingScreen++;
851 if (mService.mAppsFreezingScreen == 1) {
852 mService.startFreezingDisplayLocked(false, 0, 0);
853 mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
854 mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700855 }
856 }
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700857 final int count = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700858 for (int i = 0; i < count; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700859 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700860 w.onStartFreezingScreen();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700861 }
862 }
863 }
864
865 void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) {
866 if (!mAppAnimator.freezingScreen) {
867 return;
868 }
869 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Clear freezing of " + this + " force=" + force);
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700870 final int count = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700871 boolean unfrozeWindows = false;
872 for (int i = 0; i < count; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700873 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700874 unfrozeWindows |= w.onStopFreezingScreen();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700875 }
876 if (force || unfrozeWindows) {
877 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this);
878 mAppAnimator.freezingScreen = false;
Wale Ogunwale3f4433d2016-08-18 20:42:42 -0700879 mService.unregisterAppFreezeListener(this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700880 mAppAnimator.lastFreezeDuration =
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700881 (int)(SystemClock.elapsedRealtime() - mService.mDisplayFreezeTime);
882 mService.mAppsFreezingScreen--;
883 mService.mLastFinishedFreezeSource = this;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700884 }
885 if (unfreezeSurfaceNow) {
886 if (unfrozeWindows) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700887 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700888 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700889 mService.stopFreezingDisplayLocked();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700890 }
891 }
892
Wale Ogunwale3f4433d2016-08-18 20:42:42 -0700893 @Override
894 public void onAppFreezeTimeout() {
895 Slog.w(TAG_WM, "Force clearing freeze: " + this);
896 stopFreezingScreen(true, true);
897 }
898
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700899 boolean transferStartingWindow(IBinder transferFrom) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700900 final AppWindowToken fromToken = mService.findAppWindowToken(transferFrom);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700901 if (fromToken == null) {
902 return false;
903 }
904
905 final WindowState tStartingWindow = fromToken.startingWindow;
906 if (tStartingWindow != null && fromToken.startingView != null) {
907 // In this case, the starting icon has already been displayed, so start
908 // letting windows get shown immediately without any more transitions.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700909 mService.mSkipAppTransitionAnimation = true;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700910
911 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Moving existing starting " + tStartingWindow
912 + " from " + fromToken + " to " + this);
913
914 final long origId = Binder.clearCallingIdentity();
915
916 // Transfer the starting window over to the new token.
917 startingData = fromToken.startingData;
918 startingView = fromToken.startingView;
919 startingDisplayed = fromToken.startingDisplayed;
920 fromToken.startingDisplayed = false;
921 startingWindow = tStartingWindow;
922 reportedVisible = fromToken.reportedVisible;
923 fromToken.startingData = null;
924 fromToken.startingView = null;
925 fromToken.startingWindow = null;
926 fromToken.startingMoved = true;
927 tStartingWindow.mToken = this;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700928 tStartingWindow.mAppToken = this;
929
930 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
931 "Removing starting window: " + tStartingWindow);
932 tStartingWindow.getWindowList().remove(tStartingWindow);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700933 mService.mWindowsChanged = true;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700934 if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
935 "Removing starting " + tStartingWindow + " from " + fromToken);
936 fromToken.removeWindow(tStartingWindow);
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700937 addWindow(tStartingWindow);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700938
939 // Propagate other interesting state between the tokens. If the old token is displayed,
940 // we should immediately force the new one to be displayed. If it is animating, we need
941 // to move that animation to the new one.
942 if (fromToken.allDrawn) {
943 allDrawn = true;
944 deferClearAllDrawn = fromToken.deferClearAllDrawn;
945 }
946 if (fromToken.firstWindowDrawn) {
947 firstWindowDrawn = true;
948 }
949 if (!fromToken.hidden) {
950 hidden = false;
951 hiddenRequested = false;
952 }
953 if (clientHidden != fromToken.clientHidden) {
954 clientHidden = fromToken.clientHidden;
955 sendAppVisibilityToClients();
956 }
957 fromToken.mAppAnimator.transferCurrentAnimation(
958 mAppAnimator, tStartingWindow.mWinAnimator);
959
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700960 mService.updateFocusedWindowLocked(
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700961 UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700962 mService.getDefaultDisplayContentLocked().layoutNeeded = true;
963 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700964 Binder.restoreCallingIdentity(origId);
965 return true;
966 } else if (fromToken.startingData != null) {
967 // The previous app was getting ready to show a
968 // starting window, but hasn't yet done so. Steal it!
969 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
970 "Moving pending starting from " + fromToken + " to " + this);
971 startingData = fromToken.startingData;
972 fromToken.startingData = null;
973 fromToken.startingMoved = true;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700974 final Message m = mService.mH.obtainMessage(H.ADD_STARTING, this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700975 // Note: we really want to do sendMessageAtFrontOfQueue() because we want to process the
976 // message ASAP, before any other queued messages.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700977 mService.mH.sendMessageAtFrontOfQueue(m);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700978 return true;
979 }
980
981 final AppWindowAnimator tAppAnimator = fromToken.mAppAnimator;
982 final AppWindowAnimator wAppAnimator = mAppAnimator;
983 if (tAppAnimator.thumbnail != null) {
984 // The old token is animating with a thumbnail, transfer that to the new token.
985 if (wAppAnimator.thumbnail != null) {
986 wAppAnimator.thumbnail.destroy();
987 }
988 wAppAnimator.thumbnail = tAppAnimator.thumbnail;
989 wAppAnimator.thumbnailLayer = tAppAnimator.thumbnailLayer;
990 wAppAnimator.thumbnailAnimation = tAppAnimator.thumbnailAnimation;
991 tAppAnimator.thumbnail = null;
992 }
993 return false;
994 }
995
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700996 boolean isLastWindow(WindowState win) {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700997 return mChildren.size() == 1 && mChildren.get(0) == win;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700998 }
999
1000 void setAllAppWinAnimators() {
1001 final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators;
1002 allAppWinAnimators.clear();
1003
Wale Ogunwaled1c37912016-08-16 03:19:39 -07001004 final int windowsCount = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001005 for (int j = 0; j < windowsCount; j++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -07001006 (mChildren.get(j)).addWinAnimatorToList(allAppWinAnimators);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001007 }
1008 }
1009
Wale Ogunwale9adfe572016-09-08 20:43:58 -07001010 @Override
1011 void onAppTransitionDone() {
1012 sendingToBottom = false;
1013 }
1014
Wale Ogunwale51362492016-09-08 17:49:17 -07001015 /**
1016 * We override because this class doesn't want its children affecting its reported orientation
1017 * in anyway.
1018 */
1019 @Override
1020 int getOrientation() {
1021 if (hidden || hiddenRequested) {
1022 return SCREEN_ORIENTATION_UNSET;
1023 }
1024 return mOrientation;
1025 }
1026
Craig Mautnerdbb79912012-03-01 18:59:14 -08001027 @Override
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001028 void checkAppWindowsReadyToShow(int displayId) {
1029 if (allDrawn == mAppAnimator.allDrawn) {
1030 return;
1031 }
1032
1033 mAppAnimator.allDrawn = allDrawn;
1034 if (!allDrawn) {
1035 return;
1036 }
1037
1038 // The token has now changed state to having all windows shown... what to do, what to do?
1039 if (mAppAnimator.freezingScreen) {
1040 mAppAnimator.showAllWindowsLocked();
1041 stopFreezingScreen(false, true);
1042 if (DEBUG_ORIENTATION) Slog.i(TAG,
1043 "Setting mOrientationChangeComplete=true because wtoken " + this
1044 + " numInteresting=" + numInterestingWindows + " numDrawn=" + numDrawnWindows);
1045 // This will set mOrientationChangeComplete and cause a pass through layout.
1046 setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER,
1047 "checkAppWindowsReadyToShow: freezingScreen", displayId);
1048 } else {
1049 setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow", displayId);
1050
1051 // We can now show all of the drawn windows!
1052 if (!mService.mOpeningApps.contains(this)) {
1053 mService.mAnimator.orAnimating(mAppAnimator.showAllWindowsLocked());
1054 }
1055 }
1056 }
1057
1058 @Override
1059 void updateAllDrawn(int displayId) {
1060 final DisplayContent displayContent = mService.getDisplayContentLocked(displayId);
1061
1062 if (!allDrawn) {
1063 final int numInteresting = numInterestingWindows;
1064 if (numInteresting > 0 && numDrawnWindows >= numInteresting) {
1065 if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawn: " + this
1066 + " interesting=" + numInteresting + " drawn=" + numDrawnWindows);
1067 allDrawn = true;
1068 // Force an additional layout pass where
1069 // WindowStateAnimator#commitFinishDrawingLocked() will call performShowLocked().
1070 displayContent.layoutNeeded = true;
1071 mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
1072 }
1073 }
1074 if (!allDrawnExcludingSaved) {
1075 int numInteresting = numInterestingWindowsExcludingSaved;
1076 if (numInteresting > 0 && numDrawnWindowsExcludingSaved >= numInteresting) {
1077 if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawnExcludingSaved: " + this
1078 + " interesting=" + numInteresting
1079 + " drawn=" + numDrawnWindowsExcludingSaved);
1080 allDrawnExcludingSaved = true;
1081 displayContent.layoutNeeded = true;
1082 if (isAnimatingInvisibleWithSavedSurface()
1083 && !mService.mFinishedEarlyAnim.contains(this)) {
1084 mService.mFinishedEarlyAnim.add(this);
1085 }
1086 }
1087 }
1088 }
1089
1090 @Override
1091 void stepAppWindowsAnimation(long currentTime, int displayId) {
1092 mAppAnimator.wasAnimating = mAppAnimator.animating;
1093 if (mAppAnimator.stepAnimationLocked(currentTime, displayId)) {
1094 mAppAnimator.animating = true;
1095 mService.mAnimator.setAnimating(true);
1096 mService.mAnimator.mAppWindowAnimating = true;
1097 } else if (mAppAnimator.wasAnimating) {
1098 // stopped animating, do one more pass through the layout
1099 setAppLayoutChanges(
1100 FINISH_LAYOUT_REDO_WALLPAPER, "appToken " + this + " done", displayId);
1101 if (DEBUG_ANIM) Slog.v(TAG, "updateWindowsApps...: done animating " + this);
1102 }
1103 }
1104
1105 @Override
Wale Ogunwale9adfe572016-09-08 20:43:58 -07001106 int rebuildWindowList(DisplayContent dc, int addIndex) {
1107 if (mIsExiting && !waitingForReplacement()) {
1108 return addIndex;
1109 }
1110 return super.rebuildWindowList(dc, addIndex);
1111 }
1112
1113 @Override
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001114 AppWindowToken asAppWindowToken() {
1115 // I am an app window token!
1116 return this;
1117 }
1118
1119 @Override
Wale Ogunwale51362492016-09-08 17:49:17 -07001120 boolean fillsParent() {
1121 return mFillsParent;
1122 }
1123
1124 void setFillsParent(boolean fillsParent) {
1125 mFillsParent = fillsParent;
1126 }
1127
1128 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001129 void dump(PrintWriter pw, String prefix) {
1130 super.dump(pw, prefix);
1131 if (appToken != null) {
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001132 pw.print(prefix); pw.print("app=true voiceInteraction="); pw.println(voiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001133 }
Craig Mautner83162a92015-01-26 14:43:30 -08001134 pw.print(prefix); pw.print("task="); pw.println(mTask);
Wale Ogunwale51362492016-09-08 17:49:17 -07001135 pw.print(prefix); pw.print(" mFillsParent="); pw.print(mFillsParent);
1136 pw.print(" mOrientation="); pw.println(mOrientation);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001137 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
1138 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -07001139 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001140 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -07001141 if (paused) {
1142 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001143 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001144 if (mAppStopped) {
1145 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
1146 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001147 if (numInterestingWindows != 0 || numDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -07001148 || allDrawn || mAppAnimator.allDrawn) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001149 pw.print(prefix); pw.print("numInterestingWindows=");
1150 pw.print(numInterestingWindows);
1151 pw.print(" numDrawnWindows="); pw.print(numDrawnWindows);
1152 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -07001153 pw.print(" allDrawn="); pw.print(allDrawn);
1154 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
1155 pw.println(")");
1156 }
1157 if (inPendingTransaction) {
1158 pw.print(prefix); pw.print("inPendingTransaction=");
1159 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001160 }
Craig Mautner799bc1d2015-01-14 10:33:48 -08001161 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001162 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
1163 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -08001164 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -08001165 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001166 }
1167 if (startingWindow != null || startingView != null
1168 || startingDisplayed || startingMoved) {
1169 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
1170 pw.print(" startingView="); pw.print(startingView);
1171 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001172 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001173 }
Jorim Jaggi0429f352015-12-22 16:29:16 +01001174 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -08001175 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -07001176 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -08001177 }
1178 if (mPendingRelaunchCount != 0) {
1179 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +01001180 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001181 }
1182
1183 @Override
1184 public String toString() {
1185 if (stringName == null) {
1186 StringBuilder sb = new StringBuilder();
1187 sb.append("AppWindowToken{");
1188 sb.append(Integer.toHexString(System.identityHashCode(this)));
1189 sb.append(" token="); sb.append(token); sb.append('}');
1190 stringName = sb.toString();
1191 }
1192 return stringName;
1193 }
Jeff Browne9bdb312012-04-05 15:30:10 -07001194}