blob: 35bebbe9e0891a133f1c7ac568afa4418dc42d21 [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;
24import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
25
Jeff Brown4532e612012-04-05 14:27:12 -070026import com.android.server.input.InputWindowHandle;
27
Craig Mautnere7ae2502012-03-26 17:11:19 -070028import android.content.Context;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080029import android.content.res.Configuration;
30import android.graphics.Matrix;
31import android.graphics.PixelFormat;
32import android.graphics.Rect;
Dianne Hackbornd040edb2011-08-31 12:47:58 -070033import android.graphics.RectF;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080034import android.graphics.Region;
35import android.os.IBinder;
36import android.os.RemoteException;
Craig Mautner9dc52bc2012-08-06 14:15:42 -070037import android.os.UserHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080038import android.util.Slog;
Craig Mautner59c00972012-07-30 12:10:24 -070039import android.view.DisplayInfo;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080040import android.view.Gravity;
41import android.view.IApplicationToken;
42import android.view.IWindow;
43import android.view.InputChannel;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080044import android.view.View;
45import android.view.ViewTreeObserver;
46import android.view.WindowManager;
47import android.view.WindowManagerPolicy;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080048
49import java.io.PrintWriter;
50import java.util.ArrayList;
51
Craig Mautner59c00972012-07-30 12:10:24 -070052class WindowList extends ArrayList<WindowState> {
53}
54
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080055/**
56 * A window in the window manager.
57 */
Craig Mautnere32c3072012-03-12 15:25:35 -070058final class WindowState implements WindowManagerPolicy.WindowState {
Craig Mautnerd87946b2012-03-29 18:00:19 -070059 static final String TAG = "WindowState";
60
Dianne Hackborn5fd21692011-06-07 14:09:47 -070061 static final boolean DEBUG_VISIBILITY = WindowManagerService.DEBUG_VISIBILITY;
62 static final boolean SHOW_TRANSACTIONS = WindowManagerService.SHOW_TRANSACTIONS;
Dianne Hackborn36991742011-10-11 21:35:26 -070063 static final boolean SHOW_LIGHT_TRANSACTIONS = WindowManagerService.SHOW_LIGHT_TRANSACTIONS;
Dianne Hackborn5fd21692011-06-07 14:09:47 -070064 static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC;
65
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080066 final WindowManagerService mService;
Craig Mautnere7ae2502012-03-26 17:11:19 -070067 final WindowManagerPolicy mPolicy;
68 final Context mContext;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080069 final Session mSession;
70 final IWindow mClient;
71 WindowToken mToken;
72 WindowToken mRootToken;
73 AppWindowToken mAppToken;
74 AppWindowToken mTargetAppToken;
Craig Mautnerd09cc4b2012-04-04 10:23:31 -070075
76 // mAttrs.flags is tested in animation without being locked. If the bits tested are ever
77 // modified they will need to be locked.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080078 final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
79 final DeathRecipient mDeathRecipient;
80 final WindowState mAttachedWindow;
81 final ArrayList<WindowState> mChildWindows = new ArrayList<WindowState>();
82 final int mBaseLayer;
83 final int mSubLayer;
84 final boolean mLayoutAttached;
85 final boolean mIsImWindow;
86 final boolean mIsWallpaper;
87 final boolean mIsFloatingLayer;
Dianne Hackborn9a230e02011-10-06 11:51:27 -070088 int mSeq;
Dianne Hackborn5fd21692011-06-07 14:09:47 -070089 boolean mEnforceSizeCompat;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080090 int mViewVisibility;
Dianne Hackborn9a230e02011-10-06 11:51:27 -070091 int mSystemUiVisibility;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080092 boolean mPolicyVisibility = true;
93 boolean mPolicyVisibilityAfterAnim = true;
94 boolean mAppFreezing;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080095 boolean mAttachedHidden; // is our parent window hidden?
Dianne Hackborn6e1eb762011-02-17 16:07:28 -080096 boolean mWallpaperVisible; // for wallpaper, what was last vis report?
Dianne Hackbornffb3d932011-05-17 17:44:51 -070097
98 /**
99 * The window size that was requested by the application. These are in
100 * the application's coordinate space (without compatibility scale applied).
101 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800102 int mRequestedWidth;
103 int mRequestedHeight;
Dianne Hackborn1743b642012-03-12 17:04:43 -0700104 int mLastRequestedWidth;
105 int mLastRequestedHeight;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700106
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800107 int mLayer;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800108 boolean mHaveFrame;
109 boolean mObscured;
110 boolean mTurnOnScreen;
111
112 int mLayoutSeq = -1;
Craig Mautnera2c77052012-03-26 12:14:43 -0700113
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800114 Configuration mConfiguration = null;
Craig Mautnera2c77052012-03-26 12:14:43 -0700115
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700116 /**
117 * Actual frame shown on-screen (may be modified by animation). These
118 * are in the screen's coordinate space (WITH the compatibility scale
119 * applied).
120 */
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700121 final RectF mShownFrame = new RectF();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800122
123 /**
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700124 * Insets that determine the actually visible area. These are in the application's
125 * coordinate space (without compatibility scale applied).
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800126 */
127 final Rect mVisibleInsets = new Rect();
128 final Rect mLastVisibleInsets = new Rect();
129 boolean mVisibleInsetsChanged;
130
131 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700132 * Insets that are covered by system windows (such as the status bar) and
133 * transient docking windows (such as the IME). These are in the application's
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700134 * coordinate space (without compatibility scale applied).
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800135 */
136 final Rect mContentInsets = new Rect();
137 final Rect mLastContentInsets = new Rect();
138 boolean mContentInsetsChanged;
139
140 /**
141 * Set to true if we are waiting for this window to receive its
142 * given internal insets before laying out other windows based on it.
143 */
144 boolean mGivenInsetsPending;
145
146 /**
147 * These are the content insets that were given during layout for
148 * this window, to be applied to windows behind it.
149 */
150 final Rect mGivenContentInsets = new Rect();
151
152 /**
153 * These are the visible insets that were given during layout for
154 * this window, to be applied to windows behind it.
155 */
156 final Rect mGivenVisibleInsets = new Rect();
157
158 /**
159 * This is the given touchable area relative to the window frame, or null if none.
160 */
161 final Region mGivenTouchableRegion = new Region();
162
163 /**
164 * Flag indicating whether the touchable region should be adjusted by
165 * the visible insets; if false the area outside the visible insets is
166 * NOT touchable, so we must use those to adjust the frame during hit
167 * tests.
168 */
169 int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
170
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700171 /**
172 * This is rectangle of the window's surface that is not covered by
173 * system decorations.
174 */
175 final Rect mSystemDecorRect = new Rect();
176 final Rect mLastSystemDecorRect = new Rect();
177
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800178 // Current transformation being applied.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400179 float mGlobalScale=1;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700180 float mInvGlobalScale=1;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800181 float mHScale=1, mVScale=1;
182 float mLastHScale=1, mLastVScale=1;
183 final Matrix mTmpMatrix = new Matrix();
184
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700185 // "Real" frame that the application sees, in display coordinate space.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800186 final Rect mFrame = new Rect();
187 final Rect mLastFrame = new Rect();
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700188 // Frame that is scaled to the application's coordinate space when in
189 // screen size compatibility mode.
190 final Rect mCompatFrame = new Rect();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800191
192 final Rect mContainingFrame = new Rect();
193 final Rect mDisplayFrame = new Rect();
194 final Rect mContentFrame = new Rect();
195 final Rect mParentFrame = new Rect();
196 final Rect mVisibleFrame = new Rect();
197
198 boolean mContentChanged;
199
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800200 // If a window showing a wallpaper: the requested offset for the
201 // wallpaper; if a wallpaper window: the currently applied offset.
202 float mWallpaperX = -1;
203 float mWallpaperY = -1;
204
205 // If a window showing a wallpaper: what fraction of the offset
206 // range corresponds to a full virtual screen.
207 float mWallpaperXStep = -1;
208 float mWallpaperYStep = -1;
209
210 // Wallpaper windows: pixels offset based on above variables.
211 int mXOffset;
212 int mYOffset;
213
214 // This is set after IWindowSession.relayout() has been called at
215 // least once for the window. It allows us to detect the situation
216 // where we don't yet have a surface, but should have one soon, so
217 // we can give the window focus before waiting for the relayout.
218 boolean mRelayoutCalled;
219
Dianne Hackbornb7ff51b2012-01-23 19:15:27 -0800220 // If the application has called relayout() with changes that can
221 // impact its window's size, we need to perform a layout pass on it
222 // even if it is not currently visible for layout. This is set
223 // when in that case until the layout is done.
224 boolean mLayoutNeeded;
225
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800226 // Currently running an exit animation?
227 boolean mExiting;
228
229 // Currently on the mDestroySurface list?
230 boolean mDestroying;
231
232 // Completely remove from window manager after exit animation?
233 boolean mRemoveOnExit;
234
235 // Set when the orientation is changing and this window has not yet
236 // been updated for the new orientation.
237 boolean mOrientationChanging;
238
239 // Is this window now (or just being) removed?
240 boolean mRemoved;
241
242 // Temp for keeping track of windows that have been removed when
243 // rebuilding window list.
244 boolean mRebuilding;
245
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800246 // Input channel and input window handle used by the input dispatcher.
Jeff Brown9302c872011-07-13 22:51:29 -0700247 final InputWindowHandle mInputWindowHandle;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800248 InputChannel mInputChannel;
249
250 // Used to improve performance of toString()
251 String mStringNameCache;
252 CharSequence mLastTitle;
Dianne Hackborn529e7442012-11-01 14:22:28 -0700253 boolean mWasExiting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800254
Craig Mautnera2c77052012-03-26 12:14:43 -0700255 final WindowStateAnimator mWinAnimator;
256
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700257 boolean mHasSurface = false;
258
Craig Mautner59c00972012-07-30 12:10:24 -0700259 DisplayContent mDisplayContent;
Craig Mautner6881a102012-07-27 13:04:51 -0700260
Craig Mautnera2d7b112012-08-21 15:12:20 -0700261 // UserId and appId of the owner. Don't display windows of non-current user.
Craig Mautner88400d32012-09-30 12:35:45 -0700262 int mOwnerUid;
263
264 /** When true this window can be displayed on screens owther than mOwnerUid's */
265 private boolean mShowToOwnerOnly;
Craig Mautner9dc52bc2012-08-06 14:15:42 -0700266
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800267 WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700268 WindowState attachedWindow, int seq, WindowManager.LayoutParams a,
Craig Mautner59c00972012-07-30 12:10:24 -0700269 int viewVisibility, final DisplayContent displayContent) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800270 mService = service;
271 mSession = s;
272 mClient = c;
273 mToken = token;
Craig Mautnera2d7b112012-08-21 15:12:20 -0700274 mOwnerUid = s.mUid;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800275 mAttrs.copyFrom(a);
276 mViewVisibility = viewVisibility;
Craig Mautner59c00972012-07-30 12:10:24 -0700277 mDisplayContent = displayContent;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700278 mPolicy = mService.mPolicy;
279 mContext = mService.mContext;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800280 DeathRecipient deathRecipient = new DeathRecipient();
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700281 mSeq = seq;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400282 mEnforceSizeCompat = (mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800283 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautnerd87946b2012-03-29 18:00:19 -0700284 TAG, "Window " + this + " client=" + c.asBinder()
Craig Mautnerad09bcc2012-10-08 13:33:11 -0700285 + " token=" + token + " (" + mAttrs.token + ")" + " params=" + a);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800286 try {
287 c.asBinder().linkToDeath(deathRecipient, 0);
288 } catch (RemoteException e) {
289 mDeathRecipient = null;
290 mAttachedWindow = null;
291 mLayoutAttached = false;
292 mIsImWindow = false;
293 mIsWallpaper = false;
294 mIsFloatingLayer = false;
295 mBaseLayer = 0;
296 mSubLayer = 0;
Jeff Brown9302c872011-07-13 22:51:29 -0700297 mInputWindowHandle = null;
Craig Mautnera2c77052012-03-26 12:14:43 -0700298 mWinAnimator = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800299 return;
300 }
301 mDeathRecipient = deathRecipient;
302
303 if ((mAttrs.type >= FIRST_SUB_WINDOW &&
304 mAttrs.type <= LAST_SUB_WINDOW)) {
305 // The multiplier here is to reserve space for multiple
306 // windows in the same type layer.
Craig Mautnere7ae2502012-03-26 17:11:19 -0700307 mBaseLayer = mPolicy.windowTypeToLayerLw(
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800308 attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER
309 + WindowManagerService.TYPE_LAYER_OFFSET;
Craig Mautnere7ae2502012-03-26 17:11:19 -0700310 mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800311 mAttachedWindow = attachedWindow;
Craig Mautnerd87946b2012-03-29 18:00:19 -0700312 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800313 mAttachedWindow.mChildWindows.add(this);
314 mLayoutAttached = mAttrs.type !=
315 WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
316 mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD
317 || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
318 mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER;
319 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
320 } else {
321 // The multiplier here is to reserve space for multiple
322 // windows in the same type layer.
Craig Mautnere7ae2502012-03-26 17:11:19 -0700323 mBaseLayer = mPolicy.windowTypeToLayerLw(a.type)
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800324 * WindowManagerService.TYPE_LAYER_MULTIPLIER
325 + WindowManagerService.TYPE_LAYER_OFFSET;
326 mSubLayer = 0;
327 mAttachedWindow = null;
328 mLayoutAttached = false;
329 mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD
330 || mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
331 mIsWallpaper = mAttrs.type == TYPE_WALLPAPER;
332 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
333 }
334
335 WindowState appWin = this;
336 while (appWin.mAttachedWindow != null) {
Craig Mautnera2c77052012-03-26 12:14:43 -0700337 appWin = appWin.mAttachedWindow;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800338 }
339 WindowToken appToken = appWin.mToken;
340 while (appToken.appWindowToken == null) {
341 WindowToken parent = mService.mTokenMap.get(appToken.token);
342 if (parent == null || appToken == parent) {
343 break;
344 }
345 appToken = parent;
346 }
347 mRootToken = appToken;
348 mAppToken = appToken.appWindowToken;
349
Craig Mautner322e4032012-07-13 13:35:20 -0700350 mWinAnimator = new WindowStateAnimator(this);
351 mWinAnimator.mAlpha = a.alpha;
352
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800353 mRequestedWidth = 0;
354 mRequestedHeight = 0;
Dianne Hackborn1743b642012-03-12 17:04:43 -0700355 mLastRequestedWidth = 0;
356 mLastRequestedHeight = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800357 mXOffset = 0;
358 mYOffset = 0;
359 mLayer = 0;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800360 mInputWindowHandle = new InputWindowHandle(
Craig Mautner59c00972012-07-30 12:10:24 -0700361 mAppToken != null ? mAppToken.mInputApplicationHandle : null, this,
362 displayContent.getDisplayId());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800363 }
364
365 void attach() {
366 if (WindowManagerService.localLOGV) Slog.v(
Craig Mautnerd87946b2012-03-29 18:00:19 -0700367 TAG, "Attaching " + this + " token=" + mToken
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800368 + ", list=" + mToken.windows);
369 mSession.windowAddedLocked();
370 }
371
Craig Mautnera2c77052012-03-26 12:14:43 -0700372 @Override
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700373 public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800374 mHaveFrame = true;
375
376 final Rect container = mContainingFrame;
377 container.set(pf);
378
379 final Rect display = mDisplayFrame;
380 display.set(df);
381
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800382 final int pw = container.right - container.left;
383 final int ph = container.bottom - container.top;
384
385 int w,h;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700386 if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) {
387 if (mAttrs.width < 0) {
388 w = pw;
389 } else if (mEnforceSizeCompat) {
390 w = (int)(mAttrs.width * mGlobalScale + .5f);
391 } else {
392 w = mAttrs.width;
393 }
394 if (mAttrs.height < 0) {
395 h = ph;
396 } else if (mEnforceSizeCompat) {
397 h = (int)(mAttrs.height * mGlobalScale + .5f);
398 } else {
399 h = mAttrs.height;
400 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800401 } else {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700402 if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) {
403 w = pw;
404 } else if (mEnforceSizeCompat) {
405 w = (int)(mRequestedWidth * mGlobalScale + .5f);
406 } else {
407 w = mRequestedWidth;
408 }
409 if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
410 h = ph;
411 } else if (mEnforceSizeCompat) {
412 h = (int)(mRequestedHeight * mGlobalScale + .5f);
413 } else {
414 h = mRequestedHeight;
415 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800416 }
417
418 if (!mParentFrame.equals(pf)) {
419 //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame
420 // + " to " + pf);
421 mParentFrame.set(pf);
422 mContentChanged = true;
423 }
Dianne Hackborn1743b642012-03-12 17:04:43 -0700424 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
425 mLastRequestedWidth = mRequestedWidth;
426 mLastRequestedHeight = mRequestedHeight;
427 mContentChanged = true;
428 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800429
430 final Rect content = mContentFrame;
431 content.set(cf);
432
433 final Rect visible = mVisibleFrame;
434 visible.set(vf);
435
436 final Rect frame = mFrame;
437 final int fw = frame.width();
438 final int fh = frame.height();
439
440 //System.out.println("In: w=" + w + " h=" + h + " container=" +
441 // container + " x=" + mAttrs.x + " y=" + mAttrs.y);
442
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700443 float x, y;
444 if (mEnforceSizeCompat) {
445 x = mAttrs.x * mGlobalScale;
446 y = mAttrs.y * mGlobalScale;
447 } else {
448 x = mAttrs.x;
449 y = mAttrs.y;
450 }
451
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800452 Gravity.apply(mAttrs.gravity, w, h, container,
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700453 (int) (x + mAttrs.horizontalMargin * pw),
454 (int) (y + mAttrs.verticalMargin * ph), frame);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800455
456 //System.out.println("Out: " + mFrame);
457
458 // Now make sure the window fits in the overall display.
459 Gravity.applyDisplay(mAttrs.gravity, df, frame);
460
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700461 // Make sure the system, content and visible frames are inside of the
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800462 // final window frame.
463 if (content.left < frame.left) content.left = frame.left;
464 if (content.top < frame.top) content.top = frame.top;
465 if (content.right > frame.right) content.right = frame.right;
466 if (content.bottom > frame.bottom) content.bottom = frame.bottom;
467 if (visible.left < frame.left) visible.left = frame.left;
468 if (visible.top < frame.top) visible.top = frame.top;
469 if (visible.right > frame.right) visible.right = frame.right;
470 if (visible.bottom > frame.bottom) visible.bottom = frame.bottom;
471
472 final Rect contentInsets = mContentInsets;
473 contentInsets.left = content.left-frame.left;
474 contentInsets.top = content.top-frame.top;
475 contentInsets.right = frame.right-content.right;
476 contentInsets.bottom = frame.bottom-content.bottom;
477
478 final Rect visibleInsets = mVisibleInsets;
479 visibleInsets.left = visible.left-frame.left;
480 visibleInsets.top = visible.top-frame.top;
481 visibleInsets.right = frame.right-visible.right;
482 visibleInsets.bottom = frame.bottom-visible.bottom;
483
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700484 mCompatFrame.set(frame);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400485 if (mEnforceSizeCompat) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700486 // If there is a size compatibility scale being applied to the
487 // window, we need to apply this to its insets so that they are
488 // reported to the app in its coordinate space.
489 contentInsets.scale(mInvGlobalScale);
490 visibleInsets.scale(mInvGlobalScale);
491
492 // Also the scaled frame that we report to the app needs to be
493 // adjusted to be in its coordinate space.
494 mCompatFrame.scale(mInvGlobalScale);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400495 }
496
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800497 if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
Craig Mautner59c00972012-07-30 12:10:24 -0700498 final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
499 mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight,
500 false);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800501 }
502
503 if (WindowManagerService.localLOGV) {
504 //if ("com.google.android.youtube".equals(mAttrs.packageName)
505 // && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700506 Slog.v(TAG, "Resolving (mRequestedWidth="
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800507 + mRequestedWidth + ", mRequestedheight="
508 + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
509 + "): frame=" + mFrame.toShortString()
510 + " ci=" + contentInsets.toShortString()
511 + " vi=" + visibleInsets.toShortString());
512 //}
513 }
514 }
515
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700516 MagnificationSpec getWindowMagnificationSpecLocked() {
517 MagnificationSpec spec = mDisplayContent.mMagnificationSpec;
518 if (spec != null && !spec.isNop()) {
519 if (mAttachedWindow != null) {
Craig Mautnerf1b67412012-09-19 13:18:29 -0700520 if (!mPolicy.canMagnifyWindowLw(mAttachedWindow.mAttrs)) {
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700521 return null;
522 }
523 }
Craig Mautnerf1b67412012-09-19 13:18:29 -0700524 if (!mPolicy.canMagnifyWindowLw(mAttrs)) {
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700525 return null;
526 }
527 }
528 return spec;
529 }
530
Craig Mautnera2c77052012-03-26 12:14:43 -0700531 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800532 public Rect getFrameLw() {
533 return mFrame;
534 }
535
Craig Mautnera2c77052012-03-26 12:14:43 -0700536 @Override
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700537 public RectF getShownFrameLw() {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800538 return mShownFrame;
539 }
540
Craig Mautnera2c77052012-03-26 12:14:43 -0700541 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800542 public Rect getDisplayFrameLw() {
543 return mDisplayFrame;
544 }
545
Craig Mautnera2c77052012-03-26 12:14:43 -0700546 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800547 public Rect getContentFrameLw() {
548 return mContentFrame;
549 }
550
Craig Mautnera2c77052012-03-26 12:14:43 -0700551 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800552 public Rect getVisibleFrameLw() {
553 return mVisibleFrame;
554 }
555
Craig Mautnera2c77052012-03-26 12:14:43 -0700556 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800557 public boolean getGivenInsetsPendingLw() {
558 return mGivenInsetsPending;
559 }
560
Craig Mautnera2c77052012-03-26 12:14:43 -0700561 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800562 public Rect getGivenContentInsetsLw() {
563 return mGivenContentInsets;
564 }
565
Craig Mautnera2c77052012-03-26 12:14:43 -0700566 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800567 public Rect getGivenVisibleInsetsLw() {
568 return mGivenVisibleInsets;
569 }
570
Craig Mautnera2c77052012-03-26 12:14:43 -0700571 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800572 public WindowManager.LayoutParams getAttrs() {
573 return mAttrs;
574 }
575
Craig Mautner812d2ca2012-09-27 15:35:34 -0700576 @Override
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800577 public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) {
578 int index = -1;
579 WindowState ws = this;
Craig Mautner59c00972012-07-30 12:10:24 -0700580 WindowList windows = getWindowList();
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800581 while (true) {
582 if ((ws.mAttrs.privateFlags
583 & WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY) != 0) {
584 return (ws.mAttrs.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0;
585 }
586 // If we reached the bottom of the range of windows we are considering,
587 // assume no menu is needed.
588 if (ws == bottom) {
589 return false;
590 }
591 // The current window hasn't specified whether menu key is needed;
592 // look behind it.
593 // First, we may need to determine the starting position.
594 if (index < 0) {
Craig Mautner59c00972012-07-30 12:10:24 -0700595 index = windows.indexOf(ws);
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800596 }
597 index--;
598 if (index < 0) {
599 return false;
600 }
Craig Mautner59c00972012-07-30 12:10:24 -0700601 ws = windows.get(index);
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800602 }
603 }
604
Craig Mautner19d59bc2012-09-04 11:15:56 -0700605 @Override
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700606 public int getSystemUiVisibility() {
607 return mSystemUiVisibility;
608 }
609
Craig Mautner19d59bc2012-09-04 11:15:56 -0700610 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800611 public int getSurfaceLayer() {
612 return mLayer;
613 }
614
Craig Mautner812d2ca2012-09-27 15:35:34 -0700615 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800616 public IApplicationToken getAppToken() {
617 return mAppToken != null ? mAppToken.appToken : null;
618 }
Craig Mautner19d59bc2012-09-04 11:15:56 -0700619
620 public int getDisplayId() {
621 return mDisplayContent.getDisplayId();
622 }
623
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800624 public long getInputDispatchingTimeoutNanos() {
625 return mAppToken != null
626 ? mAppToken.inputDispatchingTimeoutNanos
627 : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
628 }
629
630 public boolean hasAppShownWindows() {
Craig Mautnerf4120952012-06-21 18:25:39 -0700631 return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800632 }
633
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800634 boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
635 if (dsdx < .99999f || dsdx > 1.00001f) return false;
636 if (dtdy < .99999f || dtdy > 1.00001f) return false;
637 if (dtdx < -.000001f || dtdx > .000001f) return false;
638 if (dsdy < -.000001f || dsdy > .000001f) return false;
639 return true;
640 }
641
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400642 void prelayout() {
643 if (mEnforceSizeCompat) {
644 mGlobalScale = mService.mCompatibleScreenScale;
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700645 mInvGlobalScale = 1/mGlobalScale;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400646 } else {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700647 mGlobalScale = mInvGlobalScale = 1;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400648 }
649 }
650
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800651 /**
652 * Is this window visible? It is not visible if there is no
653 * surface, or we are in the process of running an exit animation
654 * that will remove the surface, or its app token has been hidden.
655 */
Craig Mautner88400d32012-09-30 12:35:45 -0700656 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800657 public boolean isVisibleLw() {
658 final AppWindowToken atoken = mAppToken;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700659 return mHasSurface && mPolicyVisibility && !mAttachedHidden
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800660 && (atoken == null || !atoken.hiddenRequested)
661 && !mExiting && !mDestroying;
662 }
663
664 /**
665 * Like {@link #isVisibleLw}, but also counts a window that is currently
666 * "hidden" behind the keyguard as visible. This allows us to apply
667 * things like window flags that impact the keyguard.
668 * XXX I am starting to think we need to have ANOTHER visibility flag
669 * for this "hidden behind keyguard" state rather than overloading
670 * mPolicyVisibility. Ungh.
671 */
Craig Mautner88400d32012-09-30 12:35:45 -0700672 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800673 public boolean isVisibleOrBehindKeyguardLw() {
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700674 if (mRootToken.waitingToShow &&
675 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
676 return false;
677 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800678 final AppWindowToken atoken = mAppToken;
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700679 final boolean animating = atoken != null
Craig Mautner59431632012-04-04 11:56:44 -0700680 ? (atoken.mAppAnimator.animation != null) : false;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700681 return mHasSurface && !mDestroying && !mExiting
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800682 && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested)
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700683 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
684 && !mRootToken.hidden)
Craig Mautnera2c77052012-03-26 12:14:43 -0700685 || mWinAnimator.mAnimation != null || animating);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800686 }
687
688 /**
689 * Is this window visible, ignoring its app token? It is not visible
690 * if there is no surface, or we are in the process of running an exit animation
691 * that will remove the surface.
692 */
693 public boolean isWinVisibleLw() {
694 final AppWindowToken atoken = mAppToken;
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700695 return mHasSurface && mPolicyVisibility && !mAttachedHidden
Craig Mautner59431632012-04-04 11:56:44 -0700696 && (atoken == null || !atoken.hiddenRequested || atoken.mAppAnimator.animating)
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800697 && !mExiting && !mDestroying;
698 }
699
700 /**
701 * The same as isVisible(), but follows the current hidden state of
702 * the associated app token, not the pending requested hidden state.
703 */
704 boolean isVisibleNow() {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700705 return mHasSurface && mPolicyVisibility && !mAttachedHidden
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800706 && !mRootToken.hidden && !mExiting && !mDestroying;
707 }
708
709 /**
710 * Can this window possibly be a drag/drop target? The test here is
711 * a combination of the above "visible now" with the check that the
712 * Input Manager uses when discarding windows from input consideration.
713 */
714 boolean isPotentialDragTarget() {
Jeff Browncc4f7db2011-08-30 20:34:48 -0700715 return isVisibleNow() && !mRemoved
716 && mInputChannel != null && mInputWindowHandle != null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800717 }
718
719 /**
720 * Same as isVisible(), but we also count it as visible between the
721 * call to IWindowSession.add() and the first relayout().
722 */
723 boolean isVisibleOrAdding() {
724 final AppWindowToken atoken = mAppToken;
Craig Mautnerbf08af32012-05-16 19:43:42 -0700725 return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800726 && mPolicyVisibility && !mAttachedHidden
727 && (atoken == null || !atoken.hiddenRequested)
728 && !mExiting && !mDestroying;
729 }
730
731 /**
732 * Is this window currently on-screen? It is on-screen either if it
733 * is visible or it is currently running an animation before no longer
734 * being visible.
735 */
736 boolean isOnScreen() {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700737 if (!mHasSurface || !mPolicyVisibility || mDestroying) {
738 return false;
739 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800740 final AppWindowToken atoken = mAppToken;
741 if (atoken != null) {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700742 return ((!mAttachedHidden && !atoken.hiddenRequested)
Craig Mautner59431632012-04-04 11:56:44 -0700743 || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800744 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700745 return !mAttachedHidden || mWinAnimator.mAnimation != null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800746 }
747
748 /**
749 * Like isOnScreen(), but we don't return true if the window is part
750 * of a transition that has not yet been started.
751 */
752 boolean isReadyForDisplay() {
753 if (mRootToken.waitingToShow &&
754 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
755 return false;
756 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700757 return mHasSurface && mPolicyVisibility && !mDestroying
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800758 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
759 && !mRootToken.hidden)
Craig Mautnera2c77052012-03-26 12:14:43 -0700760 || mWinAnimator.mAnimation != null
Craig Mautner59431632012-04-04 11:56:44 -0700761 || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null)));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800762 }
763
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800764 /**
Dianne Hackborn6e2281d2012-06-19 17:48:32 -0700765 * Like isReadyForDisplay(), but ignores any force hiding of the window due
766 * to the keyguard.
767 */
768 boolean isReadyForDisplayIgnoringKeyguard() {
769 if (mRootToken.waitingToShow &&
770 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
771 return false;
772 }
773 final AppWindowToken atoken = mAppToken;
774 if (atoken == null && !mPolicyVisibility) {
775 // If this is not an app window, and the policy has asked to force
776 // hide, then we really do want to hide.
777 return false;
778 }
779 return mHasSurface && !mDestroying
780 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
781 && !mRootToken.hidden)
782 || mWinAnimator.mAnimation != null
Craig Mautner9c5bf3b2012-06-22 15:19:13 -0700783 || ((atoken != null) && (atoken.mAppAnimator.animation != null)
784 && !mWinAnimator.isDummyAnimation()));
Dianne Hackborn6e2281d2012-06-19 17:48:32 -0700785 }
786
787 /**
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800788 * Like isOnScreen, but returns false if the surface hasn't yet
789 * been drawn.
790 */
Craig Mautnere6f7d5052012-10-08 10:34:17 -0700791 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800792 public boolean isDisplayedLw() {
793 final AppWindowToken atoken = mAppToken;
Craig Mautnerbf90eaa2012-03-15 11:28:53 -0700794 return isDrawnLw() && mPolicyVisibility
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800795 && ((!mAttachedHidden &&
796 (atoken == null || !atoken.hiddenRequested))
Craig Mautnere6f7d5052012-10-08 10:34:17 -0700797 || mWinAnimator.mAnimating
798 || (atoken != null && atoken.mAppAnimator.animation != null));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800799 }
800
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700801 /**
802 * Return true if this window (or a window it is attached to, but not
803 * considering its app token) is currently animating.
804 */
Craig Mautnere6f7d5052012-10-08 10:34:17 -0700805 @Override
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700806 public boolean isAnimatingLw() {
807 return mWinAnimator.mAnimation != null;
808 }
809
Craig Mautner812d2ca2012-09-27 15:35:34 -0700810 @Override
Dianne Hackborncfbf7de2012-01-12 14:05:03 -0800811 public boolean isGoneForLayoutLw() {
812 final AppWindowToken atoken = mAppToken;
813 return mViewVisibility == View.GONE
814 || !mRelayoutCalled
815 || (atoken == null && mRootToken.hidden)
Craig Mautner812d2ca2012-09-27 15:35:34 -0700816 || (atoken != null && (atoken.hiddenRequested || atoken.hidden))
Dianne Hackborncfbf7de2012-01-12 14:05:03 -0800817 || mAttachedHidden
818 || mExiting || mDestroying;
819 }
820
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800821 /**
822 * Returns true if the window has a surface that it has drawn a
823 * complete UI in to.
824 */
825 public boolean isDrawnLw() {
Craig Mautnerc8bc97e2012-04-02 12:54:54 -0700826 return mHasSurface && !mDestroying &&
Craig Mautner749a7bb2012-04-02 13:49:53 -0700827 (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW
828 || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800829 }
830
831 /**
832 * Return true if the window is opaque and fully drawn. This indicates
833 * it may obscure windows behind it.
834 */
835 boolean isOpaqueDrawn() {
836 return (mAttrs.format == PixelFormat.OPAQUE
837 || mAttrs.type == TYPE_WALLPAPER)
Craig Mautnera2c77052012-03-26 12:14:43 -0700838 && isDrawnLw() && mWinAnimator.mAnimation == null
Craig Mautner59431632012-04-04 11:56:44 -0700839 && (mAppToken == null || mAppToken.mAppAnimator.animation == null);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800840 }
841
842 /**
843 * Return whether this window is wanting to have a translation
844 * animation applied to it for an in-progress move. (Only makes
845 * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
846 */
847 boolean shouldAnimateMove() {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700848 return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800849 && (mFrame.top != mLastFrame.top
850 || mFrame.left != mLastFrame.left)
Craig Mautner2fb98b12012-03-20 17:24:00 -0700851 && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove());
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800852 }
853
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800854 boolean isFullscreen(int screenWidth, int screenHeight) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -0700855 return mFrame.left <= 0 && mFrame.top <= 0 &&
856 mFrame.right >= screenWidth && mFrame.bottom >= screenHeight;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800857 }
858
Craig Mautner812d2ca2012-09-27 15:35:34 -0700859 boolean isConfigChanged() {
860 return mConfiguration != mService.mCurConfiguration
861 && (mConfiguration == null
862 || (mConfiguration.diff(mService.mCurConfiguration) != 0));
863 }
864
865 boolean isConfigDiff(int mask) {
866 return mConfiguration != mService.mCurConfiguration
867 && mConfiguration != null
868 && (mConfiguration.diff(mService.mCurConfiguration) & mask) != 0;
869 }
870
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800871 void removeLocked() {
872 disposeInputChannel();
873
874 if (mAttachedWindow != null) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700875 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800876 mAttachedWindow.mChildWindows.remove(this);
877 }
Dianne Hackborn98129732012-11-01 16:28:16 -0700878 mWinAnimator.destroyDeferredSurfaceLocked(false);
879 mWinAnimator.destroySurfaceLocked(false);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800880 mSession.windowRemovedLocked();
881 try {
882 mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
883 } catch (RuntimeException e) {
884 // Ignore if it has already been removed (usually because
885 // we are doing this as part of processing a death note.)
886 }
887 }
Jeff Browncc4f7db2011-08-30 20:34:48 -0700888
889 void setInputChannel(InputChannel inputChannel) {
890 if (mInputChannel != null) {
891 throw new IllegalStateException("Window already has an input channel.");
892 }
893
894 mInputChannel = inputChannel;
895 mInputWindowHandle.inputChannel = inputChannel;
896 }
897
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800898 void disposeInputChannel() {
899 if (mInputChannel != null) {
900 mService.mInputManager.unregisterInputChannel(mInputChannel);
901
902 mInputChannel.dispose();
903 mInputChannel = null;
904 }
Jeff Browncc4f7db2011-08-30 20:34:48 -0700905
906 mInputWindowHandle.inputChannel = null;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800907 }
908
909 private class DeathRecipient implements IBinder.DeathRecipient {
910 public void binderDied() {
911 try {
912 synchronized(mService.mWindowMap) {
913 WindowState win = mService.windowForClientLocked(mSession, mClient, false);
Craig Mautnerd87946b2012-03-29 18:00:19 -0700914 Slog.i(TAG, "WIN DEATH: " + win);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800915 if (win != null) {
916 mService.removeWindowLocked(mSession, win);
917 }
918 }
919 } catch (IllegalArgumentException ex) {
920 // This will happen if the window has already been
921 // removed.
922 }
923 }
924 }
925
Craig Mautneref25d7a2012-05-15 23:01:47 -0700926 /** Returns true if this window desires key events.
927 * TODO(cmautner): Is this the same as {@link WindowManagerService#canBeImeTarget}
928 */
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800929 public final boolean canReceiveKeys() {
930 return isVisibleOrAdding()
931 && (mViewVisibility == View.VISIBLE)
932 && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0);
933 }
934
Craig Mautner749a7bb2012-04-02 13:49:53 -0700935 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800936 public boolean hasDrawnLw() {
Craig Mautner749a7bb2012-04-02 13:49:53 -0700937 return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800938 }
939
Craig Mautner749a7bb2012-04-02 13:49:53 -0700940 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800941 public boolean showLw(boolean doAnimation) {
942 return showLw(doAnimation, true);
943 }
944
945 boolean showLw(boolean doAnimation, boolean requestAnim) {
Craig Mautner5962b122012-10-05 14:45:52 -0700946 if (isHiddenFromUserLocked()) {
Craig Mautner88400d32012-09-30 12:35:45 -0700947 Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display "
Craig Mautnera2d7b112012-08-21 15:12:20 -0700948 + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUid);
Craig Mautner9dc52bc2012-08-06 14:15:42 -0700949 return false;
950 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800951 if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
Craig Mautnere32c3072012-03-12 15:25:35 -0700952 // Already showing.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800953 return false;
954 }
Craig Mautnerd87946b2012-03-29 18:00:19 -0700955 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800956 if (doAnimation) {
Craig Mautnerd87946b2012-03-29 18:00:19 -0700957 if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility="
Craig Mautnera2c77052012-03-26 12:14:43 -0700958 + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation);
Craig Mautner2fb98b12012-03-20 17:24:00 -0700959 if (!mService.okToDisplay()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800960 doAnimation = false;
Craig Mautnera2c77052012-03-26 12:14:43 -0700961 } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800962 // Check for the case where we are currently visible and
963 // not animating; we do not want to do animation at such a
964 // point to become visible when we already are.
965 doAnimation = false;
966 }
967 }
968 mPolicyVisibility = true;
969 mPolicyVisibilityAfterAnim = true;
970 if (doAnimation) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700971 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800972 }
973 if (requestAnim) {
Craig Mautner711f90a2012-07-03 18:43:52 -0700974 mService.updateLayoutToAnimationLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800975 }
976 return true;
977 }
978
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700979 @Override
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800980 public boolean hideLw(boolean doAnimation) {
981 return hideLw(doAnimation, true);
982 }
983
984 boolean hideLw(boolean doAnimation, boolean requestAnim) {
985 if (doAnimation) {
Craig Mautner2fb98b12012-03-20 17:24:00 -0700986 if (!mService.okToDisplay()) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800987 doAnimation = false;
988 }
989 }
990 boolean current = doAnimation ? mPolicyVisibilityAfterAnim
991 : mPolicyVisibility;
992 if (!current) {
Craig Mautnere32c3072012-03-12 15:25:35 -0700993 // Already hiding.
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800994 return false;
995 }
996 if (doAnimation) {
Craig Mautnerc2f9be02012-03-27 17:32:29 -0700997 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false);
Craig Mautnera2c77052012-03-26 12:14:43 -0700998 if (mWinAnimator.mAnimation == null) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -0800999 doAnimation = false;
1000 }
1001 }
1002 if (doAnimation) {
1003 mPolicyVisibilityAfterAnim = false;
1004 } else {
Craig Mautnerd87946b2012-03-29 18:00:19 -07001005 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001006 mPolicyVisibilityAfterAnim = false;
1007 mPolicyVisibility = false;
1008 // Window is no longer visible -- make sure if we were waiting
1009 // for it to be displayed before enabling the display, that
1010 // we allow the display to be enabled now.
1011 mService.enableScreenIfNeededLocked();
1012 if (mService.mCurrentFocus == this) {
1013 mService.mFocusMayChange = true;
1014 }
1015 }
1016 if (requestAnim) {
Craig Mautner711f90a2012-07-03 18:43:52 -07001017 mService.updateLayoutToAnimationLocked();
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001018 }
1019 return true;
1020 }
1021
Dianne Hackbornf87d1962012-04-04 12:48:24 -07001022 @Override
1023 public boolean isAlive() {
1024 return mClient.asBinder().isBinderAlive();
1025 }
1026
Craig Mautnera987d432012-10-11 14:07:58 -07001027 boolean isClosing() {
1028 return mExiting || (mService.mClosingApps.contains(mAppToken));
1029 }
1030
Craig Mautner69b08182012-09-05 13:07:13 -07001031 @Override
1032 public boolean isDefaultDisplay() {
1033 return mDisplayContent.isDefaultDisplay;
1034 }
1035
Craig Mautner88400d32012-09-30 12:35:45 -07001036 public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {
1037 mShowToOwnerOnly = showToOwnerOnly;
1038 }
1039
Craig Mautner5962b122012-10-05 14:45:52 -07001040 boolean isHiddenFromUserLocked() {
Craig Mautner341220f2012-10-16 15:20:09 -07001041 // Attached windows are evaluated based on the window that they are attached to.
1042 WindowState win = this;
1043 while (win.mAttachedWindow != null) {
1044 win = win.mAttachedWindow;
1045 }
1046 if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
1047 && win.mAppToken != null && win.mAppToken.showWhenLocked) {
1048 // Save some cycles by not calling getDisplayInfo unless it is an application
1049 // window intended for all users.
1050 final DisplayInfo displayInfo = win.mDisplayContent.getDisplayInfo();
1051 if (win.mFrame.left <= 0 && win.mFrame.top <= 0
1052 && win.mFrame.right >= displayInfo.appWidth
1053 && win.mFrame.bottom >= displayInfo.appHeight) {
Craig Mautner5962b122012-10-05 14:45:52 -07001054 // Is a fullscreen window, like the clock alarm. Show to everyone.
1055 return false;
1056 }
1057 }
1058
Craig Mautner341220f2012-10-16 15:20:09 -07001059 return win.mShowToOwnerOnly
1060 && UserHandle.getUserId(win.mOwnerUid) != mService.mCurrentUserId;
Craig Mautner9dc52bc2012-08-06 14:15:42 -07001061 }
1062
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001063 private static void applyInsets(Region outRegion, Rect frame, Rect inset) {
1064 outRegion.set(
1065 frame.left + inset.left, frame.top + inset.top,
1066 frame.right - inset.right, frame.bottom - inset.bottom);
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001067 }
1068
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001069 public void getTouchableRegion(Region outRegion) {
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001070 final Rect frame = mFrame;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001071 switch (mTouchableInsets) {
1072 default:
1073 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME:
1074 outRegion.set(frame);
1075 break;
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001076 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT:
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001077 applyInsets(outRegion, frame, mGivenContentInsets);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001078 break;
Dianne Hackborne2515ee2011-04-27 18:52:56 -04001079 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE:
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001080 applyInsets(outRegion, frame, mGivenVisibleInsets);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001081 break;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001082 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: {
1083 final Region givenTouchableRegion = mGivenTouchableRegion;
1084 outRegion.set(givenTouchableRegion);
1085 outRegion.translate(frame.left, frame.top);
1086 break;
1087 }
1088 }
1089 }
1090
Craig Mautner59c00972012-07-30 12:10:24 -07001091 WindowList getWindowList() {
1092 return mDisplayContent.getWindowList();
1093 }
1094
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001095 void dump(PrintWriter pw, String prefix, boolean dumpAll) {
Craig Mautner59c00972012-07-30 12:10:24 -07001096 pw.print(prefix); pw.print("mDisplayId="); pw.print(mDisplayContent.getDisplayId());
1097 pw.print(" mSession="); pw.print(mSession);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001098 pw.print(" mClient="); pw.println(mClient.asBinder());
Craig Mautner88400d32012-09-30 12:35:45 -07001099 pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid);
1100 pw.print(" mShowToOwnerOnly="); pw.println(mShowToOwnerOnly);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001101 pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001102 pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth);
1103 pw.print(" h="); pw.print(mRequestedHeight);
1104 pw.print(" mLayoutSeq="); pw.println(mLayoutSeq);
Dianne Hackborn1743b642012-03-12 17:04:43 -07001105 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
1106 pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth);
1107 pw.print(" h="); pw.println(mLastRequestedHeight);
1108 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001109 if (mAttachedWindow != null || mLayoutAttached) {
1110 pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow);
1111 pw.print(" mLayoutAttached="); pw.println(mLayoutAttached);
1112 }
1113 if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) {
1114 pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow);
1115 pw.print(" mIsWallpaper="); pw.print(mIsWallpaper);
1116 pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer);
1117 pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible);
1118 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001119 if (dumpAll) {
1120 pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer);
1121 pw.print(" mSubLayer="); pw.print(mSubLayer);
1122 pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+");
Craig Mautner59431632012-04-04 11:56:44 -07001123 pw.print((mTargetAppToken != null ?
1124 mTargetAppToken.mAppAnimator.animLayerAdjustment
1125 : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0)));
Craig Mautnerc2f9be02012-03-27 17:32:29 -07001126 pw.print("="); pw.print(mWinAnimator.mAnimLayer);
1127 pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer);
Dianne Hackborn6d05fd32011-11-19 14:36:15 -08001128 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001129 if (dumpAll) {
1130 pw.print(prefix); pw.print("mToken="); pw.println(mToken);
1131 pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
1132 if (mAppToken != null) {
1133 pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken);
1134 }
1135 if (mTargetAppToken != null) {
1136 pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken);
1137 }
1138 pw.print(prefix); pw.print("mViewVisibility=0x");
1139 pw.print(Integer.toHexString(mViewVisibility));
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001140 pw.print(" mHaveFrame="); pw.print(mHaveFrame);
1141 pw.print(" mObscured="); pw.println(mObscured);
Dianne Hackborn9a230e02011-10-06 11:51:27 -07001142 pw.print(prefix); pw.print("mSeq="); pw.print(mSeq);
1143 pw.print(" mSystemUiVisibility=0x");
1144 pw.println(Integer.toHexString(mSystemUiVisibility));
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001145 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001146 if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) {
1147 pw.print(prefix); pw.print("mPolicyVisibility=");
1148 pw.print(mPolicyVisibility);
1149 pw.print(" mPolicyVisibilityAfterAnim=");
1150 pw.print(mPolicyVisibilityAfterAnim);
1151 pw.print(" mAttachedHidden="); pw.println(mAttachedHidden);
1152 }
Dianne Hackbornb7ff51b2012-01-23 19:15:27 -08001153 if (!mRelayoutCalled || mLayoutNeeded) {
1154 pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled);
1155 pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001156 }
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001157 if (mXOffset != 0 || mYOffset != 0) {
1158 pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset);
1159 pw.print(" y="); pw.println(mYOffset);
1160 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001161 if (dumpAll) {
1162 pw.print(prefix); pw.print("mGivenContentInsets=");
1163 mGivenContentInsets.printShortString(pw);
1164 pw.print(" mGivenVisibleInsets=");
1165 mGivenVisibleInsets.printShortString(pw);
1166 pw.println();
1167 if (mTouchableInsets != 0 || mGivenInsetsPending) {
1168 pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets);
1169 pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending);
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -07001170 Region region = new Region();
1171 getTouchableRegion(region);
1172 pw.print(prefix); pw.print("touchable region="); pw.println(region);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001173 }
1174 pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001175 }
Craig Mautnerc8bc97e2012-04-02 12:54:54 -07001176 pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
Craig Mautner178af592012-09-17 10:37:29 -07001177 pw.print(" mShownFrame="); mShownFrame.printShortString(pw);
1178 pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay());
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001179 if (dumpAll) {
1180 pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
1181 pw.print(" last="); mLastFrame.printShortString(pw);
1182 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001183 pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
1184 pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
1185 pw.println();
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001186 }
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001187 if (mEnforceSizeCompat) {
1188 pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
Dianne Hackbornffb3d932011-05-17 17:44:51 -07001189 pw.println();
1190 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001191 if (dumpAll) {
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001192 pw.print(prefix); pw.print("Frames: containing=");
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001193 mContainingFrame.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001194 pw.print(" parent="); mParentFrame.printShortString(pw);
1195 pw.print(" display="); mDisplayFrame.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001196 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001197 pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001198 pw.print(" visible="); mVisibleFrame.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001199 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001200 pw.print(prefix); pw.print("Cur insets: content=");
1201 mContentInsets.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001202 pw.print(" visible="); mVisibleInsets.printShortString(pw);
1203 pw.println();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001204 pw.print(prefix); pw.print("Lst insets: content=");
1205 mLastContentInsets.printShortString(pw);
Dianne Hackborn5c58de32012-04-28 19:52:37 -07001206 pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001207 pw.println();
1208 }
Dianne Hackborn529e7442012-11-01 14:22:28 -07001209 pw.print(prefix); pw.print(mWinAnimator); pw.println(":");
1210 mWinAnimator.dump(pw, prefix + " ", dumpAll);
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001211 if (mExiting || mRemoveOnExit || mDestroying || mRemoved) {
1212 pw.print(prefix); pw.print("mExiting="); pw.print(mExiting);
1213 pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit);
1214 pw.print(" mDestroying="); pw.print(mDestroying);
1215 pw.print(" mRemoved="); pw.println(mRemoved);
1216 }
1217 if (mOrientationChanging || mAppFreezing || mTurnOnScreen) {
1218 pw.print(prefix); pw.print("mOrientationChanging=");
1219 pw.print(mOrientationChanging);
1220 pw.print(" mAppFreezing="); pw.print(mAppFreezing);
1221 pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen);
1222 }
1223 if (mHScale != 1 || mVScale != 1) {
1224 pw.print(prefix); pw.print("mHScale="); pw.print(mHScale);
1225 pw.print(" mVScale="); pw.println(mVScale);
1226 }
1227 if (mWallpaperX != -1 || mWallpaperY != -1) {
1228 pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX);
1229 pw.print(" mWallpaperY="); pw.println(mWallpaperY);
1230 }
1231 if (mWallpaperXStep != -1 || mWallpaperYStep != -1) {
1232 pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep);
1233 pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep);
1234 }
1235 }
1236
1237 String makeInputChannelName() {
1238 return Integer.toHexString(System.identityHashCode(this))
1239 + " " + mAttrs.getTitle();
1240 }
1241
1242 @Override
1243 public String toString() {
1244 if (mStringNameCache == null || mLastTitle != mAttrs.getTitle()
Dianne Hackborn529e7442012-11-01 14:22:28 -07001245 || mWasExiting != mExiting) {
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001246 mLastTitle = mAttrs.getTitle();
Dianne Hackborn529e7442012-11-01 14:22:28 -07001247 mWasExiting = mExiting;
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001248 mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -07001249 + " u" + UserHandle.getUserId(mSession.mUid)
Craig Mautnera987d432012-10-11 14:07:58 -07001250 + " " + mLastTitle + (mExiting ? " EXITING}" : "}");
Dianne Hackborn6e1eb762011-02-17 16:07:28 -08001251 }
1252 return mStringNameCache;
1253 }
satokcef37fb2011-10-24 21:49:38 +09001254}