blob: 379e3cea405ee9bc412244035145300cc7376834 [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 Ogunwale72919d22016-12-08 18:58:50 -080020import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
21import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
Wale Ogunwale51362492016-09-08 17:49:17 -070022import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070023import static android.view.Display.DEFAULT_DISPLAY;
Jorim Jaggife762342016-10-13 14:33:27 +020024import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
25import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
Wale Ogunwaled1c37912016-08-16 03:19:39 -070026import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080027import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070028import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
Wale Ogunwale3f4433d2016-08-18 20:42:42 -070029import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
30import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
Wale Ogunwaleac2561e2016-11-01 15:43:46 -070031import static com.android.server.wm.AppTransition.TRANSIT_UNSET;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -080032import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080033import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
34import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
Wale Ogunwaleac2561e2016-11-01 15:43:46 -070035import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070036import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
37import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
Wale Ogunwale9017ec02016-02-25 08:55:25 -080038import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
Wale Ogunwaleac2561e2016-11-01 15:43:46 -070039import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080040import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
41import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEMENT;
42import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
43import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Chong Zhang92147042016-05-09 12:47:11 -070044import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -070045import static com.android.server.wm.WindowManagerService.H.NOTIFY_STARTING_WINDOW_DRAWN;
Wale Ogunwaleac2561e2016-11-01 15:43:46 -070046import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070047import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070048import static com.android.server.wm.WindowManagerService.logWithStack;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080049
Filip Gruszczynskia590c992015-11-25 16:45:26 -080050import android.annotation.NonNull;
Jorim Jaggi26c8c422016-05-09 19:57:25 -070051import android.content.res.Configuration;
Jorim Jaggi0429f352015-12-22 16:29:16 +010052import android.graphics.Rect;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070053import android.os.Binder;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -080054import android.os.Debug;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070055import android.os.IBinder;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -070056import android.os.SystemClock;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080057import android.util.Slog;
58import android.view.IApplicationToken;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080059import android.view.WindowManager;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -080060import android.view.WindowManagerPolicy.StartingSurface;
61
62import com.android.internal.util.ToBooleanFunction;
63import com.android.server.input.InputApplicationHandle;
64import com.android.server.wm.WindowManagerService.H;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080065
66import java.io.PrintWriter;
Jorim Jaggi0429f352015-12-22 16:29:16 +010067import java.util.ArrayDeque;
Craig Mautnerb1fd65c02013-02-05 13:34:57 -080068import java.util.ArrayList;
69
70class AppTokenList extends ArrayList<AppWindowToken> {
71}
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080072
73/**
74 * Version of WindowToken that is specifically for a particular application (or
75 * really activity) that is displaying windows.
76 */
Wale Ogunwale3f4433d2016-08-18 20:42:42 -070077class AppWindowToken extends WindowToken implements WindowManagerService.AppFreezeListener {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080078 private static final String TAG = TAG_WITH_CLASS_NAME ? "AppWindowToken" : TAG_WM;
79
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080080 // Non-null only for application tokens.
81 final IApplicationToken appToken;
82
Filip Gruszczynskia590c992015-11-25 16:45:26 -080083 @NonNull final AppWindowAnimator mAppAnimator;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070084
Wale Ogunwale72919d22016-12-08 18:58:50 -080085 final boolean mVoiceInteraction;
Dianne Hackborne30e02f2014-05-27 18:24:45 -070086
Wale Ogunwalef6192862016-09-10 13:42:30 -070087 // TODO: Use getParent instead?
Craig Mautner83162a92015-01-26 14:43:30 -080088 Task mTask;
Wale Ogunwale51362492016-09-08 17:49:17 -070089 /** @see WindowContainer#fillsParent() */
90 private boolean mFillsParent;
Craig Mautner4c5eb222013-11-18 12:59:05 -080091 boolean layoutConfigChanges;
Wale Ogunwale72919d22016-12-08 18:58:50 -080092 boolean mShowForAllUsers;
93 int mTargetSdk;
Craig Mautnera2c77052012-03-26 12:14:43 -070094
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080095 // The input dispatching timeout for this application token in nanoseconds.
Wale Ogunwale72919d22016-12-08 18:58:50 -080096 long mInputDispatchingTimeoutNanos;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080097
98 // These are used for determining when all windows associated with
99 // an activity have been drawn, so they can be made visible together
100 // at the same time.
Craig Mautner764983d2012-03-22 11:37:36 -0700101 // initialize so that it doesn't match mTransactionSequence which is an int.
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -0700102 private long mLastTransactionSequence = Long.MIN_VALUE;
103 private int mNumInterestingWindows;
104 private int mNumDrawnWindows;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800105 boolean inPendingTransaction;
106 boolean allDrawn;
Craig Mautner7636dfb2012-11-16 15:24:11 -0800107 // Set to true when this app creates a surface while in the middle of an animation. In that
108 // case do not clear allDrawn until the animation completes.
109 boolean deferClearAllDrawn;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800110
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -0700111 /**
112 * These are to track the app's real drawing status if there were no saved surfaces.
113 * @see #updateDrawnWindowStates
114 */
Chong Zhang8e4bda92016-05-04 15:08:18 -0700115 boolean allDrawnExcludingSaved;
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -0700116 private int mNumInterestingWindowsExcludingSaved;
117 private int mNumDrawnWindowsExcludingSaved;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700118
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800119 // Is this window's surface needed? This is almost like hidden, except
120 // it will sometimes be true a little earlier: when the token has
121 // been shown, but is still waiting for its app transition to execute
122 // before making its windows shown.
123 boolean hiddenRequested;
124
125 // Have we told the window clients to hide themselves?
126 boolean clientHidden;
127
128 // Last visibility state we reported to the app token.
129 boolean reportedVisible;
130
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700131 // Last drawn state we reported to the app token.
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -0700132 private boolean reportedDrawn;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700133
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800134 // Set to true when the token has been removed from the window mgr.
135 boolean removed;
136
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800137 // Information about an application starting window if displayed.
138 StartingData startingData;
139 WindowState startingWindow;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800140 StartingSurface startingSurface;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800141 boolean startingDisplayed;
142 boolean startingMoved;
143 boolean firstWindowDrawn;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700144 private final WindowState.UpdateReportedVisibilityResults mReportedVisibilityResults =
145 new WindowState.UpdateReportedVisibilityResults();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800146
147 // Input application handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700148 final InputApplicationHandle mInputApplicationHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800149
Wale Ogunwale571771c2016-08-26 13:18:50 -0700150 // TODO: Have a WindowContainer state for tracking exiting/deferred removal.
Craig Mautner799bc1d2015-01-14 10:33:48 -0800151 boolean mIsExiting;
Craig Mautner9ef471f2014-02-07 13:11:47 -0800152
Craig Mautnerbb742462014-07-07 15:28:55 -0700153 boolean mLaunchTaskBehind;
Craig Mautner8746a472014-07-24 15:12:54 -0700154 boolean mEnteringAnimation;
Craig Mautnerbb742462014-07-07 15:28:55 -0700155
Wale Ogunwale72919d22016-12-08 18:58:50 -0800156 private boolean mAlwaysFocusable;
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800157
Robert Carre12aece2016-02-02 22:43:27 -0800158 boolean mAppStopped;
Robert Carrfd10cd12016-06-29 16:41:50 -0700159 int mRotationAnimationHint;
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -0700160 private int mPendingRelaunchCount;
Robert Carre12aece2016-02-02 22:43:27 -0800161
Jorim Jaggife762342016-10-13 14:33:27 +0200162 private boolean mLastContainsShowWhenLockedWindow;
163 private boolean mLastContainsDismissKeyguardWindow;
164
Robert Carr91b228092016-06-28 17:32:37 -0700165 private ArrayList<WindowSurfaceController.SurfaceControlWithBackground> mSurfaceViewBackgrounds =
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700166 new ArrayList<>();
Robert Carr91b228092016-06-28 17:32:37 -0700167
Jorim Jaggi0429f352015-12-22 16:29:16 +0100168 ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700169 ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100170
Wale Ogunwale72919d22016-12-08 18:58:50 -0800171 AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction,
172 DisplayContent dc, long inputDispatchingTimeoutNanos, boolean fullscreen,
173 boolean showForAllUsers, int targetSdk, int orientation, int rotationAnimationHint,
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800174 int configChanges, boolean launchTaskBehind, boolean alwaysFocusable,
175 AppWindowContainerController controller) {
Wale Ogunwale17f175c2017-02-07 16:54:10 -0800176 this(service, token, voiceInteraction, dc, fullscreen);
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800177 setController(controller);
Wale Ogunwale72919d22016-12-08 18:58:50 -0800178 mInputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos;
Wale Ogunwale72919d22016-12-08 18:58:50 -0800179 mShowForAllUsers = showForAllUsers;
180 mTargetSdk = targetSdk;
181 mOrientation = orientation;
182 layoutConfigChanges = (configChanges & (CONFIG_SCREEN_SIZE | CONFIG_ORIENTATION)) != 0;
183 mLaunchTaskBehind = launchTaskBehind;
184 mAlwaysFocusable = alwaysFocusable;
185 mRotationAnimationHint = rotationAnimationHint;
186
187 // Application tokens start out hidden.
188 hidden = true;
189 hiddenRequested = true;
190 }
191
192 AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction,
Wale Ogunwale17f175c2017-02-07 16:54:10 -0800193 DisplayContent dc, boolean fillsParent) {
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800194 super(service, token != null ? token.asBinder() : null, TYPE_APPLICATION, true, dc,
195 false /* ownerCanManageAppTokens */);
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700196 appToken = token;
Wale Ogunwale72919d22016-12-08 18:58:50 -0800197 mVoiceInteraction = voiceInteraction;
Wale Ogunwale17f175c2017-02-07 16:54:10 -0800198 mFillsParent = fillsParent;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800199 mInputApplicationHandle = new InputApplicationHandle(this);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700200 mAppAnimator = new AppWindowAnimator(this, service);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800201 }
202
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800203 void onFirstWindowDrawn(WindowState win, WindowStateAnimator winAnimator) {
204 firstWindowDrawn = true;
205
206 // We now have a good window to show, remove dead placeholders
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700207 removeDeadWindows();
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800208
Jorim Jaggi02886a82016-12-06 09:10:06 -0800209 if (startingWindow != null) {
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800210 if (DEBUG_STARTING_WINDOW || DEBUG_ANIM) Slog.v(TAG, "Finish starting "
211 + win.mToken + ": first real window is shown, no animation");
212 // If this initial window is animating, stop it -- we will do an animation to reveal
213 // it from behind the starting window, so there is no need for it to also be doing its
214 // own stuff.
215 winAnimator.clearAnimation();
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800216 if (getController() != null) {
217 getController().removeStartingWindow();
218 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -0800219 }
220 updateReportedVisibilityLocked();
221 }
222
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800223 void updateReportedVisibilityLocked() {
224 if (appToken == null) {
225 return;
226 }
227
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700228 if (DEBUG_VISIBILITY) Slog.v(TAG, "Update reported visibility: " + this);
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700229 final int count = mChildren.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800230
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700231 mReportedVisibilityResults.reset();
232
233 for (int i = 0; i < count; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700234 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700235 win.updateReportedVisibility(mReportedVisibilityResults);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800236 }
237
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700238 int numInteresting = mReportedVisibilityResults.numInteresting;
239 int numVisible = mReportedVisibilityResults.numVisible;
240 int numDrawn = mReportedVisibilityResults.numDrawn;
241 boolean nowGone = mReportedVisibilityResults.nowGone;
242
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700243 boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800244 boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting;
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700245 if (!nowGone) {
246 // If the app is not yet gone, then it can only become visible/drawn.
247 if (!nowDrawn) {
248 nowDrawn = reportedDrawn;
249 }
250 if (!nowVisible) {
251 nowVisible = reportedVisible;
252 }
253 }
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800254 if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800255 + numInteresting + " visible=" + numVisible);
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800256 final AppWindowContainerController controller = getController();
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700257 if (nowDrawn != reportedDrawn) {
258 if (nowDrawn) {
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800259 if (controller != null) {
260 controller.reportWindowsDrawn();
261 }
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -0700262 }
263 reportedDrawn = nowDrawn;
264 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800265 if (nowVisible != reportedVisible) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700266 if (DEBUG_VISIBILITY) Slog.v(TAG,
267 "Visibility changed in " + this + ": vis=" + nowVisible);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800268 reportedVisible = nowVisible;
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800269 if (controller != null) {
270 if (nowVisible) {
271 controller.reportWindowsVisible();
272 } else {
273 controller.reportWindowsGone();
274 }
275 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800276 }
277 }
278
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700279 boolean setVisibility(WindowManager.LayoutParams lp,
280 boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) {
281
282 boolean delayed = false;
283 inPendingTransaction = false;
284
285 if (clientHidden == visible) {
286 clientHidden = !visible;
287 sendAppVisibilityToClients();
288 }
289
290 // Allow for state changes and animation to be applied if:
291 // * token is transitioning visibility state
292 // * or the token was marked as hidden and is exiting before we had a chance to play the
293 // transition animation
294 // * or this is an opening app and windows are being replaced.
295 boolean visibilityChanged = false;
296 if (hidden == visible || (hidden && mIsExiting) || (visible && waitingForReplacement())) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700297 final AccessibilityController accessibilityController = mService.mAccessibilityController;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700298 boolean changed = false;
299 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
300 "Changing app " + this + " hidden=" + hidden + " performLayout=" + performLayout);
301
302 boolean runningAppAnimation = false;
303
304 if (transit != AppTransition.TRANSIT_UNSET) {
305 if (mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) {
306 mAppAnimator.setNullAnimation();
307 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700308 if (mService.applyAnimationLocked(this, lp, transit, visible, isVoiceInteraction)) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700309 delayed = runningAppAnimation = true;
310 }
311 final WindowState window = findMainWindow();
312 //TODO (multidisplay): Magnification is supported only for the default display.
313 if (window != null && accessibilityController != null
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700314 && getDisplayContent().getDisplayId() == DEFAULT_DISPLAY) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700315 accessibilityController.onAppWindowTransitionLocked(window, transit);
316 }
317 changed = true;
318 }
319
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700320 final int windowsCount = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700321 for (int i = 0; i < windowsCount; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700322 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700323 changed |= win.onAppVisibilityChanged(visible, runningAppAnimation);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700324 }
325
326 hidden = hiddenRequested = !visible;
327 visibilityChanged = true;
328 if (!visible) {
329 stopFreezingScreen(true, true);
330 } else {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700331 // If we are being set visible, and the starting window is not yet displayed,
332 // then make sure it doesn't get displayed.
333 if (startingWindow != null && !startingWindow.isDrawnLw()) {
334 startingWindow.mPolicyVisibility = false;
335 startingWindow.mPolicyVisibilityAfterAnim = false;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700336 }
337 }
338
339 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this
340 + ": hidden=" + hidden + " hiddenRequested=" + hiddenRequested);
341
342 if (changed) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700343 mService.mInputMonitor.setUpdateInputWindowsNeededLw();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700344 if (performLayout) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700345 mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700346 false /*updateInputWindows*/);
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700347 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700348 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700349 mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700350 }
351 }
352
353 if (mAppAnimator.animation != null) {
354 delayed = true;
355 }
356
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700357 for (int i = mChildren.size() - 1; i >= 0 && !delayed; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700358 if ((mChildren.get(i)).isWindowAnimationSet()) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700359 delayed = true;
360 }
361 }
362
363 if (visibilityChanged) {
364 if (visible && !delayed) {
365 // The token was made immediately visible, there will be no entrance animation.
366 // We need to inform the client the enter animation was finished.
367 mEnteringAnimation = true;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700368 mService.mActivityManagerAppTransitionNotifier.onAppTransitionFinishedLocked(token);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700369 }
370
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700371 if (!mService.mClosingApps.contains(this) && !mService.mOpeningApps.contains(this)) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700372 // The token is not closing nor opening, so even if there is an animation set, that
373 // doesn't mean that it goes through the normal app transition cycle so we have
374 // to inform the docked controller about visibility change.
Andrii Kulian1e32e022016-09-16 15:29:34 -0700375 // TODO(multi-display): notify docked divider on all displays where visibility was
376 // affected.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700377 mService.getDefaultDisplayContentLocked().getDockedDividerController()
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700378 .notifyAppVisibilityChanged();
Jorim Jaggi8b702ed2017-01-20 16:59:03 +0100379 mService.mTaskSnapshotController.notifyAppVisibilityChanged(this, visible);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700380 }
381 }
382
383 return delayed;
384 }
385
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800386 WindowState findMainWindow() {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700387 WindowState candidate = null;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700388 int j = mChildren.size();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800389 while (j > 0) {
390 j--;
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700391 final WindowState win = mChildren.get(j);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700392 final int type = win.mAttrs.type;
393 // No need to loop through child window as base application and starting types can't be
394 // child windows.
395 if (type == TYPE_BASE_APPLICATION || type == TYPE_APPLICATION_STARTING) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700396 // In cases where there are multiple windows, we prefer the non-exiting window. This
Sungsoo Lim0d3d1f82015-12-02 14:47:59 +0900397 // happens for example when replacing windows during an activity relaunch. When
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700398 // constructing the animation, we want the new window, not the exiting one.
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800399 if (win.mAnimatingExit) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700400 candidate = win;
401 } else {
402 return win;
403 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800404 }
405 }
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700406 return candidate;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800407 }
408
Wale Ogunwale6cae7652015-12-26 07:36:26 -0800409 boolean windowsAreFocusable() {
410 return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
Wale Ogunwaled045c822015-12-02 09:14:28 -0800411 }
412
Wale Ogunwale26c0dfe2016-12-14 14:42:30 -0800413 AppWindowContainerController getController() {
414 final WindowContainerController controller = super.getController();
415 return controller != null ? (AppWindowContainerController) controller : null;
416 }
417
Wale Ogunwale571771c2016-08-26 13:18:50 -0700418 @Override
Wale Ogunwale44f21802016-09-02 12:49:48 -0700419 boolean isVisible() {
Wale Ogunwalee471be62016-10-03 07:53:55 -0700420 // If the app token isn't hidden then it is considered visible and there is no need to check
421 // its children windows to see if they are visible.
422 return !hidden;
Wale Ogunwale44f21802016-09-02 12:49:48 -0700423 }
424
425 @Override
Wale Ogunwale571771c2016-08-26 13:18:50 -0700426 void removeIfPossible() {
Craig Mautnere3119b72015-01-20 15:02:36 -0800427 mIsExiting = false;
Wale Ogunwale3d0bfd92016-12-05 11:38:02 -0800428 removeAllWindowsIfPossible();
Wale Ogunwale571771c2016-08-26 13:18:50 -0700429 if (mTask != null) {
Wale Ogunwalef6192862016-09-10 13:42:30 -0700430 mTask.mStack.mExitingAppTokens.remove(this);
Wale Ogunwale3d0bfd92016-12-05 11:38:02 -0800431 removeImmediately();
Craig Mautnere3119b72015-01-20 15:02:36 -0800432 }
433 }
434
Wale Ogunwale3f4433d2016-08-18 20:42:42 -0700435 @Override
436 boolean checkCompleteDeferredRemoval() {
437 if (mIsExiting) {
438 removeIfPossible();
439 }
440 return super.checkCompleteDeferredRemoval();
441 }
442
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700443 void onRemovedFromDisplay() {
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700444 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "Removing app token: " + this);
445
Wale Ogunwale72919d22016-12-08 18:58:50 -0800446 boolean delayed = setVisibility(null, false, TRANSIT_UNSET, true, mVoiceInteraction);
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700447
448 mService.mOpeningApps.remove(this);
Jorim Jaggi1b4b23e2016-11-15 16:30:12 -0800449 mService.mUnknownAppVisibilityController.appRemoved(this);
Jorim Jaggi10abe2f2017-01-03 16:44:46 +0100450 mService.mTaskSnapshotController.onAppRemoved(this);
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700451 waitingToShow = false;
452 if (mService.mClosingApps.contains(this)) {
453 delayed = true;
454 } else if (mService.mAppTransition.isTransitionSet()) {
455 mService.mClosingApps.add(this);
456 delayed = true;
457 }
458
459 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "Removing app " + this + " delayed=" + delayed
460 + " animation=" + mAppAnimator.animation + " animating=" + mAppAnimator.animating);
461
462 if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG_WM, "removeAppToken: "
463 + this + " delayed=" + delayed + " Callers=" + Debug.getCallers(4));
464
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800465 if (startingData != null && getController() != null) {
466 getController().removeStartingWindow();
467 }
468
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700469 final TaskStack stack = mTask.mStack;
470 if (delayed && !isEmpty()) {
471 // set the token aside because it has an active animation to be finished
472 if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG_WM,
473 "removeAppToken make exiting: " + this);
474 stack.mExitingAppTokens.add(this);
475 mIsExiting = true;
476 } else {
477 // Make sure there is no animation running on this token, so any windows associated
478 // with it will be removed as soon as their animations are complete
479 mAppAnimator.clearAnimation();
480 mAppAnimator.animating = false;
481 removeIfPossible();
482 }
483
484 removed = true;
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700485 stopFreezingScreen(true, true);
486 if (mService.mFocusedApp == this) {
487 if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "Removing focused app token:" + this);
488 mService.mFocusedApp = null;
489 mService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /*updateInputWindows*/);
490 mService.mInputMonitor.setFocusedAppLw(null);
491 }
492
493 if (!delayed) {
494 updateReportedVisibilityLocked();
495 }
Wale Ogunwaleac2561e2016-11-01 15:43:46 -0700496 }
497
Chong Zhange05bcb12016-07-26 17:47:29 -0700498 void clearAnimatingFlags() {
Chong Zhangb0d26702016-08-12 16:03:29 -0700499 boolean wallpaperMightChange = false;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700500 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700501 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700502 wallpaperMightChange |= win.clearAnimatingFlags();
Chong Zhange05bcb12016-07-26 17:47:29 -0700503 }
Chong Zhangb0d26702016-08-12 16:03:29 -0700504 if (wallpaperMightChange) {
505 requestUpdateWallpaperIfNeeded();
506 }
Chong Zhange05bcb12016-07-26 17:47:29 -0700507 }
508
Robert Carre12aece2016-02-02 22:43:27 -0800509 void destroySurfaces() {
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700510 destroySurfaces(false /*cleanupOnResume*/);
511 }
512
513 /**
514 * Destroy surfaces which have been marked as eligible by the animator, taking care to ensure
515 * the client has finished with them.
516 *
517 * @param cleanupOnResume whether this is done when app is resumed without fully stopped. If
518 * set to true, destroy only surfaces of removed windows, and clear relevant flags of the
519 * others so that they are ready to be reused. If set to false (common case), destroy all
520 * surfaces that's eligible, if the app is already stopped.
521 */
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700522 private void destroySurfaces(boolean cleanupOnResume) {
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700523 boolean destroyedSomething = false;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700524 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700525 final WindowState win = mChildren.get(i);
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700526 destroyedSomething |= win.destroySurface(cleanupOnResume, mAppStopped);
Robert Carre12aece2016-02-02 22:43:27 -0800527 }
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700528 if (destroyedSomething) {
529 final DisplayContent dc = getDisplayContent();
Wale Ogunwalec69694a2016-10-18 13:51:15 -0700530 dc.assignWindowLayers(true /*setLayoutNeeded*/);
Robert Carre12aece2016-02-02 22:43:27 -0800531 }
532 }
533
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800534 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700535 * Notify that the app is now resumed, and it was not stopped before, perform a clean
536 * up of the surfaces
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800537 */
Chong Zhangad24f962016-08-25 12:12:33 -0700538 void notifyAppResumed(boolean wasStopped, boolean allowSavedSurface) {
539 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppResumed: wasStopped=" + wasStopped
540 + " allowSavedSurface=" + allowSavedSurface + " " + this);
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700541 mAppStopped = false;
542 if (!wasStopped) {
543 destroySurfaces(true /*cleanupOnResume*/);
Wale Ogunwale8d5a5422016-03-03 18:28:21 -0800544 }
Chong Zhangad24f962016-08-25 12:12:33 -0700545 if (!allowSavedSurface) {
546 destroySavedSurfaces();
547 }
Robert Carre12aece2016-02-02 22:43:27 -0800548 }
549
Chong Zhangbef461f2015-10-27 11:38:24 -0700550 /**
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700551 * Notify that the app has stopped, and it is okay to destroy any surfaces which were
552 * keeping alive in case they were still being used.
553 */
554 void notifyAppStopped() {
555 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "notifyAppStopped: " + this);
556 mAppStopped = true;
557 destroySurfaces();
558 // Remove any starting window that was added for this app if they are still around.
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800559 if (getController() != null) {
560 getController().removeStartingWindow();
561 }
Chong Zhang45e6d2d2016-07-20 18:33:56 -0700562 }
563
564 /**
Chong Zhangbef461f2015-10-27 11:38:24 -0700565 * Checks whether we should save surfaces for this app.
566 *
567 * @return true if the surfaces should be saved, false otherwise.
568 */
569 boolean shouldSaveSurface() {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800570 // We want to save surface if the app's windows are "allDrawn".
571 // (If we started entering animation early with saved surfaces, allDrawn
572 // should have been restored to true. So we'll save again in that case
573 // even if app didn't actually finish drawing.)
574 return allDrawn;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800575 }
576
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700577 private boolean canRestoreSurfaces() {
578 for (int i = mChildren.size() -1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700579 final WindowState w = mChildren.get(i);
Chong Zhang92147042016-05-09 12:47:11 -0700580 if (w.canRestoreSurface()) {
Robert Carr13f7be9e2015-12-02 18:39:45 -0800581 return true;
582 }
Chong Zhangbef461f2015-10-27 11:38:24 -0700583 }
584 return false;
585 }
586
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700587 private void clearWasVisibleBeforeClientHidden() {
588 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700589 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700590 w.clearWasVisibleBeforeClientHidden();
Chong Zhang92147042016-05-09 12:47:11 -0700591 }
592 }
593
Chong Zhang8e4bda92016-05-04 15:08:18 -0700594 /**
595 * Whether the app has some window that is invisible in layout, but
596 * animating with saved surface.
597 */
598 boolean isAnimatingInvisibleWithSavedSurface() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700599 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700600 final WindowState w = mChildren.get(i);
Chong Zhang8e4bda92016-05-04 15:08:18 -0700601 if (w.isAnimatingInvisibleWithSavedSurface()) {
602 return true;
603 }
604 }
605 return false;
606 }
607
608 /**
609 * Hide all window surfaces that's still invisible in layout but animating
610 * with a saved surface, and mark them destroying.
611 */
612 void stopUsingSavedSurfaceLocked() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700613 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700614 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700615 w.stopUsingSavedSurface();
Chong Zhang8e4bda92016-05-04 15:08:18 -0700616 }
617 destroySurfaces();
618 }
619
Chong Zhangf58631a2016-05-24 16:02:10 -0700620 void markSavedSurfaceExiting() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700621 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700622 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700623 w.markSavedSurfaceExiting();
Chong Zhangf58631a2016-05-24 16:02:10 -0700624 }
625 }
626
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700627 void restoreSavedSurfaceForInterestingWindows() {
Chong Zhang92147042016-05-09 12:47:11 -0700628 if (!canRestoreSurfaces()) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700629 clearWasVisibleBeforeClientHidden();
Chong Zhangbef461f2015-10-27 11:38:24 -0700630 return;
631 }
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700632
633 // Check if all interesting windows are drawn and we can mark allDrawn=true.
634 int interestingNotDrawn = -1;
635
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700636 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700637 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700638 interestingNotDrawn = w.restoreSavedSurfaceForInterestingWindow();
Chong Zhangbef461f2015-10-27 11:38:24 -0700639 }
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800640
Chong Zhang92147042016-05-09 12:47:11 -0700641 if (!allDrawn) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700642 allDrawn = (interestingNotDrawn == 0);
Chong Zhang92147042016-05-09 12:47:11 -0700643 if (allDrawn) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700644 mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
Chong Zhang92147042016-05-09 12:47:11 -0700645 }
646 }
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700647 clearWasVisibleBeforeClientHidden();
Chong Zhangbfc2f8f2016-01-29 15:50:34 -0800648
649 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700650 "restoreSavedSurfaceForInterestingWindows: " + this + " allDrawn=" + allDrawn
651 + " interestingNotDrawn=" + interestingNotDrawn);
Chong Zhangbef461f2015-10-27 11:38:24 -0700652 }
653
654 void destroySavedSurfaces() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700655 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700656 final WindowState win = mChildren.get(i);
Robert Carr13f7be9e2015-12-02 18:39:45 -0800657 win.destroySavedSurface();
Chong Zhangbef461f2015-10-27 11:38:24 -0700658 }
Chong Zhang92147042016-05-09 12:47:11 -0700659 }
660
661 void clearAllDrawn() {
662 allDrawn = false;
663 deferClearAllDrawn = false;
Chong Zhang8e4bda92016-05-04 15:08:18 -0700664 allDrawnExcludingSaved = false;
Chong Zhangbef461f2015-10-27 11:38:24 -0700665 }
666
Wale Ogunwalefa854eb2016-09-20 13:43:52 -0700667 void postWindowRemoveStartingWindowCleanup(WindowState win) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700668 // TODO: Something smells about the code below...Is there a better way?
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700669 if (startingWindow == win) {
670 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Notify removed startingWindow " + win);
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800671 if (getController() != null) {
672 getController().removeStartingWindow();
673 }
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700674 } else if (mChildren.size() == 0 && startingData != null) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700675 // If this is the last window and we had requested a starting transition window,
676 // well there is no point now.
Jorim Jaggi02886a82016-12-06 09:10:06 -0800677 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Nulling last startingData");
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700678 startingData = null;
Jorim Jaggi829b9cd2017-01-23 16:20:53 +0100679 } else if (mChildren.size() == 1 && startingSurface != null && !isRelaunching()) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700680 // If this is the last window except for a starting transition window,
681 // we need to get rid of the starting transition.
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800682 if (getController() != null) {
683 getController().removeStartingWindow();
684 }
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700685 }
686 }
687
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700688 void removeDeadWindows() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700689 for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700690 WindowState win = mChildren.get(winNdx);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800691 if (win.mAppDied) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700692 if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.w(TAG,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700693 "removeDeadWindows: " + win);
Chong Zhang112eb8c2015-11-02 11:17:00 -0800694 // Set mDestroying, we don't want any animation or delayed removal here.
695 win.mDestroying = true;
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700696 // Also removes child windows.
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700697 win.removeIfPossible();
Chong Zhang112eb8c2015-11-02 11:17:00 -0800698 }
699 }
700 }
701
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700702 boolean hasWindowsAlive() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700703 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700704 // No need to loop through child windows as the answer should be the same as that of the
705 // parent window.
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700706 if (!(mChildren.get(i)).mAppDied) {
Wale Ogunwalee42d0e12016-05-02 16:40:59 -0700707 return true;
708 }
709 }
710 return false;
711 }
712
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700713 void setWillReplaceWindows(boolean animate) {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700714 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
715 "Marking app token " + this + " with replacing windows.");
Robert Carra1eb4392015-12-10 12:43:51 -0800716
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700717 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700718 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700719 w.setWillReplaceWindow(animate);
Robert Carra1eb4392015-12-10 12:43:51 -0800720 }
721 if (animate) {
722 // Set-up dummy animation so we can start treating windows associated with this
723 // token like they are in transition before the new app window is ready for us to
724 // run the real transition animation.
725 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM,
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700726 "setWillReplaceWindow() Setting dummy animation on: " + this);
Robert Carra1eb4392015-12-10 12:43:51 -0800727 mAppAnimator.setDummyAnimation();
728 }
729 }
730
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700731 void setWillReplaceChildWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700732 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + this
Robert Carr23fa16b2016-01-13 13:19:58 -0800733 + " with replacing child windows.");
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700734 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700735 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700736 w.setWillReplaceChildWindows();
Robert Carr23fa16b2016-01-13 13:19:58 -0800737 }
738 }
739
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700740 void clearWillReplaceWindows() {
Wale Ogunwale455fac52016-07-21 07:24:49 -0700741 if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
742 "Resetting app token " + this + " of replacing window marks.");
Chong Zhangf596cd52016-01-05 13:42:44 -0800743
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700744 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700745 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700746 w.clearWillReplaceWindow();
Chong Zhangf596cd52016-01-05 13:42:44 -0800747 }
748 }
749
Chong Zhang4d7369a2016-04-25 16:09:14 -0700750 void requestUpdateWallpaperIfNeeded() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700751 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700752 final WindowState w = mChildren.get(i);
Chong Zhang4d7369a2016-04-25 16:09:14 -0700753 w.requestUpdateWallpaperIfNeeded();
754 }
755 }
756
Chong Zhangd78ddb42016-03-02 17:01:14 -0800757 boolean isRelaunching() {
758 return mPendingRelaunchCount > 0;
759 }
760
761 void startRelaunching() {
762 if (canFreezeBounds()) {
763 freezeBounds();
764 }
Robert Carr693f3432016-12-19 10:12:48 -0800765
766 // In the process of tearing down before relaunching, the app will
767 // try and clean up it's child surfaces. We need to prevent this from
768 // happening, so we sever the children, transfering their ownership
769 // from the client it-self to the parent surface (owned by us).
770 for (int i = mChildren.size() - 1; i >= 0; i--) {
771 final WindowState w = mChildren.get(i);
772 w.mWinAnimator.detachChildren();
773 }
774
Chong Zhangd78ddb42016-03-02 17:01:14 -0800775 mPendingRelaunchCount++;
776 }
777
778 void finishRelaunching() {
779 if (canFreezeBounds()) {
780 unfreezeBounds();
781 }
782 if (mPendingRelaunchCount > 0) {
783 mPendingRelaunchCount--;
784 }
785 }
786
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700787 void clearRelaunching() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700788 if (mPendingRelaunchCount == 0) {
789 return;
790 }
Wale Ogunwale8fd75422016-06-24 14:20:37 -0700791 if (canFreezeBounds()) {
792 unfreezeBounds();
793 }
794 mPendingRelaunchCount = 0;
795 }
796
Wale Ogunwale07bcab72016-10-14 15:30:09 -0700797 /**
798 * Returns true if the new child window we are adding to this token is considered greater than
799 * the existing child window in this token in terms of z-order.
800 */
801 @Override
802 protected boolean isFirstChildWindowGreaterThanSecond(WindowState newWindow,
803 WindowState existingWindow) {
804 final int type1 = newWindow.mAttrs.type;
805 final int type2 = existingWindow.mAttrs.type;
806
807 // Base application windows should be z-ordered BELOW all other windows in the app token.
808 if (type1 == TYPE_BASE_APPLICATION && type2 != TYPE_BASE_APPLICATION) {
809 return false;
810 } else if (type1 != TYPE_BASE_APPLICATION && type2 == TYPE_BASE_APPLICATION) {
811 return true;
812 }
813
814 // Starting windows should be z-ordered ABOVE all other windows in the app token.
815 if (type1 == TYPE_APPLICATION_STARTING && type2 != TYPE_APPLICATION_STARTING) {
816 return true;
817 } else if (type1 != TYPE_APPLICATION_STARTING && type2 == TYPE_APPLICATION_STARTING) {
818 return false;
819 }
820
821 // Otherwise the new window is greater than the existing window.
822 return true;
823 }
824
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700825 @Override
Robert Carra1eb4392015-12-10 12:43:51 -0800826 void addWindow(WindowState w) {
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700827 super.addWindow(w);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700828
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700829 boolean gotReplacementWindow = false;
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700830 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700831 final WindowState candidate = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700832 gotReplacementWindow |= candidate.setReplacementWindowIfNeeded(w);
833 }
Wale Ogunwale92fc3722016-08-05 12:19:08 -0700834
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700835 // if we got a replacement window, reset the timeout to give drawing more time
836 if (gotReplacementWindow) {
837 mService.scheduleWindowReplacementTimeouts(this);
Robert Carra1eb4392015-12-10 12:43:51 -0800838 }
Jorim Jaggife762342016-10-13 14:33:27 +0200839 checkKeyguardFlagsChanged();
840 }
841
842 @Override
843 void removeChild(WindowState child) {
844 super.removeChild(child);
845 checkKeyguardFlagsChanged();
Robert Carra1eb4392015-12-10 12:43:51 -0800846 }
847
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700848 private boolean waitingForReplacement() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700849 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700850 final WindowState candidate = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700851 if (candidate.waitingForReplacement()) {
Robert Carra1eb4392015-12-10 12:43:51 -0800852 return true;
853 }
854 }
855 return false;
856 }
857
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700858 void onWindowReplacementTimeout() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700859 for (int i = mChildren.size() - 1; i >= 0; --i) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700860 (mChildren.get(i)).onWindowReplacementTimeout();
Robert Carra1eb4392015-12-10 12:43:51 -0800861 }
862 }
863
Winson Chung30480042017-01-26 10:55:34 -0800864 void reparent(Task task, int position) {
865 if (task == mTask) {
866 throw new IllegalArgumentException(
867 "window token=" + this + " already child of task=" + mTask);
868 }
869 if (DEBUG_ADD_REMOVE) Slog.i(TAG, "reParentWindowToken: removing window token=" + this
870 + " from task=" + mTask);
871 final DisplayContent prevDisplayContent = getDisplayContent();
872
873 getParent().removeChild(this);
874 task.addChild(this, position);
875
876 // Relayout display(s).
877 final DisplayContent displayContent = task.getDisplayContent();
878 displayContent.setLayoutNeeded();
879 if (prevDisplayContent != displayContent) {
880 onDisplayChanged(displayContent);
881 prevDisplayContent.setLayoutNeeded();
882 }
883 }
884
Chong Zhangd78ddb42016-03-02 17:01:14 -0800885 private boolean canFreezeBounds() {
886 // For freeform windows, we can't freeze the bounds at the moment because this would make
887 // the resizing unresponsive.
888 return mTask != null && !mTask.inFreeformWorkspace();
889 }
890
Jorim Jaggi0429f352015-12-22 16:29:16 +0100891 /**
892 * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
893 * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
894 * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
895 * with a queue.
896 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800897 private void freezeBounds() {
Jorim Jaggi0429f352015-12-22 16:29:16 +0100898 mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700899
900 if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
901 // We didn't call prepareFreezingBounds on the task, so use the current value.
Andrii Kulian441e4492016-09-29 15:25:00 -0700902 mFrozenMergedConfig.offer(new Configuration(mTask.getConfiguration()));
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700903 } else {
904 mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
905 }
Andrii Kulianb10330d2016-09-16 13:51:46 -0700906 // Calling unset() to make it equal to Configuration.EMPTY.
907 mTask.mPreparedFrozenMergedConfig.unset();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100908 }
909
910 /**
911 * Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
912 */
Chong Zhangd78ddb42016-03-02 17:01:14 -0800913 private void unfreezeBounds() {
Wale Ogunwale37dbafc2016-06-27 10:15:20 -0700914 if (!mFrozenBounds.isEmpty()) {
915 mFrozenBounds.remove();
916 }
917 if (!mFrozenMergedConfig.isEmpty()) {
918 mFrozenMergedConfig.remove();
919 }
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700920 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700921 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700922 win.onUnfreezeBounds();
Jorim Jaggi4846ee32016-01-07 17:39:12 +0100923 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700924 mService.mWindowPlacerLocked.performSurfacePlacement();
Jorim Jaggi0429f352015-12-22 16:29:16 +0100925 }
926
Robert Carr91b228092016-06-28 17:32:37 -0700927 void addSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
928 mSurfaceViewBackgrounds.add(background);
929 }
930
931 void removeSurfaceViewBackground(WindowSurfaceController.SurfaceControlWithBackground background) {
932 mSurfaceViewBackgrounds.remove(background);
933 updateSurfaceViewBackgroundVisibilities();
934 }
935
936 // We use DimLayers behind SurfaceViews to prevent holes while resizing and creating.
937 // However, we need to ensure one SurfaceView doesn't cover another when they are both placed
938 // below the main app window (as traditionally a SurfaceView which is never drawn
939 // to is totally translucent). So we look at all our SurfaceView backgrounds and only enable
940 // the background for the SurfaceView with lowest Z order
941 void updateSurfaceViewBackgroundVisibilities() {
942 WindowSurfaceController.SurfaceControlWithBackground bottom = null;
943 int bottomLayer = Integer.MAX_VALUE;
944 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
945 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
946 if (sc.mVisible && sc.mLayer < bottomLayer) {
947 bottomLayer = sc.mLayer;
948 bottom = sc;
949 }
950 }
951 for (int i = 0; i < mSurfaceViewBackgrounds.size(); i++) {
952 WindowSurfaceController.SurfaceControlWithBackground sc = mSurfaceViewBackgrounds.get(i);
953 sc.updateBackgroundVisibility(sc != bottom);
954 }
955 }
956
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700957 void resetJustMovedInStack() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700958 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700959 (mChildren.get(i)).resetJustMovedInStack();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700960 }
961 }
962
963 void notifyMovedInStack() {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700964 for (int winNdx = mChildren.size() - 1; winNdx >= 0; --winNdx) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700965 final WindowState win = mChildren.get(winNdx);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700966 win.notifyMovedInStack();
967 }
968 }
969
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -0700970 void setAppLayoutChanges(int changes, String reason) {
971 if (!mChildren.isEmpty()) {
972 final DisplayContent dc = getDisplayContent();
973 dc.pendingLayoutChanges |= changes;
974 if (DEBUG_LAYOUT_REPEATS) {
975 mService.mWindowPlacerLocked.debugLayoutRepeats(reason, dc.pendingLayoutChanges);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700976 }
977 }
978 }
979
980 void removeReplacedWindowIfNeeded(WindowState replacement) {
Wale Ogunwaled1c37912016-08-16 03:19:39 -0700981 for (int i = mChildren.size() - 1; i >= 0; i--) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -0700982 final WindowState win = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700983 if (win.removeReplacedWindowIfNeeded(replacement)) {
984 return;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700985 }
986 }
987 }
988
989 void startFreezingScreen() {
990 if (DEBUG_ORIENTATION) logWithStack(TAG, "Set freezing of " + appToken + ": hidden="
Wale Ogunwale9bc47732016-08-10 14:44:22 -0700991 + hidden + " freezing=" + mAppAnimator.freezingScreen + " hiddenRequested="
992 + hiddenRequested);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700993 if (!hiddenRequested) {
994 if (!mAppAnimator.freezingScreen) {
995 mAppAnimator.freezingScreen = true;
Wale Ogunwale3f4433d2016-08-18 20:42:42 -0700996 mService.registerAppFreezeListener(this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -0700997 mAppAnimator.lastFreezeDuration = 0;
Wale Ogunwale2049dbf2016-08-02 21:05:23 -0700998 mService.mAppsFreezingScreen++;
999 if (mService.mAppsFreezingScreen == 1) {
1000 mService.startFreezingDisplayLocked(false, 0, 0);
1001 mService.mH.removeMessages(H.APP_FREEZE_TIMEOUT);
1002 mService.mH.sendEmptyMessageDelayed(H.APP_FREEZE_TIMEOUT, 2000);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001003 }
1004 }
Wale Ogunwaled1c37912016-08-16 03:19:39 -07001005 final int count = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001006 for (int i = 0; i < count; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -07001007 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -07001008 w.onStartFreezingScreen();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001009 }
1010 }
1011 }
1012
1013 void stopFreezingScreen(boolean unfreezeSurfaceNow, boolean force) {
1014 if (!mAppAnimator.freezingScreen) {
1015 return;
1016 }
1017 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Clear freezing of " + this + " force=" + force);
Wale Ogunwaled1c37912016-08-16 03:19:39 -07001018 final int count = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001019 boolean unfrozeWindows = false;
1020 for (int i = 0; i < count; i++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -07001021 final WindowState w = mChildren.get(i);
Wale Ogunwale9bc47732016-08-10 14:44:22 -07001022 unfrozeWindows |= w.onStopFreezingScreen();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001023 }
1024 if (force || unfrozeWindows) {
1025 if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "No longer freezing: " + this);
1026 mAppAnimator.freezingScreen = false;
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001027 mService.unregisterAppFreezeListener(this);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001028 mAppAnimator.lastFreezeDuration =
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001029 (int)(SystemClock.elapsedRealtime() - mService.mDisplayFreezeTime);
1030 mService.mAppsFreezingScreen--;
1031 mService.mLastFinishedFreezeSource = this;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001032 }
1033 if (unfreezeSurfaceNow) {
1034 if (unfrozeWindows) {
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001035 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001036 }
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001037 mService.stopFreezingDisplayLocked();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001038 }
1039 }
1040
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001041 @Override
1042 public void onAppFreezeTimeout() {
1043 Slog.w(TAG_WM, "Force clearing freeze: " + this);
1044 stopFreezingScreen(true, true);
1045 }
1046
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001047 boolean transferStartingWindow(IBinder transferFrom) {
Wale Ogunwale02319a62016-09-26 15:21:22 -07001048 final AppWindowToken fromToken = getDisplayContent().getAppWindowToken(transferFrom);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001049 if (fromToken == null) {
1050 return false;
1051 }
1052
1053 final WindowState tStartingWindow = fromToken.startingWindow;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -08001054 if (tStartingWindow != null && fromToken.startingSurface != null) {
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001055 // In this case, the starting icon has already been displayed, so start
1056 // letting windows get shown immediately without any more transitions.
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001057 mService.mSkipAppTransitionAnimation = true;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001058
1059 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Moving existing starting " + tStartingWindow
1060 + " from " + fromToken + " to " + this);
1061
1062 final long origId = Binder.clearCallingIdentity();
1063
1064 // Transfer the starting window over to the new token.
1065 startingData = fromToken.startingData;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -08001066 startingSurface = fromToken.startingSurface;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001067 startingDisplayed = fromToken.startingDisplayed;
1068 fromToken.startingDisplayed = false;
1069 startingWindow = tStartingWindow;
1070 reportedVisible = fromToken.reportedVisible;
1071 fromToken.startingData = null;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -08001072 fromToken.startingSurface = null;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001073 fromToken.startingWindow = null;
1074 fromToken.startingMoved = true;
1075 tStartingWindow.mToken = this;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001076 tStartingWindow.mAppToken = this;
1077
Wale Ogunwale6213caa2016-12-02 16:47:15 +00001078 if (DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001079 "Removing starting " + tStartingWindow + " from " + fromToken);
Wale Ogunwalefa854eb2016-09-20 13:43:52 -07001080 fromToken.removeChild(tStartingWindow);
1081 fromToken.postWindowRemoveStartingWindowCleanup(tStartingWindow);
Wale Ogunwale92fc3722016-08-05 12:19:08 -07001082 addWindow(tStartingWindow);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001083
1084 // Propagate other interesting state between the tokens. If the old token is displayed,
1085 // we should immediately force the new one to be displayed. If it is animating, we need
1086 // to move that animation to the new one.
1087 if (fromToken.allDrawn) {
1088 allDrawn = true;
1089 deferClearAllDrawn = fromToken.deferClearAllDrawn;
1090 }
1091 if (fromToken.firstWindowDrawn) {
1092 firstWindowDrawn = true;
1093 }
1094 if (!fromToken.hidden) {
1095 hidden = false;
1096 hiddenRequested = false;
1097 }
1098 if (clientHidden != fromToken.clientHidden) {
1099 clientHidden = fromToken.clientHidden;
1100 sendAppVisibilityToClients();
1101 }
1102 fromToken.mAppAnimator.transferCurrentAnimation(
1103 mAppAnimator, tStartingWindow.mWinAnimator);
1104
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001105 mService.updateFocusedWindowLocked(
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001106 UPDATE_FOCUS_WILL_PLACE_SURFACES, true /*updateInputWindows*/);
Andrii Kulian5406e7a2016-10-21 11:55:23 -07001107 getDisplayContent().setLayoutNeeded();
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001108 mService.mWindowPlacerLocked.performSurfacePlacement();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001109 Binder.restoreCallingIdentity(origId);
1110 return true;
1111 } else if (fromToken.startingData != null) {
1112 // The previous app was getting ready to show a
1113 // starting window, but hasn't yet done so. Steal it!
1114 if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
1115 "Moving pending starting from " + fromToken + " to " + this);
1116 startingData = fromToken.startingData;
1117 fromToken.startingData = null;
1118 fromToken.startingMoved = true;
Jorim Jaggiba41f4b2016-12-14 17:43:07 -08001119 if (getController() != null) {
1120 getController().scheduleAddStartingWindow();
1121 }
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001122 return true;
1123 }
1124
1125 final AppWindowAnimator tAppAnimator = fromToken.mAppAnimator;
1126 final AppWindowAnimator wAppAnimator = mAppAnimator;
1127 if (tAppAnimator.thumbnail != null) {
1128 // The old token is animating with a thumbnail, transfer that to the new token.
1129 if (wAppAnimator.thumbnail != null) {
1130 wAppAnimator.thumbnail.destroy();
1131 }
1132 wAppAnimator.thumbnail = tAppAnimator.thumbnail;
1133 wAppAnimator.thumbnailLayer = tAppAnimator.thumbnailLayer;
1134 wAppAnimator.thumbnailAnimation = tAppAnimator.thumbnailAnimation;
1135 tAppAnimator.thumbnail = null;
1136 }
1137 return false;
1138 }
1139
Wale Ogunwale9bc47732016-08-10 14:44:22 -07001140 boolean isLastWindow(WindowState win) {
Wale Ogunwaled1c37912016-08-16 03:19:39 -07001141 return mChildren.size() == 1 && mChildren.get(0) == win;
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001142 }
1143
1144 void setAllAppWinAnimators() {
1145 final ArrayList<WindowStateAnimator> allAppWinAnimators = mAppAnimator.mAllAppWinAnimators;
1146 allAppWinAnimators.clear();
1147
Wale Ogunwaled1c37912016-08-16 03:19:39 -07001148 final int windowsCount = mChildren.size();
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001149 for (int j = 0; j < windowsCount; j++) {
Wale Ogunwaled90546a2016-09-09 23:28:03 -07001150 (mChildren.get(j)).addWinAnimatorToList(allAppWinAnimators);
Wale Ogunwale9f25bee2016-08-02 07:23:47 -07001151 }
1152 }
1153
Wale Ogunwale9adfe572016-09-08 20:43:58 -07001154 @Override
1155 void onAppTransitionDone() {
1156 sendingToBottom = false;
1157 }
1158
Wale Ogunwale51362492016-09-08 17:49:17 -07001159 /**
1160 * We override because this class doesn't want its children affecting its reported orientation
1161 * in anyway.
1162 */
1163 @Override
1164 int getOrientation() {
Bryce Leea163b762017-01-24 11:05:01 -08001165 if (fillsParent() && (isVisible() || mService.mOpeningApps.contains(this))) {
1166 return mOrientation;
Wale Ogunwale51362492016-09-08 17:49:17 -07001167 }
Bryce Leea163b762017-01-24 11:05:01 -08001168
1169 return SCREEN_ORIENTATION_UNSET;
Wale Ogunwale51362492016-09-08 17:49:17 -07001170 }
1171
Wale Ogunwaleb198b742016-12-01 08:44:09 -08001172 /** Returns the app's preferred orientation regardless of its currently visibility state. */
1173 int getOrientationIgnoreVisibility() {
1174 return mOrientation;
1175 }
1176
Craig Mautnerdbb79912012-03-01 18:59:14 -08001177 @Override
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -07001178 void checkAppWindowsReadyToShow() {
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001179 if (allDrawn == mAppAnimator.allDrawn) {
1180 return;
1181 }
1182
1183 mAppAnimator.allDrawn = allDrawn;
1184 if (!allDrawn) {
1185 return;
1186 }
1187
1188 // The token has now changed state to having all windows shown... what to do, what to do?
1189 if (mAppAnimator.freezingScreen) {
1190 mAppAnimator.showAllWindowsLocked();
1191 stopFreezingScreen(false, true);
1192 if (DEBUG_ORIENTATION) Slog.i(TAG,
1193 "Setting mOrientationChangeComplete=true because wtoken " + this
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001194 + " numInteresting=" + mNumInterestingWindows + " numDrawn=" + mNumDrawnWindows);
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001195 // This will set mOrientationChangeComplete and cause a pass through layout.
1196 setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER,
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -07001197 "checkAppWindowsReadyToShow: freezingScreen");
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001198 } else {
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -07001199 setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow");
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001200
1201 // We can now show all of the drawn windows!
1202 if (!mService.mOpeningApps.contains(this)) {
1203 mService.mAnimator.orAnimating(mAppAnimator.showAllWindowsLocked());
1204 }
1205 }
1206 }
1207
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001208 void updateAllDrawn(DisplayContent dc) {
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001209 if (!allDrawn) {
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001210 final int numInteresting = mNumInterestingWindows;
1211 if (numInteresting > 0 && mNumDrawnWindows >= numInteresting) {
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001212 if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawn: " + this
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001213 + " interesting=" + numInteresting + " drawn=" + mNumDrawnWindows);
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001214 allDrawn = true;
1215 // Force an additional layout pass where
1216 // WindowStateAnimator#commitFinishDrawingLocked() will call performShowLocked().
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001217 dc.setLayoutNeeded();
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001218 mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
1219 }
1220 }
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001221
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001222 if (!allDrawnExcludingSaved) {
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001223 int numInteresting = mNumInterestingWindowsExcludingSaved;
1224 if (numInteresting > 0 && mNumDrawnWindowsExcludingSaved >= numInteresting) {
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001225 if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawnExcludingSaved: " + this
1226 + " interesting=" + numInteresting
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001227 + " drawn=" + mNumDrawnWindowsExcludingSaved);
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001228 allDrawnExcludingSaved = true;
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001229 dc.setLayoutNeeded();
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001230 if (isAnimatingInvisibleWithSavedSurface()
1231 && !mService.mFinishedEarlyAnim.contains(this)) {
1232 mService.mFinishedEarlyAnim.add(this);
1233 }
1234 }
1235 }
1236 }
1237
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001238 /**
1239 * Updated this app token tracking states for interesting and drawn windows based on the window.
1240 *
1241 * @return Returns true if the input window is considered interesting and drawn while all the
1242 * windows in this app token where not considered drawn as of the last pass.
1243 */
1244 boolean updateDrawnWindowStates(WindowState w) {
1245 if (DEBUG_STARTING_WINDOW && w == startingWindow) {
1246 Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen=" + w.isOnScreen()
1247 + " allDrawn=" + allDrawn + " freezingScreen=" + mAppAnimator.freezingScreen);
1248 }
1249
1250 if (allDrawn && allDrawnExcludingSaved && !mAppAnimator.freezingScreen) {
1251 return false;
1252 }
1253
1254 if (mLastTransactionSequence != mService.mTransactionSequence) {
1255 mLastTransactionSequence = mService.mTransactionSequence;
1256 mNumInterestingWindows = mNumDrawnWindows = 0;
1257 mNumInterestingWindowsExcludingSaved = 0;
1258 mNumDrawnWindowsExcludingSaved = 0;
1259 startingDisplayed = false;
1260 }
1261
1262 final WindowStateAnimator winAnimator = w.mWinAnimator;
1263
1264 boolean isInterestingAndDrawn = false;
1265
1266 if (!allDrawn && w.mightAffectAllDrawn(false /* visibleOnly */)) {
1267 if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
1268 Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw()
1269 + ", isAnimationSet=" + winAnimator.isAnimationSet());
1270 if (!w.isDrawnLw()) {
1271 Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceController
1272 + " pv=" + w.mPolicyVisibility
1273 + " mDrawState=" + winAnimator.drawStateToString()
1274 + " ph=" + w.isParentWindowHidden() + " th=" + hiddenRequested
1275 + " a=" + winAnimator.mAnimating);
1276 }
1277 }
1278
1279 if (w != startingWindow) {
1280 if (w.isInteresting()) {
1281 mNumInterestingWindows++;
1282 if (w.isDrawnLw()) {
1283 mNumDrawnWindows++;
1284
1285 if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Slog.v(TAG, "tokenMayBeDrawn: "
1286 + this + " w=" + w + " numInteresting=" + mNumInterestingWindows
1287 + " freezingScreen=" + mAppAnimator.freezingScreen
1288 + " mAppFreezing=" + w.mAppFreezing);
1289
1290 isInterestingAndDrawn = true;
1291 }
1292 }
1293 } else if (w.isDrawnLw()) {
1294 mService.mH.sendEmptyMessage(NOTIFY_STARTING_WINDOW_DRAWN);
1295 startingDisplayed = true;
1296 }
1297 }
1298
1299 if (!allDrawnExcludingSaved && w.mightAffectAllDrawn(true /* visibleOnly */)) {
1300 if (w != startingWindow && w.isInteresting()) {
1301 mNumInterestingWindowsExcludingSaved++;
1302 if (w.isDrawnLw() && !w.isAnimatingWithSavedSurface()) {
1303 mNumDrawnWindowsExcludingSaved++;
1304
1305 if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Slog.v(TAG,
1306 "tokenMayBeDrawnExcludingSaved: " + this + " w=" + w
1307 + " numInteresting=" + mNumInterestingWindowsExcludingSaved
1308 + " freezingScreen=" + mAppAnimator.freezingScreen
1309 + " mAppFreezing=" + w.mAppFreezing);
1310
1311 isInterestingAndDrawn = true;
1312 }
1313 }
1314 }
1315
1316 return isInterestingAndDrawn;
1317 }
1318
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001319 @Override
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -07001320 void stepAppWindowsAnimation(long currentTime) {
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001321 mAppAnimator.wasAnimating = mAppAnimator.animating;
Wale Ogunwaleb0f3b832016-10-17 10:13:07 -07001322 if (mAppAnimator.stepAnimationLocked(currentTime)) {
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001323 mAppAnimator.animating = true;
1324 mService.mAnimator.setAnimating(true);
1325 mService.mAnimator.mAppWindowAnimating = true;
1326 } else if (mAppAnimator.wasAnimating) {
1327 // stopped animating, do one more pass through the layout
Wale Ogunwale1e129a42016-11-21 13:03:47 -08001328 setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER,
1329 DEBUG_LAYOUT_REPEATS ? "appToken " + this + " done" : null);
Wale Ogunwale3f4433d2016-08-18 20:42:42 -07001330 if (DEBUG_ANIM) Slog.v(TAG, "updateWindowsApps...: done animating " + this);
1331 }
1332 }
1333
Wale Ogunwale9adfe572016-09-08 20:43:58 -07001334 @Override
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -08001335 boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) {
Wale Ogunwaleb783fd82016-11-04 09:51:54 -07001336 // For legacy reasons we process the TaskStack.mExitingAppTokens first in DisplayContent
1337 // before the non-exiting app tokens. So, we skip the exiting app tokens here.
1338 // TODO: Investigate if we need to continue to do this or if we can just process them
1339 // in-order.
1340 if (mIsExiting && !waitingForReplacement()) {
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -08001341 return false;
Wale Ogunwaleb783fd82016-11-04 09:51:54 -07001342 }
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -08001343 return forAllWindowsUnchecked(callback, traverseTopToBottom);
Wale Ogunwaleb783fd82016-11-04 09:51:54 -07001344 }
1345
Wale Ogunwalef4ebe2e2016-11-09 13:24:43 -08001346 boolean forAllWindowsUnchecked(ToBooleanFunction<WindowState> callback,
1347 boolean traverseTopToBottom) {
1348 return super.forAllWindows(callback, traverseTopToBottom);
Wale Ogunwaleb783fd82016-11-04 09:51:54 -07001349 }
1350
1351 @Override
Wale Ogunwale2049dbf2016-08-02 21:05:23 -07001352 AppWindowToken asAppWindowToken() {
1353 // I am an app window token!
1354 return this;
1355 }
1356
1357 @Override
Wale Ogunwale51362492016-09-08 17:49:17 -07001358 boolean fillsParent() {
1359 return mFillsParent;
1360 }
1361
1362 void setFillsParent(boolean fillsParent) {
1363 mFillsParent = fillsParent;
1364 }
1365
Jorim Jaggife762342016-10-13 14:33:27 +02001366 boolean containsDismissKeyguardWindow() {
1367 for (int i = mChildren.size() - 1; i >= 0; i--) {
1368 if ((mChildren.get(i).mAttrs.flags & FLAG_DISMISS_KEYGUARD) != 0) {
1369 return true;
1370 }
1371 }
1372 return false;
1373 }
1374
1375 boolean containsShowWhenLockedWindow() {
1376 for (int i = mChildren.size() - 1; i >= 0; i--) {
1377 if ((mChildren.get(i).mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) {
1378 return true;
1379 }
1380 }
1381 return false;
1382 }
1383
1384 void checkKeyguardFlagsChanged() {
1385 final boolean containsDismissKeyguard = containsDismissKeyguardWindow();
1386 final boolean containsShowWhenLocked = containsShowWhenLockedWindow();
1387 if (containsDismissKeyguard != mLastContainsDismissKeyguardWindow
1388 || containsShowWhenLocked != mLastContainsShowWhenLockedWindow) {
1389 mService.notifyKeyguardFlagsChanged(null /* callback */);
1390 }
1391 mLastContainsDismissKeyguardWindow = containsDismissKeyguard;
1392 mLastContainsShowWhenLockedWindow = containsShowWhenLocked;
1393 }
1394
Wale Ogunwale6213caa2016-12-02 16:47:15 +00001395 WindowState getImeTargetBelowWindow(WindowState w) {
1396 final int index = mChildren.indexOf(w);
1397 if (index > 0) {
1398 final WindowState target = mChildren.get(index - 1);
1399 if (target.canBeImeTarget()) {
1400 return target;
1401 }
1402 }
1403 return null;
1404 }
1405
1406 WindowState getHighestAnimLayerWindow(WindowState currentTarget) {
1407 WindowState candidate = null;
1408 for (int i = mChildren.indexOf(currentTarget); i >= 0; i--) {
1409 final WindowState w = mChildren.get(i);
1410 if (w.mRemoved) {
1411 continue;
1412 }
1413 if (candidate == null || w.mWinAnimator.mAnimLayer >
1414 candidate.mWinAnimator.mAnimLayer) {
1415 candidate = w;
1416 }
1417 }
1418 return candidate;
1419 }
1420
Wale Ogunwale51362492016-09-08 17:49:17 -07001421 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001422 void dump(PrintWriter pw, String prefix) {
1423 super.dump(pw, prefix);
1424 if (appToken != null) {
Wale Ogunwale72919d22016-12-08 18:58:50 -08001425 pw.println(prefix + "app=true mVoiceInteraction=" + mVoiceInteraction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001426 }
Craig Mautner83162a92015-01-26 14:43:30 -08001427 pw.print(prefix); pw.print("task="); pw.println(mTask);
Wale Ogunwale51362492016-09-08 17:49:17 -07001428 pw.print(prefix); pw.print(" mFillsParent="); pw.print(mFillsParent);
1429 pw.print(" mOrientation="); pw.println(mOrientation);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001430 pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
1431 pw.print(" clientHidden="); pw.print(clientHidden);
Dianne Hackborn2c84cfc2011-10-31 15:39:59 -07001432 pw.print(" reportedDrawn="); pw.print(reportedDrawn);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001433 pw.print(" reportedVisible="); pw.println(reportedVisible);
Craig Mautner59431632012-04-04 11:56:44 -07001434 if (paused) {
1435 pw.print(prefix); pw.print("paused="); pw.println(paused);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001436 }
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001437 if (mAppStopped) {
1438 pw.print(prefix); pw.print("mAppStopped="); pw.println(mAppStopped);
1439 }
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001440 if (mNumInterestingWindows != 0 || mNumDrawnWindows != 0
Craig Mautner6fbda632012-07-03 09:26:39 -07001441 || allDrawn || mAppAnimator.allDrawn) {
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001442 pw.print(prefix); pw.print("mNumInterestingWindows=");
1443 pw.print(mNumInterestingWindows);
1444 pw.print(" mNumDrawnWindows="); pw.print(mNumDrawnWindows);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001445 pw.print(" inPendingTransaction="); pw.print(inPendingTransaction);
Craig Mautner6fbda632012-07-03 09:26:39 -07001446 pw.print(" allDrawn="); pw.print(allDrawn);
1447 pw.print(" (animator="); pw.print(mAppAnimator.allDrawn);
1448 pw.println(")");
1449 }
1450 if (inPendingTransaction) {
1451 pw.print(prefix); pw.print("inPendingTransaction=");
1452 pw.println(inPendingTransaction);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001453 }
Craig Mautner799bc1d2015-01-14 10:33:48 -08001454 if (startingData != null || removed || firstWindowDrawn || mIsExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001455 pw.print(prefix); pw.print("startingData="); pw.print(startingData);
1456 pw.print(" removed="); pw.print(removed);
Craig Mautner3d7ca312015-01-08 10:56:00 -08001457 pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
Craig Mautner799bc1d2015-01-14 10:33:48 -08001458 pw.print(" mIsExiting="); pw.println(mIsExiting);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001459 }
Jorim Jaggiba41f4b2016-12-14 17:43:07 -08001460 if (startingWindow != null || startingSurface != null
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001461 || startingDisplayed || startingMoved) {
1462 pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
Jorim Jaggiba41f4b2016-12-14 17:43:07 -08001463 pw.print(" startingSurface="); pw.print(startingSurface);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001464 pw.print(" startingDisplayed="); pw.print(startingDisplayed);
Wale Ogunwale9017ec02016-02-25 08:55:25 -08001465 pw.print(" startingMoved="); pw.println(startingMoved);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001466 }
Jorim Jaggi0429f352015-12-22 16:29:16 +01001467 if (!mFrozenBounds.isEmpty()) {
Chong Zhangd78ddb42016-03-02 17:01:14 -08001468 pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
Jorim Jaggi26c8c422016-05-09 19:57:25 -07001469 pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
Chong Zhangd78ddb42016-03-02 17:01:14 -08001470 }
1471 if (mPendingRelaunchCount != 0) {
1472 pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
Jorim Jaggi0429f352015-12-22 16:29:16 +01001473 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001474 }
1475
1476 @Override
1477 public String toString() {
1478 if (stringName == null) {
1479 StringBuilder sb = new StringBuilder();
1480 sb.append("AppWindowToken{");
1481 sb.append(Integer.toHexString(System.identityHashCode(this)));
1482 sb.append(" token="); sb.append(token); sb.append('}');
1483 stringName = sb.toString();
1484 }
Wale Ogunwaleba51ca22016-09-23 06:06:54 -07001485 return stringName + ((mIsExiting) ? " mIsExiting=" : "");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001486 }
Jeff Browne9bdb312012-04-05 15:30:10 -07001487}