blob: 5c40947c822ea27ba7c3f3357d914ad652110260 [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 Ogunwale053c8e42015-11-16 14:27:21 -080019import android.app.ActivityManager;
20import android.app.AppOpsManager;
21import android.content.Context;
22import android.content.res.Configuration;
23import android.graphics.Matrix;
24import android.graphics.PixelFormat;
25import android.graphics.Point;
26import android.graphics.Rect;
27import android.graphics.Region;
Wale Ogunwale9d147902016-07-16 11:58:55 -070028import android.os.Debug;
Wale Ogunwale053c8e42015-11-16 14:27:21 -080029import android.os.IBinder;
30import android.os.PowerManager;
31import android.os.RemoteCallbackList;
32import android.os.RemoteException;
33import android.os.SystemClock;
34import android.os.Trace;
35import android.os.UserHandle;
36import android.os.WorkSource;
37import android.util.DisplayMetrics;
38import android.util.Slog;
39import android.util.TimeUtils;
40import android.view.Display;
41import android.view.DisplayInfo;
42import android.view.Gravity;
43import android.view.IApplicationToken;
44import android.view.IWindow;
45import android.view.IWindowFocusObserver;
46import android.view.IWindowId;
47import android.view.InputChannel;
48import android.view.InputEvent;
49import android.view.InputEventReceiver;
50import android.view.View;
51import android.view.ViewTreeObserver;
52import android.view.WindowManager;
53import android.view.WindowManagerPolicy;
54
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080055import com.android.server.input.InputWindowHandle;
56
Wale Ogunwale053c8e42015-11-16 14:27:21 -080057import java.io.PrintWriter;
58import java.util.ArrayList;
59
Wale Ogunwaled045c822015-12-02 09:14:28 -080060import static android.app.ActivityManager.StackId;
Wale Ogunwalea9f9b372016-02-04 18:04:39 -080061import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
Filip Gruszczynski84fa3352016-01-25 16:28:49 -080062import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
Wale Ogunwalecad05a02015-09-25 10:41:44 -070063import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
Wale Ogunwale053c8e42015-11-16 14:27:21 -080064import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT;
65import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
66import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
67import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE;
Wale Ogunwalef9c81492015-02-25 18:06:17 -080068import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -080069import static android.view.WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON;
Filip Gruszczynski4501d232015-09-02 13:00:02 -070070import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND;
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -080071import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
Jorim Jaggi5f23a572016-04-22 15:05:50 -070072import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
Wale Ogunwale053c8e42015-11-16 14:27:21 -080073import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
74import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -080075import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
Wale Ogunwale945d1972016-03-23 13:16:41 -070076import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
Chong Zhang4d7369a2016-04-25 16:09:14 -070077import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -070078import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -080079import static android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
Wale Ogunwalef9c81492015-02-25 18:06:17 -080080import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
Robert Carr31e28482015-12-02 16:53:18 -080081import static android.view.WindowManager.LayoutParams.MATCH_PARENT;
Wale Ogunwalef9c81492015-02-25 18:06:17 -080082import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
Wale Ogunwalef9c81492015-02-25 18:06:17 -080083import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080084import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME;
Robert Carra1eb4392015-12-10 12:43:51 -080085import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH;
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -080086import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
87import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
Robert Carrd1a010f2016-04-07 22:36:22 -070088import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
Wale Ogunwalef9c81492015-02-25 18:06:17 -080089import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -080090import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
Filip Gruszczynski466f3212015-09-21 17:57:57 -070091import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
Wale Ogunwalef9c81492015-02-25 18:06:17 -080092import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
93import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
94import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
Chong Zhang4d7369a2016-04-25 16:09:14 -070095import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
Jorim Jaggi0b46f3c2016-03-14 12:21:37 +010096import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_DOCKED_DIVIDER;
97import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_FREEFORM;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -080098import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
99import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
100import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
101import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_CONFIGURATION;
102import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
103import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
104import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
105import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_POWER;
106import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RESIZE;
Wale Ogunwale9d147902016-07-16 11:58:55 -0700107import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
108import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SURFACE_TRACE;
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800109import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
110import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
111import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Wale Ogunwale9d147902016-07-16 11:58:55 -0700112import static com.android.server.wm.WindowStateAnimator.COMMIT_DRAW_PENDING;
113import static com.android.server.wm.WindowStateAnimator.HAS_DRAWN;
114import static com.android.server.wm.WindowStateAnimator.READY_TO_SHOW;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800115
Craig Mautner59c00972012-07-30 12:10:24 -0700116class WindowList extends ArrayList<WindowState> {
Wale Ogunwale33fde7d2016-03-05 22:38:51 -0800117 WindowList() {}
118 WindowList(WindowList windowList) {
119 super(windowList);
120 }
Craig Mautner59c00972012-07-30 12:10:24 -0700121}
122
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800123/**
124 * A window in the window manager.
125 */
Craig Mautnere32c3072012-03-12 15:25:35 -0700126final class WindowState implements WindowManagerPolicy.WindowState {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800127 static final String TAG = TAG_WITH_CLASS_NAME ? "WindowState" : TAG_WM;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800128
Skuhne81c524a2015-08-12 13:34:14 -0700129 // The minimal size of a window within the usable area of the freeform stack.
Wale Ogunwale231b06e2015-09-16 12:03:09 -0700130 // TODO(multi-window): fix the min sizes when we have mininum width/height support,
131 // use hard-coded min sizes for now.
132 static final int MINIMUM_VISIBLE_WIDTH_IN_DP = 48;
133 static final int MINIMUM_VISIBLE_HEIGHT_IN_DP = 32;
Skuhnef932e562015-08-20 12:07:30 -0700134
135 // The thickness of a window resize handle outside the window bounds on the free form workspace
136 // to capture touch events in that area.
Wale Ogunwale231b06e2015-09-16 12:03:09 -0700137 static final int RESIZE_HANDLE_WIDTH_IN_DP = 30;
Skuhnef932e562015-08-20 12:07:30 -0700138
Robert Carr7098dbd2016-02-01 12:31:01 -0800139 static final boolean DEBUG_DISABLE_SAVING_SURFACES = false;
140
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800141 final WindowManagerService mService;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700142 final WindowManagerPolicy mPolicy;
143 final Context mContext;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800144 final Session mSession;
145 final IWindow mClient;
Dianne Hackbornc2293022013-02-06 23:14:49 -0800146 final int mAppOp;
147 // UserId and appId of the owner. Don't display windows of non-current user.
148 final int mOwnerUid;
Dianne Hackborne3f23a32013-03-01 13:25:35 -0800149 final IWindowId mWindowId;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800150 WindowToken mToken;
151 WindowToken mRootToken;
152 AppWindowToken mAppToken;
153 AppWindowToken mTargetAppToken;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -0700154
155 // mAttrs.flags is tested in animation without being locked. If the bits tested are ever
156 // modified they will need to be locked.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800157 final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
158 final DeathRecipient mDeathRecipient;
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700159 final WindowState mParentWindow;
Craig Mautner7b1aa772012-11-30 16:14:45 -0800160 final WindowList mChildWindows = new WindowList();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800161 final int mBaseLayer;
162 final int mSubLayer;
163 final boolean mLayoutAttached;
164 final boolean mIsImWindow;
165 final boolean mIsWallpaper;
166 final boolean mIsFloatingLayer;
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700167 int mSeq;
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700168 boolean mEnforceSizeCompat;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800169 int mViewVisibility;
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700170 int mSystemUiVisibility;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800171 boolean mPolicyVisibility = true;
172 boolean mPolicyVisibilityAfterAnim = true;
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -0800173 boolean mAppOpVisibility = true;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800174 boolean mAppFreezing;
Wale Ogunwale9d147902016-07-16 11:58:55 -0700175 boolean mHidden; // Used to determine if to show child windows.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800176 boolean mWallpaperVisible; // for wallpaper, what was last vis report?
Chong Zhang0275e392015-09-17 10:41:44 -0700177 boolean mDragResizing;
Jorim Jaggic662d8e2016-02-05 16:54:54 -0800178 boolean mDragResizingChangeReported;
Jorim Jaggidcf467c2015-11-05 13:59:32 +0100179 int mResizeMode;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700180
Dianne Hackborne3f23a32013-03-01 13:25:35 -0800181 RemoteCallbackList<IWindowFocusObserver> mFocusCallbacks;
182
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700183 /**
184 * The window size that was requested by the application. These are in
185 * the application's coordinate space (without compatibility scale applied).
186 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800187 int mRequestedWidth;
188 int mRequestedHeight;
Dianne Hackborn1743b642012-03-12 17:04:43 -0700189 int mLastRequestedWidth;
190 int mLastRequestedHeight;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700191
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800192 int mLayer;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800193 boolean mHaveFrame;
194 boolean mObscured;
195 boolean mTurnOnScreen;
196
197 int mLayoutSeq = -1;
Craig Mautnera2c77052012-03-26 12:14:43 -0700198
Jorim Jaggi26c8c422016-05-09 19:57:25 -0700199 private final Configuration mTmpConfig = new Configuration();
Robert Carrc24d8f92016-02-29 16:24:33 -0800200 // Represents the changes from our override configuration applied
201 // to the global configuration. This is the only form of configuration
202 // which is suitable for delivery to the client.
203 private Configuration mMergedConfiguration = new Configuration();
Craig Mautnere8552142012-11-07 13:55:47 -0800204 // Sticky answer to isConfigChanged(), remains true until new Configuration is assigned.
205 // Used only on {@link #TYPE_KEYGUARD}.
206 private boolean mConfigHasChanged;
Craig Mautnera2c77052012-03-26 12:14:43 -0700207
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700208 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700209 * Actual position of the surface shown on-screen (may be modified by animation). These are
210 * in the screen's coordinate space (WITH the compatibility scale applied).
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700211 */
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700212 final Point mShownPosition = new Point();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800213
214 /**
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700215 * Insets that determine the actually visible area. These are in the application's
216 * coordinate space (without compatibility scale applied).
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800217 */
218 final Rect mVisibleInsets = new Rect();
219 final Rect mLastVisibleInsets = new Rect();
220 boolean mVisibleInsetsChanged;
221
222 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700223 * Insets that are covered by system windows (such as the status bar) and
224 * transient docking windows (such as the IME). These are in the application's
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700225 * coordinate space (without compatibility scale applied).
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800226 */
227 final Rect mContentInsets = new Rect();
228 final Rect mLastContentInsets = new Rect();
229 boolean mContentInsetsChanged;
230
231 /**
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800232 * Insets that determine the area covered by the display overscan region. These are in the
233 * application's coordinate space (without compatibility scale applied).
234 */
235 final Rect mOverscanInsets = new Rect();
236 final Rect mLastOverscanInsets = new Rect();
237 boolean mOverscanInsetsChanged;
238
239 /**
Adrian Roosfa104232014-06-20 16:10:14 -0700240 * Insets that determine the area covered by the stable system windows. These are in the
241 * application's coordinate space (without compatibility scale applied).
242 */
243 final Rect mStableInsets = new Rect();
244 final Rect mLastStableInsets = new Rect();
245 boolean mStableInsetsChanged;
246
247 /**
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700248 * Outsets determine the area outside of the surface where we want to pretend that it's possible
249 * to draw anyway.
250 */
251 final Rect mOutsets = new Rect();
252 final Rect mLastOutsets = new Rect();
253 boolean mOutsetsChanged = false;
254
255 /**
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800256 * Set to true if we are waiting for this window to receive its
257 * given internal insets before laying out other windows based on it.
258 */
259 boolean mGivenInsetsPending;
260
261 /**
262 * These are the content insets that were given during layout for
263 * this window, to be applied to windows behind it.
264 */
265 final Rect mGivenContentInsets = new Rect();
266
267 /**
268 * These are the visible insets that were given during layout for
269 * this window, to be applied to windows behind it.
270 */
271 final Rect mGivenVisibleInsets = new Rect();
272
273 /**
274 * This is the given touchable area relative to the window frame, or null if none.
275 */
276 final Region mGivenTouchableRegion = new Region();
277
278 /**
279 * Flag indicating whether the touchable region should be adjusted by
280 * the visible insets; if false the area outside the visible insets is
281 * NOT touchable, so we must use those to adjust the frame during hit
282 * tests.
283 */
284 int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
285
286 // Current transformation being applied.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400287 float mGlobalScale=1;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700288 float mInvGlobalScale=1;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800289 float mHScale=1, mVScale=1;
290 float mLastHScale=1, mLastVScale=1;
291 final Matrix mTmpMatrix = new Matrix();
292
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700293 // "Real" frame that the application sees, in display coordinate space.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800294 final Rect mFrame = new Rect();
295 final Rect mLastFrame = new Rect();
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700296 // Frame that is scaled to the application's coordinate space when in
297 // screen size compatibility mode.
298 final Rect mCompatFrame = new Rect();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800299
300 final Rect mContainingFrame = new Rect();
Wale Ogunwalec6061fa2014-10-21 13:15:11 -0700301
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800302 final Rect mParentFrame = new Rect();
Wale Ogunwalec6061fa2014-10-21 13:15:11 -0700303
Wale Ogunwale94596652015-02-06 19:27:34 -0800304 // The entire screen area of the {@link TaskStack} this window is in. Usually equal to the
305 // screen area of the device.
Wale Ogunwalec6061fa2014-10-21 13:15:11 -0700306 final Rect mDisplayFrame = new Rect();
307
308 // The region of the display frame that the display type supports displaying content on. This
309 // is mostly a special case for TV where some displays don’t have the entire display usable.
310 // {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_OVERSCAN} flag can be used to allow
311 // window display contents to extend into the overscan region.
312 final Rect mOverscanFrame = new Rect();
313
314 // The display frame minus the stable insets. This value is always constant regardless of if
315 // the status bar or navigation bar is visible.
Adrian Roosfa104232014-06-20 16:10:14 -0700316 final Rect mStableFrame = new Rect();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800317
Wale Ogunwalec6061fa2014-10-21 13:15:11 -0700318 // The area not occupied by the status and navigation bars. So, if both status and navigation
319 // bars are visible, the decor frame is equal to the stable frame.
320 final Rect mDecorFrame = new Rect();
321
322 // Equal to the decor frame if the IME (e.g. keyboard) is not present. Equal to the decor frame
323 // minus the area occupied by the IME if the IME is present.
324 final Rect mContentFrame = new Rect();
325
326 // Legacy stuff. Generally equal to the content frame expect when the IME for older apps
327 // displays hint text.
328 final Rect mVisibleFrame = new Rect();
329
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700330 // Frame that includes dead area outside of the surface but where we want to pretend that it's
331 // possible to draw.
332 final Rect mOutsetFrame = new Rect();
333
Jorim Jaggidc249c42015-12-15 14:57:31 -0800334 /**
335 * Usually empty. Set to the task's tempInsetFrame. See
336 *{@link android.app.IActivityManager#resizeDockedStack}.
337 */
338 final Rect mInsetFrame = new Rect();
339
Jorim Jaggif5834272016-04-04 20:25:41 -0700340 private static final Rect sTmpRect = new Rect();
341
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800342 boolean mContentChanged;
343
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800344 // If a window showing a wallpaper: the requested offset for the
345 // wallpaper; if a wallpaper window: the currently applied offset.
346 float mWallpaperX = -1;
347 float mWallpaperY = -1;
348
349 // If a window showing a wallpaper: what fraction of the offset
350 // range corresponds to a full virtual screen.
351 float mWallpaperXStep = -1;
352 float mWallpaperYStep = -1;
353
Dianne Hackborn067e5f62014-09-07 23:14:30 -0700354 // If a window showing a wallpaper: a raw pixel offset to forcibly apply
355 // to its window; if a wallpaper window: not used.
356 int mWallpaperDisplayOffsetX = Integer.MIN_VALUE;
357 int mWallpaperDisplayOffsetY = Integer.MIN_VALUE;
358
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800359 // Wallpaper windows: pixels offset based on above variables.
360 int mXOffset;
361 int mYOffset;
362
Craig Mautner2268e7e2012-12-13 15:40:00 -0800363 /**
364 * This is set after IWindowSession.relayout() has been called at
365 * least once for the window. It allows us to detect the situation
366 * where we don't yet have a surface, but should have one soon, so
367 * we can give the window focus before waiting for the relayout.
368 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800369 boolean mRelayoutCalled;
370
Robert Carrfed10072016-05-26 11:48:49 -0700371 boolean mInRelayout;
372
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800373 /**
374 * If the application has called relayout() with changes that can
375 * impact its window's size, we need to perform a layout pass on it
376 * even if it is not currently visible for layout. This is set
377 * when in that case until the layout is done.
378 */
Dianne Hackbornb7ff51b2012-01-23 19:15:27 -0800379 boolean mLayoutNeeded;
380
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800381 /** Currently running an exit animation? */
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800382 boolean mAnimatingExit;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800383
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800384 /** Currently on the mDestroySurface list? */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800385 boolean mDestroying;
386
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800387 /** Completely remove from window manager after exit animation? */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800388 boolean mRemoveOnExit;
389
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800390 /**
Chong Zhang112eb8c2015-11-02 11:17:00 -0800391 * Whether the app died while it was visible, if true we might need
392 * to continue to show it until it's restarted.
393 */
394 boolean mAppDied;
395
396 /**
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800397 * Set when the orientation is changing and this window has not yet
398 * been updated for the new orientation.
399 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800400 boolean mOrientationChanging;
401
Dianne Hackborna57c6952013-03-29 14:46:40 -0700402 /**
403 * How long we last kept the screen frozen.
404 */
405 int mLastFreezeDuration;
406
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800407 /** Is this window now (or just being) removed? */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800408 boolean mRemoved;
409
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800410 /**
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800411 * It is save to remove the window and destroy the surface because the client requested removal
412 * or some other higher level component said so (e.g. activity manager).
413 * TODO: We should either have different booleans for the removal reason or use a bit-field.
Robert Carre12aece2016-02-02 22:43:27 -0800414 */
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800415 boolean mWindowRemovalAllowed;
Robert Carre12aece2016-02-02 22:43:27 -0800416
417 /**
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800418 * Temp for keeping track of windows that have been removed when
419 * rebuilding window list.
420 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800421 boolean mRebuilding;
422
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800423 // Input channel and input window handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700424 final InputWindowHandle mInputWindowHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800425 InputChannel mInputChannel;
Chong Zhang112eb8c2015-11-02 11:17:00 -0800426 InputChannel mClientChannel;
Craig Mautner164d4bb2012-11-26 13:51:23 -0800427
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800428 // Used to improve performance of toString()
429 String mStringNameCache;
430 CharSequence mLastTitle;
Dianne Hackborn529e7442012-11-01 14:22:28 -0700431 boolean mWasExiting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800432
Craig Mautnera2c77052012-03-26 12:14:43 -0700433 final WindowStateAnimator mWinAnimator;
434
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700435 boolean mHasSurface = false;
436
Craig Mautner19ab8282014-05-07 10:35:34 -0700437 boolean mNotOnAppsDisplay = false;
Craig Mautner59c00972012-07-30 12:10:24 -0700438 DisplayContent mDisplayContent;
Craig Mautner6881a102012-07-27 13:04:51 -0700439
Craig Mautner88400d32012-09-30 12:35:45 -0700440 /** When true this window can be displayed on screens owther than mOwnerUid's */
441 private boolean mShowToOwnerOnly;
Craig Mautner9dc52bc2012-08-06 14:15:42 -0700442
Robert Carr13f7be9e2015-12-02 18:39:45 -0800443 // Whether the window has a saved surface from last pause, which can be
444 // used to start an entering animation earlier.
Chong Zhang92147042016-05-09 12:47:11 -0700445 private boolean mSurfaceSaved = false;
446
Chong Zhang8e4bda92016-05-04 15:08:18 -0700447 // Whether we're performing an entering animation with a saved surface. This flag is
448 // true during the time we're showing a window with a previously saved surface. It's
449 // cleared when surface is destroyed, saved, or re-drawn by the app.
Chong Zhang92147042016-05-09 12:47:11 -0700450 private boolean mAnimatingWithSavedSurface;
451
452 // Whether the window was visible when we set the app to invisible last time. WM uses
453 // this as a hint to restore the surface (if available) for early animation next time
454 // the app is brought visible.
455 boolean mWasVisibleBeforeClientHidden;
Robert Carr13f7be9e2015-12-02 18:39:45 -0800456
Robert Carra1eb4392015-12-10 12:43:51 -0800457 // This window will be replaced due to relaunch. This allows window manager
458 // to differentiate between simple removal of a window and replacement. In the latter case it
459 // will preserve the old window until the new one is drawn.
460 boolean mWillReplaceWindow = false;
461 // If true, the replaced window was already requested to be removed.
462 boolean mReplacingRemoveRequested = false;
463 // Whether the replacement of the window should trigger app transition animation.
464 boolean mAnimateReplacingWindow = false;
465 // If not null, the window that will be used to replace the old one. This is being set when
466 // the window is added and unset when this window reports its first draw.
467 WindowState mReplacingWindow = null;
Robert Carrb439a632016-04-07 22:52:10 -0700468 // For the new window in the replacement transition, if we have
469 // requested to replace without animation, then we should
470 // make sure we also don't apply an enter animation for
471 // the new window.
472 boolean mSkipEnterAnimationForSeamlessReplacement = false;
Chong Zhangbd0d9372015-12-28 15:18:29 -0800473 // Whether this window is being moved via the resize API
474 boolean mMovedByResize;
Robert Carr0d00c2e2016-02-29 17:45:02 -0800475
Jeff Brownc2932a12014-11-20 18:04:05 -0800476 /**
477 * Wake lock for drawing.
478 * Even though it's slightly more expensive to do so, we will use a separate wake lock
479 * for each app that is requesting to draw while dozing so that we can accurately track
480 * who is preventing the system from suspending.
481 * This lock is only acquired on first use.
482 */
483 PowerManager.WakeLock mDrawLock;
484
Wale Ogunwale2b19b602015-09-18 15:14:59 -0700485 final private Rect mTmpRect = new Rect();
486
Jorim Jaggi8fa45222016-02-19 19:54:39 -0800487 /**
Jorim Jaggi5e6968d2016-02-19 18:02:13 -0800488 * See {@link #notifyMovedInStack}.
489 */
490 private boolean mJustMovedInStack;
491
492 /**
Jorim Jaggi8fa45222016-02-19 19:54:39 -0800493 * Whether the window was resized by us while it was gone for layout.
494 */
495 boolean mResizedWhileGone = false;
496
Andrii Kulianeb1d3222016-05-16 15:17:55 -0700497 /** @see #isResizedWhileNotDragResizing(). */
498 private boolean mResizedWhileNotDragResizing;
499
500 /** @see #isResizedWhileNotDragResizingReported(). */
501 private boolean mResizedWhileNotDragResizingReported;
Jorim Jaggif3df0aa2016-04-06 15:56:33 -0700502
Robert Carr6da3cc02016-06-16 15:17:07 -0700503 /**
504 * During seamless rotation we have two phases, first the old window contents
505 * are rotated to look as if they didn't move in the new coordinate system. Then we
506 * have to freeze updates to this layer (to preserve the transformation) until
507 * the resize actually occurs. This is true from when the transformation is set
508 * and false until the transaction to resize is sent.
509 */
510 boolean mSeamlesslyRotated = false;
511
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800512 WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700513 WindowState parentWindow, int appOp, int seq, WindowManager.LayoutParams a,
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700514 int viewVisibility, final DisplayContent displayContent, int ownerId) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800515 mService = service;
516 mSession = s;
517 mClient = c;
Dianne Hackbornc2293022013-02-06 23:14:49 -0800518 mAppOp = appOp;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800519 mToken = token;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700520 mOwnerUid = ownerId;
Dianne Hackborne3f23a32013-03-01 13:25:35 -0800521 mWindowId = new IWindowId.Stub() {
522 @Override
523 public void registerFocusObserver(IWindowFocusObserver observer) {
524 WindowState.this.registerFocusObserver(observer);
525 }
526 @Override
527 public void unregisterFocusObserver(IWindowFocusObserver observer) {
528 WindowState.this.unregisterFocusObserver(observer);
529 }
530 @Override
531 public boolean isFocused() {
532 return WindowState.this.isFocused();
533 }
534 };
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800535 mAttrs.copyFrom(a);
536 mViewVisibility = viewVisibility;
Craig Mautner59c00972012-07-30 12:10:24 -0700537 mDisplayContent = displayContent;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700538 mPolicy = mService.mPolicy;
539 mContext = mService.mContext;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800540 DeathRecipient deathRecipient = new DeathRecipient();
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700541 mSeq = seq;
Adam Lesinski95c42972013-10-02 10:13:27 -0700542 mEnforceSizeCompat = (mAttrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800543 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautnerd87946b2012-03-29 18:00:19 -0700544 TAG, "Window " + this + " client=" + c.asBinder()
Craig Mautnerad09bcc2012-10-08 13:33:11 -0700545 + " token=" + token + " (" + mAttrs.token + ")" + " params=" + a);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800546 try {
547 c.asBinder().linkToDeath(deathRecipient, 0);
548 } catch (RemoteException e) {
549 mDeathRecipient = null;
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700550 mParentWindow = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800551 mLayoutAttached = false;
552 mIsImWindow = false;
553 mIsWallpaper = false;
554 mIsFloatingLayer = false;
555 mBaseLayer = 0;
556 mSubLayer = 0;
Jeff Brown9302c872011-07-13 22:51:29 -0700557 mInputWindowHandle = null;
Craig Mautnera2c77052012-03-26 12:14:43 -0700558 mWinAnimator = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800559 return;
560 }
561 mDeathRecipient = deathRecipient;
562
563 if ((mAttrs.type >= FIRST_SUB_WINDOW &&
564 mAttrs.type <= LAST_SUB_WINDOW)) {
565 // The multiplier here is to reserve space for multiple
566 // windows in the same type layer.
Craig Mautnere7ae2502012-03-26 17:11:19 -0700567 mBaseLayer = mPolicy.windowTypeToLayerLw(
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700568 parentWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800569 + WindowManagerService.TYPE_LAYER_OFFSET;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700570 mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type);
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700571 mParentWindow = parentWindow;
572 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mParentWindow);
takeda.masayuki18735092012-12-12 11:06:24 +0900573
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700574 final WindowList childWindows = mParentWindow.mChildWindows;
tiger_huange2a98a72014-11-13 19:46:28 +0800575 final int numChildWindows = childWindows.size();
576 if (numChildWindows == 0) {
577 childWindows.add(this);
takeda.masayuki18735092012-12-12 11:06:24 +0900578 } else {
tiger_huange2a98a72014-11-13 19:46:28 +0800579 boolean added = false;
580 for (int i = 0; i < numChildWindows; i++) {
581 final int childSubLayer = childWindows.get(i).mSubLayer;
582 if (mSubLayer < childSubLayer
583 || (mSubLayer == childSubLayer && childSubLayer < 0)) {
584 // We insert the child window into the list ordered by the sub-layer. For
585 // same sub-layers, the negative one should go below others; the positive
586 // one should go above others.
587 childWindows.add(i, this);
588 added = true;
takeda.masayuki18735092012-12-12 11:06:24 +0900589 break;
takeda.masayuki18735092012-12-12 11:06:24 +0900590 }
591 }
tiger_huange2a98a72014-11-13 19:46:28 +0800592 if (!added) {
593 childWindows.add(this);
takeda.masayuki18735092012-12-12 11:06:24 +0900594 }
595 }
596
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800597 mLayoutAttached = mAttrs.type !=
598 WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700599 mIsImWindow = parentWindow.mAttrs.type == TYPE_INPUT_METHOD
600 || parentWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
601 mIsWallpaper = parentWindow.mAttrs.type == TYPE_WALLPAPER;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800602 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
603 } else {
604 // The multiplier here is to reserve space for multiple
605 // windows in the same type layer.
Craig Mautnere7ae2502012-03-26 17:11:19 -0700606 mBaseLayer = mPolicy.windowTypeToLayerLw(a.type)
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800607 * WindowManagerService.TYPE_LAYER_MULTIPLIER
608 + WindowManagerService.TYPE_LAYER_OFFSET;
609 mSubLayer = 0;
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700610 mParentWindow = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800611 mLayoutAttached = false;
612 mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD
613 || mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
614 mIsWallpaper = mAttrs.type == TYPE_WALLPAPER;
615 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
616 }
617
618 WindowState appWin = this;
Robert Carr51a1b872015-12-08 14:03:13 -0800619 while (appWin.isChildWindow()) {
Wale Ogunwale7ed4d372016-07-09 15:28:55 -0700620 appWin = appWin.mParentWindow;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800621 }
622 WindowToken appToken = appWin.mToken;
623 while (appToken.appWindowToken == null) {
624 WindowToken parent = mService.mTokenMap.get(appToken.token);
625 if (parent == null || appToken == parent) {
626 break;
627 }
628 appToken = parent;
629 }
630 mRootToken = appToken;
631 mAppToken = appToken.appWindowToken;
Craig Mautner19ab8282014-05-07 10:35:34 -0700632 if (mAppToken != null) {
633 final DisplayContent appDisplay = getDisplayContent();
634 mNotOnAppsDisplay = displayContent != appDisplay;
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -0700635
636 if (mAppToken.showForAllUsers) {
637 // Windows for apps that can show for all users should also show when the
638 // device is locked.
639 mAttrs.flags |= FLAG_SHOW_WHEN_LOCKED;
640 }
Craig Mautner19ab8282014-05-07 10:35:34 -0700641 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800642
Craig Mautner322e4032012-07-13 13:35:20 -0700643 mWinAnimator = new WindowStateAnimator(this);
644 mWinAnimator.mAlpha = a.alpha;
645
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800646 mRequestedWidth = 0;
647 mRequestedHeight = 0;
Dianne Hackborn1743b642012-03-12 17:04:43 -0700648 mLastRequestedWidth = 0;
649 mLastRequestedHeight = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800650 mXOffset = 0;
651 mYOffset = 0;
652 mLayer = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800653 mInputWindowHandle = new InputWindowHandle(
Craig Mautner59c00972012-07-30 12:10:24 -0700654 mAppToken != null ? mAppToken.mInputApplicationHandle : null, this,
655 displayContent.getDisplayId());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800656 }
657
658 void attach() {
659 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautnerd87946b2012-03-29 18:00:19 -0700660 TAG, "Attaching " + this + " token=" + mToken
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800661 + ", list=" + mToken.windows);
662 mSession.windowAddedLocked();
663 }
664
Craig Mautnera2c77052012-03-26 12:14:43 -0700665 @Override
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800666 public int getOwningUid() {
Dianne Hackbornc2293022013-02-06 23:14:49 -0800667 return mOwnerUid;
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800668 }
669
670 @Override
671 public String getOwningPackage() {
672 return mAttrs.packageName;
673 }
674
Jorim Jaggif5834272016-04-04 20:25:41 -0700675 /**
676 * Subtracts the insets calculated by intersecting {@param layoutFrame} with {@param insetFrame}
677 * from {@param frame}. In other words, it applies the insets that would result if
678 * {@param frame} would be shifted to {@param layoutFrame} and then applying the insets from
Andrii Kuliandaea3572016-04-08 13:20:51 -0700679 * {@param insetFrame}. Also it respects {@param displayFrame} in case window has minimum
680 * width/height applied and insets should be overridden.
Jorim Jaggif5834272016-04-04 20:25:41 -0700681 */
Andrii Kuliandaea3572016-04-08 13:20:51 -0700682 private void subtractInsets(Rect frame, Rect layoutFrame, Rect insetFrame, Rect displayFrame) {
683 final int left = Math.max(0, insetFrame.left - Math.max(layoutFrame.left, displayFrame.left));
684 final int top = Math.max(0, insetFrame.top - Math.max(layoutFrame.top, displayFrame.top));
685 final int right = Math.max(0, Math.min(layoutFrame.right, displayFrame.right) - insetFrame.right);
686 final int bottom = Math.max(0, Math.min(layoutFrame.bottom, displayFrame.bottom) - insetFrame.bottom);
Jorim Jaggif5834272016-04-04 20:25:41 -0700687 frame.inset(left, top, right, bottom);
688 }
689
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800690 @Override
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700691 public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf, Rect sf,
692 Rect osf) {
Wale Ogunwalec48a3542016-02-19 15:18:45 -0800693 if (mWillReplaceWindow && (mAnimatingExit || !mReplacingRemoveRequested)) {
Filip Gruszczynski55a309f2015-09-04 17:15:01 -0700694 // This window is being replaced and either already got information that it's being
695 // removed or we are still waiting for some information. Because of this we don't
696 // want to apply any more changes to it, so it remains in this state until new window
697 // appears.
698 return;
699 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800700 mHaveFrame = true;
701
Wale Ogunwale5a2f2cb2015-09-17 12:31:55 -0700702 final Task task = getTask();
Andrii Kulian933076d2016-03-29 17:04:42 -0700703 final boolean fullscreenTask = !isInMultiWindowMode();
Robert Carre6275582016-02-29 15:45:45 -0800704 final boolean windowsAreFloating = task != null && task.isFloating();
Wale Ogunwale79f268d2015-12-18 08:25:47 -0800705
Chong Zhangae35fef2016-03-16 15:56:55 -0700706 // If the task has temp inset bounds set, we have to make sure all its windows uses
707 // the temp inset frame. Otherwise different display frames get applied to the main
708 // window and the child window, making them misaligned.
709 if (fullscreenTask) {
710 mInsetFrame.setEmpty();
711 } else {
712 task.getTempInsetBounds(mInsetFrame);
713 }
714
Jorim Jaggif5834272016-04-04 20:25:41 -0700715 // Denotes the actual frame used to calculate the insets and to perform the layout. When
716 // resizing in docked mode, we'd like to freeze the layout, so we also need to freeze the
717 // insets temporarily. By the notion of a task having a different layout frame, we can
718 // achieve that while still moving the task around.
719 final Rect layoutContainingFrame;
720 final Rect layoutDisplayFrame;
721
722 // The offset from the layout containing frame to the actual containing frame.
723 final int layoutXDiff;
724 final int layoutYDiff;
Wale Ogunwale7cd4b012016-05-07 12:41:22 -0700725 if (fullscreenTask || layoutInParentFrame()) {
Wale Ogunwale79f268d2015-12-18 08:25:47 -0800726 // We use the parent frame as the containing frame for fullscreen and child windows
727 mContainingFrame.set(pf);
728 mDisplayFrame.set(df);
Jorim Jaggif5834272016-04-04 20:25:41 -0700729 layoutDisplayFrame = df;
730 layoutContainingFrame = pf;
731 layoutXDiff = 0;
732 layoutYDiff = 0;
Wale Ogunwale79f268d2015-12-18 08:25:47 -0800733 } else {
Wale Ogunwalee4a0c572015-06-30 08:40:31 -0700734 task.getBounds(mContainingFrame);
Jorim Jaggi0429f352015-12-22 16:29:16 +0100735 if (mAppToken != null && !mAppToken.mFrozenBounds.isEmpty()) {
736
737 // If the bounds are frozen, we still want to translate the window freely and only
738 // freeze the size.
739 Rect frozen = mAppToken.mFrozenBounds.peek();
740 mContainingFrame.right = mContainingFrame.left + frozen.width();
741 mContainingFrame.bottom = mContainingFrame.top + frozen.height();
742 }
Wale Ogunwalef9c81492015-02-25 18:06:17 -0800743 final WindowState imeWin = mService.mInputMethodWindow;
Robert Carrfc03b2b2016-03-31 15:22:02 -0700744 // IME is up and obscuring this window. Adjust the window position so it is visible.
745 if (imeWin != null && imeWin.isVisibleNow() && mService.mInputMethodTarget == this) {
746 if (windowsAreFloating && mContainingFrame.bottom > cf.bottom) {
747 // In freeform we want to move the top up directly.
748 // TODO: Investigate why this is cf not pf.
749 mContainingFrame.top -= mContainingFrame.bottom - cf.bottom;
750 } else if (mContainingFrame.bottom > pf.bottom) {
751 // But in docked we want to behave like fullscreen
752 // and behave as if the task were given smaller bounds
753 // for the purposes of layout.
754 mContainingFrame.bottom = pf.bottom;
755 }
Craig Mautnerc5a6e442013-06-05 17:22:35 -0700756 }
Skuhne81c524a2015-08-12 13:34:14 -0700757
Robert Carre6275582016-02-29 15:45:45 -0800758 if (windowsAreFloating) {
Chong Zhang65d15d02016-03-14 13:59:32 -0700759 // In floating modes (e.g. freeform, pinned) we have only to set the rectangle
760 // if it wasn't set already. No need to intersect it with the (visible)
Robert Carre6275582016-02-29 15:45:45 -0800761 // "content frame" since it is allowed to be outside the visible desktop.
Skuhne81c524a2015-08-12 13:34:14 -0700762 if (mContainingFrame.isEmpty()) {
763 mContainingFrame.set(cf);
764 }
Doris Liu06d582d2015-06-01 13:18:43 -0700765 }
Wale Ogunwale94596652015-02-06 19:27:34 -0800766 mDisplayFrame.set(mContainingFrame);
Jorim Jaggif5834272016-04-04 20:25:41 -0700767 layoutXDiff = !mInsetFrame.isEmpty() ? mInsetFrame.left - mContainingFrame.left : 0;
768 layoutYDiff = !mInsetFrame.isEmpty() ? mInsetFrame.top - mContainingFrame.top : 0;
769 layoutContainingFrame = !mInsetFrame.isEmpty() ? mInsetFrame : mContainingFrame;
Andrii Kuliandaea3572016-04-08 13:20:51 -0700770 mTmpRect.set(0, 0, mDisplayContent.getDisplayInfo().logicalWidth,
771 mDisplayContent.getDisplayInfo().logicalHeight);
772 subtractInsets(mDisplayFrame, layoutContainingFrame, df, mTmpRect);
Robert Carrfd2bd1b2016-04-07 13:52:43 -0700773 if (!layoutInParentFrame()) {
Andrii Kuliandaea3572016-04-08 13:20:51 -0700774 subtractInsets(mContainingFrame, layoutContainingFrame, pf, mTmpRect);
775 subtractInsets(mInsetFrame, layoutContainingFrame, pf, mTmpRect);
Robert Carrfd2bd1b2016-04-07 13:52:43 -0700776 }
Jorim Jaggif5834272016-04-04 20:25:41 -0700777 layoutDisplayFrame = df;
778 layoutDisplayFrame.intersect(layoutContainingFrame);
Craig Mautner967212c2013-04-13 21:10:58 -0700779 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800780
Craig Mautner967212c2013-04-13 21:10:58 -0700781 final int pw = mContainingFrame.width();
782 final int ph = mContainingFrame.height();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800783
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800784 if (!mParentFrame.equals(pf)) {
Filip Gruszczynski0bd180d2015-12-07 15:43:52 -0800785 //Slog.i(TAG_WM, "Window " + this + " content frame from " + mParentFrame
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800786 // + " to " + pf);
787 mParentFrame.set(pf);
788 mContentChanged = true;
789 }
Dianne Hackborn1743b642012-03-12 17:04:43 -0700790 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
791 mLastRequestedWidth = mRequestedWidth;
792 mLastRequestedHeight = mRequestedHeight;
793 mContentChanged = true;
794 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800795
Craig Mautnereda67292013-04-28 13:50:14 -0700796 mOverscanFrame.set(of);
797 mContentFrame.set(cf);
798 mVisibleFrame.set(vf);
John Spurlock46646232013-09-30 22:32:42 -0400799 mDecorFrame.set(dcf);
Adrian Roosfa104232014-06-20 16:10:14 -0700800 mStableFrame.set(sf);
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700801 final boolean hasOutsets = osf != null;
802 if (hasOutsets) {
803 mOutsetFrame.set(osf);
804 }
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800805
Craig Mautnereda67292013-04-28 13:50:14 -0700806 final int fw = mFrame.width();
807 final int fh = mFrame.height();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800808
Jorim Jaggif5834272016-04-04 20:25:41 -0700809 applyGravityAndUpdateFrame(layoutContainingFrame, layoutDisplayFrame);
810
Filip Gruszczynskiaaf18112015-06-05 13:37:40 -0700811 // Calculate the outsets before the content frame gets shrinked to the window frame.
812 if (hasOutsets) {
813 mOutsets.set(Math.max(mContentFrame.left - mOutsetFrame.left, 0),
814 Math.max(mContentFrame.top - mOutsetFrame.top, 0),
815 Math.max(mOutsetFrame.right - mContentFrame.right, 0),
816 Math.max(mOutsetFrame.bottom - mContentFrame.bottom, 0));
817 } else {
818 mOutsets.set(0, 0, 0, 0);
819 }
820
Craig Mautnera248eee2013-05-07 11:41:27 -0700821 // Make sure the content and visible frames are inside of the
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800822 // final window frame.
Robert Carre6275582016-02-29 15:45:45 -0800823 if (windowsAreFloating && !mFrame.isEmpty()) {
Skuhne81c524a2015-08-12 13:34:14 -0700824 // Keep the frame out of the blocked system area, limit it in size to the content area
825 // and make sure that there is always a minimum visible so that the user can drag it
826 // into a usable area..
827 final int height = Math.min(mFrame.height(), mContentFrame.height());
828 final int width = Math.min(mContentFrame.width(), mFrame.width());
Wale Ogunwale231b06e2015-09-16 12:03:09 -0700829 final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics();
Filip Gruszczynski0689ae92015-10-01 12:30:31 -0700830 final int minVisibleHeight = WindowManagerService.dipToPixel(
831 MINIMUM_VISIBLE_HEIGHT_IN_DP, displayMetrics);
832 final int minVisibleWidth = WindowManagerService.dipToPixel(
833 MINIMUM_VISIBLE_WIDTH_IN_DP, displayMetrics);
Skuhne81c524a2015-08-12 13:34:14 -0700834 final int top = Math.max(mContentFrame.top,
835 Math.min(mFrame.top, mContentFrame.bottom - minVisibleHeight));
836 final int left = Math.max(mContentFrame.left + minVisibleWidth - width,
837 Math.min(mFrame.left, mContentFrame.right - minVisibleWidth));
838 mFrame.set(left, top, left + width, top + height);
839 mContentFrame.set(mFrame);
840 mVisibleFrame.set(mContentFrame);
841 mStableFrame.set(mContentFrame);
Filip Gruszczynski466f3212015-09-21 17:57:57 -0700842 } else if (mAttrs.type == TYPE_DOCK_DIVIDER) {
Jorim Jaggi192086e2016-03-11 17:17:03 +0100843 mDisplayContent.getDockedDividerController().positionDockedStackedDivider(mFrame);
844 mContentFrame.set(mFrame);
845 if (!mFrame.equals(mLastFrame)) {
846 mMovedByResize = true;
Filip Gruszczynskiae100802015-11-11 15:58:03 -0800847 }
Skuhne81c524a2015-08-12 13:34:14 -0700848 } else {
Jorim Jaggi656f6502016-04-11 21:08:17 -0700849 mContentFrame.set(Math.max(mContentFrame.left, mFrame.left),
850 Math.max(mContentFrame.top, mFrame.top),
851 Math.min(mContentFrame.right, mFrame.right),
852 Math.min(mContentFrame.bottom, mFrame.bottom));
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800853
Jorim Jaggi656f6502016-04-11 21:08:17 -0700854 mVisibleFrame.set(Math.max(mVisibleFrame.left, mFrame.left),
855 Math.max(mVisibleFrame.top, mFrame.top),
856 Math.min(mVisibleFrame.right, mFrame.right),
857 Math.min(mVisibleFrame.bottom, mFrame.bottom));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800858
Jorim Jaggi656f6502016-04-11 21:08:17 -0700859 mStableFrame.set(Math.max(mStableFrame.left, mFrame.left),
860 Math.max(mStableFrame.top, mFrame.top),
861 Math.min(mStableFrame.right, mFrame.right),
862 Math.min(mStableFrame.bottom, mFrame.bottom));
Skuhne81c524a2015-08-12 13:34:14 -0700863 }
Adrian Roosfa104232014-06-20 16:10:14 -0700864
Jorim Jaggi899327f2016-02-25 20:44:18 -0500865 if (fullscreenTask && !windowsAreFloating) {
866 // Windows that are not fullscreen can be positioned outside of the display frame,
867 // but that is not a reason to provide them with overscan insets.
Jorim Jaggif5834272016-04-04 20:25:41 -0700868 mOverscanInsets.set(Math.max(mOverscanFrame.left - layoutContainingFrame.left, 0),
869 Math.max(mOverscanFrame.top - layoutContainingFrame.top, 0),
870 Math.max(layoutContainingFrame.right - mOverscanFrame.right, 0),
871 Math.max(layoutContainingFrame.bottom - mOverscanFrame.bottom, 0));
Filip Gruszczynski01ef404d52016-01-28 18:14:27 -0800872 }
Craig Mautnereda67292013-04-28 13:50:14 -0700873
Jorim Jaggi81fe2d12015-12-21 14:45:18 +0100874 if (mAttrs.type == TYPE_DOCK_DIVIDER) {
Jorim Jaggi81fe2d12015-12-21 14:45:18 +0100875 // For the docked divider, we calculate the stable insets like a full-screen window
876 // so it can use it to calculate the snap positions.
877 mStableInsets.set(Math.max(mStableFrame.left - mDisplayFrame.left, 0),
878 Math.max(mStableFrame.top - mDisplayFrame.top, 0),
879 Math.max(mDisplayFrame.right - mStableFrame.right, 0),
880 Math.max(mDisplayFrame.bottom - mStableFrame.bottom, 0));
Jorim Jaggi2e95a482016-01-14 17:36:55 -0800881
882 // The divider doesn't care about insets in any case, so set it to empty so we don't
883 // trigger a relayout when moving it.
884 mContentInsets.setEmpty();
885 mVisibleInsets.setEmpty();
Jorim Jaggi81fe2d12015-12-21 14:45:18 +0100886 } else {
Andrii Kuliand9003372016-04-04 17:46:59 -0700887 getDisplayContent().getLogicalDisplayRect(mTmpRect);
Andrii Kuliana9d168c2016-03-23 13:19:32 -0700888 // Override right and/or bottom insets in case if the frame doesn't fit the screen in
889 // non-fullscreen mode.
Jorim Jaggi656f6502016-04-11 21:08:17 -0700890 boolean overrideRightInset = !fullscreenTask && mFrame.right > mTmpRect.right;
891 boolean overrideBottomInset = !fullscreenTask && mFrame.bottom > mTmpRect.bottom;
892 mContentInsets.set(mContentFrame.left - mFrame.left,
893 mContentFrame.top - mFrame.top,
Andrii Kuliand9003372016-04-04 17:46:59 -0700894 overrideRightInset ? mTmpRect.right - mContentFrame.right
Jorim Jaggi656f6502016-04-11 21:08:17 -0700895 : mFrame.right - mContentFrame.right,
Andrii Kuliand9003372016-04-04 17:46:59 -0700896 overrideBottomInset ? mTmpRect.bottom - mContentFrame.bottom
Jorim Jaggi656f6502016-04-11 21:08:17 -0700897 : mFrame.bottom - mContentFrame.bottom);
Jorim Jaggi2e95a482016-01-14 17:36:55 -0800898
Jorim Jaggi656f6502016-04-11 21:08:17 -0700899 mVisibleInsets.set(mVisibleFrame.left - mFrame.left,
900 mVisibleFrame.top - mFrame.top,
Andrii Kuliand9003372016-04-04 17:46:59 -0700901 overrideRightInset ? mTmpRect.right - mVisibleFrame.right
Jorim Jaggi656f6502016-04-11 21:08:17 -0700902 : mFrame.right - mVisibleFrame.right,
Andrii Kuliand9003372016-04-04 17:46:59 -0700903 overrideBottomInset ? mTmpRect.bottom - mVisibleFrame.bottom
Jorim Jaggi656f6502016-04-11 21:08:17 -0700904 : mFrame.bottom - mVisibleFrame.bottom);
Jorim Jaggi2e95a482016-01-14 17:36:55 -0800905
Jorim Jaggi656f6502016-04-11 21:08:17 -0700906 mStableInsets.set(Math.max(mStableFrame.left - mFrame.left, 0),
907 Math.max(mStableFrame.top - mFrame.top, 0),
Andrii Kuliand9003372016-04-04 17:46:59 -0700908 overrideRightInset ? Math.max(mTmpRect.right - mStableFrame.right, 0)
Jorim Jaggi656f6502016-04-11 21:08:17 -0700909 : Math.max(mFrame.right - mStableFrame.right, 0),
Andrii Kuliand9003372016-04-04 17:46:59 -0700910 overrideBottomInset ? Math.max(mTmpRect.bottom - mStableFrame.bottom, 0)
Jorim Jaggi656f6502016-04-11 21:08:17 -0700911 : Math.max(mFrame.bottom - mStableFrame.bottom, 0));
Jorim Jaggi81fe2d12015-12-21 14:45:18 +0100912 }
Adrian Roosfa104232014-06-20 16:10:14 -0700913
Jorim Jaggi656f6502016-04-11 21:08:17 -0700914 // Offset the actual frame by the amount layout frame is off.
915 mFrame.offset(-layoutXDiff, -layoutYDiff);
916 mCompatFrame.offset(-layoutXDiff, -layoutYDiff);
Jorim Jaggif5834272016-04-04 20:25:41 -0700917 mContentFrame.offset(-layoutXDiff, -layoutYDiff);
918 mVisibleFrame.offset(-layoutXDiff, -layoutYDiff);
919 mStableFrame.offset(-layoutXDiff, -layoutYDiff);
920
Craig Mautnereda67292013-04-28 13:50:14 -0700921 mCompatFrame.set(mFrame);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400922 if (mEnforceSizeCompat) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700923 // If there is a size compatibility scale being applied to the
924 // window, we need to apply this to its insets so that they are
925 // reported to the app in its coordinate space.
Craig Mautnereda67292013-04-28 13:50:14 -0700926 mOverscanInsets.scale(mInvGlobalScale);
927 mContentInsets.scale(mInvGlobalScale);
928 mVisibleInsets.scale(mInvGlobalScale);
Adrian Roosfa104232014-06-20 16:10:14 -0700929 mStableInsets.scale(mInvGlobalScale);
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700930 mOutsets.scale(mInvGlobalScale);
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700931
932 // Also the scaled frame that we report to the app needs to be
933 // adjusted to be in its coordinate space.
934 mCompatFrame.scale(mInvGlobalScale);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400935 }
936
Craig Mautnereda67292013-04-28 13:50:14 -0700937 if (mIsWallpaper && (fw != mFrame.width() || fh != mFrame.height())) {
Craig Mautnerdf88d732014-01-27 09:21:32 -0800938 final DisplayContent displayContent = getDisplayContent();
939 if (displayContent != null) {
940 final DisplayInfo displayInfo = displayContent.getDisplayInfo();
Wale Ogunwalee8069dc2015-08-18 09:52:01 -0700941 mService.mWallpaperControllerLocked.updateWallpaperOffset(
942 this, displayInfo.logicalWidth, displayInfo.logicalHeight, false);
Craig Mautnerdf88d732014-01-27 09:21:32 -0800943 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800944 }
945
Craig Mautnerb3b36ba2013-05-20 13:21:10 -0700946 if (DEBUG_LAYOUT || WindowManagerService.localLOGV) Slog.v(TAG,
947 "Resolving (mRequestedWidth="
948 + mRequestedWidth + ", mRequestedheight="
949 + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
950 + "): frame=" + mFrame.toShortString()
951 + " ci=" + mContentInsets.toShortString()
Adrian Roosfa104232014-06-20 16:10:14 -0700952 + " vi=" + mVisibleInsets.toShortString()
Andrii Kuliana9d168c2016-03-23 13:19:32 -0700953 + " si=" + mStableInsets.toShortString()
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700954 + " of=" + mOutsets.toShortString());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800955 }
956
Craig Mautnera2c77052012-03-26 12:14:43 -0700957 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800958 public Rect getFrameLw() {
959 return mFrame;
960 }
961
Craig Mautnera2c77052012-03-26 12:14:43 -0700962 @Override
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700963 public Point getShownPositionLw() {
964 return mShownPosition;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800965 }
966
Craig Mautnera2c77052012-03-26 12:14:43 -0700967 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800968 public Rect getDisplayFrameLw() {
969 return mDisplayFrame;
970 }
971
Craig Mautnera2c77052012-03-26 12:14:43 -0700972 @Override
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800973 public Rect getOverscanFrameLw() {
974 return mOverscanFrame;
975 }
976
977 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800978 public Rect getContentFrameLw() {
979 return mContentFrame;
980 }
981
Craig Mautnera2c77052012-03-26 12:14:43 -0700982 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800983 public Rect getVisibleFrameLw() {
984 return mVisibleFrame;
985 }
986
Craig Mautnera2c77052012-03-26 12:14:43 -0700987 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800988 public boolean getGivenInsetsPendingLw() {
989 return mGivenInsetsPending;
990 }
991
Craig Mautnera2c77052012-03-26 12:14:43 -0700992 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800993 public Rect getGivenContentInsetsLw() {
994 return mGivenContentInsets;
995 }
996
Craig Mautnera2c77052012-03-26 12:14:43 -0700997 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800998 public Rect getGivenVisibleInsetsLw() {
999 return mGivenVisibleInsets;
1000 }
1001
Craig Mautnera2c77052012-03-26 12:14:43 -07001002 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001003 public WindowManager.LayoutParams getAttrs() {
1004 return mAttrs;
1005 }
1006
Craig Mautner812d2ca2012-09-27 15:35:34 -07001007 @Override
Dianne Hackborn73ab6a42011-12-13 11:16:23 -08001008 public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) {
1009 int index = -1;
1010 WindowState ws = this;
Craig Mautner59c00972012-07-30 12:10:24 -07001011 WindowList windows = getWindowList();
Dianne Hackborn73ab6a42011-12-13 11:16:23 -08001012 while (true) {
Wale Ogunwale393b1c12014-10-18 16:22:01 -07001013 if (ws.mAttrs.needsMenuKey != WindowManager.LayoutParams.NEEDS_MENU_UNSET) {
1014 return ws.mAttrs.needsMenuKey == WindowManager.LayoutParams.NEEDS_MENU_SET_TRUE;
Dianne Hackborn73ab6a42011-12-13 11:16:23 -08001015 }
1016 // If we reached the bottom of the range of windows we are considering,
1017 // assume no menu is needed.
1018 if (ws == bottom) {
1019 return false;
1020 }
1021 // The current window hasn't specified whether menu key is needed;
1022 // look behind it.
1023 // First, we may need to determine the starting position.
1024 if (index < 0) {
Craig Mautner59c00972012-07-30 12:10:24 -07001025 index = windows.indexOf(ws);
Dianne Hackborn73ab6a42011-12-13 11:16:23 -08001026 }
1027 index--;
1028 if (index < 0) {
1029 return false;
1030 }
Craig Mautner59c00972012-07-30 12:10:24 -07001031 ws = windows.get(index);
Dianne Hackborn73ab6a42011-12-13 11:16:23 -08001032 }
1033 }
1034
Craig Mautner19d59bc2012-09-04 11:15:56 -07001035 @Override
Dianne Hackborn9a230e02011-10-06 11:51:27 -07001036 public int getSystemUiVisibility() {
1037 return mSystemUiVisibility;
1038 }
1039
Craig Mautner19d59bc2012-09-04 11:15:56 -07001040 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001041 public int getSurfaceLayer() {
1042 return mLayer;
1043 }
1044
Craig Mautner812d2ca2012-09-27 15:35:34 -07001045 @Override
Selim Cinekd6623612015-05-22 18:56:22 -07001046 public int getBaseType() {
1047 WindowState win = this;
Robert Carr51a1b872015-12-08 14:03:13 -08001048 while (win.isChildWindow()) {
Wale Ogunwale7ed4d372016-07-09 15:28:55 -07001049 win = win.mParentWindow;
Selim Cinekd6623612015-05-22 18:56:22 -07001050 }
1051 return win.mAttrs.type;
1052 }
1053
1054 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001055 public IApplicationToken getAppToken() {
1056 return mAppToken != null ? mAppToken.appToken : null;
1057 }
Craig Mautner19d59bc2012-09-04 11:15:56 -07001058
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001059 @Override
1060 public boolean isVoiceInteraction() {
Filip Gruszczynski0689ae92015-10-01 12:30:31 -07001061 return mAppToken != null && mAppToken.voiceInteraction;
Dianne Hackborne30e02f2014-05-27 18:24:45 -07001062 }
1063
Craig Mautner4c5eb222013-11-18 12:59:05 -08001064 boolean setInsetsChanged() {
1065 mOverscanInsetsChanged |= !mLastOverscanInsets.equals(mOverscanInsets);
1066 mContentInsetsChanged |= !mLastContentInsets.equals(mContentInsets);
1067 mVisibleInsetsChanged |= !mLastVisibleInsets.equals(mVisibleInsets);
Adrian Roosfa104232014-06-20 16:10:14 -07001068 mStableInsetsChanged |= !mLastStableInsets.equals(mStableInsets);
Filip Gruszczynski2217f612015-05-26 11:32:08 -07001069 mOutsetsChanged |= !mLastOutsets.equals(mOutsets);
1070 return mOverscanInsetsChanged || mContentInsetsChanged || mVisibleInsetsChanged
1071 || mOutsetsChanged;
Craig Mautner4c5eb222013-11-18 12:59:05 -08001072 }
1073
Craig Mautnerdf88d732014-01-27 09:21:32 -08001074 public DisplayContent getDisplayContent() {
Chad Jonesf391ebc2014-06-12 17:45:05 -07001075 if (mAppToken == null || mNotOnAppsDisplay) {
Craig Mautnerbe634952014-06-12 13:39:24 -07001076 return mDisplayContent;
1077 }
1078 final TaskStack stack = getStack();
1079 return stack == null ? mDisplayContent : stack.getDisplayContent();
Craig Mautnerdf88d732014-01-27 09:21:32 -08001080 }
1081
Chong Zhang09b21ef2015-09-14 10:20:21 -07001082 public DisplayInfo getDisplayInfo() {
1083 final DisplayContent displayContent = getDisplayContent();
1084 return displayContent != null ? displayContent.getDisplayInfo() : null;
1085 }
1086
Craig Mautner19d59bc2012-09-04 11:15:56 -07001087 public int getDisplayId() {
Craig Mautnerdf88d732014-01-27 09:21:32 -08001088 final DisplayContent displayContent = getDisplayContent();
1089 if (displayContent == null) {
1090 return -1;
1091 }
1092 return displayContent.getDisplayId();
Craig Mautner19d59bc2012-09-04 11:15:56 -07001093 }
1094
Wale Ogunwalee4a0c572015-06-30 08:40:31 -07001095 Task getTask() {
Wale Ogunwale5a2f2cb2015-09-17 12:31:55 -07001096 return mAppToken != null ? mAppToken.mTask : null;
Wale Ogunwalee4a0c572015-06-30 08:40:31 -07001097 }
1098
1099 TaskStack getStack() {
1100 Task task = getTask();
1101 if (task != null) {
1102 if (task.mStack != null) {
1103 return task.mStack;
Craig Mautnerf06b8c12013-04-18 14:27:28 -07001104 }
Craig Mautnerd9a22882013-03-16 15:00:36 -07001105 }
Filip Gruszczynski0689ae92015-10-01 12:30:31 -07001106 // Some system windows (e.g. "Power off" dialog) don't have a task, but we would still
1107 // associate them with some stack to enable dimming.
1108 return mAttrs.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
1109 && mDisplayContent != null ? mDisplayContent.getHomeStack() : null;
Craig Mautnerd9a22882013-03-16 15:00:36 -07001110 }
1111
Skuhnef932e562015-08-20 12:07:30 -07001112 /**
Wale Ogunwale61b009e2015-09-16 15:43:05 -07001113 * Retrieves the visible bounds of the window.
Skuhnef932e562015-08-20 12:07:30 -07001114 * @param bounds The rect which gets the bounds.
Skuhnef932e562015-08-20 12:07:30 -07001115 */
Chong Zhang4c9ba52a2015-11-10 18:36:33 -08001116 void getVisibleBounds(Rect bounds) {
Wale Ogunwaleb1faf602016-01-27 09:12:31 -08001117 final Task task = getTask();
1118 boolean intersectWithStackBounds = task != null && task.cropWindowsToStackBounds();
Wale Ogunwale61b009e2015-09-16 15:43:05 -07001119 bounds.setEmpty();
Wale Ogunwale2b19b602015-09-18 15:14:59 -07001120 mTmpRect.setEmpty();
1121 if (intersectWithStackBounds) {
Wale Ogunwaleb1faf602016-01-27 09:12:31 -08001122 final TaskStack stack = task.mStack;
Wale Ogunwale61b009e2015-09-16 15:43:05 -07001123 if (stack != null) {
Chong Zhang4c9ba52a2015-11-10 18:36:33 -08001124 stack.getDimBounds(mTmpRect);
Wale Ogunwale2b19b602015-09-18 15:14:59 -07001125 } else {
1126 intersectWithStackBounds = false;
Wale Ogunwale61b009e2015-09-16 15:43:05 -07001127 }
1128 }
Wale Ogunwale2b19b602015-09-18 15:14:59 -07001129
Chong Zhang9184ec62015-09-24 12:32:21 -07001130 bounds.set(mVisibleFrame);
1131 if (intersectWithStackBounds) {
1132 bounds.intersect(mTmpRect);
Wale Ogunwale2b19b602015-09-18 15:14:59 -07001133 }
1134
Wale Ogunwale61b009e2015-09-16 15:43:05 -07001135 if (bounds.isEmpty()) {
1136 bounds.set(mFrame);
Wale Ogunwale2b19b602015-09-18 15:14:59 -07001137 if (intersectWithStackBounds) {
1138 bounds.intersect(mTmpRect);
1139 }
Craig Mautnerbdc748af2013-12-02 14:08:25 -08001140 return;
Craig Mautner4cd0c13f2013-04-16 15:55:52 -07001141 }
Craig Mautner4cd0c13f2013-04-16 15:55:52 -07001142 }
1143
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001144 public long getInputDispatchingTimeoutNanos() {
1145 return mAppToken != null
1146 ? mAppToken.inputDispatchingTimeoutNanos
1147 : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
1148 }
1149
Craig Mautnere8552142012-11-07 13:55:47 -08001150 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001151 public boolean hasAppShownWindows() {
Craig Mautnerf4120952012-06-21 18:25:39 -07001152 return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001153 }
1154
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001155 boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
1156 if (dsdx < .99999f || dsdx > 1.00001f) return false;
1157 if (dtdy < .99999f || dtdy > 1.00001f) return false;
1158 if (dtdx < -.000001f || dtdx > .000001f) return false;
1159 if (dsdy < -.000001f || dsdy > .000001f) return false;
1160 return true;
1161 }
1162
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001163 void prelayout() {
1164 if (mEnforceSizeCompat) {
1165 mGlobalScale = mService.mCompatibleScreenScale;
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001166 mInvGlobalScale = 1/mGlobalScale;
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001167 } else {
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001168 mGlobalScale = mInvGlobalScale = 1;
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001169 }
1170 }
1171
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001172 /**
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001173 * Does the minimal check for visibility. Callers generally want to use one of the public
1174 * methods as they perform additional checks on the app token.
1175 * TODO: See if there are other places we can use this check below instead of duplicating...
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001176 */
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001177 private boolean isVisibleUnchecked() {
Wale Ogunwale9d147902016-07-16 11:58:55 -07001178 return mHasSurface && mPolicyVisibility && !isParentWindowHidden()
Wale Ogunwalec48a3542016-02-19 15:18:45 -08001179 && !mAnimatingExit && !mDestroying && (!mIsWallpaper || mWallpaperVisible);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001180 }
1181
1182 /**
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001183 * Is this window visible? It is not visible if there is no surface, or we are in the process
1184 * of running an exit animation that will remove the surface, or its app token has been hidden.
1185 */
1186 @Override
1187 public boolean isVisibleLw() {
1188 return (mAppToken == null || !mAppToken.hiddenRequested) && isVisibleUnchecked();
1189 }
1190
1191 /**
1192 * Like {@link #isVisibleLw}, but also counts a window that is currently "hidden" behind the
1193 * keyguard as visible. This allows us to apply things like window flags that impact the
1194 * keyguard. XXX I am starting to think we need to have ANOTHER visibility flag for this
1195 * "hidden behind keyguard" state rather than overloading mPolicyVisibility. Ungh.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001196 */
Craig Mautner88400d32012-09-30 12:35:45 -07001197 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001198 public boolean isVisibleOrBehindKeyguardLw() {
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001199 if (mRootToken.waitingToShow && mService.mAppTransition.isTransitionSet()) {
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -07001200 return false;
1201 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001202 final AppWindowToken atoken = mAppToken;
Filip Gruszczynski0689ae92015-10-01 12:30:31 -07001203 final boolean animating = atoken != null && atoken.mAppAnimator.animation != null;
Wale Ogunwalec48a3542016-02-19 15:18:45 -08001204 return mHasSurface && !mDestroying && !mAnimatingExit
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001205 && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested)
Wale Ogunwale9d147902016-07-16 11:58:55 -07001206 && ((!isParentWindowHidden() && mViewVisibility == View.VISIBLE && !mRootToken.hidden)
Craig Mautnera2c77052012-03-26 12:14:43 -07001207 || mWinAnimator.mAnimation != null || animating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001208 }
1209
1210 /**
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001211 * Is this window visible, ignoring its app token? It is not visible if there is no surface,
1212 * or we are in the process of running an exit animation that will remove the surface.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001213 */
1214 public boolean isWinVisibleLw() {
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001215 return (mAppToken == null || !mAppToken.hiddenRequested || mAppToken.mAppAnimator.animating)
1216 && isVisibleUnchecked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001217 }
1218
1219 /**
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001220 * The same as isVisible(), but follows the current hidden state of the associated app token,
1221 * not the pending requested hidden state.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001222 */
1223 boolean isVisibleNow() {
Wale Ogunwale329b7e52016-01-15 15:00:57 -08001224 return (!mRootToken.hidden || mAttrs.type == TYPE_APPLICATION_STARTING)
1225 && isVisibleUnchecked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001226 }
1227
1228 /**
1229 * Can this window possibly be a drag/drop target? The test here is
1230 * a combination of the above "visible now" with the check that the
1231 * Input Manager uses when discarding windows from input consideration.
1232 */
1233 boolean isPotentialDragTarget() {
Jeff Browncc4f7db2011-08-30 20:34:48 -07001234 return isVisibleNow() && !mRemoved
1235 && mInputChannel != null && mInputWindowHandle != null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001236 }
1237
1238 /**
1239 * Same as isVisible(), but we also count it as visible between the
1240 * call to IWindowSession.add() and the first relayout().
1241 */
1242 boolean isVisibleOrAdding() {
1243 final AppWindowToken atoken = mAppToken;
Craig Mautnerbf08af32012-05-16 19:43:42 -07001244 return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
Wale Ogunwale9d147902016-07-16 11:58:55 -07001245 && mPolicyVisibility && !isParentWindowHidden()
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001246 && (atoken == null || !atoken.hiddenRequested)
Wale Ogunwalec48a3542016-02-19 15:18:45 -08001247 && !mAnimatingExit && !mDestroying;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001248 }
1249
1250 /**
1251 * Is this window currently on-screen? It is on-screen either if it
1252 * is visible or it is currently running an animation before no longer
1253 * being visible.
1254 */
1255 boolean isOnScreen() {
Jorim Jaggi44f60cc2014-11-07 20:33:51 +01001256 return mPolicyVisibility && isOnScreenIgnoringKeyguard();
1257 }
1258
1259 /**
1260 * Like isOnScreen(), but ignores any force hiding of the window due
1261 * to the keyguard.
1262 */
1263 boolean isOnScreenIgnoringKeyguard() {
1264 if (!mHasSurface || mDestroying) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001265 return false;
1266 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001267 final AppWindowToken atoken = mAppToken;
1268 if (atoken != null) {
Wale Ogunwale9d147902016-07-16 11:58:55 -07001269 return ((!isParentWindowHidden() && !atoken.hiddenRequested)
Craig Mautnerccc9e9b2012-12-11 09:40:34 -08001270 || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001271 }
Wale Ogunwale9d147902016-07-16 11:58:55 -07001272 return !isParentWindowHidden() || mWinAnimator.mAnimation != null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001273 }
1274
1275 /**
Chong Zhang8e4bda92016-05-04 15:08:18 -07001276 * Whether this window's drawn state might affect the drawn states of the app token.
1277 *
1278 * @param visibleOnly Whether we should consider only the windows that's currently
1279 * visible in layout. If true, windows that has not relayout to VISIBLE
1280 * would always return false.
1281 *
1282 * @return true if the window should be considered while evaluating allDrawn flags.
1283 */
1284 boolean mightAffectAllDrawn(boolean visibleOnly) {
Chong Zhange292eb32016-05-21 09:23:55 -07001285 final boolean isViewVisible = (mAppToken == null || !mAppToken.clientHidden)
1286 && (mViewVisibility == View.VISIBLE) && !mWindowRemovalAllowed;
Chong Zhang8e4bda92016-05-04 15:08:18 -07001287 return (isOnScreenIgnoringKeyguard() && (!visibleOnly || isViewVisible)
1288 || mWinAnimator.mAttrType == TYPE_BASE_APPLICATION)
1289 && !mAnimatingExit && !mDestroying;
1290 }
1291
1292 /**
1293 * Whether this window is "interesting" when evaluating allDrawn. If it's interesting,
1294 * it must be drawn before allDrawn can become true.
1295 */
1296 boolean isInteresting() {
1297 return mAppToken != null && !mAppDied
1298 && (!mAppToken.mAppAnimator.freezingScreen || !mAppFreezing);
1299 }
1300
1301 /**
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001302 * Like isOnScreen(), but we don't return true if the window is part
1303 * of a transition that has not yet been started.
1304 */
1305 boolean isReadyForDisplay() {
Filip Gruszczynski0689ae92015-10-01 12:30:31 -07001306 if (mRootToken.waitingToShow && mService.mAppTransition.isTransitionSet()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001307 return false;
1308 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001309 return mHasSurface && mPolicyVisibility && !mDestroying
Wale Ogunwale9d147902016-07-16 11:58:55 -07001310 && ((!isParentWindowHidden() && mViewVisibility == View.VISIBLE && !mRootToken.hidden)
Craig Mautnera2c77052012-03-26 12:14:43 -07001311 || mWinAnimator.mAnimation != null
Craig Mautner59431632012-04-04 11:56:44 -07001312 || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null)));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001313 }
1314
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001315 /**
Dianne Hackborn6e2281d2012-06-19 17:48:32 -07001316 * Like isReadyForDisplay(), but ignores any force hiding of the window due
1317 * to the keyguard.
1318 */
1319 boolean isReadyForDisplayIgnoringKeyguard() {
Craig Mautner164d4bb2012-11-26 13:51:23 -08001320 if (mRootToken.waitingToShow && mService.mAppTransition.isTransitionSet()) {
Dianne Hackborn6e2281d2012-06-19 17:48:32 -07001321 return false;
1322 }
1323 final AppWindowToken atoken = mAppToken;
1324 if (atoken == null && !mPolicyVisibility) {
1325 // If this is not an app window, and the policy has asked to force
1326 // hide, then we really do want to hide.
1327 return false;
1328 }
1329 return mHasSurface && !mDestroying
Wale Ogunwale9d147902016-07-16 11:58:55 -07001330 && ((!isParentWindowHidden() && mViewVisibility == View.VISIBLE && !mRootToken.hidden)
Dianne Hackborn6e2281d2012-06-19 17:48:32 -07001331 || mWinAnimator.mAnimation != null
Craig Mautner9c5bf3b2012-06-22 15:19:13 -07001332 || ((atoken != null) && (atoken.mAppAnimator.animation != null)
1333 && !mWinAnimator.isDummyAnimation()));
Dianne Hackborn6e2281d2012-06-19 17:48:32 -07001334 }
1335
1336 /**
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001337 * Like isOnScreen, but returns false if the surface hasn't yet
1338 * been drawn.
1339 */
Craig Mautnere6f7d5052012-10-08 10:34:17 -07001340 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001341 public boolean isDisplayedLw() {
1342 final AppWindowToken atoken = mAppToken;
Craig Mautnerbf90eaa2012-03-15 11:28:53 -07001343 return isDrawnLw() && mPolicyVisibility
Wale Ogunwale9d147902016-07-16 11:58:55 -07001344 && ((!isParentWindowHidden() &&
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001345 (atoken == null || !atoken.hiddenRequested))
Craig Mautnere6f7d5052012-10-08 10:34:17 -07001346 || mWinAnimator.mAnimating
1347 || (atoken != null && atoken.mAppAnimator.animation != null));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001348 }
1349
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001350 /**
Craig Mautnerae446592012-12-06 19:05:05 -08001351 * Return true if this window or its app token is currently animating.
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001352 */
Craig Mautnere6f7d5052012-10-08 10:34:17 -07001353 @Override
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001354 public boolean isAnimatingLw() {
Craig Mautnerae446592012-12-06 19:05:05 -08001355 return mWinAnimator.mAnimation != null
1356 || (mAppToken != null && mAppToken.mAppAnimator.animation != null);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001357 }
1358
Craig Mautner812d2ca2012-09-27 15:35:34 -07001359 @Override
Dianne Hackborncfbf7de2012-01-12 14:05:03 -08001360 public boolean isGoneForLayoutLw() {
1361 final AppWindowToken atoken = mAppToken;
1362 return mViewVisibility == View.GONE
1363 || !mRelayoutCalled
1364 || (atoken == null && mRootToken.hidden)
Jorim Jaggi8fa45222016-02-19 19:54:39 -08001365 || (atoken != null && atoken.hiddenRequested)
Wale Ogunwale9d147902016-07-16 11:58:55 -07001366 || isParentWindowHidden()
Wale Ogunwalec48a3542016-02-19 15:18:45 -08001367 || (mAnimatingExit && !isAnimatingLw())
Craig Mautner0e415c62013-04-29 16:10:58 -07001368 || mDestroying;
Dianne Hackborncfbf7de2012-01-12 14:05:03 -08001369 }
1370
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001371 /**
1372 * Returns true if the window has a surface that it has drawn a
1373 * complete UI in to.
1374 */
Craig Mautnerccc9e9b2012-12-11 09:40:34 -08001375 public boolean isDrawFinishedLw() {
1376 return mHasSurface && !mDestroying &&
Wale Ogunwale9d147902016-07-16 11:58:55 -07001377 (mWinAnimator.mDrawState == COMMIT_DRAW_PENDING
1378 || mWinAnimator.mDrawState == READY_TO_SHOW
1379 || mWinAnimator.mDrawState == HAS_DRAWN);
Craig Mautnerccc9e9b2012-12-11 09:40:34 -08001380 }
1381
1382 /**
1383 * Returns true if the window has a surface that it has drawn a
1384 * complete UI in to.
1385 */
Adrian Roos76d2fe42015-07-09 14:54:08 -07001386 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001387 public boolean isDrawnLw() {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001388 return mHasSurface && !mDestroying &&
Wale Ogunwale9d147902016-07-16 11:58:55 -07001389 (mWinAnimator.mDrawState == READY_TO_SHOW
1390 || mWinAnimator.mDrawState == HAS_DRAWN);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001391 }
1392
1393 /**
1394 * Return true if the window is opaque and fully drawn. This indicates
1395 * it may obscure windows behind it.
1396 */
1397 boolean isOpaqueDrawn() {
Chong Zhang66bf071d2016-02-05 14:42:36 -08001398 // When there is keyguard, wallpaper could be placed over the secure app
1399 // window but invisible. We need to check wallpaper visibility explicitly
1400 // to determine if it's occluding apps.
1401 return ((!mIsWallpaper && mAttrs.format == PixelFormat.OPAQUE)
1402 || (mIsWallpaper && mWallpaperVisible))
Craig Mautnera2c77052012-03-26 12:14:43 -07001403 && isDrawnLw() && mWinAnimator.mAnimation == null
Craig Mautner59431632012-04-04 11:56:44 -07001404 && (mAppToken == null || mAppToken.mAppAnimator.animation == null);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001405 }
1406
1407 /**
Craig Mautner4557c082015-04-27 13:07:40 -07001408 * Return whether this window has moved. (Only makes
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001409 * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
1410 */
Craig Mautner4557c082015-04-27 13:07:40 -07001411 boolean hasMoved() {
Chong Zhangbd0d9372015-12-28 15:18:29 -08001412 return mHasSurface && (mContentChanged || mMovedByResize)
Jorim Jaggi192086e2016-03-11 17:17:03 +01001413 && !mAnimatingExit && mService.okToDisplay()
Chong Zhangbd0d9372015-12-28 15:18:29 -08001414 && (mFrame.top != mLastFrame.top || mFrame.left != mLastFrame.left)
Wale Ogunwale7ed4d372016-07-09 15:28:55 -07001415 && (!isChildWindow() || !mParentWindow.hasMoved());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001416 }
1417
Chong Zhang0abb20f2015-11-19 14:17:31 -08001418 boolean isObscuringFullscreen(final DisplayInfo displayInfo) {
1419 Task task = getTask();
1420 if (task != null && task.mStack != null && !task.mStack.isFullscreen()) {
1421 return false;
1422 }
1423 if (!isOpaqueDrawn() || !isFrameFullscreen(displayInfo)) {
1424 return false;
1425 }
1426 return true;
1427 }
1428
1429 boolean isFrameFullscreen(final DisplayInfo displayInfo) {
1430 return mFrame.left <= 0 && mFrame.top <= 0
1431 && mFrame.right >= displayInfo.appWidth && mFrame.bottom >= displayInfo.appHeight;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001432 }
1433
Craig Mautner812d2ca2012-09-27 15:35:34 -07001434 boolean isConfigChanged() {
Jorim Jaggi26c8c422016-05-09 19:57:25 -07001435 getMergedConfig(mTmpConfig);
1436
1437 // If the merged configuration is still empty, it means that we haven't issues the
1438 // configuration to the client yet and we need to return true so the configuration updates.
1439 boolean configChanged = mMergedConfiguration.equals(Configuration.EMPTY)
1440 || mTmpConfig.diff(mMergedConfiguration) != 0;
Craig Mautnere8552142012-11-07 13:55:47 -08001441
Jorim Jaggi380ecb82014-03-14 17:25:20 +01001442 if ((mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
Craig Mautnere8552142012-11-07 13:55:47 -08001443 // Retain configuration changed status until resetConfiguration called.
1444 mConfigHasChanged |= configChanged;
1445 configChanged = mConfigHasChanged;
1446 }
1447
1448 return configChanged;
Craig Mautner812d2ca2012-09-27 15:35:34 -07001449 }
1450
Jorim Jaggib72c9ad2016-04-11 18:27:58 -07001451 boolean isAdjustedForMinimizedDock() {
1452 return mAppToken != null && mAppToken.mTask != null
1453 && mAppToken.mTask.mStack.isAdjustedForMinimizedDock();
1454 }
1455
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001456 void removeLocked() {
1457 disposeInputChannel();
Craig Mautner164d4bb2012-11-26 13:51:23 -08001458
Robert Carr51a1b872015-12-08 14:03:13 -08001459 if (isChildWindow()) {
Wale Ogunwale7ed4d372016-07-09 15:28:55 -07001460 if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mParentWindow);
1461 mParentWindow.mChildWindows.remove(this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001462 }
Craig Mautner96868332012-12-04 14:29:11 -08001463 mWinAnimator.destroyDeferredSurfaceLocked();
1464 mWinAnimator.destroySurfaceLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001465 mSession.windowRemovedLocked();
1466 try {
1467 mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
1468 } catch (RuntimeException e) {
1469 // Ignore if it has already been removed (usually because
1470 // we are doing this as part of processing a death note.)
1471 }
1472 }
Jeff Browncc4f7db2011-08-30 20:34:48 -07001473
Filip Gruszczynski10a80e02015-11-06 09:21:17 -08001474 void setHasSurface(boolean hasSurface) {
1475 mHasSurface = hasSurface;
1476 }
1477
Filip Gruszczynski92e432c2015-12-15 19:17:09 -08001478 int getAnimLayerAdjustment() {
1479 if (mTargetAppToken != null) {
1480 return mTargetAppToken.mAppAnimator.animLayerAdjustment;
1481 } else if (mAppToken != null) {
1482 return mAppToken.mAppAnimator.animLayerAdjustment;
1483 } else {
1484 // Nothing is animating, so there is no animation adjustment.
1485 return 0;
1486 }
1487 }
1488
1489 void scheduleAnimationIfDimming() {
1490 if (mDisplayContent == null) {
1491 return;
1492 }
1493 final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser();
1494 if (dimLayerUser != null && mDisplayContent.mDimLayerController.isDimming(
1495 dimLayerUser, mWinAnimator)) {
1496 // Force an animation pass just to update the mDimLayer layer.
1497 mService.scheduleAnimationLocked();
1498 }
1499 }
1500
Jorim Jaggi5e6968d2016-02-19 18:02:13 -08001501 /**
1502 * Notifies this window that the corresponding task has just moved in the stack.
1503 * <p>
1504 * This is used to fix the following: If we moved in the stack, and if the last clip rect was
1505 * empty, meaning that our task was completely offscreen, we need to keep it invisible because
1506 * the actual app transition that updates the visibility is delayed by a few transactions.
1507 * Instead of messing around with the ordering and timing how transitions and transactions are
1508 * executed, we introduce this little hack which prevents this window of getting visible again
1509 * with the wrong bounds until the app transitions has started.
1510 * <p>
1511 * This method notifies the window about that we just moved in the stack so we can apply this
1512 * logic in {@link WindowStateAnimator#updateSurfaceWindowCrop}
1513 */
1514 void notifyMovedInStack() {
1515 mJustMovedInStack = true;
1516 }
1517
1518 /**
1519 * See {@link #notifyMovedInStack}.
1520 *
1521 * @return Whether we just got moved in the corresponding stack.
1522 */
1523 boolean hasJustMovedInStack() {
1524 return mJustMovedInStack;
1525 }
1526
1527 /**
1528 * Resets that we just moved in the corresponding stack. See {@link #notifyMovedInStack}.
1529 */
1530 void resetJustMovedInStack() {
1531 mJustMovedInStack = false;
1532 }
1533
Chong Zhangacf11402015-11-04 16:23:10 -08001534 private final class DeadWindowEventReceiver extends InputEventReceiver {
1535 DeadWindowEventReceiver(InputChannel inputChannel) {
1536 super(inputChannel, mService.mH.getLooper());
1537 }
1538 @Override
1539 public void onInputEvent(InputEvent event) {
1540 finishInputEvent(event, true);
1541 }
1542 }
1543 /**
1544 * Dummy event receiver for windows that died visible.
1545 */
1546 private DeadWindowEventReceiver mDeadWindowEventReceiver;
1547
Chong Zhang112eb8c2015-11-02 11:17:00 -08001548 void openInputChannel(InputChannel outInputChannel) {
Jeff Browncc4f7db2011-08-30 20:34:48 -07001549 if (mInputChannel != null) {
1550 throw new IllegalStateException("Window already has an input channel.");
1551 }
Chong Zhang112eb8c2015-11-02 11:17:00 -08001552 String name = makeInputChannelName();
1553 InputChannel[] inputChannels = InputChannel.openInputChannelPair(name);
1554 mInputChannel = inputChannels[0];
1555 mClientChannel = inputChannels[1];
1556 mInputWindowHandle.inputChannel = inputChannels[0];
1557 if (outInputChannel != null) {
1558 mClientChannel.transferTo(outInputChannel);
1559 mClientChannel.dispose();
1560 mClientChannel = null;
Chong Zhangacf11402015-11-04 16:23:10 -08001561 } else {
1562 // If the window died visible, we setup a dummy input channel, so that taps
1563 // can still detected by input monitor channel, and we can relaunch the app.
1564 // Create dummy event receiver that simply reports all events as handled.
1565 mDeadWindowEventReceiver = new DeadWindowEventReceiver(mClientChannel);
Chong Zhang112eb8c2015-11-02 11:17:00 -08001566 }
1567 mService.mInputManager.registerInputChannel(mInputChannel, mInputWindowHandle);
Jeff Browncc4f7db2011-08-30 20:34:48 -07001568 }
1569
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001570 void disposeInputChannel() {
Chong Zhangacf11402015-11-04 16:23:10 -08001571 if (mDeadWindowEventReceiver != null) {
1572 mDeadWindowEventReceiver.dispose();
1573 mDeadWindowEventReceiver = null;
1574 }
1575
1576 // unregister server channel first otherwise it complains about broken channel
1577 if (mInputChannel != null) {
1578 mService.mInputManager.unregisterInputChannel(mInputChannel);
1579 mInputChannel.dispose();
1580 mInputChannel = null;
1581 }
Chong Zhang112eb8c2015-11-02 11:17:00 -08001582 if (mClientChannel != null) {
1583 mClientChannel.dispose();
1584 mClientChannel = null;
1585 }
Jeff Browncc4f7db2011-08-30 20:34:48 -07001586 mInputWindowHandle.inputChannel = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001587 }
1588
Chong Zhang112eb8c2015-11-02 11:17:00 -08001589 void applyDimLayerIfNeeded() {
Chong Zhangeb917322015-11-10 14:05:40 -08001590 // When the app is terminated (eg. from Recents), the task might have already been
1591 // removed with the window pending removal. Don't apply dim in such cases, as there
1592 // will be no more updateDimLayer() calls, which leaves the dimlayer invalid.
1593 final AppWindowToken token = mAppToken;
1594 if (token != null && token.removed) {
1595 return;
1596 }
1597
Wale Ogunwalec48a3542016-02-19 15:18:45 -08001598 if (!mAnimatingExit && mAppDied) {
Chong Zhang112eb8c2015-11-02 11:17:00 -08001599 // If app died visible, apply a dim over the window to indicate that it's inactive
1600 mDisplayContent.mDimLayerController.applyDimAbove(getDimLayerUser(), mWinAnimator);
1601 } else if ((mAttrs.flags & FLAG_DIM_BEHIND) != 0
Robert Carr9fe459d2016-04-07 23:32:28 -07001602 && mDisplayContent != null && !mAnimatingExit && isVisibleUnchecked()) {
Chong Zhang112eb8c2015-11-02 11:17:00 -08001603 mDisplayContent.mDimLayerController.applyDimBehind(getDimLayerUser(), mWinAnimator);
Filip Gruszczynski4501d232015-09-02 13:00:02 -07001604 }
1605 }
1606
Filip Gruszczynski0689ae92015-10-01 12:30:31 -07001607 DimLayer.DimLayerUser getDimLayerUser() {
1608 Task task = getTask();
1609 if (task != null) {
1610 return task;
1611 }
1612 return getStack();
1613 }
1614
Filip Gruszczynski76cc44f2015-09-03 16:03:10 -07001615 void maybeRemoveReplacedWindow() {
Robert Carra1eb4392015-12-10 12:43:51 -08001616 if (mAppToken == null) {
1617 return;
1618 }
1619 for (int i = mAppToken.allAppWindows.size() - 1; i >= 0; i--) {
1620 final WindowState win = mAppToken.allAppWindows.get(i);
Robert Carrdcdca582016-04-07 22:59:24 -07001621 if (win.mWillReplaceWindow && win.mReplacingWindow == this && hasDrawnLw()) {
Chong Zhangbfc2f8f2016-01-29 15:50:34 -08001622 if (DEBUG_ADD_REMOVE) Slog.d(TAG, "Removing replaced window: " + win);
Robert Carr9fe459d2016-04-07 23:32:28 -07001623 if (win.isDimming()) {
1624 win.transferDimToReplacement();
1625 }
Robert Carra1eb4392015-12-10 12:43:51 -08001626 win.mWillReplaceWindow = false;
Wale Ogunwaled0a166a2016-05-09 11:18:18 -07001627 final boolean animateReplacingWindow = win.mAnimateReplacingWindow;
Robert Carra1eb4392015-12-10 12:43:51 -08001628 win.mAnimateReplacingWindow = false;
1629 win.mReplacingRemoveRequested = false;
1630 win.mReplacingWindow = null;
Robert Carrb439a632016-04-07 22:52:10 -07001631 mSkipEnterAnimationForSeamlessReplacement = false;
Wale Ogunwaled0a166a2016-05-09 11:18:18 -07001632 if (win.mAnimatingExit || !animateReplacingWindow) {
Filip Gruszczynski76cc44f2015-09-03 16:03:10 -07001633 mService.removeWindowInnerLocked(win);
1634 }
1635 }
1636 }
1637 }
1638
Filip Gruszczynskie92179d2015-09-26 16:12:30 -07001639 void setDisplayLayoutNeeded() {
1640 if (mDisplayContent != null) {
1641 mDisplayContent.layoutNeeded = true;
1642 }
1643 }
1644
Robert Carrfed10072016-05-26 11:48:49 -07001645 // TODO: Strange usage of word workspace here and above.
1646 boolean inPinnedWorkspace() {
1647 final Task task = getTask();
1648 return task != null && task.inPinnedWorkspace();
1649 }
1650
Chong Zhang5117e272016-05-03 12:47:34 -07001651 void applyAdjustForImeIfNeeded() {
1652 final Task task = getTask();
1653 if (task != null && task.mStack != null && task.mStack.isAdjustedForIme()) {
1654 task.mStack.applyAdjustForImeIfNeeded(task);
1655 }
1656 }
1657
Wale Ogunwale053c8e42015-11-16 14:27:21 -08001658 int getTouchableRegion(Region region, int flags) {
1659 final boolean modal = (flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0;
Filip Gruszczynski9cac3b42015-10-30 14:20:37 -07001660 if (modal && mAppToken != null) {
1661 // Limit the outer touch to the activity stack region.
Wale Ogunwale053c8e42015-11-16 14:27:21 -08001662 flags |= FLAG_NOT_TOUCH_MODAL;
Chong Zhang4c9ba52a2015-11-10 18:36:33 -08001663 // If this is a modal window we need to dismiss it if it's not full screen and the
1664 // touch happens outside of the frame that displays the content. This means we
1665 // need to intercept touches outside of that window. The dim layer user
1666 // associated with the window (task or stack) will give us the good bounds, as
1667 // they would be used to display the dim layer.
1668 final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser();
1669 if (dimLayerUser != null) {
1670 dimLayerUser.getDimBounds(mTmpRect);
Filip Gruszczynski9cac3b42015-10-30 14:20:37 -07001671 } else {
Chong Zhang4c9ba52a2015-11-10 18:36:33 -08001672 getVisibleBounds(mTmpRect);
1673 }
1674 if (inFreeformWorkspace()) {
Filip Gruszczynski9cac3b42015-10-30 14:20:37 -07001675 // For freeform windows we the touch region to include the whole surface for the
1676 // shadows.
Chong Zhang4c9ba52a2015-11-10 18:36:33 -08001677 final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics();
1678 final int delta = WindowManagerService.dipToPixel(
1679 RESIZE_HANDLE_WIDTH_IN_DP, displayMetrics);
1680 mTmpRect.inset(-delta, -delta);
Filip Gruszczynski9cac3b42015-10-30 14:20:37 -07001681 }
1682 region.set(mTmpRect);
Wale Ogunwale053c8e42015-11-16 14:27:21 -08001683 cropRegionToStackBoundsIfNeeded(region);
Filip Gruszczynski9cac3b42015-10-30 14:20:37 -07001684 } else {
1685 // Not modal or full screen modal
1686 getTouchableRegion(region);
1687 }
1688 return flags;
1689 }
1690
Filip Gruszczynski14b4e572015-11-03 15:53:55 -08001691 void checkPolicyVisibilityChange() {
1692 if (mPolicyVisibility != mPolicyVisibilityAfterAnim) {
1693 if (DEBUG_VISIBILITY) {
1694 Slog.v(TAG, "Policy visibility changing after anim in " +
1695 mWinAnimator + ": " + mPolicyVisibilityAfterAnim);
1696 }
1697 mPolicyVisibility = mPolicyVisibilityAfterAnim;
Filip Gruszczynski63a35e22015-11-05 15:38:59 -08001698 setDisplayLayoutNeeded();
Filip Gruszczynski14b4e572015-11-03 15:53:55 -08001699 if (!mPolicyVisibility) {
1700 if (mService.mCurrentFocus == this) {
1701 if (DEBUG_FOCUS_LIGHT) Slog.i(TAG,
1702 "setAnimationLocked: setting mFocusMayChange true");
1703 mService.mFocusMayChange = true;
1704 }
1705 // Window is no longer visible -- make sure if we were waiting
1706 // for it to be displayed before enabling the display, that
1707 // we allow the display to be enabled now.
1708 mService.enableScreenIfNeededLocked();
1709 }
1710 }
1711 }
1712
1713 void setRequestedSize(int requestedWidth, int requestedHeight) {
1714 if ((mRequestedWidth != requestedWidth || mRequestedHeight != requestedHeight)) {
1715 mLayoutNeeded = true;
1716 mRequestedWidth = requestedWidth;
1717 mRequestedHeight = requestedHeight;
1718 }
1719 }
1720
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -08001721 void prepareWindowToDisplayDuringRelayout(Configuration outConfig) {
1722 if ((mAttrs.softInputMode & SOFT_INPUT_MASK_ADJUST)
1723 == SOFT_INPUT_ADJUST_RESIZE) {
1724 mLayoutNeeded = true;
1725 }
1726 if (isDrawnLw() && mService.okToDisplay()) {
1727 mWinAnimator.applyEnterAnimationLocked();
1728 }
1729 if ((mAttrs.flags & FLAG_TURN_SCREEN_ON) != 0) {
1730 if (DEBUG_VISIBILITY) Slog.v(TAG, "Relayout window turning screen on: " + this);
1731 mTurnOnScreen = true;
1732 }
1733 if (isConfigChanged()) {
Robert Carrc24d8f92016-02-29 16:24:33 -08001734 final Configuration newConfig = updateConfiguration();
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -08001735 if (DEBUG_CONFIGURATION) Slog.i(TAG, "Window " + this + " visible with new config: "
Robert Carrc24d8f92016-02-29 16:24:33 -08001736 + newConfig);
1737 outConfig.setTo(newConfig);
Filip Gruszczynski84cc5e32015-11-03 18:05:47 -08001738 }
1739 }
1740
1741 void adjustStartingWindowFlags() {
1742 if (mAttrs.type == TYPE_BASE_APPLICATION && mAppToken != null
1743 && mAppToken.startingWindow != null) {
1744 // Special handling of starting window over the base
1745 // window of the app: propagate lock screen flags to it,
1746 // to provide the correct semantics while starting.
1747 final int mask = FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD
1748 | FLAG_ALLOW_LOCK_WHILE_SCREEN_ON;
1749 WindowManager.LayoutParams sa = mAppToken.startingWindow.mAttrs;
1750 sa.flags = (sa.flags & ~mask) | (mAttrs.flags & mask);
1751 }
1752 }
1753
1754 void setWindowScale(int requestedWidth, int requestedHeight) {
1755 final boolean scaledWindow = (mAttrs.flags & FLAG_SCALED) != 0;
1756
1757 if (scaledWindow) {
1758 // requested{Width|Height} Surface's physical size
1759 // attrs.{width|height} Size on screen
1760 // TODO: We don't check if attrs != null here. Is it implicitly checked?
1761 mHScale = (mAttrs.width != requestedWidth) ?
1762 (mAttrs.width / (float)requestedWidth) : 1.0f;
1763 mVScale = (mAttrs.height != requestedHeight) ?
1764 (mAttrs.height / (float)requestedHeight) : 1.0f;
1765 } else {
1766 mHScale = mVScale = 1;
1767 }
1768 }
1769
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001770 private class DeathRecipient implements IBinder.DeathRecipient {
Craig Mautnere8552142012-11-07 13:55:47 -08001771 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001772 public void binderDied() {
1773 try {
1774 synchronized(mService.mWindowMap) {
1775 WindowState win = mService.windowForClientLocked(mSession, mClient, false);
Craig Mautnerd87946b2012-03-29 18:00:19 -07001776 Slog.i(TAG, "WIN DEATH: " + win);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001777 if (win != null) {
Wale Ogunwalee42d0e12016-05-02 16:40:59 -07001778 mService.removeWindowLocked(win, shouldKeepVisibleDeadAppWindow());
Wale Ogunwalea9f9b372016-02-04 18:04:39 -08001779 if (win.mAttrs.type == TYPE_DOCK_DIVIDER) {
1780 // The owner of the docked divider died :( We reset the docked stack,
Jorim Jaggidcb68142016-02-09 21:51:30 -08001781 // just in case they have the divider at an unstable position. Better
1782 // also reset drag resizing state, because the owner can't do it
1783 // anymore.
Wale Ogunwalea9f9b372016-02-04 18:04:39 -08001784 final TaskStack stack = mService.mStackIdToStack.get(DOCKED_STACK_ID);
1785 if (stack != null) {
1786 stack.resetDockedStackToMiddle();
1787 }
Jorim Jaggidcb68142016-02-09 21:51:30 -08001788 mService.setDockedStackResizing(false);
Wale Ogunwalea9f9b372016-02-04 18:04:39 -08001789 }
Craig Mautnerb3b36ba2013-05-20 13:21:10 -07001790 } else if (mHasSurface) {
Craig Mautnera99764e2013-03-06 10:22:16 -08001791 Slog.e(TAG, "!!! LEAK !!! Window removed but surface still valid.");
Wale Ogunwalea6ab5c42015-04-24 09:00:25 -07001792 mService.removeWindowLocked(WindowState.this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001793 }
1794 }
1795 } catch (IllegalArgumentException ex) {
Wale Ogunwalee42d0e12016-05-02 16:40:59 -07001796 // This will happen if the window has already been removed.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001797 }
1798 }
1799 }
1800
Wale Ogunwale3fd20fe2016-01-23 17:41:28 -08001801 /**
1802 * Returns true if this window is visible and belongs to a dead app and shouldn't be removed,
1803 * because we want to preserve its location on screen to be re-activated later when the user
1804 * interacts with it.
1805 */
1806 boolean shouldKeepVisibleDeadAppWindow() {
Wale Ogunwalee42d0e12016-05-02 16:40:59 -07001807 if (!isWinVisibleLw() || mAppToken == null || mAppToken.clientHidden) {
Wale Ogunwale3fd20fe2016-01-23 17:41:28 -08001808 // Not a visible app window or the app isn't dead.
1809 return false;
1810 }
1811
Wale Ogunwale51d1d912016-05-04 13:27:18 -07001812 if (mAttrs.token != mClient.asBinder()) {
1813 // The window was add by a client using another client's app token. We don't want to
1814 // keep the dead window around for this case since this is meant for 'real' apps.
1815 return false;
1816 }
1817
Wale Ogunwale3fd20fe2016-01-23 17:41:28 -08001818 if (mAttrs.type == TYPE_APPLICATION_STARTING) {
1819 // We don't keep starting windows since they were added by the window manager before
1820 // the app even launched.
1821 return false;
1822 }
1823
1824 final TaskStack stack = getStack();
1825 return stack != null && StackId.keepVisibleDeadAppWindowOnScreen(stack.mStackId);
1826 }
1827
Wale Ogunwaled045c822015-12-02 09:14:28 -08001828 /** @return true if this window desires key events. */
1829 boolean canReceiveKeys() {
Craig Mautner58106812012-12-28 12:27:40 -08001830 return isVisibleOrAdding()
Chong Zhange292eb32016-05-21 09:23:55 -07001831 && (mViewVisibility == View.VISIBLE) && !mRemoveOnExit
Wale Ogunwaled045c822015-12-02 09:14:28 -08001832 && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0)
Jorim Jaggib72c9ad2016-04-11 18:27:58 -07001833 && (mAppToken == null || mAppToken.windowsAreFocusable())
1834 && !isAdjustedForMinimizedDock();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001835 }
1836
Craig Mautner749a7bb2012-04-02 13:49:53 -07001837 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001838 public boolean hasDrawnLw() {
Craig Mautner749a7bb2012-04-02 13:49:53 -07001839 return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001840 }
1841
Craig Mautner749a7bb2012-04-02 13:49:53 -07001842 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001843 public boolean showLw(boolean doAnimation) {
1844 return showLw(doAnimation, true);
1845 }
1846
1847 boolean showLw(boolean doAnimation, boolean requestAnim) {
Craig Mautner5962b122012-10-05 14:45:52 -07001848 if (isHiddenFromUserLocked()) {
Craig Mautner9dc52bc2012-08-06 14:15:42 -07001849 return false;
1850 }
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08001851 if (!mAppOpVisibility) {
1852 // Being hidden due to app op request.
1853 return false;
1854 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001855 if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
Craig Mautnere32c3072012-03-12 15:25:35 -07001856 // Already showing.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001857 return false;
1858 }
Craig Mautnerd87946b2012-03-29 18:00:19 -07001859 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001860 if (doAnimation) {
Craig Mautnerd87946b2012-03-29 18:00:19 -07001861 if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility="
Craig Mautnera2c77052012-03-26 12:14:43 -07001862 + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation);
Craig Mautner2fb98b12012-03-20 17:24:00 -07001863 if (!mService.okToDisplay()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001864 doAnimation = false;
Craig Mautnera2c77052012-03-26 12:14:43 -07001865 } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001866 // Check for the case where we are currently visible and
1867 // not animating; we do not want to do animation at such a
1868 // point to become visible when we already are.
1869 doAnimation = false;
1870 }
1871 }
1872 mPolicyVisibility = true;
1873 mPolicyVisibilityAfterAnim = true;
1874 if (doAnimation) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001875 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001876 }
1877 if (requestAnim) {
Craig Mautner96868332012-12-04 14:29:11 -08001878 mService.scheduleAnimationLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001879 }
1880 return true;
1881 }
1882
Dianne Hackbornf87d1962012-04-04 12:48:24 -07001883 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001884 public boolean hideLw(boolean doAnimation) {
1885 return hideLw(doAnimation, true);
1886 }
1887
1888 boolean hideLw(boolean doAnimation, boolean requestAnim) {
1889 if (doAnimation) {
Craig Mautner2fb98b12012-03-20 17:24:00 -07001890 if (!mService.okToDisplay()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001891 doAnimation = false;
1892 }
1893 }
Filip Gruszczynski19723a42015-11-25 15:01:48 -08001894 boolean current = doAnimation ? mPolicyVisibilityAfterAnim
1895 : mPolicyVisibility;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001896 if (!current) {
Craig Mautnere32c3072012-03-12 15:25:35 -07001897 // Already hiding.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001898 return false;
1899 }
1900 if (doAnimation) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001901 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false);
Craig Mautnera2c77052012-03-26 12:14:43 -07001902 if (mWinAnimator.mAnimation == null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001903 doAnimation = false;
1904 }
1905 }
Filip Gruszczynski19723a42015-11-25 15:01:48 -08001906 if (doAnimation) {
1907 mPolicyVisibilityAfterAnim = false;
1908 } else {
Craig Mautnerd87946b2012-03-29 18:00:19 -07001909 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this);
Filip Gruszczynski19723a42015-11-25 15:01:48 -08001910 mPolicyVisibilityAfterAnim = false;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001911 mPolicyVisibility = false;
1912 // Window is no longer visible -- make sure if we were waiting
1913 // for it to be displayed before enabling the display, that
1914 // we allow the display to be enabled now.
1915 mService.enableScreenIfNeededLocked();
1916 if (mService.mCurrentFocus == this) {
Filip Gruszczynski14b4e572015-11-03 15:53:55 -08001917 if (DEBUG_FOCUS_LIGHT) Slog.i(TAG,
Craig Mautner58458122013-09-14 14:59:50 -07001918 "WindowState.hideLw: setting mFocusMayChange true");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001919 mService.mFocusMayChange = true;
1920 }
1921 }
1922 if (requestAnim) {
Craig Mautner96868332012-12-04 14:29:11 -08001923 mService.scheduleAnimationLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001924 }
1925 return true;
1926 }
1927
Craig Mautnerfb32c6e2013-02-12 15:08:44 -08001928 public void setAppOpVisibilityLw(boolean state) {
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08001929 if (mAppOpVisibility != state) {
1930 mAppOpVisibility = state;
1931 if (state) {
1932 // If the policy visibility had last been to hide, then this
1933 // will incorrectly show at this point since we lost that
1934 // information. Not a big deal -- for the windows that have app
1935 // ops modifies they should only be hidden by policy due to the
1936 // lock screen, and the user won't be changing this if locked.
1937 // Plus it will quickly be fixed the next time we do a layout.
Craig Mautnerfb32c6e2013-02-12 15:08:44 -08001938 showLw(true, true);
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08001939 } else {
Craig Mautnerfb32c6e2013-02-12 15:08:44 -08001940 hideLw(true, true);
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08001941 }
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08001942 }
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08001943 }
1944
Jeff Brownc2932a12014-11-20 18:04:05 -08001945 public void pokeDrawLockLw(long timeout) {
1946 if (isVisibleOrAdding()) {
1947 if (mDrawLock == null) {
1948 // We want the tag name to be somewhat stable so that it is easier to correlate
1949 // in wake lock statistics. So in particular, we don't want to include the
1950 // window's hash code as in toString().
Wale Ogunwalecad05a02015-09-25 10:41:44 -07001951 final CharSequence tag = getWindowTag();
Jeff Brownc2932a12014-11-20 18:04:05 -08001952 mDrawLock = mService.mPowerManager.newWakeLock(
1953 PowerManager.DRAW_WAKE_LOCK, "Window:" + tag);
1954 mDrawLock.setReferenceCounted(false);
1955 mDrawLock.setWorkSource(new WorkSource(mOwnerUid, mAttrs.packageName));
1956 }
1957 // Each call to acquire resets the timeout.
1958 if (DEBUG_POWER) {
1959 Slog.d(TAG, "pokeDrawLock: poking draw lock on behalf of visible window owned by "
1960 + mAttrs.packageName);
1961 }
1962 mDrawLock.acquire(timeout);
1963 } else if (DEBUG_POWER) {
1964 Slog.d(TAG, "pokeDrawLock: suppressed draw lock request for invisible window "
1965 + "owned by " + mAttrs.packageName);
1966 }
1967 }
1968
Dianne Hackbornf87d1962012-04-04 12:48:24 -07001969 @Override
1970 public boolean isAlive() {
1971 return mClient.asBinder().isBinderAlive();
1972 }
1973
Craig Mautnera987d432012-10-11 14:07:58 -07001974 boolean isClosing() {
Wale Ogunwalec48a3542016-02-19 15:18:45 -08001975 return mAnimatingExit || (mService.mClosingApps.contains(mAppToken));
Craig Mautnera987d432012-10-11 14:07:58 -07001976 }
1977
Chong Zhangbef461f2015-10-27 11:38:24 -07001978 boolean isAnimatingWithSavedSurface() {
Chong Zhang92147042016-05-09 12:47:11 -07001979 return mAnimatingWithSavedSurface;
1980 }
1981
Chong Zhang8e4bda92016-05-04 15:08:18 -07001982 boolean isAnimatingInvisibleWithSavedSurface() {
1983 return mAnimatingWithSavedSurface
1984 && (mViewVisibility != View.VISIBLE || mWindowRemovalAllowed);
1985 }
1986
Chong Zhang92147042016-05-09 12:47:11 -07001987 public void setVisibleBeforeClientHidden() {
1988 mWasVisibleBeforeClientHidden |=
1989 (mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface);
1990 }
1991
1992 public void clearVisibleBeforeClientHidden() {
1993 mWasVisibleBeforeClientHidden = false;
1994 }
1995
1996 public boolean wasVisibleBeforeClientHidden() {
1997 return mWasVisibleBeforeClientHidden;
Chong Zhangbef461f2015-10-27 11:38:24 -07001998 }
1999
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002000 private boolean shouldSaveSurface() {
Chong Zhang6c71c0b2016-04-01 15:10:31 -07002001 if (mWinAnimator.mSurfaceController == null) {
2002 // Don't bother if the surface controller is gone for any reason.
2003 return false;
2004 }
2005
Chong Zhang92147042016-05-09 12:47:11 -07002006 if (!mWasVisibleBeforeClientHidden) {
2007 return false;
2008 }
2009
Wale Ogunwale945d1972016-03-23 13:16:41 -07002010 if ((mAttrs.flags & FLAG_SECURE) != 0) {
2011 // We don't save secure surfaces since their content shouldn't be shown while the app
2012 // isn't on screen and content might leak through during the transition animation with
2013 // saved surface.
2014 return false;
2015 }
2016
Chong Zhangdb20b5f2015-10-23 14:01:43 -07002017 if (ActivityManager.isLowRamDeviceStatic()) {
2018 // Don't save surfaces on Svelte devices.
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002019 return false;
2020 }
2021
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002022 Task task = getTask();
2023 if (task == null || task.inHomeStack()) {
Chong Zhangdb20b5f2015-10-23 14:01:43 -07002024 // Don't save surfaces for home stack apps. These usually resume and draw
2025 // first frame very fast. Saving surfaces are mostly a waste of memory.
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002026 return false;
Chong Zhangdb20b5f2015-10-23 14:01:43 -07002027 }
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002028
2029 final AppWindowToken taskTop = task.getTopVisibleAppToken();
2030 if (taskTop != null && taskTop != mAppToken) {
2031 // Don't save if the window is not the topmost window.
2032 return false;
2033 }
2034
Jorim Jaggi8fa45222016-02-19 19:54:39 -08002035 if (mResizedWhileGone) {
2036 // Somebody resized our window while we were gone for layout, which means that the
2037 // client got an old size, so we have an outdated surface here.
2038 return false;
2039 }
2040
Robert Carr7098dbd2016-02-01 12:31:01 -08002041 if (DEBUG_DISABLE_SAVING_SURFACES) {
2042 return false;
2043 }
2044
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002045 return mAppToken.shouldSaveSurface();
2046 }
2047
Chris Craik3131bde2016-05-06 13:39:08 -07002048 static final Region sEmptyRegion = new Region();
2049
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002050 void destroyOrSaveSurface() {
2051 mSurfaceSaved = shouldSaveSurface();
2052 if (mSurfaceSaved) {
2053 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
2054 Slog.v(TAG, "Saving surface: " + this);
2055 }
Chris Craik3131bde2016-05-06 13:39:08 -07002056 // Previous user of the surface may have set a transparent region signaling a portion
2057 // doesn't need to be composited, so reset to default empty state.
2058 mSession.setTransparentRegion(mClient, sEmptyRegion);
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002059
2060 mWinAnimator.hide("saved surface");
2061 mWinAnimator.mDrawState = WindowStateAnimator.NO_SURFACE;
2062 setHasSurface(false);
Chong Zhang47e36a32016-02-29 16:44:33 -08002063 // The client should have disconnected at this point, but if it doesn't,
2064 // we need to make sure it's disconnected. Otherwise when we reuse the surface
2065 // the client can't reconnect to the buffer queue, and rendering will fail.
2066 if (mWinAnimator.mSurfaceController != null) {
2067 mWinAnimator.mSurfaceController.disconnectInTransaction();
2068 }
Chong Zhang8e4bda92016-05-04 15:08:18 -07002069 mAnimatingWithSavedSurface = false;
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002070 } else {
Robert Carr13f7be9e2015-12-02 18:39:45 -08002071 mWinAnimator.destroySurfaceLocked();
2072 }
Chong Zhang92147042016-05-09 12:47:11 -07002073 // Clear animating flags now, since the surface is now gone. (Note this is true even
2074 // if the surface is saved, to outside world the surface is still NO_SURFACE.)
2075 mAnimatingExit = false;
Robert Carr13f7be9e2015-12-02 18:39:45 -08002076 }
Chong Zhangdb20b5f2015-10-23 14:01:43 -07002077
Chong Zhang92147042016-05-09 12:47:11 -07002078 void destroySavedSurface() {
Robert Carr13f7be9e2015-12-02 18:39:45 -08002079 if (mSurfaceSaved) {
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002080 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
2081 Slog.v(TAG, "Destroying saved surface: " + this);
2082 }
Robert Carr13f7be9e2015-12-02 18:39:45 -08002083 mWinAnimator.destroySurfaceLocked();
2084 }
Chong Zhang92147042016-05-09 12:47:11 -07002085 mWasVisibleBeforeClientHidden = false;
Robert Carr13f7be9e2015-12-02 18:39:45 -08002086 }
2087
Chong Zhang92147042016-05-09 12:47:11 -07002088 void restoreSavedSurface() {
Chong Zhang4113ffa2016-02-18 12:39:13 -08002089 if (!mSurfaceSaved) {
2090 return;
2091 }
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002092 mSurfaceSaved = false;
Chong Zhang6c71c0b2016-04-01 15:10:31 -07002093 if (mWinAnimator.mSurfaceController != null) {
2094 setHasSurface(true);
Wale Ogunwale9d147902016-07-16 11:58:55 -07002095 mWinAnimator.mDrawState = READY_TO_SHOW;
Chong Zhang92147042016-05-09 12:47:11 -07002096 mAnimatingWithSavedSurface = true;
Chong Zhang6c71c0b2016-04-01 15:10:31 -07002097
2098 if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
2099 Slog.v(TAG, "Restoring saved surface: " + this);
2100 }
2101 } else {
2102 // mSurfaceController shouldn't be null if mSurfaceSaved was still true at
2103 // this point. Even if we destroyed the saved surface because of rotation
2104 // or resize, mSurfaceSaved flag should have been cleared. So this is a wtf.
2105 Slog.wtf(TAG, "Failed to restore saved surface: surface gone! " + this);
Chong Zhangeb22e8e2016-01-20 19:52:22 -08002106 }
2107 }
2108
Chong Zhang92147042016-05-09 12:47:11 -07002109 boolean canRestoreSurface() {
2110 return mWasVisibleBeforeClientHidden && mSurfaceSaved;
2111 }
2112
2113 boolean hasSavedSurface() {
Robert Carr13f7be9e2015-12-02 18:39:45 -08002114 return mSurfaceSaved;
2115 }
2116
Chong Zhang92147042016-05-09 12:47:11 -07002117 void clearHasSavedSurface() {
2118 mSurfaceSaved = false;
2119 mAnimatingWithSavedSurface = false;
Chong Zhangf58631a2016-05-24 16:02:10 -07002120 if (mWasVisibleBeforeClientHidden) {
2121 mAppToken.destroySavedSurfaces();
2122 }
Chong Zhang92147042016-05-09 12:47:11 -07002123 }
2124
Chong Zhangcbbcc0f2016-05-17 20:46:58 -07002125 boolean clearAnimatingWithSavedSurface() {
Chong Zhang92147042016-05-09 12:47:11 -07002126 if (mAnimatingWithSavedSurface) {
2127 // App has drawn something to its windows, we're no longer animating with
2128 // the saved surfaces.
2129 if (DEBUG_ANIM) Slog.d(TAG,
2130 "clearAnimatingWithSavedSurface(): win=" + this);
2131 mAnimatingWithSavedSurface = false;
Chong Zhangcbbcc0f2016-05-17 20:46:58 -07002132 return true;
Chong Zhang92147042016-05-09 12:47:11 -07002133 }
Chong Zhangcbbcc0f2016-05-17 20:46:58 -07002134 return false;
Chong Zhang92147042016-05-09 12:47:11 -07002135 }
2136
Craig Mautner69b08182012-09-05 13:07:13 -07002137 @Override
2138 public boolean isDefaultDisplay() {
Craig Mautnerdf88d732014-01-27 09:21:32 -08002139 final DisplayContent displayContent = getDisplayContent();
2140 if (displayContent == null) {
2141 // Only a window that was on a non-default display can be detached from it.
2142 return false;
2143 }
Winson Chung47a3e652014-05-21 16:03:42 -07002144 return displayContent.isDefaultDisplay;
Craig Mautner69b08182012-09-05 13:07:13 -07002145 }
2146
Adrian Rooscd3884d2015-02-18 17:25:23 +01002147 @Override
2148 public boolean isDimming() {
Filip Gruszczynski0689ae92015-10-01 12:30:31 -07002149 final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser();
2150 return dimLayerUser != null && mDisplayContent != null &&
Chong Zhang112eb8c2015-11-02 11:17:00 -08002151 mDisplayContent.mDimLayerController.isDimming(dimLayerUser, mWinAnimator);
Adrian Rooscd3884d2015-02-18 17:25:23 +01002152 }
2153
Craig Mautner88400d32012-09-30 12:35:45 -07002154 public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {
2155 mShowToOwnerOnly = showToOwnerOnly;
2156 }
2157
Craig Mautner5962b122012-10-05 14:45:52 -07002158 boolean isHiddenFromUserLocked() {
Craig Mautner341220f2012-10-16 15:20:09 -07002159 // Attached windows are evaluated based on the window that they are attached to.
2160 WindowState win = this;
Robert Carr51a1b872015-12-08 14:03:13 -08002161 while (win.isChildWindow()) {
Wale Ogunwale7ed4d372016-07-09 15:28:55 -07002162 win = win.mParentWindow;
Craig Mautner341220f2012-10-16 15:20:09 -07002163 }
2164 if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
Wale Ogunwale6dfdfd62015-04-15 12:01:38 -07002165 && win.mAppToken != null && win.mAppToken.showForAllUsers) {
Jorim Jaggidbe44ac2016-04-22 19:50:13 -07002166
2167 // All window frames that are fullscreen extend above status bar, but some don't extend
2168 // below navigation bar. Thus, check for display frame for top/left and stable frame for
2169 // bottom right.
2170 if (win.mFrame.left <= win.mDisplayFrame.left
2171 && win.mFrame.top <= win.mDisplayFrame.top
2172 && win.mFrame.right >= win.mStableFrame.right
2173 && win.mFrame.bottom >= win.mStableFrame.bottom) {
Craig Mautner5962b122012-10-05 14:45:52 -07002174 // Is a fullscreen window, like the clock alarm. Show to everyone.
2175 return false;
2176 }
2177 }
2178
Craig Mautner341220f2012-10-16 15:20:09 -07002179 return win.mShowToOwnerOnly
Kenny Guy2a764942014-04-02 13:29:20 +01002180 && !mService.isCurrentProfileLocked(UserHandle.getUserId(win.mOwnerUid));
Craig Mautner9dc52bc2012-08-06 14:15:42 -07002181 }
2182
Dianne Hackbornffb3d932011-05-17 17:44:51 -07002183 private static void applyInsets(Region outRegion, Rect frame, Rect inset) {
2184 outRegion.set(
2185 frame.left + inset.left, frame.top + inset.top,
2186 frame.right - inset.right, frame.bottom - inset.bottom);
Dianne Hackborne2515ee2011-04-27 18:52:56 -04002187 }
2188
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002189 void getTouchableRegion(Region outRegion) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -07002190 final Rect frame = mFrame;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002191 switch (mTouchableInsets) {
2192 default:
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002193 case TOUCHABLE_INSETS_FRAME:
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002194 outRegion.set(frame);
2195 break;
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002196 case TOUCHABLE_INSETS_CONTENT:
Dianne Hackbornffb3d932011-05-17 17:44:51 -07002197 applyInsets(outRegion, frame, mGivenContentInsets);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002198 break;
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002199 case TOUCHABLE_INSETS_VISIBLE:
Dianne Hackbornffb3d932011-05-17 17:44:51 -07002200 applyInsets(outRegion, frame, mGivenVisibleInsets);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002201 break;
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002202 case TOUCHABLE_INSETS_REGION: {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002203 final Region givenTouchableRegion = mGivenTouchableRegion;
2204 outRegion.set(givenTouchableRegion);
2205 outRegion.translate(frame.left, frame.top);
2206 break;
2207 }
2208 }
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002209 cropRegionToStackBoundsIfNeeded(outRegion);
2210 }
2211
2212 void cropRegionToStackBoundsIfNeeded(Region region) {
Wale Ogunwaleb1faf602016-01-27 09:12:31 -08002213 final Task task = getTask();
2214 if (task == null || !task.cropWindowsToStackBounds()) {
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002215 return;
2216 }
2217
Wale Ogunwaleb1faf602016-01-27 09:12:31 -08002218 final TaskStack stack = task.mStack;
Wale Ogunwale053c8e42015-11-16 14:27:21 -08002219 if (stack == null) {
2220 return;
2221 }
2222
2223 stack.getDimBounds(mTmpRect);
2224 region.op(mTmpRect, Region.Op.INTERSECT);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002225 }
2226
Craig Mautner59c00972012-07-30 12:10:24 -07002227 WindowList getWindowList() {
Craig Mautnerdf88d732014-01-27 09:21:32 -08002228 final DisplayContent displayContent = getDisplayContent();
2229 return displayContent == null ? null : displayContent.getWindowList();
Craig Mautner59c00972012-07-30 12:10:24 -07002230 }
2231
Dianne Hackborne3f23a32013-03-01 13:25:35 -08002232 /**
2233 * Report a focus change. Must be called with no locks held, and consistently
2234 * from the same serialized thread (such as dispatched from a handler).
2235 */
2236 public void reportFocusChangedSerialized(boolean focused, boolean inTouchMode) {
2237 try {
2238 mClient.windowFocusChanged(focused, inTouchMode);
2239 } catch (RemoteException e) {
2240 }
2241 if (mFocusCallbacks != null) {
2242 final int N = mFocusCallbacks.beginBroadcast();
2243 for (int i=0; i<N; i++) {
2244 IWindowFocusObserver obs = mFocusCallbacks.getBroadcastItem(i);
2245 try {
2246 if (focused) {
2247 obs.focusGained(mWindowId.asBinder());
2248 } else {
2249 obs.focusLost(mWindowId.asBinder());
2250 }
2251 } catch (RemoteException e) {
2252 }
2253 }
2254 mFocusCallbacks.finishBroadcast();
2255 }
2256 }
2257
Robert Carrc24d8f92016-02-29 16:24:33 -08002258 /**
2259 * Update our current configurations, based on task configuration.
2260 *
2261 * @return A configuration suitable for sending to the client.
2262 */
2263 private Configuration updateConfiguration() {
Robert Carrc24d8f92016-02-29 16:24:33 -08002264 final boolean configChanged = isConfigChanged();
Jorim Jaggi26c8c422016-05-09 19:57:25 -07002265 getMergedConfig(mMergedConfiguration);
2266 mConfigHasChanged = false;
Robert Carrc24d8f92016-02-29 16:24:33 -08002267 if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION) && configChanged) {
2268 Slog.i(TAG, "Sending new config to window " + this + ": " +
Jorim Jaggi26c8c422016-05-09 19:57:25 -07002269 " / mergedConfig=" + mMergedConfiguration);
Robert Carrc24d8f92016-02-29 16:24:33 -08002270 }
Robert Carrc24d8f92016-02-29 16:24:33 -08002271 return mMergedConfiguration;
2272 }
2273
Jorim Jaggi26c8c422016-05-09 19:57:25 -07002274 private void getMergedConfig(Configuration outConfig) {
2275 if (mAppToken != null && mAppToken.mFrozenMergedConfig.size() > 0) {
2276 outConfig.setTo(mAppToken.mFrozenMergedConfig.peek());
2277 return;
2278 }
2279 final Task task = getTask();
2280 final Configuration overrideConfig = task != null
2281 ? task.mOverrideConfig
2282 : Configuration.EMPTY;
2283 final Configuration serviceConfig = mService.mCurConfiguration;
2284 outConfig.setTo(serviceConfig);
2285 if (overrideConfig != Configuration.EMPTY) {
2286 outConfig.updateFrom(overrideConfig);
2287 }
2288 }
2289
Craig Mautnerdf88d732014-01-27 09:21:32 -08002290 void reportResized() {
Wale Ogunwalecad05a02015-09-25 10:41:44 -07002291 Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "wm.reportResized_" + getWindowTag());
Craig Mautnerdf88d732014-01-27 09:21:32 -08002292 try {
Craig Mautnerd1c2c542014-02-06 10:31:41 -08002293 if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG, "Reporting new frame to " + this
2294 + ": " + mCompatFrame);
Robert Carrc24d8f92016-02-29 16:24:33 -08002295 final Configuration newConfig = isConfigChanged() ? updateConfiguration() : null;
Craig Mautnerd1c2c542014-02-06 10:31:41 -08002296 if (DEBUG_ORIENTATION && mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING)
2297 Slog.i(TAG, "Resizing " + this + " WITH DRAW PENDING");
2298
Craig Mautnerdf88d732014-01-27 09:21:32 -08002299 final Rect frame = mFrame;
2300 final Rect overscanInsets = mLastOverscanInsets;
2301 final Rect contentInsets = mLastContentInsets;
2302 final Rect visibleInsets = mLastVisibleInsets;
Adrian Roosfa104232014-06-20 16:10:14 -07002303 final Rect stableInsets = mLastStableInsets;
Filip Gruszczynski2217f612015-05-26 11:32:08 -07002304 final Rect outsets = mLastOutsets;
Craig Mautnerd1c2c542014-02-06 10:31:41 -08002305 final boolean reportDraw = mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING;
Chet Haase8eb48d22014-09-24 07:31:29 -07002306 if (mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_STARTING
2307 && mClient instanceof IWindow.Stub) {
Craig Mautnerdf88d732014-01-27 09:21:32 -08002308 // To prevent deadlock simulate one-way call if win.mClient is a local object.
2309 mService.mH.post(new Runnable() {
2310 @Override
2311 public void run() {
2312 try {
Jorim Jaggi253a20f2015-11-03 12:38:42 +01002313 dispatchResized(frame, overscanInsets, contentInsets, visibleInsets,
2314 stableInsets, outsets, reportDraw, newConfig);
Craig Mautnerdf88d732014-01-27 09:21:32 -08002315 } catch (RemoteException e) {
2316 // Not a remote call, RemoteException won't be raised.
2317 }
2318 }
2319 });
2320 } else {
Jorim Jaggi253a20f2015-11-03 12:38:42 +01002321 dispatchResized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets,
Filip Gruszczynski2217f612015-05-26 11:32:08 -07002322 outsets, reportDraw, newConfig);
Craig Mautnerdf88d732014-01-27 09:21:32 -08002323 }
Svetoslav4604abc2014-06-10 18:59:30 -07002324
2325 //TODO (multidisplay): Accessibility supported only for the default display.
2326 if (mService.mAccessibilityController != null
2327 && getDisplayId() == Display.DEFAULT_DISPLAY) {
Svetoslavf7174e82014-06-12 11:29:35 -07002328 mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
Svetoslav4604abc2014-06-10 18:59:30 -07002329 }
2330
Craig Mautnerdf88d732014-01-27 09:21:32 -08002331 mOverscanInsetsChanged = false;
2332 mContentInsetsChanged = false;
2333 mVisibleInsetsChanged = false;
Adrian Roosfa104232014-06-20 16:10:14 -07002334 mStableInsetsChanged = false;
Filip Gruszczynski2217f612015-05-26 11:32:08 -07002335 mOutsetsChanged = false;
Andrii Kulianeb1d3222016-05-16 15:17:55 -07002336 mResizedWhileNotDragResizingReported = true;
Craig Mautnerdf88d732014-01-27 09:21:32 -08002337 mWinAnimator.mSurfaceResized = false;
2338 } catch (RemoteException e) {
2339 mOrientationChanging = false;
2340 mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
2341 - mService.mDisplayFreezeTime);
tiger_huang950ee772014-07-11 18:41:48 +08002342 // We are assuming the hosting process is dead or in a zombie state.
2343 Slog.w(TAG, "Failed to report 'resized' to the client of " + this
2344 + ", removing this window.");
2345 mService.mPendingRemove.add(this);
Filip Gruszczynski24966d42015-09-05 15:00:00 -07002346 mService.mWindowPlacerLocked.requestTraversal();
Craig Mautnerdf88d732014-01-27 09:21:32 -08002347 }
Wale Ogunwalecad05a02015-09-25 10:41:44 -07002348 Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
Craig Mautnerdf88d732014-01-27 09:21:32 -08002349 }
2350
Jorim Jaggi2e95a482016-01-14 17:36:55 -08002351 Rect getBackdropFrame(Rect frame) {
Chong Zhangd153c4f2015-11-06 20:26:40 -08002352 // When the task is docked, we send fullscreen sized backDropFrame as soon as resizing
2353 // start even if we haven't received the relayout window, so that the client requests
2354 // the relayout sooner. When dragging stops, backDropFrame needs to stay fullscreen
2355 // until the window to small size, otherwise the multithread renderer will shift last
2356 // one or more frame to wrong offset. So here we send fullscreen backdrop if either
2357 // isDragResizing() or isDragResizeChanged() is true.
Filip Gruszczynski84fa3352016-01-25 16:28:49 -08002358 boolean resizing = isDragResizing() || isDragResizeChanged();
2359 if (StackId.useWindowFrameForBackdrop(getStackId()) || !resizing) {
2360 return frame;
2361 }
Jorim Jaggi2e95a482016-01-14 17:36:55 -08002362 DisplayInfo displayInfo = getDisplayInfo();
2363 mTmpRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
Filip Gruszczynski84fa3352016-01-25 16:28:49 -08002364 return mTmpRect;
2365 }
2366
Jorim Jaggi86905582016-02-09 21:36:09 -08002367 @Override
2368 public int getStackId() {
Filip Gruszczynski84fa3352016-01-25 16:28:49 -08002369 final TaskStack stack = getStack();
2370 if (stack == null) {
2371 return INVALID_STACK_ID;
2372 }
2373 return stack.mStackId;
Jorim Jaggi2e95a482016-01-14 17:36:55 -08002374 }
2375
2376 private void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets,
2377 Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
2378 Configuration newConfig) throws RemoteException {
Chong Zhangedaf3052016-04-22 15:04:31 -07002379 final boolean forceRelayout = isDragResizeChanged() || mResizedWhileNotDragResizing;
2380
Jorim Jaggidc249c42015-12-15 14:57:31 -08002381 mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets, outsets,
Jorim Jaggia4a58ef2016-01-27 02:10:08 -08002382 reportDraw, newConfig, getBackdropFrame(frame),
Chong Zhangedaf3052016-04-22 15:04:31 -07002383 forceRelayout, mPolicy.isNavBarForcedShownLw(this));
Jorim Jaggic662d8e2016-02-05 16:54:54 -08002384 mDragResizingChangeReported = true;
Jorim Jaggi253a20f2015-11-03 12:38:42 +01002385 }
2386
Dianne Hackborne3f23a32013-03-01 13:25:35 -08002387 public void registerFocusObserver(IWindowFocusObserver observer) {
2388 synchronized(mService.mWindowMap) {
2389 if (mFocusCallbacks == null) {
2390 mFocusCallbacks = new RemoteCallbackList<IWindowFocusObserver>();
2391 }
2392 mFocusCallbacks.register(observer);
2393 }
2394 }
2395
2396 public void unregisterFocusObserver(IWindowFocusObserver observer) {
2397 synchronized(mService.mWindowMap) {
2398 if (mFocusCallbacks != null) {
2399 mFocusCallbacks.unregister(observer);
2400 }
2401 }
2402 }
2403
2404 public boolean isFocused() {
2405 synchronized(mService.mWindowMap) {
2406 return mService.mCurrentFocus == this;
2407 }
2408 }
2409
Filip Gruszczynski1a1d8312015-08-26 17:00:47 -07002410 boolean inFreeformWorkspace() {
Wale Ogunwale5a2f2cb2015-09-17 12:31:55 -07002411 final Task task = getTask();
Chong Zhang09b21ef2015-09-14 10:20:21 -07002412 return task != null && task.inFreeformWorkspace();
2413 }
2414
Wale Ogunwale9185fb02016-03-11 18:06:14 -08002415 @Override
Andrii Kulian933076d2016-03-29 17:04:42 -07002416 public boolean isInMultiWindowMode() {
Wale Ogunwale9185fb02016-03-11 18:06:14 -08002417 final Task task = getTask();
2418 return task != null && !task.isFullscreen();
2419 }
2420
Chong Zhang3005e752015-09-18 18:46:28 -07002421 boolean isDragResizeChanged() {
Filip Gruszczynski3ddc5d62015-09-23 15:01:30 -07002422 return mDragResizing != computeDragResizing();
2423 }
2424
Jorim Jaggic662d8e2016-02-05 16:54:54 -08002425 /**
2426 * @return Whether we reported a drag resize change to the application or not already.
2427 */
2428 boolean isDragResizingChangeReported() {
2429 return mDragResizingChangeReported;
2430 }
2431
2432 /**
2433 * Resets the state whether we reported a drag resize change to the app.
2434 */
2435 void resetDragResizingChangeReported() {
2436 mDragResizingChangeReported = false;
2437 }
2438
Andrii Kulianeb1d3222016-05-16 15:17:55 -07002439 /**
2440 * Set whether we got resized but drag resizing flag was false.
2441 * @see #isResizedWhileNotDragResizing().
2442 */
2443 void setResizedWhileNotDragResizing(boolean resizedWhileNotDragResizing) {
2444 mResizedWhileNotDragResizing = resizedWhileNotDragResizing;
2445 mResizedWhileNotDragResizingReported = !resizedWhileNotDragResizing;
2446 }
2447
2448 /**
2449 * Indicates whether we got resized but drag resizing flag was false. In this case, we also
2450 * need to recreate the surface and defer surface bound updates in order to make sure the
2451 * buffer contents and the positioning/size stay in sync.
2452 */
2453 boolean isResizedWhileNotDragResizing() {
2454 return mResizedWhileNotDragResizing;
2455 }
2456
2457 /**
2458 * @return Whether we reported "resize while not drag resizing" to the application.
2459 * @see #isResizedWhileNotDragResizing()
2460 */
2461 boolean isResizedWhileNotDragResizingReported() {
2462 return mResizedWhileNotDragResizingReported;
2463 }
2464
Jorim Jaggidcf467c2015-11-05 13:59:32 +01002465 int getResizeMode() {
2466 return mResizeMode;
2467 }
2468
Jorim Jaggi192086e2016-03-11 17:17:03 +01002469 boolean computeDragResizing() {
Wale Ogunwale5a2f2cb2015-09-17 12:31:55 -07002470 final Task task = getTask();
Filip Gruszczynski3ddc5d62015-09-23 15:01:30 -07002471 if (task == null) {
2472 return false;
2473 }
Jorim Jaggidd6e4c12016-02-17 22:13:43 -08002474 if (mAttrs.width != MATCH_PARENT || mAttrs.height != MATCH_PARENT) {
2475
2476 // Floating windows never enter drag resize mode.
2477 return false;
2478 }
Filip Gruszczynski3ddc5d62015-09-23 15:01:30 -07002479 if (task.isDragResizing()) {
2480 return true;
2481 }
Jorim Jaggi0429f352015-12-22 16:29:16 +01002482
2483 // If the bounds are currently frozen, it means that the layout size that the app sees
2484 // and the bounds we clip this window to might be different. In order to avoid holes, we
2485 // simulate that we are still resizing so the app fills the hole with the resizing
2486 // background.
2487 return (mDisplayContent.mDividerControllerLocked.isResizing()
2488 || mAppToken != null && !mAppToken.mFrozenBounds.isEmpty()) &&
Jorim Jaggi899327f2016-02-25 20:44:18 -05002489 !task.inFreeformWorkspace() && !isGoneForLayoutLw();
Jorim Jaggi9511b0f2016-01-29 19:12:44 -08002490
Chong Zhang3005e752015-09-18 18:46:28 -07002491 }
2492
2493 void setDragResizing() {
Jorim Jaggic662d8e2016-02-05 16:54:54 -08002494 final boolean resizing = computeDragResizing();
2495 if (resizing == mDragResizing) {
2496 return;
2497 }
2498 mDragResizing = resizing;
Jorim Jaggi0b46f3c2016-03-14 12:21:37 +01002499 final Task task = getTask();
2500 if (task != null && task.isDragResizing()) {
2501 mResizeMode = task.getDragResizeMode();
2502 } else {
2503 mResizeMode = mDragResizing && mDisplayContent.mDividerControllerLocked.isResizing()
2504 ? DRAG_RESIZE_MODE_DOCKED_DIVIDER
2505 : DRAG_RESIZE_MODE_FREEFORM;
2506 }
Chong Zhang3005e752015-09-18 18:46:28 -07002507 }
2508
2509 boolean isDragResizing() {
2510 return mDragResizing;
Skuhnef932e562015-08-20 12:07:30 -07002511 }
2512
Robert Carr2487ce72016-04-07 15:18:45 -07002513 boolean isDockedResizing() {
2514 return mDragResizing && getResizeMode() == DRAG_RESIZE_MODE_DOCKED_DIVIDER;
2515 }
2516
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002517 void dump(PrintWriter pw, String prefix, boolean dumpAll) {
Wale Ogunwale30cc7bf2015-02-04 16:47:57 -08002518 final TaskStack stack = getStack();
Craig Mautnerdf88d732014-01-27 09:21:32 -08002519 pw.print(prefix); pw.print("mDisplayId="); pw.print(getDisplayId());
Wale Ogunwale30cc7bf2015-02-04 16:47:57 -08002520 if (stack != null) {
2521 pw.print(" stackId="); pw.print(stack.mStackId);
2522 }
Wale Ogunwale4c5aa5172016-04-19 11:29:05 -07002523 if (mNotOnAppsDisplay) {
2524 pw.print(" mNotOnAppsDisplay="); pw.print(mNotOnAppsDisplay);
2525 }
Craig Mautner59c00972012-07-30 12:10:24 -07002526 pw.print(" mSession="); pw.print(mSession);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002527 pw.print(" mClient="); pw.println(mClient.asBinder());
Craig Mautner88400d32012-09-30 12:35:45 -07002528 pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid);
Dianne Hackbornc2293022013-02-06 23:14:49 -08002529 pw.print(" mShowToOwnerOnly="); pw.print(mShowToOwnerOnly);
2530 pw.print(" package="); pw.print(mAttrs.packageName);
2531 pw.print(" appop="); pw.println(AppOpsManager.opToName(mAppOp));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002532 pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002533 pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth);
2534 pw.print(" h="); pw.print(mRequestedHeight);
2535 pw.print(" mLayoutSeq="); pw.println(mLayoutSeq);
Dianne Hackborn1743b642012-03-12 17:04:43 -07002536 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
2537 pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth);
2538 pw.print(" h="); pw.println(mLastRequestedHeight);
2539 }
Robert Carr51a1b872015-12-08 14:03:13 -08002540 if (isChildWindow() || mLayoutAttached) {
Wale Ogunwale7ed4d372016-07-09 15:28:55 -07002541 pw.print(prefix); pw.print("mParentWindow="); pw.print(mParentWindow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002542 pw.print(" mLayoutAttached="); pw.println(mLayoutAttached);
2543 }
2544 if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) {
2545 pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow);
2546 pw.print(" mIsWallpaper="); pw.print(mIsWallpaper);
2547 pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer);
2548 pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible);
2549 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002550 if (dumpAll) {
2551 pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer);
2552 pw.print(" mSubLayer="); pw.print(mSubLayer);
2553 pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+");
Craig Mautner59431632012-04-04 11:56:44 -07002554 pw.print((mTargetAppToken != null ?
2555 mTargetAppToken.mAppAnimator.animLayerAdjustment
2556 : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0)));
Craig Mautnerc2f9be02012-03-27 17:32:29 -07002557 pw.print("="); pw.print(mWinAnimator.mAnimLayer);
2558 pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer);
Dianne Hackborn6d05fd32011-11-19 14:36:15 -08002559 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002560 if (dumpAll) {
2561 pw.print(prefix); pw.print("mToken="); pw.println(mToken);
2562 pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
2563 if (mAppToken != null) {
Wale Ogunwale6bab4cf2016-04-07 12:23:08 -07002564 pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken);
2565 pw.print(prefix); pw.print(" isAnimatingWithSavedSurface()=");
Chong Zhangbfc2f8f2016-01-29 15:50:34 -08002566 pw.print(isAnimatingWithSavedSurface());
Chong Zhang112eb8c2015-11-02 11:17:00 -08002567 pw.print(" mAppDied=");pw.println(mAppDied);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002568 }
2569 if (mTargetAppToken != null) {
2570 pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken);
2571 }
2572 pw.print(prefix); pw.print("mViewVisibility=0x");
2573 pw.print(Integer.toHexString(mViewVisibility));
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002574 pw.print(" mHaveFrame="); pw.print(mHaveFrame);
2575 pw.print(" mObscured="); pw.println(mObscured);
Dianne Hackborn9a230e02011-10-06 11:51:27 -07002576 pw.print(prefix); pw.print("mSeq="); pw.print(mSeq);
2577 pw.print(" mSystemUiVisibility=0x");
2578 pw.println(Integer.toHexString(mSystemUiVisibility));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002579 }
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08002580 if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || !mAppOpVisibility
Wale Ogunwale9d147902016-07-16 11:58:55 -07002581 || isParentWindowHidden()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002582 pw.print(prefix); pw.print("mPolicyVisibility=");
2583 pw.print(mPolicyVisibility);
2584 pw.print(" mPolicyVisibilityAfterAnim=");
2585 pw.print(mPolicyVisibilityAfterAnim);
Dianne Hackbornb6b23ec2013-02-11 19:29:06 -08002586 pw.print(" mAppOpVisibility=");
2587 pw.print(mAppOpVisibility);
Wale Ogunwale9d147902016-07-16 11:58:55 -07002588 pw.print(" parentHidden="); pw.println(isParentWindowHidden());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002589 }
Dianne Hackbornb7ff51b2012-01-23 19:15:27 -08002590 if (!mRelayoutCalled || mLayoutNeeded) {
2591 pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled);
2592 pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002593 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002594 if (mXOffset != 0 || mYOffset != 0) {
2595 pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset);
2596 pw.print(" y="); pw.println(mYOffset);
2597 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002598 if (dumpAll) {
2599 pw.print(prefix); pw.print("mGivenContentInsets=");
2600 mGivenContentInsets.printShortString(pw);
2601 pw.print(" mGivenVisibleInsets=");
2602 mGivenVisibleInsets.printShortString(pw);
2603 pw.println();
2604 if (mTouchableInsets != 0 || mGivenInsetsPending) {
2605 pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets);
2606 pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending);
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -07002607 Region region = new Region();
2608 getTouchableRegion(region);
2609 pw.print(prefix); pw.print("touchable region="); pw.println(region);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002610 }
Jorim Jaggi26c8c422016-05-09 19:57:25 -07002611 pw.print(prefix); pw.print("mMergedConfiguration="); pw.println(mMergedConfiguration);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002612 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07002613 pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07002614 pw.print(" mShownPosition="); mShownPosition.printShortString(pw);
Chong Zhanga8975bd2016-01-28 17:13:47 -08002615 pw.print(" isReadyForDisplay()="); pw.print(isReadyForDisplay());
Wale Ogunwale9017ec02016-02-25 08:55:25 -08002616 pw.print(" hasSavedSurface()="); pw.print(hasSavedSurface());
2617 pw.print(" mWindowRemovalAllowed="); pw.println(mWindowRemovalAllowed);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002618 if (dumpAll) {
2619 pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
2620 pw.print(" last="); mLastFrame.printShortString(pw);
2621 pw.println();
2622 }
Dianne Hackbornffb3d932011-05-17 17:44:51 -07002623 if (mEnforceSizeCompat) {
2624 pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
Dianne Hackbornffb3d932011-05-17 17:44:51 -07002625 pw.println();
2626 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002627 if (dumpAll) {
Dianne Hackborn5c58de32012-04-28 19:52:37 -07002628 pw.print(prefix); pw.print("Frames: containing=");
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002629 mContainingFrame.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07002630 pw.print(" parent="); mParentFrame.printShortString(pw);
Dianne Hackbornc4aad012013-02-22 15:05:25 -08002631 pw.println();
2632 pw.print(prefix); pw.print(" display="); mDisplayFrame.printShortString(pw);
2633 pw.print(" overscan="); mOverscanFrame.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002634 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07002635 pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07002636 pw.print(" visible="); mVisibleFrame.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002637 pw.println();
John Spurlock46646232013-09-30 22:32:42 -04002638 pw.print(prefix); pw.print(" decor="); mDecorFrame.printShortString(pw);
2639 pw.println();
Filip Gruszczynski2217f612015-05-26 11:32:08 -07002640 pw.print(prefix); pw.print(" outset="); mOutsetFrame.printShortString(pw);
2641 pw.println();
Dianne Hackbornc4aad012013-02-22 15:05:25 -08002642 pw.print(prefix); pw.print("Cur insets: overscan=");
2643 mOverscanInsets.printShortString(pw);
2644 pw.print(" content="); mContentInsets.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07002645 pw.print(" visible="); mVisibleInsets.printShortString(pw);
Adrian Roosfa104232014-06-20 16:10:14 -07002646 pw.print(" stable="); mStableInsets.printShortString(pw);
Wale Ogunwale6bab4cf2016-04-07 12:23:08 -07002647 pw.print(" surface="); mAttrs.surfaceInsets.printShortString(pw);
Filip Gruszczynski2217f612015-05-26 11:32:08 -07002648 pw.print(" outsets="); mOutsets.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07002649 pw.println();
Dianne Hackbornc4aad012013-02-22 15:05:25 -08002650 pw.print(prefix); pw.print("Lst insets: overscan=");
2651 mLastOverscanInsets.printShortString(pw);
2652 pw.print(" content="); mLastContentInsets.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07002653 pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
Adrian Roosfa104232014-06-20 16:10:14 -07002654 pw.print(" stable="); mLastStableInsets.printShortString(pw);
Filip Gruszczynski2217f612015-05-26 11:32:08 -07002655 pw.print(" physical="); mLastOutsets.printShortString(pw);
2656 pw.print(" outset="); mLastOutsets.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07002657 pw.println();
2658 }
Dianne Hackborn529e7442012-11-01 14:22:28 -07002659 pw.print(prefix); pw.print(mWinAnimator); pw.println(":");
2660 mWinAnimator.dump(pw, prefix + " ", dumpAll);
Wale Ogunwalec48a3542016-02-19 15:18:45 -08002661 if (mAnimatingExit || mRemoveOnExit || mDestroying || mRemoved) {
2662 pw.print(prefix); pw.print("mAnimatingExit="); pw.print(mAnimatingExit);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002663 pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit);
2664 pw.print(" mDestroying="); pw.print(mDestroying);
2665 pw.print(" mRemoved="); pw.println(mRemoved);
2666 }
2667 if (mOrientationChanging || mAppFreezing || mTurnOnScreen) {
2668 pw.print(prefix); pw.print("mOrientationChanging=");
2669 pw.print(mOrientationChanging);
2670 pw.print(" mAppFreezing="); pw.print(mAppFreezing);
2671 pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen);
2672 }
Dianne Hackborna57c6952013-03-29 14:46:40 -07002673 if (mLastFreezeDuration != 0) {
2674 pw.print(prefix); pw.print("mLastFreezeDuration=");
2675 TimeUtils.formatDuration(mLastFreezeDuration, pw); pw.println();
2676 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002677 if (mHScale != 1 || mVScale != 1) {
2678 pw.print(prefix); pw.print("mHScale="); pw.print(mHScale);
2679 pw.print(" mVScale="); pw.println(mVScale);
2680 }
2681 if (mWallpaperX != -1 || mWallpaperY != -1) {
2682 pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX);
2683 pw.print(" mWallpaperY="); pw.println(mWallpaperY);
2684 }
2685 if (mWallpaperXStep != -1 || mWallpaperYStep != -1) {
2686 pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep);
2687 pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep);
2688 }
Dianne Hackborn067e5f62014-09-07 23:14:30 -07002689 if (mWallpaperDisplayOffsetX != Integer.MIN_VALUE
2690 || mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
2691 pw.print(prefix); pw.print("mWallpaperDisplayOffsetX=");
2692 pw.print(mWallpaperDisplayOffsetX);
2693 pw.print(" mWallpaperDisplayOffsetY=");
2694 pw.println(mWallpaperDisplayOffsetY);
2695 }
Jeff Brownc2932a12014-11-20 18:04:05 -08002696 if (mDrawLock != null) {
Wale Ogunwale85b90ab2015-04-27 20:54:47 -07002697 pw.print(prefix); pw.println("mDrawLock=" + mDrawLock);
Jeff Brownc2932a12014-11-20 18:04:05 -08002698 }
Jorim Jaggi9511b0f2016-01-29 19:12:44 -08002699 if (isDragResizing()) {
2700 pw.print(prefix); pw.println("isDragResizing=" + isDragResizing());
2701 }
2702 if (computeDragResizing()) {
2703 pw.print(prefix); pw.println("computeDragResizing=" + computeDragResizing());
2704 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002705 }
Craig Mautner164d4bb2012-11-26 13:51:23 -08002706
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002707 String makeInputChannelName() {
2708 return Integer.toHexString(System.identityHashCode(this))
Wale Ogunwalecad05a02015-09-25 10:41:44 -07002709 + " " + getWindowTag();
2710 }
2711
Robert Carra1eb4392015-12-10 12:43:51 -08002712 CharSequence getWindowTag() {
Wale Ogunwalecad05a02015-09-25 10:41:44 -07002713 CharSequence tag = mAttrs.getTitle();
2714 if (tag == null || tag.length() <= 0) {
2715 tag = mAttrs.packageName;
2716 }
2717 return tag;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002718 }
2719
2720 @Override
2721 public String toString() {
Wale Ogunwalecad05a02015-09-25 10:41:44 -07002722 final CharSequence title = getWindowTag();
Wale Ogunwalec48a3542016-02-19 15:18:45 -08002723 if (mStringNameCache == null || mLastTitle != title || mWasExiting != mAnimatingExit) {
Dianne Hackbornc2293022013-02-06 23:14:49 -08002724 mLastTitle = title;
Wale Ogunwalec48a3542016-02-19 15:18:45 -08002725 mWasExiting = mAnimatingExit;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002726 mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -07002727 + " u" + UserHandle.getUserId(mSession.mUid)
Wale Ogunwalec48a3542016-02-19 15:18:45 -08002728 + " " + mLastTitle + (mAnimatingExit ? " EXITING}" : "}");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08002729 }
2730 return mStringNameCache;
2731 }
Robert Carr58f29132015-10-29 14:19:05 -07002732
Chia-I Wue6bcaf12016-05-27 10:58:48 +08002733 void transformClipRectFromScreenToSurfaceSpace(Rect clipRect) {
Robert Carr58f29132015-10-29 14:19:05 -07002734 if (mHScale >= 0) {
Chia-I Wue6bcaf12016-05-27 10:58:48 +08002735 clipRect.left = (int) (clipRect.left / mHScale);
2736 clipRect.right = (int) Math.ceil(clipRect.right / mHScale);
Robert Carr58f29132015-10-29 14:19:05 -07002737 }
2738 if (mVScale >= 0) {
Chia-I Wue6bcaf12016-05-27 10:58:48 +08002739 clipRect.top = (int) (clipRect.top / mVScale);
2740 clipRect.bottom = (int) Math.ceil(clipRect.bottom / mVScale);
Robert Carr58f29132015-10-29 14:19:05 -07002741 }
2742 }
Robert Carr31e28482015-12-02 16:53:18 -08002743
Jorim Jaggif5834272016-04-04 20:25:41 -07002744 void applyGravityAndUpdateFrame(Rect containingFrame, Rect displayFrame) {
2745 final int pw = containingFrame.width();
2746 final int ph = containingFrame.height();
Robert Carr31e28482015-12-02 16:53:18 -08002747 final Task task = getTask();
Andrii Kulian933076d2016-03-29 17:04:42 -07002748 final boolean nonFullscreenTask = isInMultiWindowMode();
Jorim Jaggi5f23a572016-04-22 15:05:50 -07002749 final boolean noLimits = (mAttrs.flags & FLAG_LAYOUT_NO_LIMITS) != 0;
2750
2751 // We need to fit it to the display if either
2752 // a) The task is fullscreen, or we don't have a task (we assume fullscreen for the taskless
2753 // windows)
2754 // b) If it's a child window, we also need to fit it to the display unless
2755 // FLAG_LAYOUT_NO_LIMITS is set. This is so we place Popup and similar windows on screen,
2756 // but SurfaceViews want to be always at a specific location so we don't fit it to the
2757 // display.
2758 final boolean fitToDisplay = (task == null || !nonFullscreenTask)
2759 || (isChildWindow() && !noLimits);
Robert Carr31e28482015-12-02 16:53:18 -08002760 float x, y;
2761 int w,h;
2762
2763 if ((mAttrs.flags & FLAG_SCALED) != 0) {
2764 if (mAttrs.width < 0) {
2765 w = pw;
2766 } else if (mEnforceSizeCompat) {
2767 w = (int)(mAttrs.width * mGlobalScale + .5f);
2768 } else {
2769 w = mAttrs.width;
2770 }
2771 if (mAttrs.height < 0) {
2772 h = ph;
2773 } else if (mEnforceSizeCompat) {
2774 h = (int)(mAttrs.height * mGlobalScale + .5f);
2775 } else {
2776 h = mAttrs.height;
2777 }
2778 } else {
2779 if (mAttrs.width == MATCH_PARENT) {
2780 w = pw;
2781 } else if (mEnforceSizeCompat) {
2782 w = (int)(mRequestedWidth * mGlobalScale + .5f);
2783 } else {
2784 w = mRequestedWidth;
2785 }
2786 if (mAttrs.height == MATCH_PARENT) {
2787 h = ph;
2788 } else if (mEnforceSizeCompat) {
2789 h = (int)(mRequestedHeight * mGlobalScale + .5f);
2790 } else {
2791 h = mRequestedHeight;
2792 }
2793 }
2794
2795 if (mEnforceSizeCompat) {
2796 x = mAttrs.x * mGlobalScale;
2797 y = mAttrs.y * mGlobalScale;
2798 } else {
2799 x = mAttrs.x;
2800 y = mAttrs.y;
2801 }
2802
Robert Carr1d2bacb2016-03-30 14:29:35 -07002803 if (nonFullscreenTask && !layoutInParentFrame()) {
Wale Ogunwale79f268d2015-12-18 08:25:47 -08002804 // Make sure window fits in containing frame since it is in a non-fullscreen task as
Robert Carr31e28482015-12-02 16:53:18 -08002805 // required by {@link Gravity#apply} call.
2806 w = Math.min(w, pw);
2807 h = Math.min(h, ph);
2808 }
2809
2810 // Set mFrame
Jorim Jaggif5834272016-04-04 20:25:41 -07002811 Gravity.apply(mAttrs.gravity, w, h, containingFrame,
Robert Carr31e28482015-12-02 16:53:18 -08002812 (int) (x + mAttrs.horizontalMargin * pw),
2813 (int) (y + mAttrs.verticalMargin * ph), mFrame);
2814
2815 // Now make sure the window fits in the overall display frame.
Robert Carre6275582016-02-29 15:45:45 -08002816 if (fitToDisplay) {
Jorim Jaggif5834272016-04-04 20:25:41 -07002817 Gravity.applyDisplay(mAttrs.gravity, displayFrame, mFrame);
Robert Carre6275582016-02-29 15:45:45 -08002818 }
Robert Carr6e18c5e2016-02-29 15:57:13 -08002819
2820 // We need to make sure we update the CompatFrame as it is used for
2821 // cropping decisions, etc, on systems where we lack a decor layer.
2822 mCompatFrame.set(mFrame);
2823 if (mEnforceSizeCompat) {
2824 // See comparable block in computeFrameLw.
2825 mCompatFrame.scale(mInvGlobalScale);
2826 }
Robert Carr31e28482015-12-02 16:53:18 -08002827 }
Robert Carr51a1b872015-12-08 14:03:13 -08002828
2829 boolean isChildWindow() {
Wale Ogunwale7ed4d372016-07-09 15:28:55 -07002830 return mParentWindow != null;
Robert Carr51a1b872015-12-08 14:03:13 -08002831 }
Robert Carra1eb4392015-12-10 12:43:51 -08002832
Robert Carrf3b72c72016-03-21 18:16:39 -07002833 boolean layoutInParentFrame() {
2834 return isChildWindow() && (mAttrs.privateFlags & PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME) != 0;
2835 }
2836
Wale Ogunwale9d147902016-07-16 11:58:55 -07002837 boolean isParentWindowHidden() {
2838 return (mParentWindow != null) ? mParentWindow.mHidden : false;
2839 }
2840
Robert Carra1eb4392015-12-10 12:43:51 -08002841 void setReplacing(boolean animate) {
Wale Ogunwale6d8e06b2016-01-05 10:43:25 -08002842 if ((mAttrs.privateFlags & PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH) != 0
2843 || mAttrs.type == TYPE_APPLICATION_STARTING) {
2844 // We don't set replacing on starting windows since they are added by window manager and
2845 // not the client so won't be replaced by the client.
2846 return;
Robert Carra1eb4392015-12-10 12:43:51 -08002847 }
Wale Ogunwale6d8e06b2016-01-05 10:43:25 -08002848
2849 mWillReplaceWindow = true;
2850 mReplacingWindow = null;
2851 mAnimateReplacingWindow = animate;
Robert Carra1eb4392015-12-10 12:43:51 -08002852 }
Chong Zhangf596cd52016-01-05 13:42:44 -08002853
2854 void resetReplacing() {
2855 mWillReplaceWindow = false;
2856 mReplacingWindow = null;
2857 mAnimateReplacingWindow = false;
2858 }
Vladislav Kaznacheev989b58a2016-02-10 12:19:33 -08002859
Chong Zhang4d7369a2016-04-25 16:09:14 -07002860 void requestUpdateWallpaperIfNeeded() {
2861 if (mDisplayContent != null && (mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
2862 mDisplayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
2863 mDisplayContent.layoutNeeded = true;
2864 mService.mWindowPlacerLocked.requestTraversal();
2865 }
2866 }
2867
Vladislav Kaznacheev989b58a2016-02-10 12:19:33 -08002868 float translateToWindowX(float x) {
2869 float winX = x - mFrame.left;
2870 if (mEnforceSizeCompat) {
2871 winX *= mGlobalScale;
2872 }
2873 return winX;
2874 }
2875
2876 float translateToWindowY(float y) {
2877 float winY = y - mFrame.top;
2878 if (mEnforceSizeCompat) {
2879 winY *= mGlobalScale;
2880 }
2881 return winY;
2882 }
Robert Carrd1a010f2016-04-07 22:36:22 -07002883
Robert Carr9fe459d2016-04-07 23:32:28 -07002884 void transferDimToReplacement() {
2885 final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser();
2886 if (dimLayerUser != null && mDisplayContent != null) {
2887 mDisplayContent.mDimLayerController.applyDim(dimLayerUser,
2888 mReplacingWindow.mWinAnimator,
2889 (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? true : false);
2890 }
2891 }
2892
Robert Carrd1a010f2016-04-07 22:36:22 -07002893 // During activity relaunch due to resize, we sometimes use window replacement
2894 // for only child windows (as the main window is handled by window preservation)
2895 // and the big surface.
2896 //
2897 // Though windows of TYPE_APPLICATION (as opposed to TYPE_BASE_APPLICATION)
2898 // are not children in the sense of an attached window, we also want to replace
2899 // them at such phases, as they won't be covered by window preservation,
2900 // and in general we expect them to return following relaunch.
2901 boolean shouldBeReplacedWithChildren() {
2902 return isChildWindow() || mAttrs.type == TYPE_APPLICATION;
2903 }
Robert Carrfd10cd12016-06-29 16:41:50 -07002904
2905 public int getRotationAnimationHint() {
2906 if (mAppToken != null) {
2907 return mAppToken.mRotationAnimationHint;
2908 } else {
2909 return -1;
2910 }
2911 }
Wale Ogunwale9d147902016-07-16 11:58:55 -07002912
2913 // This must be called while inside a transaction.
2914 boolean performShowLocked() {
2915 if (isHiddenFromUserLocked()) {
2916 if (DEBUG_VISIBILITY) Slog.w(TAG, "hiding " + this + ", belonging to " + mOwnerUid);
2917 hideLw(false);
2918 return false;
2919 }
2920
2921 logPerformShow("performShow on ");
2922
2923 if (mWinAnimator.mDrawState != READY_TO_SHOW || !isReadyForDisplayIgnoringKeyguard()) {
2924 return false;
2925 }
2926
2927 logPerformShow("Showing ");
2928
2929 mService.enableScreenIfNeededLocked();
2930 mWinAnimator.applyEnterAnimationLocked();
2931
2932 // Force the show in the next prepareSurfaceLocked() call.
2933 mWinAnimator.mLastAlpha = -1;
2934 if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) Slog.v(TAG,
2935 "performShowLocked: mDrawState=HAS_DRAWN in " + this);
2936 mWinAnimator.mDrawState = HAS_DRAWN;
2937 mService.scheduleAnimationLocked();
2938
2939 if (mHidden) {
2940 mHidden = false;
2941 final DisplayContent displayContent = getDisplayContent();
2942
2943 for (int i = mChildWindows.size(); i >= 0; --i) {
2944 final WindowState c = mChildWindows.get(i);
2945 if (c.mWinAnimator.mSurfaceController != null) {
2946 c.performShowLocked();
2947 // It hadn't been shown, which means layout not performed on it, so now we
2948 // want to make sure to do a layout. If called from within the transaction
2949 // loop, this will cause it to restart with a new layout.
2950 if (displayContent != null) {
2951 displayContent.layoutNeeded = true;
2952 }
2953 }
2954 }
2955 }
2956
2957 if (mAttrs.type != TYPE_APPLICATION_STARTING && mAppToken != null) {
2958 mAppToken.onFirstWindowDrawn(this, mWinAnimator);
2959 }
2960
2961 if (mAttrs.type == TYPE_INPUT_METHOD) {
2962 mDisplayContent.mDividerControllerLocked.resetImeHideRequested();
2963 }
2964
2965 return true;
2966 }
2967
2968 void logPerformShow(String prefix) {
2969 if (DEBUG_VISIBILITY
2970 || (DEBUG_STARTING_WINDOW && mAttrs.type == TYPE_APPLICATION_STARTING)) {
2971 Slog.v(TAG, prefix + this
2972 + ": mDrawState=" + mWinAnimator.drawStateToString()
2973 + " readyForDisplay=" + isReadyForDisplayIgnoringKeyguard()
2974 + " starting=" + (mAttrs.type == TYPE_APPLICATION_STARTING)
2975 + " during animation: policyVis=" + mPolicyVisibility
2976 + " parentHidden=" + isParentWindowHidden()
2977 + " tok.hiddenRequested="
2978 + (mAppToken != null ? mAppToken.hiddenRequested : false)
2979 + " tok.hidden=" + (mAppToken != null ? mAppToken.hidden : false)
2980 + " animating=" + mWinAnimator.mAnimating
2981 + " tok animating="
2982 + (mWinAnimator.mAppAnimator != null ? mWinAnimator.mAppAnimator.animating : false)
2983 + " Callers=" + Debug.getCallers(4));
2984 }
2985 }
satokcef37fb2011-10-24 21:49:38 +09002986}