blob: 81eac20cb11ed25f3fd8c9eeeb3308508bf5f1ea [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
19import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
20import static android.view.WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080021import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080022import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
23import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
Craig Mautnere8552142012-11-07 13:55:47 -080024import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080025import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
26
Jeff Brown4532e612012-04-05 14:27:12 -070027import com.android.server.input.InputWindowHandle;
28
Craig Mautnere7ae2502012-03-26 17:11:19 -070029import android.content.Context;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080030import android.content.res.Configuration;
31import android.graphics.Matrix;
32import android.graphics.PixelFormat;
33import android.graphics.Rect;
Dianne Hackbornd040edb2011-08-31 12:47:58 -070034import android.graphics.RectF;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080035import android.graphics.Region;
36import android.os.IBinder;
37import android.os.RemoteException;
Craig Mautner9dc52bc2012-08-06 14:15:42 -070038import android.os.UserHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080039import android.util.Slog;
Craig Mautner59c00972012-07-30 12:10:24 -070040import android.view.DisplayInfo;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080041import android.view.Gravity;
42import android.view.IApplicationToken;
43import android.view.IWindow;
44import android.view.InputChannel;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080045import android.view.View;
46import android.view.ViewTreeObserver;
47import android.view.WindowManager;
48import android.view.WindowManagerPolicy;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080049
50import java.io.PrintWriter;
51import java.util.ArrayList;
52
Craig Mautner59c00972012-07-30 12:10:24 -070053class WindowList extends ArrayList<WindowState> {
54}
55
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080056/**
57 * A window in the window manager.
58 */
Craig Mautnere32c3072012-03-12 15:25:35 -070059final class WindowState implements WindowManagerPolicy.WindowState {
Craig Mautnerd87946b2012-03-29 18:00:19 -070060 static final String TAG = "WindowState";
61
Dianne Hackborn5fd21692011-06-07 14:09:47 -070062 static final boolean DEBUG_VISIBILITY = WindowManagerService.DEBUG_VISIBILITY;
63 static final boolean SHOW_TRANSACTIONS = WindowManagerService.SHOW_TRANSACTIONS;
Dianne Hackborn36991742011-10-11 21:35:26 -070064 static final boolean SHOW_LIGHT_TRANSACTIONS = WindowManagerService.SHOW_LIGHT_TRANSACTIONS;
Dianne Hackborn5fd21692011-06-07 14:09:47 -070065 static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC;
66
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080067 final WindowManagerService mService;
Craig Mautnere7ae2502012-03-26 17:11:19 -070068 final WindowManagerPolicy mPolicy;
69 final Context mContext;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080070 final Session mSession;
71 final IWindow mClient;
72 WindowToken mToken;
73 WindowToken mRootToken;
74 AppWindowToken mAppToken;
75 AppWindowToken mTargetAppToken;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070076
77 // mAttrs.flags is tested in animation without being locked. If the bits tested are ever
78 // modified they will need to be locked.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080079 final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
80 final DeathRecipient mDeathRecipient;
81 final WindowState mAttachedWindow;
Craig Mautner7b1aa772012-11-30 16:14:45 -080082 final WindowList mChildWindows = new WindowList();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080083 final int mBaseLayer;
84 final int mSubLayer;
85 final boolean mLayoutAttached;
86 final boolean mIsImWindow;
87 final boolean mIsWallpaper;
88 final boolean mIsFloatingLayer;
Dianne Hackborn9a230e02011-10-06 11:51:27 -070089 int mSeq;
Dianne Hackborn5fd21692011-06-07 14:09:47 -070090 boolean mEnforceSizeCompat;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080091 int mViewVisibility;
Dianne Hackborn9a230e02011-10-06 11:51:27 -070092 int mSystemUiVisibility;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080093 boolean mPolicyVisibility = true;
94 boolean mPolicyVisibilityAfterAnim = true;
95 boolean mAppFreezing;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080096 boolean mAttachedHidden; // is our parent window hidden?
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080097 boolean mWallpaperVisible; // for wallpaper, what was last vis report?
Dianne Hackbornffb3d932011-05-17 17:44:51 -070098
99 /**
100 * The window size that was requested by the application. These are in
101 * the application's coordinate space (without compatibility scale applied).
102 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800103 int mRequestedWidth;
104 int mRequestedHeight;
Dianne Hackborn1743b642012-03-12 17:04:43 -0700105 int mLastRequestedWidth;
106 int mLastRequestedHeight;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700107
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800108 int mLayer;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800109 boolean mHaveFrame;
110 boolean mObscured;
111 boolean mTurnOnScreen;
112
113 int mLayoutSeq = -1;
Craig Mautnera2c77052012-03-26 12:14:43 -0700114
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800115 Configuration mConfiguration = null;
Craig Mautnere8552142012-11-07 13:55:47 -0800116 // Sticky answer to isConfigChanged(), remains true until new Configuration is assigned.
117 // Used only on {@link #TYPE_KEYGUARD}.
118 private boolean mConfigHasChanged;
Craig Mautnera2c77052012-03-26 12:14:43 -0700119
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700120 /**
121 * Actual frame shown on-screen (may be modified by animation). These
122 * are in the screen's coordinate space (WITH the compatibility scale
123 * applied).
124 */
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700125 final RectF mShownFrame = new RectF();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800126
127 /**
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700128 * Insets that determine the actually visible area. These are in the application's
129 * coordinate space (without compatibility scale applied).
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800130 */
131 final Rect mVisibleInsets = new Rect();
132 final Rect mLastVisibleInsets = new Rect();
133 boolean mVisibleInsetsChanged;
134
135 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700136 * Insets that are covered by system windows (such as the status bar) and
137 * transient docking windows (such as the IME). These are in the application's
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700138 * coordinate space (without compatibility scale applied).
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800139 */
140 final Rect mContentInsets = new Rect();
141 final Rect mLastContentInsets = new Rect();
142 boolean mContentInsetsChanged;
143
144 /**
145 * Set to true if we are waiting for this window to receive its
146 * given internal insets before laying out other windows based on it.
147 */
148 boolean mGivenInsetsPending;
149
150 /**
151 * These are the content insets that were given during layout for
152 * this window, to be applied to windows behind it.
153 */
154 final Rect mGivenContentInsets = new Rect();
155
156 /**
157 * These are the visible insets that were given during layout for
158 * this window, to be applied to windows behind it.
159 */
160 final Rect mGivenVisibleInsets = new Rect();
161
162 /**
163 * This is the given touchable area relative to the window frame, or null if none.
164 */
165 final Region mGivenTouchableRegion = new Region();
166
167 /**
168 * Flag indicating whether the touchable region should be adjusted by
169 * the visible insets; if false the area outside the visible insets is
170 * NOT touchable, so we must use those to adjust the frame during hit
171 * tests.
172 */
173 int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
174
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700175 /**
176 * This is rectangle of the window's surface that is not covered by
177 * system decorations.
178 */
179 final Rect mSystemDecorRect = new Rect();
180 final Rect mLastSystemDecorRect = new Rect();
181
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800182 // Current transformation being applied.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400183 float mGlobalScale=1;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700184 float mInvGlobalScale=1;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800185 float mHScale=1, mVScale=1;
186 float mLastHScale=1, mLastVScale=1;
187 final Matrix mTmpMatrix = new Matrix();
188
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700189 // "Real" frame that the application sees, in display coordinate space.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800190 final Rect mFrame = new Rect();
191 final Rect mLastFrame = new Rect();
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700192 // Frame that is scaled to the application's coordinate space when in
193 // screen size compatibility mode.
194 final Rect mCompatFrame = new Rect();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800195
196 final Rect mContainingFrame = new Rect();
197 final Rect mDisplayFrame = new Rect();
198 final Rect mContentFrame = new Rect();
199 final Rect mParentFrame = new Rect();
200 final Rect mVisibleFrame = new Rect();
201
202 boolean mContentChanged;
203
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800204 // If a window showing a wallpaper: the requested offset for the
205 // wallpaper; if a wallpaper window: the currently applied offset.
206 float mWallpaperX = -1;
207 float mWallpaperY = -1;
208
209 // If a window showing a wallpaper: what fraction of the offset
210 // range corresponds to a full virtual screen.
211 float mWallpaperXStep = -1;
212 float mWallpaperYStep = -1;
213
214 // Wallpaper windows: pixels offset based on above variables.
215 int mXOffset;
216 int mYOffset;
217
218 // This is set after IWindowSession.relayout() has been called at
219 // least once for the window. It allows us to detect the situation
220 // where we don't yet have a surface, but should have one soon, so
221 // we can give the window focus before waiting for the relayout.
222 boolean mRelayoutCalled;
223
Dianne Hackbornb7ff51b2012-01-23 19:15:27 -0800224 // If the application has called relayout() with changes that can
225 // impact its window's size, we need to perform a layout pass on it
226 // even if it is not currently visible for layout. This is set
227 // when in that case until the layout is done.
228 boolean mLayoutNeeded;
229
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800230 // Currently running an exit animation?
231 boolean mExiting;
232
233 // Currently on the mDestroySurface list?
234 boolean mDestroying;
235
236 // Completely remove from window manager after exit animation?
237 boolean mRemoveOnExit;
238
239 // Set when the orientation is changing and this window has not yet
240 // been updated for the new orientation.
241 boolean mOrientationChanging;
242
243 // Is this window now (or just being) removed?
244 boolean mRemoved;
245
246 // Temp for keeping track of windows that have been removed when
247 // rebuilding window list.
248 boolean mRebuilding;
249
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800250 // Input channel and input window handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700251 final InputWindowHandle mInputWindowHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800252 InputChannel mInputChannel;
253
254 // Used to improve performance of toString()
255 String mStringNameCache;
256 CharSequence mLastTitle;
Dianne Hackborn529e7442012-11-01 14:22:28 -0700257 boolean mWasExiting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800258
Craig Mautnera2c77052012-03-26 12:14:43 -0700259 final WindowStateAnimator mWinAnimator;
260
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700261 boolean mHasSurface = false;
262
Craig Mautner59c00972012-07-30 12:10:24 -0700263 DisplayContent mDisplayContent;
Craig Mautner6881a102012-07-27 13:04:51 -0700264
Craig Mautnera2d7b112012-08-21 15:12:20 -0700265 // UserId and appId of the owner. Don't display windows of non-current user.
Craig Mautner88400d32012-09-30 12:35:45 -0700266 int mOwnerUid;
267
268 /** When true this window can be displayed on screens owther than mOwnerUid's */
269 private boolean mShowToOwnerOnly;
Craig Mautner9dc52bc2012-08-06 14:15:42 -0700270
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800271 WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700272 WindowState attachedWindow, int seq, WindowManager.LayoutParams a,
Craig Mautner59c00972012-07-30 12:10:24 -0700273 int viewVisibility, final DisplayContent displayContent) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800274 mService = service;
275 mSession = s;
276 mClient = c;
277 mToken = token;
Craig Mautnera2d7b112012-08-21 15:12:20 -0700278 mOwnerUid = s.mUid;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800279 mAttrs.copyFrom(a);
280 mViewVisibility = viewVisibility;
Craig Mautner59c00972012-07-30 12:10:24 -0700281 mDisplayContent = displayContent;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700282 mPolicy = mService.mPolicy;
283 mContext = mService.mContext;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800284 DeathRecipient deathRecipient = new DeathRecipient();
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700285 mSeq = seq;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400286 mEnforceSizeCompat = (mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800287 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautnerd87946b2012-03-29 18:00:19 -0700288 TAG, "Window " + this + " client=" + c.asBinder()
Craig Mautnerad09bcc2012-10-08 13:33:11 -0700289 + " token=" + token + " (" + mAttrs.token + ")" + " params=" + a);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800290 try {
291 c.asBinder().linkToDeath(deathRecipient, 0);
292 } catch (RemoteException e) {
293 mDeathRecipient = null;
294 mAttachedWindow = null;
295 mLayoutAttached = false;
296 mIsImWindow = false;
297 mIsWallpaper = false;
298 mIsFloatingLayer = false;
299 mBaseLayer = 0;
300 mSubLayer = 0;
Jeff Brown9302c872011-07-13 22:51:29 -0700301 mInputWindowHandle = null;
Craig Mautnera2c77052012-03-26 12:14:43 -0700302 mWinAnimator = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800303 return;
304 }
305 mDeathRecipient = deathRecipient;
306
307 if ((mAttrs.type >= FIRST_SUB_WINDOW &&
308 mAttrs.type <= LAST_SUB_WINDOW)) {
309 // The multiplier here is to reserve space for multiple
310 // windows in the same type layer.
Craig Mautnere7ae2502012-03-26 17:11:19 -0700311 mBaseLayer = mPolicy.windowTypeToLayerLw(
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800312 attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER
313 + WindowManagerService.TYPE_LAYER_OFFSET;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700314 mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800315 mAttachedWindow = attachedWindow;
Craig Mautnerd87946b2012-03-29 18:00:19 -0700316 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800317 mAttachedWindow.mChildWindows.add(this);
318 mLayoutAttached = mAttrs.type !=
319 WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
320 mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD
321 || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
322 mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER;
323 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
324 } else {
325 // The multiplier here is to reserve space for multiple
326 // windows in the same type layer.
Craig Mautnere7ae2502012-03-26 17:11:19 -0700327 mBaseLayer = mPolicy.windowTypeToLayerLw(a.type)
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800328 * WindowManagerService.TYPE_LAYER_MULTIPLIER
329 + WindowManagerService.TYPE_LAYER_OFFSET;
330 mSubLayer = 0;
331 mAttachedWindow = null;
332 mLayoutAttached = false;
333 mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD
334 || mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
335 mIsWallpaper = mAttrs.type == TYPE_WALLPAPER;
336 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
337 }
338
339 WindowState appWin = this;
340 while (appWin.mAttachedWindow != null) {
Craig Mautnera2c77052012-03-26 12:14:43 -0700341 appWin = appWin.mAttachedWindow;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800342 }
343 WindowToken appToken = appWin.mToken;
344 while (appToken.appWindowToken == null) {
345 WindowToken parent = mService.mTokenMap.get(appToken.token);
346 if (parent == null || appToken == parent) {
347 break;
348 }
349 appToken = parent;
350 }
351 mRootToken = appToken;
352 mAppToken = appToken.appWindowToken;
353
Craig Mautner322e4032012-07-13 13:35:20 -0700354 mWinAnimator = new WindowStateAnimator(this);
355 mWinAnimator.mAlpha = a.alpha;
356
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800357 mRequestedWidth = 0;
358 mRequestedHeight = 0;
Dianne Hackborn1743b642012-03-12 17:04:43 -0700359 mLastRequestedWidth = 0;
360 mLastRequestedHeight = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800361 mXOffset = 0;
362 mYOffset = 0;
363 mLayer = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800364 mInputWindowHandle = new InputWindowHandle(
Craig Mautner59c00972012-07-30 12:10:24 -0700365 mAppToken != null ? mAppToken.mInputApplicationHandle : null, this,
366 displayContent.getDisplayId());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800367 }
368
369 void attach() {
370 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautnerd87946b2012-03-29 18:00:19 -0700371 TAG, "Attaching " + this + " token=" + mToken
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800372 + ", list=" + mToken.windows);
373 mSession.windowAddedLocked();
374 }
375
Craig Mautnera2c77052012-03-26 12:14:43 -0700376 @Override
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700377 public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800378 mHaveFrame = true;
379
380 final Rect container = mContainingFrame;
381 container.set(pf);
382
383 final Rect display = mDisplayFrame;
384 display.set(df);
385
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800386 final int pw = container.right - container.left;
387 final int ph = container.bottom - container.top;
388
389 int w,h;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700390 if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) {
391 if (mAttrs.width < 0) {
392 w = pw;
393 } else if (mEnforceSizeCompat) {
394 w = (int)(mAttrs.width * mGlobalScale + .5f);
395 } else {
396 w = mAttrs.width;
397 }
398 if (mAttrs.height < 0) {
399 h = ph;
400 } else if (mEnforceSizeCompat) {
401 h = (int)(mAttrs.height * mGlobalScale + .5f);
402 } else {
403 h = mAttrs.height;
404 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800405 } else {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700406 if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) {
407 w = pw;
408 } else if (mEnforceSizeCompat) {
409 w = (int)(mRequestedWidth * mGlobalScale + .5f);
410 } else {
411 w = mRequestedWidth;
412 }
413 if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
414 h = ph;
415 } else if (mEnforceSizeCompat) {
416 h = (int)(mRequestedHeight * mGlobalScale + .5f);
417 } else {
418 h = mRequestedHeight;
419 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800420 }
421
422 if (!mParentFrame.equals(pf)) {
423 //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame
424 // + " to " + pf);
425 mParentFrame.set(pf);
426 mContentChanged = true;
427 }
Dianne Hackborn1743b642012-03-12 17:04:43 -0700428 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
429 mLastRequestedWidth = mRequestedWidth;
430 mLastRequestedHeight = mRequestedHeight;
431 mContentChanged = true;
432 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800433
434 final Rect content = mContentFrame;
435 content.set(cf);
436
437 final Rect visible = mVisibleFrame;
438 visible.set(vf);
439
440 final Rect frame = mFrame;
441 final int fw = frame.width();
442 final int fh = frame.height();
443
444 //System.out.println("In: w=" + w + " h=" + h + " container=" +
445 // container + " x=" + mAttrs.x + " y=" + mAttrs.y);
446
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700447 float x, y;
448 if (mEnforceSizeCompat) {
449 x = mAttrs.x * mGlobalScale;
450 y = mAttrs.y * mGlobalScale;
451 } else {
452 x = mAttrs.x;
453 y = mAttrs.y;
454 }
455
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800456 Gravity.apply(mAttrs.gravity, w, h, container,
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700457 (int) (x + mAttrs.horizontalMargin * pw),
458 (int) (y + mAttrs.verticalMargin * ph), frame);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800459
460 //System.out.println("Out: " + mFrame);
461
462 // Now make sure the window fits in the overall display.
463 Gravity.applyDisplay(mAttrs.gravity, df, frame);
464
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700465 // Make sure the system, content and visible frames are inside of the
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800466 // final window frame.
467 if (content.left < frame.left) content.left = frame.left;
468 if (content.top < frame.top) content.top = frame.top;
469 if (content.right > frame.right) content.right = frame.right;
470 if (content.bottom > frame.bottom) content.bottom = frame.bottom;
471 if (visible.left < frame.left) visible.left = frame.left;
472 if (visible.top < frame.top) visible.top = frame.top;
473 if (visible.right > frame.right) visible.right = frame.right;
474 if (visible.bottom > frame.bottom) visible.bottom = frame.bottom;
475
476 final Rect contentInsets = mContentInsets;
477 contentInsets.left = content.left-frame.left;
478 contentInsets.top = content.top-frame.top;
479 contentInsets.right = frame.right-content.right;
480 contentInsets.bottom = frame.bottom-content.bottom;
481
482 final Rect visibleInsets = mVisibleInsets;
483 visibleInsets.left = visible.left-frame.left;
484 visibleInsets.top = visible.top-frame.top;
485 visibleInsets.right = frame.right-visible.right;
486 visibleInsets.bottom = frame.bottom-visible.bottom;
487
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700488 mCompatFrame.set(frame);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400489 if (mEnforceSizeCompat) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700490 // If there is a size compatibility scale being applied to the
491 // window, we need to apply this to its insets so that they are
492 // reported to the app in its coordinate space.
493 contentInsets.scale(mInvGlobalScale);
494 visibleInsets.scale(mInvGlobalScale);
495
496 // Also the scaled frame that we report to the app needs to be
497 // adjusted to be in its coordinate space.
498 mCompatFrame.scale(mInvGlobalScale);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400499 }
500
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800501 if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
Craig Mautner59c00972012-07-30 12:10:24 -0700502 final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
503 mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight,
504 false);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800505 }
506
507 if (WindowManagerService.localLOGV) {
508 //if ("com.google.android.youtube".equals(mAttrs.packageName)
509 // && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700510 Slog.v(TAG, "Resolving (mRequestedWidth="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800511 + mRequestedWidth + ", mRequestedheight="
512 + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
513 + "): frame=" + mFrame.toShortString()
514 + " ci=" + contentInsets.toShortString()
515 + " vi=" + visibleInsets.toShortString());
516 //}
517 }
518 }
519
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700520 MagnificationSpec getWindowMagnificationSpecLocked() {
521 MagnificationSpec spec = mDisplayContent.mMagnificationSpec;
522 if (spec != null && !spec.isNop()) {
523 if (mAttachedWindow != null) {
Craig Mautnerf1b67412012-09-19 13:18:29 -0700524 if (!mPolicy.canMagnifyWindowLw(mAttachedWindow.mAttrs)) {
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700525 return null;
526 }
527 }
Craig Mautnerf1b67412012-09-19 13:18:29 -0700528 if (!mPolicy.canMagnifyWindowLw(mAttrs)) {
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700529 return null;
530 }
531 }
532 return spec;
533 }
534
Craig Mautnera2c77052012-03-26 12:14:43 -0700535 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800536 public Rect getFrameLw() {
537 return mFrame;
538 }
539
Craig Mautnera2c77052012-03-26 12:14:43 -0700540 @Override
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700541 public RectF getShownFrameLw() {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800542 return mShownFrame;
543 }
544
Craig Mautnera2c77052012-03-26 12:14:43 -0700545 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800546 public Rect getDisplayFrameLw() {
547 return mDisplayFrame;
548 }
549
Craig Mautnera2c77052012-03-26 12:14:43 -0700550 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800551 public Rect getContentFrameLw() {
552 return mContentFrame;
553 }
554
Craig Mautnera2c77052012-03-26 12:14:43 -0700555 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800556 public Rect getVisibleFrameLw() {
557 return mVisibleFrame;
558 }
559
Craig Mautnera2c77052012-03-26 12:14:43 -0700560 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800561 public boolean getGivenInsetsPendingLw() {
562 return mGivenInsetsPending;
563 }
564
Craig Mautnera2c77052012-03-26 12:14:43 -0700565 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800566 public Rect getGivenContentInsetsLw() {
567 return mGivenContentInsets;
568 }
569
Craig Mautnera2c77052012-03-26 12:14:43 -0700570 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800571 public Rect getGivenVisibleInsetsLw() {
572 return mGivenVisibleInsets;
573 }
574
Craig Mautnera2c77052012-03-26 12:14:43 -0700575 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800576 public WindowManager.LayoutParams getAttrs() {
577 return mAttrs;
578 }
579
Craig Mautner812d2ca2012-09-27 15:35:34 -0700580 @Override
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800581 public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) {
582 int index = -1;
583 WindowState ws = this;
Craig Mautner59c00972012-07-30 12:10:24 -0700584 WindowList windows = getWindowList();
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800585 while (true) {
586 if ((ws.mAttrs.privateFlags
587 & WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY) != 0) {
588 return (ws.mAttrs.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0;
589 }
590 // If we reached the bottom of the range of windows we are considering,
591 // assume no menu is needed.
592 if (ws == bottom) {
593 return false;
594 }
595 // The current window hasn't specified whether menu key is needed;
596 // look behind it.
597 // First, we may need to determine the starting position.
598 if (index < 0) {
Craig Mautner59c00972012-07-30 12:10:24 -0700599 index = windows.indexOf(ws);
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800600 }
601 index--;
602 if (index < 0) {
603 return false;
604 }
Craig Mautner59c00972012-07-30 12:10:24 -0700605 ws = windows.get(index);
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800606 }
607 }
608
Craig Mautner19d59bc2012-09-04 11:15:56 -0700609 @Override
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700610 public int getSystemUiVisibility() {
611 return mSystemUiVisibility;
612 }
613
Craig Mautner19d59bc2012-09-04 11:15:56 -0700614 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800615 public int getSurfaceLayer() {
616 return mLayer;
617 }
618
Craig Mautner812d2ca2012-09-27 15:35:34 -0700619 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800620 public IApplicationToken getAppToken() {
621 return mAppToken != null ? mAppToken.appToken : null;
622 }
Craig Mautner19d59bc2012-09-04 11:15:56 -0700623
624 public int getDisplayId() {
625 return mDisplayContent.getDisplayId();
626 }
627
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800628 public long getInputDispatchingTimeoutNanos() {
629 return mAppToken != null
630 ? mAppToken.inputDispatchingTimeoutNanos
631 : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
632 }
633
Craig Mautnere8552142012-11-07 13:55:47 -0800634 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800635 public boolean hasAppShownWindows() {
Craig Mautnerf4120952012-06-21 18:25:39 -0700636 return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800637 }
638
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800639 boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
640 if (dsdx < .99999f || dsdx > 1.00001f) return false;
641 if (dtdy < .99999f || dtdy > 1.00001f) return false;
642 if (dtdx < -.000001f || dtdx > .000001f) return false;
643 if (dsdy < -.000001f || dsdy > .000001f) return false;
644 return true;
645 }
646
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400647 void prelayout() {
648 if (mEnforceSizeCompat) {
649 mGlobalScale = mService.mCompatibleScreenScale;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700650 mInvGlobalScale = 1/mGlobalScale;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400651 } else {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700652 mGlobalScale = mInvGlobalScale = 1;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400653 }
654 }
655
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800656 /**
657 * Is this window visible? It is not visible if there is no
658 * surface, or we are in the process of running an exit animation
659 * that will remove the surface, or its app token has been hidden.
660 */
Craig Mautner88400d32012-09-30 12:35:45 -0700661 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800662 public boolean isVisibleLw() {
663 final AppWindowToken atoken = mAppToken;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700664 return mHasSurface && mPolicyVisibility && !mAttachedHidden
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800665 && (atoken == null || !atoken.hiddenRequested)
666 && !mExiting && !mDestroying;
667 }
668
669 /**
670 * Like {@link #isVisibleLw}, but also counts a window that is currently
671 * "hidden" behind the keyguard as visible. This allows us to apply
672 * things like window flags that impact the keyguard.
673 * XXX I am starting to think we need to have ANOTHER visibility flag
674 * for this "hidden behind keyguard" state rather than overloading
675 * mPolicyVisibility. Ungh.
676 */
Craig Mautner88400d32012-09-30 12:35:45 -0700677 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800678 public boolean isVisibleOrBehindKeyguardLw() {
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700679 if (mRootToken.waitingToShow &&
680 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
681 return false;
682 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800683 final AppWindowToken atoken = mAppToken;
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700684 final boolean animating = atoken != null
Craig Mautner59431632012-04-04 11:56:44 -0700685 ? (atoken.mAppAnimator.animation != null) : false;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700686 return mHasSurface && !mDestroying && !mExiting
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800687 && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested)
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700688 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
689 && !mRootToken.hidden)
Craig Mautnera2c77052012-03-26 12:14:43 -0700690 || mWinAnimator.mAnimation != null || animating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800691 }
692
693 /**
694 * Is this window visible, ignoring its app token? It is not visible
695 * if there is no surface, or we are in the process of running an exit animation
696 * that will remove the surface.
697 */
698 public boolean isWinVisibleLw() {
699 final AppWindowToken atoken = mAppToken;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700700 return mHasSurface && mPolicyVisibility && !mAttachedHidden
Craig Mautner59431632012-04-04 11:56:44 -0700701 && (atoken == null || !atoken.hiddenRequested || atoken.mAppAnimator.animating)
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800702 && !mExiting && !mDestroying;
703 }
704
705 /**
706 * The same as isVisible(), but follows the current hidden state of
707 * the associated app token, not the pending requested hidden state.
708 */
709 boolean isVisibleNow() {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700710 return mHasSurface && mPolicyVisibility && !mAttachedHidden
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800711 && !mRootToken.hidden && !mExiting && !mDestroying;
712 }
713
714 /**
715 * Can this window possibly be a drag/drop target? The test here is
716 * a combination of the above "visible now" with the check that the
717 * Input Manager uses when discarding windows from input consideration.
718 */
719 boolean isPotentialDragTarget() {
Jeff Browncc4f7db2011-08-30 20:34:48 -0700720 return isVisibleNow() && !mRemoved
721 && mInputChannel != null && mInputWindowHandle != null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800722 }
723
724 /**
725 * Same as isVisible(), but we also count it as visible between the
726 * call to IWindowSession.add() and the first relayout().
727 */
728 boolean isVisibleOrAdding() {
729 final AppWindowToken atoken = mAppToken;
Craig Mautnerbf08af32012-05-16 19:43:42 -0700730 return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800731 && mPolicyVisibility && !mAttachedHidden
732 && (atoken == null || !atoken.hiddenRequested)
733 && !mExiting && !mDestroying;
734 }
735
736 /**
737 * Is this window currently on-screen? It is on-screen either if it
738 * is visible or it is currently running an animation before no longer
739 * being visible.
740 */
741 boolean isOnScreen() {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700742 if (!mHasSurface || !mPolicyVisibility || mDestroying) {
743 return false;
744 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800745 final AppWindowToken atoken = mAppToken;
746 if (atoken != null) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700747 return ((!mAttachedHidden && !atoken.hiddenRequested)
Craig Mautner59431632012-04-04 11:56:44 -0700748 || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800749 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700750 return !mAttachedHidden || mWinAnimator.mAnimation != null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800751 }
752
753 /**
754 * Like isOnScreen(), but we don't return true if the window is part
755 * of a transition that has not yet been started.
756 */
757 boolean isReadyForDisplay() {
758 if (mRootToken.waitingToShow &&
759 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
760 return false;
761 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700762 return mHasSurface && mPolicyVisibility && !mDestroying
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800763 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
764 && !mRootToken.hidden)
Craig Mautnera2c77052012-03-26 12:14:43 -0700765 || mWinAnimator.mAnimation != null
Craig Mautner59431632012-04-04 11:56:44 -0700766 || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null)));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800767 }
768
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800769 /**
Dianne Hackborn6e2281d2012-06-19 17:48:32 -0700770 * Like isReadyForDisplay(), but ignores any force hiding of the window due
771 * to the keyguard.
772 */
773 boolean isReadyForDisplayIgnoringKeyguard() {
774 if (mRootToken.waitingToShow &&
775 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
776 return false;
777 }
778 final AppWindowToken atoken = mAppToken;
779 if (atoken == null && !mPolicyVisibility) {
780 // If this is not an app window, and the policy has asked to force
781 // hide, then we really do want to hide.
782 return false;
783 }
784 return mHasSurface && !mDestroying
785 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
786 && !mRootToken.hidden)
787 || mWinAnimator.mAnimation != null
Craig Mautner9c5bf3b2012-06-22 15:19:13 -0700788 || ((atoken != null) && (atoken.mAppAnimator.animation != null)
789 && !mWinAnimator.isDummyAnimation()));
Dianne Hackborn6e2281d2012-06-19 17:48:32 -0700790 }
791
792 /**
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800793 * Like isOnScreen, but returns false if the surface hasn't yet
794 * been drawn.
795 */
Craig Mautnere6f7d5052012-10-08 10:34:17 -0700796 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800797 public boolean isDisplayedLw() {
798 final AppWindowToken atoken = mAppToken;
Craig Mautnerbf90eaa2012-03-15 11:28:53 -0700799 return isDrawnLw() && mPolicyVisibility
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800800 && ((!mAttachedHidden &&
801 (atoken == null || !atoken.hiddenRequested))
Craig Mautnere6f7d5052012-10-08 10:34:17 -0700802 || mWinAnimator.mAnimating
803 || (atoken != null && atoken.mAppAnimator.animation != null));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800804 }
805
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700806 /**
807 * Return true if this window (or a window it is attached to, but not
808 * considering its app token) is currently animating.
809 */
Craig Mautnere6f7d5052012-10-08 10:34:17 -0700810 @Override
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700811 public boolean isAnimatingLw() {
812 return mWinAnimator.mAnimation != null;
813 }
814
Craig Mautner812d2ca2012-09-27 15:35:34 -0700815 @Override
Dianne Hackborncfbf7de2012-01-12 14:05:03 -0800816 public boolean isGoneForLayoutLw() {
817 final AppWindowToken atoken = mAppToken;
818 return mViewVisibility == View.GONE
819 || !mRelayoutCalled
820 || (atoken == null && mRootToken.hidden)
Craig Mautner812d2ca2012-09-27 15:35:34 -0700821 || (atoken != null && (atoken.hiddenRequested || atoken.hidden))
Dianne Hackborncfbf7de2012-01-12 14:05:03 -0800822 || mAttachedHidden
823 || mExiting || mDestroying;
824 }
825
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800826 /**
827 * Returns true if the window has a surface that it has drawn a
828 * complete UI in to.
829 */
830 public boolean isDrawnLw() {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700831 return mHasSurface && !mDestroying &&
Craig Mautner749a7bb2012-04-02 13:49:53 -0700832 (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW
833 || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800834 }
835
836 /**
837 * Return true if the window is opaque and fully drawn. This indicates
838 * it may obscure windows behind it.
839 */
840 boolean isOpaqueDrawn() {
841 return (mAttrs.format == PixelFormat.OPAQUE
842 || mAttrs.type == TYPE_WALLPAPER)
Craig Mautnera2c77052012-03-26 12:14:43 -0700843 && isDrawnLw() && mWinAnimator.mAnimation == null
Craig Mautner59431632012-04-04 11:56:44 -0700844 && (mAppToken == null || mAppToken.mAppAnimator.animation == null);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800845 }
846
847 /**
848 * Return whether this window is wanting to have a translation
849 * animation applied to it for an in-progress move. (Only makes
850 * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
851 */
852 boolean shouldAnimateMove() {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700853 return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800854 && (mFrame.top != mLastFrame.top
855 || mFrame.left != mLastFrame.left)
Craig Mautner2fb98b12012-03-20 17:24:00 -0700856 && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800857 }
858
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800859 boolean isFullscreen(int screenWidth, int screenHeight) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700860 return mFrame.left <= 0 && mFrame.top <= 0 &&
861 mFrame.right >= screenWidth && mFrame.bottom >= screenHeight;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800862 }
863
Craig Mautner812d2ca2012-09-27 15:35:34 -0700864 boolean isConfigChanged() {
Craig Mautnere8552142012-11-07 13:55:47 -0800865 boolean configChanged = mConfiguration != mService.mCurConfiguration
Craig Mautner812d2ca2012-09-27 15:35:34 -0700866 && (mConfiguration == null
867 || (mConfiguration.diff(mService.mCurConfiguration) != 0));
Craig Mautnere8552142012-11-07 13:55:47 -0800868
869 if (mAttrs.type == TYPE_KEYGUARD) {
870 // Retain configuration changed status until resetConfiguration called.
871 mConfigHasChanged |= configChanged;
872 configChanged = mConfigHasChanged;
873 }
874
875 return configChanged;
Craig Mautner812d2ca2012-09-27 15:35:34 -0700876 }
877
878 boolean isConfigDiff(int mask) {
879 return mConfiguration != mService.mCurConfiguration
880 && mConfiguration != null
881 && (mConfiguration.diff(mService.mCurConfiguration) & mask) != 0;
882 }
883
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800884 void removeLocked() {
885 disposeInputChannel();
886
887 if (mAttachedWindow != null) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700888 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800889 mAttachedWindow.mChildWindows.remove(this);
890 }
Dianne Hackborn98129732012-11-01 16:28:16 -0700891 mWinAnimator.destroyDeferredSurfaceLocked(false);
892 mWinAnimator.destroySurfaceLocked(false);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800893 mSession.windowRemovedLocked();
894 try {
895 mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
896 } catch (RuntimeException e) {
897 // Ignore if it has already been removed (usually because
898 // we are doing this as part of processing a death note.)
899 }
900 }
Jeff Browncc4f7db2011-08-30 20:34:48 -0700901
Craig Mautnere8552142012-11-07 13:55:47 -0800902 void setConfiguration(final Configuration newConfig) {
903 mConfiguration = newConfig;
904 mConfigHasChanged = false;
905 }
906
Jeff Browncc4f7db2011-08-30 20:34:48 -0700907 void setInputChannel(InputChannel inputChannel) {
908 if (mInputChannel != null) {
909 throw new IllegalStateException("Window already has an input channel.");
910 }
911
912 mInputChannel = inputChannel;
913 mInputWindowHandle.inputChannel = inputChannel;
914 }
915
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800916 void disposeInputChannel() {
917 if (mInputChannel != null) {
918 mService.mInputManager.unregisterInputChannel(mInputChannel);
919
920 mInputChannel.dispose();
921 mInputChannel = null;
922 }
Jeff Browncc4f7db2011-08-30 20:34:48 -0700923
924 mInputWindowHandle.inputChannel = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800925 }
926
927 private class DeathRecipient implements IBinder.DeathRecipient {
Craig Mautnere8552142012-11-07 13:55:47 -0800928 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800929 public void binderDied() {
930 try {
931 synchronized(mService.mWindowMap) {
932 WindowState win = mService.windowForClientLocked(mSession, mClient, false);
Craig Mautnerd87946b2012-03-29 18:00:19 -0700933 Slog.i(TAG, "WIN DEATH: " + win);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800934 if (win != null) {
935 mService.removeWindowLocked(mSession, win);
936 }
937 }
938 } catch (IllegalArgumentException ex) {
939 // This will happen if the window has already been
940 // removed.
941 }
942 }
943 }
944
Craig Mautneref25d7a2012-05-15 23:01:47 -0700945 /** Returns true if this window desires key events.
946 * TODO(cmautner): Is this the same as {@link WindowManagerService#canBeImeTarget}
947 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800948 public final boolean canReceiveKeys() {
949 return isVisibleOrAdding()
950 && (mViewVisibility == View.VISIBLE)
951 && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0);
952 }
953
Craig Mautner749a7bb2012-04-02 13:49:53 -0700954 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800955 public boolean hasDrawnLw() {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700956 return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800957 }
958
Craig Mautner749a7bb2012-04-02 13:49:53 -0700959 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800960 public boolean showLw(boolean doAnimation) {
961 return showLw(doAnimation, true);
962 }
963
964 boolean showLw(boolean doAnimation, boolean requestAnim) {
Craig Mautner5962b122012-10-05 14:45:52 -0700965 if (isHiddenFromUserLocked()) {
Craig Mautner88400d32012-09-30 12:35:45 -0700966 Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display "
Craig Mautnera2d7b112012-08-21 15:12:20 -0700967 + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUid);
Craig Mautner9dc52bc2012-08-06 14:15:42 -0700968 return false;
969 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800970 if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
Craig Mautnere32c3072012-03-12 15:25:35 -0700971 // Already showing.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800972 return false;
973 }
Craig Mautnerd87946b2012-03-29 18:00:19 -0700974 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800975 if (doAnimation) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700976 if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility="
Craig Mautnera2c77052012-03-26 12:14:43 -0700977 + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation);
Craig Mautner2fb98b12012-03-20 17:24:00 -0700978 if (!mService.okToDisplay()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800979 doAnimation = false;
Craig Mautnera2c77052012-03-26 12:14:43 -0700980 } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800981 // Check for the case where we are currently visible and
982 // not animating; we do not want to do animation at such a
983 // point to become visible when we already are.
984 doAnimation = false;
985 }
986 }
987 mPolicyVisibility = true;
988 mPolicyVisibilityAfterAnim = true;
989 if (doAnimation) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700990 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800991 }
992 if (requestAnim) {
Craig Mautner711f90a2012-07-03 18:43:52 -0700993 mService.updateLayoutToAnimationLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800994 }
995 return true;
996 }
997
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700998 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800999 public boolean hideLw(boolean doAnimation) {
1000 return hideLw(doAnimation, true);
1001 }
1002
1003 boolean hideLw(boolean doAnimation, boolean requestAnim) {
1004 if (doAnimation) {
Craig Mautner2fb98b12012-03-20 17:24:00 -07001005 if (!mService.okToDisplay()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001006 doAnimation = false;
1007 }
1008 }
1009 boolean current = doAnimation ? mPolicyVisibilityAfterAnim
1010 : mPolicyVisibility;
1011 if (!current) {
Craig Mautnere32c3072012-03-12 15:25:35 -07001012 // Already hiding.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001013 return false;
1014 }
1015 if (doAnimation) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001016 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false);
Craig Mautnera2c77052012-03-26 12:14:43 -07001017 if (mWinAnimator.mAnimation == null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001018 doAnimation = false;
1019 }
1020 }
1021 if (doAnimation) {
1022 mPolicyVisibilityAfterAnim = false;
1023 } else {
Craig Mautnerd87946b2012-03-29 18:00:19 -07001024 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001025 mPolicyVisibilityAfterAnim = false;
1026 mPolicyVisibility = false;
1027 // Window is no longer visible -- make sure if we were waiting
1028 // for it to be displayed before enabling the display, that
1029 // we allow the display to be enabled now.
1030 mService.enableScreenIfNeededLocked();
1031 if (mService.mCurrentFocus == this) {
1032 mService.mFocusMayChange = true;
1033 }
1034 }
1035 if (requestAnim) {
Craig Mautner711f90a2012-07-03 18:43:52 -07001036 mService.updateLayoutToAnimationLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001037 }
1038 return true;
1039 }
1040
Dianne Hackbornf87d1962012-04-04 12:48:24 -07001041 @Override
1042 public boolean isAlive() {
1043 return mClient.asBinder().isBinderAlive();
1044 }
1045
Craig Mautnera987d432012-10-11 14:07:58 -07001046 boolean isClosing() {
1047 return mExiting || (mService.mClosingApps.contains(mAppToken));
1048 }
1049
Craig Mautner69b08182012-09-05 13:07:13 -07001050 @Override
1051 public boolean isDefaultDisplay() {
1052 return mDisplayContent.isDefaultDisplay;
1053 }
1054
Craig Mautner88400d32012-09-30 12:35:45 -07001055 public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {
1056 mShowToOwnerOnly = showToOwnerOnly;
1057 }
1058
Craig Mautner5962b122012-10-05 14:45:52 -07001059 boolean isHiddenFromUserLocked() {
Craig Mautner341220f2012-10-16 15:20:09 -07001060 // Attached windows are evaluated based on the window that they are attached to.
1061 WindowState win = this;
1062 while (win.mAttachedWindow != null) {
1063 win = win.mAttachedWindow;
1064 }
1065 if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
1066 && win.mAppToken != null && win.mAppToken.showWhenLocked) {
1067 // Save some cycles by not calling getDisplayInfo unless it is an application
1068 // window intended for all users.
1069 final DisplayInfo displayInfo = win.mDisplayContent.getDisplayInfo();
1070 if (win.mFrame.left <= 0 && win.mFrame.top <= 0
1071 && win.mFrame.right >= displayInfo.appWidth
1072 && win.mFrame.bottom >= displayInfo.appHeight) {
Craig Mautner5962b122012-10-05 14:45:52 -07001073 // Is a fullscreen window, like the clock alarm. Show to everyone.
1074 return false;
1075 }
1076 }
1077
Craig Mautner341220f2012-10-16 15:20:09 -07001078 return win.mShowToOwnerOnly
1079 && UserHandle.getUserId(win.mOwnerUid) != mService.mCurrentUserId;
Craig Mautner9dc52bc2012-08-06 14:15:42 -07001080 }
1081
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001082 private static void applyInsets(Region outRegion, Rect frame, Rect inset) {
1083 outRegion.set(
1084 frame.left + inset.left, frame.top + inset.top,
1085 frame.right - inset.right, frame.bottom - inset.bottom);
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001086 }
1087
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001088 public void getTouchableRegion(Region outRegion) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001089 final Rect frame = mFrame;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001090 switch (mTouchableInsets) {
1091 default:
1092 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME:
1093 outRegion.set(frame);
1094 break;
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001095 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT:
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001096 applyInsets(outRegion, frame, mGivenContentInsets);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001097 break;
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001098 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE:
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001099 applyInsets(outRegion, frame, mGivenVisibleInsets);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001100 break;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001101 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: {
1102 final Region givenTouchableRegion = mGivenTouchableRegion;
1103 outRegion.set(givenTouchableRegion);
1104 outRegion.translate(frame.left, frame.top);
1105 break;
1106 }
1107 }
1108 }
1109
Craig Mautner59c00972012-07-30 12:10:24 -07001110 WindowList getWindowList() {
1111 return mDisplayContent.getWindowList();
1112 }
1113
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001114 void dump(PrintWriter pw, String prefix, boolean dumpAll) {
Craig Mautner59c00972012-07-30 12:10:24 -07001115 pw.print(prefix); pw.print("mDisplayId="); pw.print(mDisplayContent.getDisplayId());
1116 pw.print(" mSession="); pw.print(mSession);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001117 pw.print(" mClient="); pw.println(mClient.asBinder());
Craig Mautner88400d32012-09-30 12:35:45 -07001118 pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid);
1119 pw.print(" mShowToOwnerOnly="); pw.println(mShowToOwnerOnly);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001120 pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001121 pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth);
1122 pw.print(" h="); pw.print(mRequestedHeight);
1123 pw.print(" mLayoutSeq="); pw.println(mLayoutSeq);
Dianne Hackborn1743b642012-03-12 17:04:43 -07001124 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
1125 pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth);
1126 pw.print(" h="); pw.println(mLastRequestedHeight);
1127 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001128 if (mAttachedWindow != null || mLayoutAttached) {
1129 pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow);
1130 pw.print(" mLayoutAttached="); pw.println(mLayoutAttached);
1131 }
1132 if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) {
1133 pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow);
1134 pw.print(" mIsWallpaper="); pw.print(mIsWallpaper);
1135 pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer);
1136 pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible);
1137 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001138 if (dumpAll) {
1139 pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer);
1140 pw.print(" mSubLayer="); pw.print(mSubLayer);
1141 pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+");
Craig Mautner59431632012-04-04 11:56:44 -07001142 pw.print((mTargetAppToken != null ?
1143 mTargetAppToken.mAppAnimator.animLayerAdjustment
1144 : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0)));
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001145 pw.print("="); pw.print(mWinAnimator.mAnimLayer);
1146 pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer);
Dianne Hackborn6d05fd32011-11-19 14:36:15 -08001147 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001148 if (dumpAll) {
1149 pw.print(prefix); pw.print("mToken="); pw.println(mToken);
1150 pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
1151 if (mAppToken != null) {
1152 pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken);
1153 }
1154 if (mTargetAppToken != null) {
1155 pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken);
1156 }
1157 pw.print(prefix); pw.print("mViewVisibility=0x");
1158 pw.print(Integer.toHexString(mViewVisibility));
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001159 pw.print(" mHaveFrame="); pw.print(mHaveFrame);
1160 pw.print(" mObscured="); pw.println(mObscured);
Dianne Hackborn9a230e02011-10-06 11:51:27 -07001161 pw.print(prefix); pw.print("mSeq="); pw.print(mSeq);
1162 pw.print(" mSystemUiVisibility=0x");
1163 pw.println(Integer.toHexString(mSystemUiVisibility));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001164 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001165 if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) {
1166 pw.print(prefix); pw.print("mPolicyVisibility=");
1167 pw.print(mPolicyVisibility);
1168 pw.print(" mPolicyVisibilityAfterAnim=");
1169 pw.print(mPolicyVisibilityAfterAnim);
1170 pw.print(" mAttachedHidden="); pw.println(mAttachedHidden);
1171 }
Dianne Hackbornb7ff51b2012-01-23 19:15:27 -08001172 if (!mRelayoutCalled || mLayoutNeeded) {
1173 pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled);
1174 pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001175 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001176 if (mXOffset != 0 || mYOffset != 0) {
1177 pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset);
1178 pw.print(" y="); pw.println(mYOffset);
1179 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001180 if (dumpAll) {
1181 pw.print(prefix); pw.print("mGivenContentInsets=");
1182 mGivenContentInsets.printShortString(pw);
1183 pw.print(" mGivenVisibleInsets=");
1184 mGivenVisibleInsets.printShortString(pw);
1185 pw.println();
1186 if (mTouchableInsets != 0 || mGivenInsetsPending) {
1187 pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets);
1188 pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending);
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -07001189 Region region = new Region();
1190 getTouchableRegion(region);
1191 pw.print(prefix); pw.print("touchable region="); pw.println(region);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001192 }
1193 pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001194 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001195 pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
Craig Mautner178af592012-09-17 10:37:29 -07001196 pw.print(" mShownFrame="); mShownFrame.printShortString(pw);
1197 pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay());
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001198 if (dumpAll) {
1199 pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
1200 pw.print(" last="); mLastFrame.printShortString(pw);
1201 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001202 pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
1203 pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
1204 pw.println();
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001205 }
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001206 if (mEnforceSizeCompat) {
1207 pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001208 pw.println();
1209 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001210 if (dumpAll) {
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001211 pw.print(prefix); pw.print("Frames: containing=");
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001212 mContainingFrame.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001213 pw.print(" parent="); mParentFrame.printShortString(pw);
1214 pw.print(" display="); mDisplayFrame.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001215 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001216 pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001217 pw.print(" visible="); mVisibleFrame.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001218 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001219 pw.print(prefix); pw.print("Cur insets: content=");
1220 mContentInsets.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001221 pw.print(" visible="); mVisibleInsets.printShortString(pw);
1222 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001223 pw.print(prefix); pw.print("Lst insets: content=");
1224 mLastContentInsets.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001225 pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001226 pw.println();
1227 }
Dianne Hackborn529e7442012-11-01 14:22:28 -07001228 pw.print(prefix); pw.print(mWinAnimator); pw.println(":");
1229 mWinAnimator.dump(pw, prefix + " ", dumpAll);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001230 if (mExiting || mRemoveOnExit || mDestroying || mRemoved) {
1231 pw.print(prefix); pw.print("mExiting="); pw.print(mExiting);
1232 pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit);
1233 pw.print(" mDestroying="); pw.print(mDestroying);
1234 pw.print(" mRemoved="); pw.println(mRemoved);
1235 }
1236 if (mOrientationChanging || mAppFreezing || mTurnOnScreen) {
1237 pw.print(prefix); pw.print("mOrientationChanging=");
1238 pw.print(mOrientationChanging);
1239 pw.print(" mAppFreezing="); pw.print(mAppFreezing);
1240 pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen);
1241 }
1242 if (mHScale != 1 || mVScale != 1) {
1243 pw.print(prefix); pw.print("mHScale="); pw.print(mHScale);
1244 pw.print(" mVScale="); pw.println(mVScale);
1245 }
1246 if (mWallpaperX != -1 || mWallpaperY != -1) {
1247 pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX);
1248 pw.print(" mWallpaperY="); pw.println(mWallpaperY);
1249 }
1250 if (mWallpaperXStep != -1 || mWallpaperYStep != -1) {
1251 pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep);
1252 pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep);
1253 }
1254 }
1255
1256 String makeInputChannelName() {
1257 return Integer.toHexString(System.identityHashCode(this))
1258 + " " + mAttrs.getTitle();
1259 }
1260
1261 @Override
1262 public String toString() {
1263 if (mStringNameCache == null || mLastTitle != mAttrs.getTitle()
Dianne Hackborn529e7442012-11-01 14:22:28 -07001264 || mWasExiting != mExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001265 mLastTitle = mAttrs.getTitle();
Dianne Hackborn529e7442012-11-01 14:22:28 -07001266 mWasExiting = mExiting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001267 mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -07001268 + " u" + UserHandle.getUserId(mSession.mUid)
Craig Mautnera987d432012-10-11 14:07:58 -07001269 + " " + mLastTitle + (mExiting ? " EXITING}" : "}");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001270 }
1271 return mStringNameCache;
1272 }
satokcef37fb2011-10-24 21:49:38 +09001273}