2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.server.wm;
19 import static com.android.server.wm.WindowManagerService.DEBUG_CONFIGURATION;
20 import static com.android.server.wm.WindowManagerService.DEBUG_LAYOUT;
21 import static com.android.server.wm.WindowManagerService.DEBUG_ORIENTATION;
22 import static com.android.server.wm.WindowManagerService.DEBUG_RESIZE;
23 import static com.android.server.wm.WindowManagerService.DEBUG_VISIBILITY;
25 import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
26 import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
27 import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
28 import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
29 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
30 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
31 import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD;
32 import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
34 import android.app.AppOpsManager;
35 import android.os.Debug;
36 import android.os.RemoteCallbackList;
37 import android.os.SystemClock;
38 import android.util.TimeUtils;
39 import android.view.IWindowFocusObserver;
40 import android.view.IWindowId;
41 import com.android.server.input.InputWindowHandle;
43 import android.content.Context;
44 import android.content.res.Configuration;
45 import android.graphics.Matrix;
46 import android.graphics.PixelFormat;
47 import android.graphics.Rect;
48 import android.graphics.RectF;
49 import android.graphics.Region;
50 import android.os.IBinder;
51 import android.os.RemoteException;
52 import android.os.UserHandle;
53 import android.util.Slog;
54 import android.view.DisplayInfo;
55 import android.view.Gravity;
56 import android.view.IApplicationToken;
57 import android.view.IWindow;
58 import android.view.InputChannel;
59 import android.view.View;
60 import android.view.ViewTreeObserver;
61 import android.view.WindowManager;
62 import android.view.WindowManagerPolicy;
64 import java.io.PrintWriter;
65 import java.util.ArrayList;
67 class WindowList extends ArrayList<WindowState> {
71 * A window in the window manager.
73 final class WindowState implements WindowManagerPolicy.WindowState {
74 static final String TAG = "WindowState";
76 final WindowManagerService mService;
77 final WindowManagerPolicy mPolicy;
78 final Context mContext;
79 final Session mSession;
80 final IWindow mClient;
82 // UserId and appId of the owner. Don't display windows of non-current user.
84 final IWindowId mWindowId;
86 WindowToken mRootToken;
87 AppWindowToken mAppToken;
88 AppWindowToken mTargetAppToken;
90 // mAttrs.flags is tested in animation without being locked. If the bits tested are ever
91 // modified they will need to be locked.
92 final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
93 final DeathRecipient mDeathRecipient;
94 final WindowState mAttachedWindow;
95 final WindowList mChildWindows = new WindowList();
98 final boolean mLayoutAttached;
99 final boolean mIsImWindow;
100 final boolean mIsWallpaper;
101 final boolean mIsFloatingLayer;
103 boolean mEnforceSizeCompat;
105 int mSystemUiVisibility;
106 boolean mPolicyVisibility = true;
107 boolean mPolicyVisibilityAfterAnim = true;
108 boolean mAppOpVisibility = true;
109 boolean mAppFreezing;
110 boolean mAttachedHidden; // is our parent window hidden?
111 boolean mWallpaperVisible; // for wallpaper, what was last vis report?
113 RemoteCallbackList<IWindowFocusObserver> mFocusCallbacks;
116 * The window size that was requested by the application. These are in
117 * the application's coordinate space (without compatibility scale applied).
120 int mRequestedHeight;
121 int mLastRequestedWidth;
122 int mLastRequestedHeight;
127 boolean mTurnOnScreen;
131 Configuration mConfiguration = null;
132 // Sticky answer to isConfigChanged(), remains true until new Configuration is assigned.
133 // Used only on {@link #TYPE_KEYGUARD}.
134 private boolean mConfigHasChanged;
137 * Actual frame shown on-screen (may be modified by animation). These
138 * are in the screen's coordinate space (WITH the compatibility scale
141 final RectF mShownFrame = new RectF();
144 * Insets that determine the actually visible area. These are in the application's
145 * coordinate space (without compatibility scale applied).
147 final Rect mVisibleInsets = new Rect();
148 final Rect mLastVisibleInsets = new Rect();
149 boolean mVisibleInsetsChanged;
152 * Insets that are covered by system windows (such as the status bar) and
153 * transient docking windows (such as the IME). These are in the application's
154 * coordinate space (without compatibility scale applied).
156 final Rect mContentInsets = new Rect();
157 final Rect mLastContentInsets = new Rect();
158 boolean mContentInsetsChanged;
161 * Insets that determine the area covered by the display overscan region. These are in the
162 * application's coordinate space (without compatibility scale applied).
164 final Rect mOverscanInsets = new Rect();
165 final Rect mLastOverscanInsets = new Rect();
166 boolean mOverscanInsetsChanged;
169 * Set to true if we are waiting for this window to receive its
170 * given internal insets before laying out other windows based on it.
172 boolean mGivenInsetsPending;
175 * These are the content insets that were given during layout for
176 * this window, to be applied to windows behind it.
178 final Rect mGivenContentInsets = new Rect();
181 * These are the visible insets that were given during layout for
182 * this window, to be applied to windows behind it.
184 final Rect mGivenVisibleInsets = new Rect();
187 * This is the given touchable area relative to the window frame, or null if none.
189 final Region mGivenTouchableRegion = new Region();
192 * Flag indicating whether the touchable region should be adjusted by
193 * the visible insets; if false the area outside the visible insets is
194 * NOT touchable, so we must use those to adjust the frame during hit
197 int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
200 * This is rectangle of the window's surface that is not covered by
201 * system decorations.
203 final Rect mSystemDecorRect = new Rect();
204 final Rect mLastSystemDecorRect = new Rect();
206 // Current transformation being applied.
207 float mGlobalScale=1;
208 float mInvGlobalScale=1;
209 float mHScale=1, mVScale=1;
210 float mLastHScale=1, mLastVScale=1;
211 final Matrix mTmpMatrix = new Matrix();
213 // "Real" frame that the application sees, in display coordinate space.
214 final Rect mFrame = new Rect();
215 final Rect mLastFrame = new Rect();
216 // Frame that is scaled to the application's coordinate space when in
217 // screen size compatibility mode.
218 final Rect mCompatFrame = new Rect();
220 final Rect mContainingFrame = new Rect();
221 final Rect mDisplayFrame = new Rect();
222 final Rect mOverscanFrame = new Rect();
223 final Rect mContentFrame = new Rect();
224 final Rect mParentFrame = new Rect();
225 final Rect mVisibleFrame = new Rect();
226 final Rect mDecorFrame = new Rect();
228 boolean mContentChanged;
230 // If a window showing a wallpaper: the requested offset for the
231 // wallpaper; if a wallpaper window: the currently applied offset.
232 float mWallpaperX = -1;
233 float mWallpaperY = -1;
235 // If a window showing a wallpaper: what fraction of the offset
236 // range corresponds to a full virtual screen.
237 float mWallpaperXStep = -1;
238 float mWallpaperYStep = -1;
240 // Wallpaper windows: pixels offset based on above variables.
245 * This is set after IWindowSession.relayout() has been called at
246 * least once for the window. It allows us to detect the situation
247 * where we don't yet have a surface, but should have one soon, so
248 * we can give the window focus before waiting for the relayout.
250 boolean mRelayoutCalled;
253 * If the application has called relayout() with changes that can
254 * impact its window's size, we need to perform a layout pass on it
255 * even if it is not currently visible for layout. This is set
256 * when in that case until the layout is done.
258 boolean mLayoutNeeded;
260 /** Currently running an exit animation? */
263 /** Currently on the mDestroySurface list? */
266 /** Completely remove from window manager after exit animation? */
267 boolean mRemoveOnExit;
270 * Set when the orientation is changing and this window has not yet
271 * been updated for the new orientation.
273 boolean mOrientationChanging;
276 * How long we last kept the screen frozen.
278 int mLastFreezeDuration;
280 /** Is this window now (or just being) removed? */
284 * Temp for keeping track of windows that have been removed when
285 * rebuilding window list.
289 // Input channel and input window handle used by the input dispatcher.
290 final InputWindowHandle mInputWindowHandle;
291 InputChannel mInputChannel;
293 // Used to improve performance of toString()
294 String mStringNameCache;
295 CharSequence mLastTitle;
298 final WindowStateAnimator mWinAnimator;
300 boolean mHasSurface = false;
302 DisplayContent mDisplayContent;
304 /** When true this window can be displayed on screens owther than mOwnerUid's */
305 private boolean mShowToOwnerOnly;
307 /** When true this window is at the top of the screen and should be layed out to extend under
309 boolean mUnderStatusBar = true;
311 WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
312 WindowState attachedWindow, int appOp, int seq, WindowManager.LayoutParams a,
313 int viewVisibility, final DisplayContent displayContent) {
320 mWindowId = new IWindowId.Stub() {
322 public void registerFocusObserver(IWindowFocusObserver observer) {
323 WindowState.this.registerFocusObserver(observer);
326 public void unregisterFocusObserver(IWindowFocusObserver observer) {
327 WindowState.this.unregisterFocusObserver(observer);
330 public boolean isFocused() {
331 return WindowState.this.isFocused();
335 mViewVisibility = viewVisibility;
336 mDisplayContent = displayContent;
337 mPolicy = mService.mPolicy;
338 mContext = mService.mContext;
339 DeathRecipient deathRecipient = new DeathRecipient();
341 mEnforceSizeCompat = (mAttrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0;
342 if (WindowManagerService.localLOGV) Slog.v(
343 TAG, "Window " + this + " client=" + c.asBinder()
344 + " token=" + token + " (" + mAttrs.token + ")" + " params=" + a);
346 c.asBinder().linkToDeath(deathRecipient, 0);
347 } catch (RemoteException e) {
348 mDeathRecipient = null;
349 mAttachedWindow = null;
350 mLayoutAttached = false;
352 mIsWallpaper = false;
353 mIsFloatingLayer = false;
356 mInputWindowHandle = null;
360 mDeathRecipient = deathRecipient;
362 if ((mAttrs.type >= FIRST_SUB_WINDOW &&
363 mAttrs.type <= LAST_SUB_WINDOW)) {
364 // The multiplier here is to reserve space for multiple
365 // windows in the same type layer.
366 mBaseLayer = mPolicy.windowTypeToLayerLw(
367 attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER
368 + WindowManagerService.TYPE_LAYER_OFFSET;
369 mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type);
370 mAttachedWindow = attachedWindow;
371 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);
373 int children_size = mAttachedWindow.mChildWindows.size();
374 if (children_size == 0) {
375 mAttachedWindow.mChildWindows.add(this);
377 for (int i = 0; i < children_size; i++) {
378 WindowState child = (WindowState)mAttachedWindow.mChildWindows.get(i);
379 if (this.mSubLayer < child.mSubLayer) {
380 mAttachedWindow.mChildWindows.add(i, this);
382 } else if (this.mSubLayer > child.mSubLayer) {
386 if (this.mBaseLayer <= child.mBaseLayer) {
387 mAttachedWindow.mChildWindows.add(i, this);
393 if (children_size == mAttachedWindow.mChildWindows.size()) {
394 mAttachedWindow.mChildWindows.add(this);
398 mLayoutAttached = mAttrs.type !=
399 WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
400 mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD
401 || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
402 mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER;
403 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
405 // The multiplier here is to reserve space for multiple
406 // windows in the same type layer.
407 mBaseLayer = mPolicy.windowTypeToLayerLw(a.type)
408 * WindowManagerService.TYPE_LAYER_MULTIPLIER
409 + WindowManagerService.TYPE_LAYER_OFFSET;
411 mAttachedWindow = null;
412 mLayoutAttached = false;
413 mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD
414 || mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
415 mIsWallpaper = mAttrs.type == TYPE_WALLPAPER;
416 mIsFloatingLayer = mIsImWindow || mIsWallpaper;
419 WindowState appWin = this;
420 while (appWin.mAttachedWindow != null) {
421 appWin = appWin.mAttachedWindow;
423 WindowToken appToken = appWin.mToken;
424 while (appToken.appWindowToken == null) {
425 WindowToken parent = mService.mTokenMap.get(appToken.token);
426 if (parent == null || appToken == parent) {
431 mRootToken = appToken;
432 mAppToken = appToken.appWindowToken;
434 mWinAnimator = new WindowStateAnimator(this);
435 mWinAnimator.mAlpha = a.alpha;
438 mRequestedHeight = 0;
439 mLastRequestedWidth = 0;
440 mLastRequestedHeight = 0;
444 mInputWindowHandle = new InputWindowHandle(
445 mAppToken != null ? mAppToken.mInputApplicationHandle : null, this,
446 displayContent.getDisplayId());
450 if (WindowManagerService.localLOGV) Slog.v(
451 TAG, "Attaching " + this + " token=" + mToken
452 + ", list=" + mToken.windows);
453 mSession.windowAddedLocked();
457 public int getOwningUid() {
462 public String getOwningPackage() {
463 return mAttrs.packageName;
467 public void computeFrameLw(Rect pf, Rect df, Rect of, Rect cf, Rect vf, Rect dcf) {
470 TaskStack stack = mAppToken != null ? getStack() : null;
471 if (stack != null && !stack.isFullscreen()) {
472 getStackBounds(stack, mContainingFrame);
473 if (mUnderStatusBar) {
474 mContainingFrame.top = pf.top;
477 mContainingFrame.set(pf);
480 mDisplayFrame.set(df);
482 final int pw = mContainingFrame.width();
483 final int ph = mContainingFrame.height();
486 if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) {
487 if (mAttrs.width < 0) {
489 } else if (mEnforceSizeCompat) {
490 w = (int)(mAttrs.width * mGlobalScale + .5f);
494 if (mAttrs.height < 0) {
496 } else if (mEnforceSizeCompat) {
497 h = (int)(mAttrs.height * mGlobalScale + .5f);
502 if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) {
504 } else if (mEnforceSizeCompat) {
505 w = (int)(mRequestedWidth * mGlobalScale + .5f);
509 if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
511 } else if (mEnforceSizeCompat) {
512 h = (int)(mRequestedHeight * mGlobalScale + .5f);
514 h = mRequestedHeight;
518 if (!mParentFrame.equals(pf)) {
519 //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame
521 mParentFrame.set(pf);
522 mContentChanged = true;
524 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
525 mLastRequestedWidth = mRequestedWidth;
526 mLastRequestedHeight = mRequestedHeight;
527 mContentChanged = true;
530 mOverscanFrame.set(of);
531 mContentFrame.set(cf);
532 mVisibleFrame.set(vf);
533 mDecorFrame.set(dcf);
535 final int fw = mFrame.width();
536 final int fh = mFrame.height();
538 //System.out.println("In: w=" + w + " h=" + h + " container=" +
539 // container + " x=" + mAttrs.x + " y=" + mAttrs.y);
542 if (mEnforceSizeCompat) {
543 x = mAttrs.x * mGlobalScale;
544 y = mAttrs.y * mGlobalScale;
550 Gravity.apply(mAttrs.gravity, w, h, mContainingFrame,
551 (int) (x + mAttrs.horizontalMargin * pw),
552 (int) (y + mAttrs.verticalMargin * ph), mFrame);
554 //System.out.println("Out: " + mFrame);
556 // Now make sure the window fits in the overall display.
557 Gravity.applyDisplay(mAttrs.gravity, df, mFrame);
559 // Make sure the content and visible frames are inside of the
560 // final window frame.
561 mContentFrame.set(Math.max(mContentFrame.left, mFrame.left),
562 Math.max(mContentFrame.top, mFrame.top),
563 Math.min(mContentFrame.right, mFrame.right),
564 Math.min(mContentFrame.bottom, mFrame.bottom));
566 mVisibleFrame.set(Math.max(mVisibleFrame.left, mFrame.left),
567 Math.max(mVisibleFrame.top, mFrame.top),
568 Math.min(mVisibleFrame.right, mFrame.right),
569 Math.min(mVisibleFrame.bottom, mFrame.bottom));
571 mOverscanInsets.set(Math.max(mOverscanFrame.left - mFrame.left, 0),
572 Math.max(mOverscanFrame.top - mFrame.top, 0),
573 Math.max(mFrame.right - mOverscanFrame.right, 0),
574 Math.max(mFrame.bottom - mOverscanFrame.bottom, 0));
576 mContentInsets.set(mContentFrame.left - mFrame.left,
577 mContentFrame.top - mFrame.top,
578 mFrame.right - mContentFrame.right,
579 mFrame.bottom - mContentFrame.bottom);
581 mVisibleInsets.set(mVisibleFrame.left - mFrame.left,
582 mVisibleFrame.top - mFrame.top,
583 mFrame.right - mVisibleFrame.right,
584 mFrame.bottom - mVisibleFrame.bottom);
586 mCompatFrame.set(mFrame);
587 if (mEnforceSizeCompat) {
588 // If there is a size compatibility scale being applied to the
589 // window, we need to apply this to its insets so that they are
590 // reported to the app in its coordinate space.
591 mOverscanInsets.scale(mInvGlobalScale);
592 mContentInsets.scale(mInvGlobalScale);
593 mVisibleInsets.scale(mInvGlobalScale);
595 // Also the scaled frame that we report to the app needs to be
596 // adjusted to be in its coordinate space.
597 mCompatFrame.scale(mInvGlobalScale);
600 if (mIsWallpaper && (fw != mFrame.width() || fh != mFrame.height())) {
601 final DisplayContent displayContent = getDisplayContent();
602 if (displayContent != null) {
603 final DisplayInfo displayInfo = displayContent.getDisplayInfo();
604 mService.updateWallpaperOffsetLocked(this,
605 displayInfo.logicalWidth, displayInfo.logicalHeight, false);
609 if (DEBUG_LAYOUT || WindowManagerService.localLOGV) Slog.v(TAG,
610 "Resolving (mRequestedWidth="
611 + mRequestedWidth + ", mRequestedheight="
612 + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
613 + "): frame=" + mFrame.toShortString()
614 + " ci=" + mContentInsets.toShortString()
615 + " vi=" + mVisibleInsets.toShortString());
619 public Rect getFrameLw() {
624 public RectF getShownFrameLw() {
629 public Rect getDisplayFrameLw() {
630 return mDisplayFrame;
634 public Rect getOverscanFrameLw() {
635 return mOverscanFrame;
639 public Rect getContentFrameLw() {
640 return mContentFrame;
644 public Rect getVisibleFrameLw() {
645 return mVisibleFrame;
649 public boolean getGivenInsetsPendingLw() {
650 return mGivenInsetsPending;
654 public Rect getGivenContentInsetsLw() {
655 return mGivenContentInsets;
659 public Rect getGivenVisibleInsetsLw() {
660 return mGivenVisibleInsets;
664 public WindowManager.LayoutParams getAttrs() {
669 public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) {
671 WindowState ws = this;
672 WindowList windows = getWindowList();
674 if ((ws.mAttrs.privateFlags
675 & WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY) != 0) {
676 return (ws.mAttrs.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0;
678 // If we reached the bottom of the range of windows we are considering,
679 // assume no menu is needed.
683 // The current window hasn't specified whether menu key is needed;
685 // First, we may need to determine the starting position.
687 index = windows.indexOf(ws);
693 ws = windows.get(index);
698 public int getSystemUiVisibility() {
699 return mSystemUiVisibility;
703 public int getSurfaceLayer() {
708 public IApplicationToken getAppToken() {
709 return mAppToken != null ? mAppToken.appToken : null;
712 boolean setInsetsChanged() {
713 mOverscanInsetsChanged |= !mLastOverscanInsets.equals(mOverscanInsets);
714 mContentInsetsChanged |= !mLastContentInsets.equals(mContentInsets);
715 mVisibleInsetsChanged |= !mLastVisibleInsets.equals(mVisibleInsets);
716 return mOverscanInsetsChanged || mContentInsetsChanged || mVisibleInsetsChanged;
719 public DisplayContent getDisplayContent() {
720 return mAppToken == null ? mDisplayContent : getStack().getDisplayContent();
723 public int getDisplayId() {
724 final DisplayContent displayContent = getDisplayContent();
725 if (displayContent == null) {
728 return displayContent.getDisplayId();
731 TaskStack getStack() {
732 AppWindowToken wtoken = mAppToken == null ? mService.mFocusedApp : mAppToken;
733 if (wtoken != null) {
734 Task task = mService.mTaskIdToTask.get(wtoken.groupId);
736 if (task.mStack != null) {
739 Slog.e(TAG, "getStack: mStack null for task=" + task);
741 Slog.e(TAG, "getStack: " + this + " couldn't find taskId=" + wtoken.groupId
742 + " Callers=" + Debug.getCallers(4));
745 return mDisplayContent.getHomeStack();
748 void getStackBounds(Rect bounds) {
749 getStackBounds(getStack(), bounds);
752 private void getStackBounds(TaskStack stack, Rect bounds) {
754 stack.getBounds(bounds);
760 public long getInputDispatchingTimeoutNanos() {
761 return mAppToken != null
762 ? mAppToken.inputDispatchingTimeoutNanos
763 : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
767 public boolean hasAppShownWindows() {
768 return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed);
771 boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
772 if (dsdx < .99999f || dsdx > 1.00001f) return false;
773 if (dtdy < .99999f || dtdy > 1.00001f) return false;
774 if (dtdx < -.000001f || dtdx > .000001f) return false;
775 if (dsdy < -.000001f || dsdy > .000001f) return false;
780 if (mEnforceSizeCompat) {
781 mGlobalScale = mService.mCompatibleScreenScale;
782 mInvGlobalScale = 1/mGlobalScale;
784 mGlobalScale = mInvGlobalScale = 1;
789 * Is this window visible? It is not visible if there is no
790 * surface, or we are in the process of running an exit animation
791 * that will remove the surface, or its app token has been hidden.
794 public boolean isVisibleLw() {
795 final AppWindowToken atoken = mAppToken;
796 return mHasSurface && mPolicyVisibility && !mAttachedHidden
797 && (atoken == null || !atoken.hiddenRequested)
798 && !mExiting && !mDestroying;
802 * Like {@link #isVisibleLw}, but also counts a window that is currently
803 * "hidden" behind the keyguard as visible. This allows us to apply
804 * things like window flags that impact the keyguard.
805 * XXX I am starting to think we need to have ANOTHER visibility flag
806 * for this "hidden behind keyguard" state rather than overloading
807 * mPolicyVisibility. Ungh.
810 public boolean isVisibleOrBehindKeyguardLw() {
811 if (mRootToken.waitingToShow &&
812 mService.mAppTransition.isTransitionSet()) {
815 final AppWindowToken atoken = mAppToken;
816 final boolean animating = atoken != null
817 ? (atoken.mAppAnimator.animation != null) : false;
818 return mHasSurface && !mDestroying && !mExiting
819 && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested)
820 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
821 && !mRootToken.hidden)
822 || mWinAnimator.mAnimation != null || animating);
826 * Is this window visible, ignoring its app token? It is not visible
827 * if there is no surface, or we are in the process of running an exit animation
828 * that will remove the surface.
830 public boolean isWinVisibleLw() {
831 final AppWindowToken atoken = mAppToken;
832 return mHasSurface && mPolicyVisibility && !mAttachedHidden
833 && (atoken == null || !atoken.hiddenRequested || atoken.mAppAnimator.animating)
834 && !mExiting && !mDestroying;
838 * The same as isVisible(), but follows the current hidden state of
839 * the associated app token, not the pending requested hidden state.
841 boolean isVisibleNow() {
842 return mHasSurface && mPolicyVisibility && !mAttachedHidden
843 && !mRootToken.hidden && !mExiting && !mDestroying;
847 * Can this window possibly be a drag/drop target? The test here is
848 * a combination of the above "visible now" with the check that the
849 * Input Manager uses when discarding windows from input consideration.
851 boolean isPotentialDragTarget() {
852 return isVisibleNow() && !mRemoved
853 && mInputChannel != null && mInputWindowHandle != null;
857 * Same as isVisible(), but we also count it as visible between the
858 * call to IWindowSession.add() and the first relayout().
860 boolean isVisibleOrAdding() {
861 final AppWindowToken atoken = mAppToken;
862 return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
863 && mPolicyVisibility && !mAttachedHidden
864 && (atoken == null || !atoken.hiddenRequested)
865 && !mExiting && !mDestroying;
869 * Is this window currently on-screen? It is on-screen either if it
870 * is visible or it is currently running an animation before no longer
873 boolean isOnScreen() {
874 if (!mHasSurface || !mPolicyVisibility || mDestroying) {
877 final AppWindowToken atoken = mAppToken;
878 if (atoken != null) {
879 return ((!mAttachedHidden && !atoken.hiddenRequested)
880 || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null);
882 return !mAttachedHidden || mWinAnimator.mAnimation != null;
886 * Like isOnScreen(), but we don't return true if the window is part
887 * of a transition that has not yet been started.
889 boolean isReadyForDisplay() {
890 if (mRootToken.waitingToShow &&
891 mService.mAppTransition.isTransitionSet()) {
894 return mHasSurface && mPolicyVisibility && !mDestroying
895 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
896 && !mRootToken.hidden)
897 || mWinAnimator.mAnimation != null
898 || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null)));
902 * Like isReadyForDisplay(), but ignores any force hiding of the window due
905 boolean isReadyForDisplayIgnoringKeyguard() {
906 if (mRootToken.waitingToShow && mService.mAppTransition.isTransitionSet()) {
909 final AppWindowToken atoken = mAppToken;
910 if (atoken == null && !mPolicyVisibility) {
911 // If this is not an app window, and the policy has asked to force
912 // hide, then we really do want to hide.
915 return mHasSurface && !mDestroying
916 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
917 && !mRootToken.hidden)
918 || mWinAnimator.mAnimation != null
919 || ((atoken != null) && (atoken.mAppAnimator.animation != null)
920 && !mWinAnimator.isDummyAnimation()));
924 * Like isOnScreen, but returns false if the surface hasn't yet
928 public boolean isDisplayedLw() {
929 final AppWindowToken atoken = mAppToken;
930 return isDrawnLw() && mPolicyVisibility
931 && ((!mAttachedHidden &&
932 (atoken == null || !atoken.hiddenRequested))
933 || mWinAnimator.mAnimating
934 || (atoken != null && atoken.mAppAnimator.animation != null));
938 * Return true if this window or its app token is currently animating.
941 public boolean isAnimatingLw() {
942 return mWinAnimator.mAnimation != null
943 || (mAppToken != null && mAppToken.mAppAnimator.animation != null);
947 public boolean isGoneForLayoutLw() {
948 final AppWindowToken atoken = mAppToken;
949 return mViewVisibility == View.GONE
951 || (atoken == null && mRootToken.hidden)
952 || (atoken != null && (atoken.hiddenRequested || atoken.hidden))
954 || (mExiting && !isAnimatingLw())
959 * Returns true if the window has a surface that it has drawn a
962 public boolean isDrawFinishedLw() {
963 return mHasSurface && !mDestroying &&
964 (mWinAnimator.mDrawState == WindowStateAnimator.COMMIT_DRAW_PENDING
965 || mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW
966 || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN);
970 * Returns true if the window has a surface that it has drawn a
973 public boolean isDrawnLw() {
974 return mHasSurface && !mDestroying &&
975 (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW
976 || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN);
980 * Return true if the window is opaque and fully drawn. This indicates
981 * it may obscure windows behind it.
983 boolean isOpaqueDrawn() {
984 return (mAttrs.format == PixelFormat.OPAQUE
985 || mAttrs.type == TYPE_WALLPAPER)
986 && isDrawnLw() && mWinAnimator.mAnimation == null
987 && (mAppToken == null || mAppToken.mAppAnimator.animation == null);
991 * Return whether this window is wanting to have a translation
992 * animation applied to it for an in-progress move. (Only makes
993 * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
995 boolean shouldAnimateMove() {
996 return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
997 && (mFrame.top != mLastFrame.top
998 || mFrame.left != mLastFrame.left)
999 && (mAttrs.privateFlags&PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0
1000 && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove());
1003 boolean isFullscreen(int screenWidth, int screenHeight) {
1004 return mFrame.left <= 0 && mFrame.top <= 0 &&
1005 mFrame.right >= screenWidth && mFrame.bottom >= screenHeight;
1008 boolean isConfigChanged() {
1009 boolean configChanged = mConfiguration != mService.mCurConfiguration
1010 && (mConfiguration == null
1011 || (mConfiguration.diff(mService.mCurConfiguration) != 0));
1013 if (mAttrs.type == TYPE_KEYGUARD) {
1014 // Retain configuration changed status until resetConfiguration called.
1015 mConfigHasChanged |= configChanged;
1016 configChanged = mConfigHasChanged;
1019 return configChanged;
1022 void removeLocked() {
1023 disposeInputChannel();
1025 if (mAttachedWindow != null) {
1026 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow);
1027 mAttachedWindow.mChildWindows.remove(this);
1029 mWinAnimator.destroyDeferredSurfaceLocked();
1030 mWinAnimator.destroySurfaceLocked();
1031 mSession.windowRemovedLocked();
1033 mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
1034 } catch (RuntimeException e) {
1035 // Ignore if it has already been removed (usually because
1036 // we are doing this as part of processing a death note.)
1040 void setConfiguration(final Configuration newConfig) {
1041 mConfiguration = newConfig;
1042 mConfigHasChanged = false;
1045 void setInputChannel(InputChannel inputChannel) {
1046 if (mInputChannel != null) {
1047 throw new IllegalStateException("Window already has an input channel.");
1050 mInputChannel = inputChannel;
1051 mInputWindowHandle.inputChannel = inputChannel;
1054 void disposeInputChannel() {
1055 if (mInputChannel != null) {
1056 mService.mInputManager.unregisterInputChannel(mInputChannel);
1058 mInputChannel.dispose();
1059 mInputChannel = null;
1062 mInputWindowHandle.inputChannel = null;
1065 private class DeathRecipient implements IBinder.DeathRecipient {
1067 public void binderDied() {
1069 synchronized(mService.mWindowMap) {
1070 WindowState win = mService.windowForClientLocked(mSession, mClient, false);
1071 Slog.i(TAG, "WIN DEATH: " + win);
1073 mService.removeWindowLocked(mSession, win);
1074 } else if (mHasSurface) {
1075 Slog.e(TAG, "!!! LEAK !!! Window removed but surface still valid.");
1076 mService.removeWindowLocked(mSession, WindowState.this);
1079 } catch (IllegalArgumentException ex) {
1080 // This will happen if the window has already been
1087 * @return true if this window desires key events.
1089 public final boolean canReceiveKeys() {
1090 return isVisibleOrAdding()
1091 && (mViewVisibility == View.VISIBLE)
1092 && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0);
1096 public boolean hasDrawnLw() {
1097 return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN;
1101 public boolean showLw(boolean doAnimation) {
1102 return showLw(doAnimation, true);
1105 boolean showLw(boolean doAnimation, boolean requestAnim) {
1106 if (isHiddenFromUserLocked()) {
1107 Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display "
1108 + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUid);
1111 if (!mAppOpVisibility) {
1112 // Being hidden due to app op request.
1115 if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
1119 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this);
1121 if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility="
1122 + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation);
1123 if (!mService.okToDisplay()) {
1124 doAnimation = false;
1125 } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) {
1126 // Check for the case where we are currently visible and
1127 // not animating; we do not want to do animation at such a
1128 // point to become visible when we already are.
1129 doAnimation = false;
1132 mPolicyVisibility = true;
1133 mPolicyVisibilityAfterAnim = true;
1135 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true);
1138 mService.scheduleAnimationLocked();
1144 public boolean hideLw(boolean doAnimation) {
1145 return hideLw(doAnimation, true);
1148 boolean hideLw(boolean doAnimation, boolean requestAnim) {
1150 if (!mService.okToDisplay()) {
1151 doAnimation = false;
1154 boolean current = doAnimation ? mPolicyVisibilityAfterAnim
1155 : mPolicyVisibility;
1161 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false);
1162 if (mWinAnimator.mAnimation == null) {
1163 doAnimation = false;
1167 mPolicyVisibilityAfterAnim = false;
1169 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this);
1170 mPolicyVisibilityAfterAnim = false;
1171 mPolicyVisibility = false;
1172 // Window is no longer visible -- make sure if we were waiting
1173 // for it to be displayed before enabling the display, that
1174 // we allow the display to be enabled now.
1175 mService.enableScreenIfNeededLocked();
1176 if (mService.mCurrentFocus == this) {
1177 if (WindowManagerService.DEBUG_FOCUS_LIGHT) Slog.i(TAG,
1178 "WindowState.hideLw: setting mFocusMayChange true");
1179 mService.mFocusMayChange = true;
1183 mService.scheduleAnimationLocked();
1188 public void setAppOpVisibilityLw(boolean state) {
1189 if (mAppOpVisibility != state) {
1190 mAppOpVisibility = state;
1192 // If the policy visibility had last been to hide, then this
1193 // will incorrectly show at this point since we lost that
1194 // information. Not a big deal -- for the windows that have app
1195 // ops modifies they should only be hidden by policy due to the
1196 // lock screen, and the user won't be changing this if locked.
1197 // Plus it will quickly be fixed the next time we do a layout.
1206 public boolean isAlive() {
1207 return mClient.asBinder().isBinderAlive();
1210 boolean isClosing() {
1211 return mExiting || (mService.mClosingApps.contains(mAppToken));
1215 public boolean isDefaultDisplay() {
1216 final DisplayContent displayContent = getDisplayContent();
1217 if (displayContent == null) {
1218 // Only a window that was on a non-default display can be detached from it.
1221 return getDisplayContent().isDefaultDisplay;
1224 public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {
1225 mShowToOwnerOnly = showToOwnerOnly;
1228 boolean isHiddenFromUserLocked() {
1229 // Attached windows are evaluated based on the window that they are attached to.
1230 WindowState win = this;
1231 while (win.mAttachedWindow != null) {
1232 win = win.mAttachedWindow;
1234 if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
1235 && win.mAppToken != null && win.mAppToken.showWhenLocked) {
1236 // Save some cycles by not calling getDisplayInfo unless it is an application
1237 // window intended for all users.
1238 final DisplayContent displayContent = win.getDisplayContent();
1239 if (displayContent == null) {
1242 final DisplayInfo displayInfo = displayContent.getDisplayInfo();
1243 if (win.mFrame.left <= 0 && win.mFrame.top <= 0
1244 && win.mFrame.right >= displayInfo.appWidth
1245 && win.mFrame.bottom >= displayInfo.appHeight) {
1246 // Is a fullscreen window, like the clock alarm. Show to everyone.
1251 return win.mShowToOwnerOnly
1252 && !mService.isRelatedToOrCurrentUserLocked(UserHandle.getUserId(win.mOwnerUid));
1255 private static void applyInsets(Region outRegion, Rect frame, Rect inset) {
1257 frame.left + inset.left, frame.top + inset.top,
1258 frame.right - inset.right, frame.bottom - inset.bottom);
1261 public void getTouchableRegion(Region outRegion) {
1262 final Rect frame = mFrame;
1263 switch (mTouchableInsets) {
1265 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME:
1266 outRegion.set(frame);
1268 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT:
1269 applyInsets(outRegion, frame, mGivenContentInsets);
1271 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE:
1272 applyInsets(outRegion, frame, mGivenVisibleInsets);
1274 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: {
1275 final Region givenTouchableRegion = mGivenTouchableRegion;
1276 outRegion.set(givenTouchableRegion);
1277 outRegion.translate(frame.left, frame.top);
1283 WindowList getWindowList() {
1284 final DisplayContent displayContent = getDisplayContent();
1285 return displayContent == null ? null : displayContent.getWindowList();
1289 * Report a focus change. Must be called with no locks held, and consistently
1290 * from the same serialized thread (such as dispatched from a handler).
1292 public void reportFocusChangedSerialized(boolean focused, boolean inTouchMode) {
1294 mClient.windowFocusChanged(focused, inTouchMode);
1295 } catch (RemoteException e) {
1297 if (mFocusCallbacks != null) {
1298 final int N = mFocusCallbacks.beginBroadcast();
1299 for (int i=0; i<N; i++) {
1300 IWindowFocusObserver obs = mFocusCallbacks.getBroadcastItem(i);
1303 obs.focusGained(mWindowId.asBinder());
1305 obs.focusLost(mWindowId.asBinder());
1307 } catch (RemoteException e) {
1310 mFocusCallbacks.finishBroadcast();
1314 void reportResized() {
1316 if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG, "Reporting new frame to " + this
1317 + ": " + mCompatFrame);
1318 boolean configChanged = isConfigChanged();
1319 if ((DEBUG_RESIZE || DEBUG_ORIENTATION || DEBUG_CONFIGURATION) && configChanged) {
1320 Slog.i(TAG, "Sending new config to window " + this + ": "
1321 + mWinAnimator.mSurfaceW + "x" + mWinAnimator.mSurfaceH
1322 + " / " + mService.mCurConfiguration);
1324 setConfiguration(mService.mCurConfiguration);
1325 if (DEBUG_ORIENTATION && mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING)
1326 Slog.i(TAG, "Resizing " + this + " WITH DRAW PENDING");
1328 final Rect frame = mFrame;
1329 final Rect overscanInsets = mLastOverscanInsets;
1330 final Rect contentInsets = mLastContentInsets;
1331 final Rect visibleInsets = mLastVisibleInsets;
1332 final boolean reportDraw = mWinAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING;
1333 final Configuration newConfig = configChanged ? mConfiguration : null;
1334 if (mClient instanceof IWindow.Stub) {
1335 // To prevent deadlock simulate one-way call if win.mClient is a local object.
1336 mService.mH.post(new Runnable() {
1340 mClient.resized(frame, overscanInsets, contentInsets,
1341 visibleInsets, reportDraw, newConfig);
1342 } catch (RemoteException e) {
1343 // Not a remote call, RemoteException won't be raised.
1348 mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, reportDraw,
1351 mOverscanInsetsChanged = false;
1352 mContentInsetsChanged = false;
1353 mVisibleInsetsChanged = false;
1354 mWinAnimator.mSurfaceResized = false;
1355 } catch (RemoteException e) {
1356 mOrientationChanging = false;
1357 mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
1358 - mService.mDisplayFreezeTime);
1362 public void registerFocusObserver(IWindowFocusObserver observer) {
1363 synchronized(mService.mWindowMap) {
1364 if (mFocusCallbacks == null) {
1365 mFocusCallbacks = new RemoteCallbackList<IWindowFocusObserver>();
1367 mFocusCallbacks.register(observer);
1371 public void unregisterFocusObserver(IWindowFocusObserver observer) {
1372 synchronized(mService.mWindowMap) {
1373 if (mFocusCallbacks != null) {
1374 mFocusCallbacks.unregister(observer);
1379 public boolean isFocused() {
1380 synchronized(mService.mWindowMap) {
1381 return mService.mCurrentFocus == this;
1385 void dump(PrintWriter pw, String prefix, boolean dumpAll) {
1386 pw.print(prefix); pw.print("mDisplayId="); pw.print(getDisplayId());
1387 pw.print(" mSession="); pw.print(mSession);
1388 pw.print(" mClient="); pw.println(mClient.asBinder());
1389 pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid);
1390 pw.print(" mShowToOwnerOnly="); pw.print(mShowToOwnerOnly);
1391 pw.print(" package="); pw.print(mAttrs.packageName);
1392 pw.print(" appop="); pw.println(AppOpsManager.opToName(mAppOp));
1393 pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs);
1394 pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth);
1395 pw.print(" h="); pw.print(mRequestedHeight);
1396 pw.print(" mLayoutSeq="); pw.println(mLayoutSeq);
1397 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
1398 pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth);
1399 pw.print(" h="); pw.println(mLastRequestedHeight);
1401 if (mAttachedWindow != null || mLayoutAttached) {
1402 pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow);
1403 pw.print(" mLayoutAttached="); pw.println(mLayoutAttached);
1405 if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) {
1406 pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow);
1407 pw.print(" mIsWallpaper="); pw.print(mIsWallpaper);
1408 pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer);
1409 pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible);
1412 pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer);
1413 pw.print(" mSubLayer="); pw.print(mSubLayer);
1414 pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+");
1415 pw.print((mTargetAppToken != null ?
1416 mTargetAppToken.mAppAnimator.animLayerAdjustment
1417 : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0)));
1418 pw.print("="); pw.print(mWinAnimator.mAnimLayer);
1419 pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer);
1422 pw.print(prefix); pw.print("mToken="); pw.println(mToken);
1423 pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
1424 if (mAppToken != null) {
1425 pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken);
1427 if (mTargetAppToken != null) {
1428 pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken);
1430 pw.print(prefix); pw.print("mViewVisibility=0x");
1431 pw.print(Integer.toHexString(mViewVisibility));
1432 pw.print(" mHaveFrame="); pw.print(mHaveFrame);
1433 pw.print(" mObscured="); pw.println(mObscured);
1434 pw.print(prefix); pw.print("mSeq="); pw.print(mSeq);
1435 pw.print(" mSystemUiVisibility=0x");
1436 pw.println(Integer.toHexString(mSystemUiVisibility));
1438 if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || !mAppOpVisibility
1439 || mAttachedHidden) {
1440 pw.print(prefix); pw.print("mPolicyVisibility=");
1441 pw.print(mPolicyVisibility);
1442 pw.print(" mPolicyVisibilityAfterAnim=");
1443 pw.print(mPolicyVisibilityAfterAnim);
1444 pw.print(" mAppOpVisibility=");
1445 pw.print(mAppOpVisibility);
1446 pw.print(" mAttachedHidden="); pw.println(mAttachedHidden);
1448 if (!mRelayoutCalled || mLayoutNeeded) {
1449 pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled);
1450 pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded);
1452 if (mXOffset != 0 || mYOffset != 0) {
1453 pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset);
1454 pw.print(" y="); pw.println(mYOffset);
1457 pw.print(prefix); pw.print("mGivenContentInsets=");
1458 mGivenContentInsets.printShortString(pw);
1459 pw.print(" mGivenVisibleInsets=");
1460 mGivenVisibleInsets.printShortString(pw);
1462 if (mTouchableInsets != 0 || mGivenInsetsPending) {
1463 pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets);
1464 pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending);
1465 Region region = new Region();
1466 getTouchableRegion(region);
1467 pw.print(prefix); pw.print("touchable region="); pw.println(region);
1469 pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration);
1471 pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
1472 pw.print(" mShownFrame="); mShownFrame.printShortString(pw);
1473 pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay());
1475 pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
1476 pw.print(" last="); mLastFrame.printShortString(pw);
1478 pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
1479 pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
1482 if (mEnforceSizeCompat) {
1483 pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
1487 pw.print(prefix); pw.print("Frames: containing=");
1488 mContainingFrame.printShortString(pw);
1489 pw.print(" parent="); mParentFrame.printShortString(pw);
1491 pw.print(prefix); pw.print(" display="); mDisplayFrame.printShortString(pw);
1492 pw.print(" overscan="); mOverscanFrame.printShortString(pw);
1494 pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw);
1495 pw.print(" visible="); mVisibleFrame.printShortString(pw);
1497 pw.print(prefix); pw.print(" decor="); mDecorFrame.printShortString(pw);
1499 pw.print(prefix); pw.print("Cur insets: overscan=");
1500 mOverscanInsets.printShortString(pw);
1501 pw.print(" content="); mContentInsets.printShortString(pw);
1502 pw.print(" visible="); mVisibleInsets.printShortString(pw);
1504 pw.print(prefix); pw.print("Lst insets: overscan=");
1505 mLastOverscanInsets.printShortString(pw);
1506 pw.print(" content="); mLastContentInsets.printShortString(pw);
1507 pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
1510 pw.print(prefix); pw.print(mWinAnimator); pw.println(":");
1511 mWinAnimator.dump(pw, prefix + " ", dumpAll);
1512 if (mExiting || mRemoveOnExit || mDestroying || mRemoved) {
1513 pw.print(prefix); pw.print("mExiting="); pw.print(mExiting);
1514 pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit);
1515 pw.print(" mDestroying="); pw.print(mDestroying);
1516 pw.print(" mRemoved="); pw.println(mRemoved);
1518 if (mOrientationChanging || mAppFreezing || mTurnOnScreen) {
1519 pw.print(prefix); pw.print("mOrientationChanging=");
1520 pw.print(mOrientationChanging);
1521 pw.print(" mAppFreezing="); pw.print(mAppFreezing);
1522 pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen);
1524 if (mLastFreezeDuration != 0) {
1525 pw.print(prefix); pw.print("mLastFreezeDuration=");
1526 TimeUtils.formatDuration(mLastFreezeDuration, pw); pw.println();
1528 if (mHScale != 1 || mVScale != 1) {
1529 pw.print(prefix); pw.print("mHScale="); pw.print(mHScale);
1530 pw.print(" mVScale="); pw.println(mVScale);
1532 if (mWallpaperX != -1 || mWallpaperY != -1) {
1533 pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX);
1534 pw.print(" mWallpaperY="); pw.println(mWallpaperY);
1536 if (mWallpaperXStep != -1 || mWallpaperYStep != -1) {
1537 pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep);
1538 pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep);
1542 String makeInputChannelName() {
1543 return Integer.toHexString(System.identityHashCode(this))
1544 + " " + mAttrs.getTitle();
1548 public String toString() {
1549 CharSequence title = mAttrs.getTitle();
1550 if (title == null || title.length() <= 0) {
1551 title = mAttrs.packageName;
1553 if (mStringNameCache == null || mLastTitle != title || mWasExiting != mExiting) {
1555 mWasExiting = mExiting;
1556 mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
1557 + " u" + UserHandle.getUserId(mSession.mUid)
1558 + " " + mLastTitle + (mExiting ? " EXITING}" : "}");
1560 return mStringNameCache;