1 /* 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 17 package com.android.server.wm; 18 19 import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; 20 import static android.view.WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW; 21 import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW; 22 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; 23 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; 24 import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD; 25 import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; 26 27 import com.android.server.input.InputWindowHandle; 28 29 import android.content.Context; 30 import android.content.res.Configuration; 31 import android.graphics.Matrix; 32 import android.graphics.PixelFormat; 33 import android.graphics.Rect; 34 import android.graphics.RectF; 35 import android.graphics.Region; 36 import android.os.IBinder; 37 import android.os.RemoteException; 38 import android.os.UserHandle; 39 import android.util.Slog; 40 import android.view.DisplayInfo; 41 import android.view.Gravity; 42 import android.view.IApplicationToken; 43 import android.view.IWindow; 44 import android.view.InputChannel; 45 import android.view.View; 46 import android.view.ViewTreeObserver; 47 import android.view.WindowManager; 48 import android.view.WindowManagerPolicy; 49 50 import java.io.PrintWriter; 51 import java.util.ArrayList; 52 53 class WindowList extends ArrayList<WindowState> { 54 } 55 56 /** 57 * A window in the window manager. 58 */ 59 final class WindowState implements WindowManagerPolicy.WindowState { 60 static final String TAG = "WindowState"; 61 62 static final boolean DEBUG_VISIBILITY = WindowManagerService.DEBUG_VISIBILITY; 63 static final boolean SHOW_TRANSACTIONS = WindowManagerService.SHOW_TRANSACTIONS; 64 static final boolean SHOW_LIGHT_TRANSACTIONS = WindowManagerService.SHOW_LIGHT_TRANSACTIONS; 65 static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC; 66 67 final WindowManagerService mService; 68 final WindowManagerPolicy mPolicy; 69 final Context mContext; 70 final Session mSession; 71 final IWindow mClient; 72 WindowToken mToken; 73 WindowToken mRootToken; 74 AppWindowToken mAppToken; 75 AppWindowToken mTargetAppToken; 76 77 // mAttrs.flags is tested in animation without being locked. If the bits tested are ever 78 // modified they will need to be locked. 79 final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams(); 80 final DeathRecipient mDeathRecipient; 81 final WindowState mAttachedWindow; 82 final WindowList mChildWindows = new WindowList(); 83 final int mBaseLayer; 84 final int mSubLayer; 85 final boolean mLayoutAttached; 86 final boolean mIsImWindow; 87 final boolean mIsWallpaper; 88 final boolean mIsFloatingLayer; 89 int mSeq; 90 boolean mEnforceSizeCompat; 91 int mViewVisibility; 92 int mSystemUiVisibility; 93 boolean mPolicyVisibility = true; 94 boolean mPolicyVisibilityAfterAnim = true; 95 boolean mAppFreezing; 96 boolean mAttachedHidden; // is our parent window hidden? 97 boolean mWallpaperVisible; // for wallpaper, what was last vis report? 98 99 /** 100 * The window size that was requested by the application. These are in 101 * the application's coordinate space (without compatibility scale applied). 102 */ 103 int mRequestedWidth; 104 int mRequestedHeight; 105 int mLastRequestedWidth; 106 int mLastRequestedHeight; 107 108 int mLayer; 109 boolean mHaveFrame; 110 boolean mObscured; 111 boolean mTurnOnScreen; 112 113 int mLayoutSeq = -1; 114 115 Configuration mConfiguration = null; 116 // Sticky answer to isConfigChanged(), remains true until new Configuration is assigned. 117 // Used only on {@link #TYPE_KEYGUARD}. 118 private boolean mConfigHasChanged; 119 120 /** 121 * Actual frame shown on-screen (may be modified by animation). These 122 * are in the screen's coordinate space (WITH the compatibility scale 123 * applied). 124 */ 125 final RectF mShownFrame = new RectF(); 126 127 /** 128 * Insets that determine the actually visible area. These are in the application's 129 * coordinate space (without compatibility scale applied). 130 */ 131 final Rect mVisibleInsets = new Rect(); 132 final Rect mLastVisibleInsets = new Rect(); 133 boolean mVisibleInsetsChanged; 134 135 /** 136 * Insets that are covered by system windows (such as the status bar) and 137 * transient docking windows (such as the IME). These are in the application's 138 * coordinate space (without compatibility scale applied). 139 */ 140 final Rect mContentInsets = new Rect(); 141 final Rect mLastContentInsets = new Rect(); 142 boolean mContentInsetsChanged; 143 144 /** 145 * Set to true if we are waiting for this window to receive its 146 * given internal insets before laying out other windows based on it. 147 */ 148 boolean mGivenInsetsPending; 149 150 /** 151 * These are the content insets that were given during layout for 152 * this window, to be applied to windows behind it. 153 */ 154 final Rect mGivenContentInsets = new Rect(); 155 156 /** 157 * These are the visible insets that were given during layout for 158 * this window, to be applied to windows behind it. 159 */ 160 final Rect mGivenVisibleInsets = new Rect(); 161 162 /** 163 * This is the given touchable area relative to the window frame, or null if none. 164 */ 165 final Region mGivenTouchableRegion = new Region(); 166 167 /** 168 * Flag indicating whether the touchable region should be adjusted by 169 * the visible insets; if false the area outside the visible insets is 170 * NOT touchable, so we must use those to adjust the frame during hit 171 * tests. 172 */ 173 int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME; 174 175 /** 176 * This is rectangle of the window's surface that is not covered by 177 * system decorations. 178 */ 179 final Rect mSystemDecorRect = new Rect(); 180 final Rect mLastSystemDecorRect = new Rect(); 181 182 // Current transformation being applied. 183 float mGlobalScale=1; 184 float mInvGlobalScale=1; 185 float mHScale=1, mVScale=1; 186 float mLastHScale=1, mLastVScale=1; 187 final Matrix mTmpMatrix = new Matrix(); 188 189 // "Real" frame that the application sees, in display coordinate space. 190 final Rect mFrame = new Rect(); 191 final Rect mLastFrame = new Rect(); 192 // Frame that is scaled to the application's coordinate space when in 193 // screen size compatibility mode. 194 final Rect mCompatFrame = new Rect(); 195 196 final Rect mContainingFrame = new Rect(); 197 final Rect mDisplayFrame = new Rect(); 198 final Rect mContentFrame = new Rect(); 199 final Rect mParentFrame = new Rect(); 200 final Rect mVisibleFrame = new Rect(); 201 202 boolean mContentChanged; 203 204 // If a window showing a wallpaper: the requested offset for the 205 // wallpaper; if a wallpaper window: the currently applied offset. 206 float mWallpaperX = -1; 207 float mWallpaperY = -1; 208 209 // If a window showing a wallpaper: what fraction of the offset 210 // range corresponds to a full virtual screen. 211 float mWallpaperXStep = -1; 212 float mWallpaperYStep = -1; 213 214 // Wallpaper windows: pixels offset based on above variables. 215 int mXOffset; 216 int mYOffset; 217 218 // This is set after IWindowSession.relayout() has been called at 219 // least once for the window. It allows us to detect the situation 220 // where we don't yet have a surface, but should have one soon, so 221 // we can give the window focus before waiting for the relayout. 222 boolean mRelayoutCalled; 223 224 // If the application has called relayout() with changes that can 225 // impact its window's size, we need to perform a layout pass on it 226 // even if it is not currently visible for layout. This is set 227 // when in that case until the layout is done. 228 boolean mLayoutNeeded; 229 230 // Currently running an exit animation? 231 boolean mExiting; 232 233 // Currently on the mDestroySurface list? 234 boolean mDestroying; 235 236 // Completely remove from window manager after exit animation? 237 boolean mRemoveOnExit; 238 239 // Set when the orientation is changing and this window has not yet 240 // been updated for the new orientation. 241 boolean mOrientationChanging; 242 243 // Is this window now (or just being) removed? 244 boolean mRemoved; 245 246 // Temp for keeping track of windows that have been removed when 247 // rebuilding window list. 248 boolean mRebuilding; 249 250 // Input channel and input window handle used by the input dispatcher. 251 final InputWindowHandle mInputWindowHandle; 252 InputChannel mInputChannel; 253 254 // Used to improve performance of toString() 255 String mStringNameCache; 256 CharSequence mLastTitle; 257 boolean mWasExiting; 258 259 final WindowStateAnimator mWinAnimator; 260 261 boolean mHasSurface = false; 262 263 DisplayContent mDisplayContent; 264 265 // UserId and appId of the owner. Don't display windows of non-current user. 266 int mOwnerUid; 267 268 /** When true this window can be displayed on screens owther than mOwnerUid's */ 269 private boolean mShowToOwnerOnly; 270 WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, WindowState attachedWindow, int seq, WindowManager.LayoutParams a, int viewVisibility, final DisplayContent displayContent)271 WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, 272 WindowState attachedWindow, int seq, WindowManager.LayoutParams a, 273 int viewVisibility, final DisplayContent displayContent) { 274 mService = service; 275 mSession = s; 276 mClient = c; 277 mToken = token; 278 mOwnerUid = s.mUid; 279 mAttrs.copyFrom(a); 280 mViewVisibility = viewVisibility; 281 mDisplayContent = displayContent; 282 mPolicy = mService.mPolicy; 283 mContext = mService.mContext; 284 DeathRecipient deathRecipient = new DeathRecipient(); 285 mSeq = seq; 286 mEnforceSizeCompat = (mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0; 287 if (WindowManagerService.localLOGV) Slog.v( 288 TAG, "Window " + this + " client=" + c.asBinder() 289 + " token=" + token + " (" + mAttrs.token + ")" + " params=" + a); 290 try { 291 c.asBinder().linkToDeath(deathRecipient, 0); 292 } catch (RemoteException e) { 293 mDeathRecipient = null; 294 mAttachedWindow = null; 295 mLayoutAttached = false; 296 mIsImWindow = false; 297 mIsWallpaper = false; 298 mIsFloatingLayer = false; 299 mBaseLayer = 0; 300 mSubLayer = 0; 301 mInputWindowHandle = null; 302 mWinAnimator = null; 303 return; 304 } 305 mDeathRecipient = deathRecipient; 306 307 if ((mAttrs.type >= FIRST_SUB_WINDOW && 308 mAttrs.type <= LAST_SUB_WINDOW)) { 309 // The multiplier here is to reserve space for multiple 310 // windows in the same type layer. 311 mBaseLayer = mPolicy.windowTypeToLayerLw( 312 attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER 313 + WindowManagerService.TYPE_LAYER_OFFSET; 314 mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type); 315 mAttachedWindow = attachedWindow; 316 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow); 317 mAttachedWindow.mChildWindows.add(this); 318 mLayoutAttached = mAttrs.type != 319 WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; 320 mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD 321 || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG; 322 mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER; 323 mIsFloatingLayer = mIsImWindow || mIsWallpaper; 324 } else { 325 // The multiplier here is to reserve space for multiple 326 // windows in the same type layer. 327 mBaseLayer = mPolicy.windowTypeToLayerLw(a.type) 328 * WindowManagerService.TYPE_LAYER_MULTIPLIER 329 + WindowManagerService.TYPE_LAYER_OFFSET; 330 mSubLayer = 0; 331 mAttachedWindow = null; 332 mLayoutAttached = false; 333 mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD 334 || mAttrs.type == TYPE_INPUT_METHOD_DIALOG; 335 mIsWallpaper = mAttrs.type == TYPE_WALLPAPER; 336 mIsFloatingLayer = mIsImWindow || mIsWallpaper; 337 } 338 339 WindowState appWin = this; 340 while (appWin.mAttachedWindow != null) { 341 appWin = appWin.mAttachedWindow; 342 } 343 WindowToken appToken = appWin.mToken; 344 while (appToken.appWindowToken == null) { 345 WindowToken parent = mService.mTokenMap.get(appToken.token); 346 if (parent == null || appToken == parent) { 347 break; 348 } 349 appToken = parent; 350 } 351 mRootToken = appToken; 352 mAppToken = appToken.appWindowToken; 353 354 mWinAnimator = new WindowStateAnimator(this); 355 mWinAnimator.mAlpha = a.alpha; 356 357 mRequestedWidth = 0; 358 mRequestedHeight = 0; 359 mLastRequestedWidth = 0; 360 mLastRequestedHeight = 0; 361 mXOffset = 0; 362 mYOffset = 0; 363 mLayer = 0; 364 mInputWindowHandle = new InputWindowHandle( 365 mAppToken != null ? mAppToken.mInputApplicationHandle : null, this, 366 displayContent.getDisplayId()); 367 } 368 attach()369 void attach() { 370 if (WindowManagerService.localLOGV) Slog.v( 371 TAG, "Attaching " + this + " token=" + mToken 372 + ", list=" + mToken.windows); 373 mSession.windowAddedLocked(); 374 } 375 376 @Override computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf)377 public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) { 378 mHaveFrame = true; 379 380 final Rect container = mContainingFrame; 381 container.set(pf); 382 383 final Rect display = mDisplayFrame; 384 display.set(df); 385 386 final int pw = container.right - container.left; 387 final int ph = container.bottom - container.top; 388 389 int w,h; 390 if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) { 391 if (mAttrs.width < 0) { 392 w = pw; 393 } else if (mEnforceSizeCompat) { 394 w = (int)(mAttrs.width * mGlobalScale + .5f); 395 } else { 396 w = mAttrs.width; 397 } 398 if (mAttrs.height < 0) { 399 h = ph; 400 } else if (mEnforceSizeCompat) { 401 h = (int)(mAttrs.height * mGlobalScale + .5f); 402 } else { 403 h = mAttrs.height; 404 } 405 } else { 406 if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) { 407 w = pw; 408 } else if (mEnforceSizeCompat) { 409 w = (int)(mRequestedWidth * mGlobalScale + .5f); 410 } else { 411 w = mRequestedWidth; 412 } 413 if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) { 414 h = ph; 415 } else if (mEnforceSizeCompat) { 416 h = (int)(mRequestedHeight * mGlobalScale + .5f); 417 } else { 418 h = mRequestedHeight; 419 } 420 } 421 422 if (!mParentFrame.equals(pf)) { 423 //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame 424 // + " to " + pf); 425 mParentFrame.set(pf); 426 mContentChanged = true; 427 } 428 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) { 429 mLastRequestedWidth = mRequestedWidth; 430 mLastRequestedHeight = mRequestedHeight; 431 mContentChanged = true; 432 } 433 434 final Rect content = mContentFrame; 435 content.set(cf); 436 437 final Rect visible = mVisibleFrame; 438 visible.set(vf); 439 440 final Rect frame = mFrame; 441 final int fw = frame.width(); 442 final int fh = frame.height(); 443 444 //System.out.println("In: w=" + w + " h=" + h + " container=" + 445 // container + " x=" + mAttrs.x + " y=" + mAttrs.y); 446 447 float x, y; 448 if (mEnforceSizeCompat) { 449 x = mAttrs.x * mGlobalScale; 450 y = mAttrs.y * mGlobalScale; 451 } else { 452 x = mAttrs.x; 453 y = mAttrs.y; 454 } 455 456 Gravity.apply(mAttrs.gravity, w, h, container, 457 (int) (x + mAttrs.horizontalMargin * pw), 458 (int) (y + mAttrs.verticalMargin * ph), frame); 459 460 //System.out.println("Out: " + mFrame); 461 462 // Now make sure the window fits in the overall display. 463 Gravity.applyDisplay(mAttrs.gravity, df, frame); 464 465 // Make sure the system, content and visible frames are inside of the 466 // final window frame. 467 if (content.left < frame.left) content.left = frame.left; 468 if (content.top < frame.top) content.top = frame.top; 469 if (content.right > frame.right) content.right = frame.right; 470 if (content.bottom > frame.bottom) content.bottom = frame.bottom; 471 if (visible.left < frame.left) visible.left = frame.left; 472 if (visible.top < frame.top) visible.top = frame.top; 473 if (visible.right > frame.right) visible.right = frame.right; 474 if (visible.bottom > frame.bottom) visible.bottom = frame.bottom; 475 476 final Rect contentInsets = mContentInsets; 477 contentInsets.left = content.left-frame.left; 478 contentInsets.top = content.top-frame.top; 479 contentInsets.right = frame.right-content.right; 480 contentInsets.bottom = frame.bottom-content.bottom; 481 482 final Rect visibleInsets = mVisibleInsets; 483 visibleInsets.left = visible.left-frame.left; 484 visibleInsets.top = visible.top-frame.top; 485 visibleInsets.right = frame.right-visible.right; 486 visibleInsets.bottom = frame.bottom-visible.bottom; 487 488 mCompatFrame.set(frame); 489 if (mEnforceSizeCompat) { 490 // If there is a size compatibility scale being applied to the 491 // window, we need to apply this to its insets so that they are 492 // reported to the app in its coordinate space. 493 contentInsets.scale(mInvGlobalScale); 494 visibleInsets.scale(mInvGlobalScale); 495 496 // Also the scaled frame that we report to the app needs to be 497 // adjusted to be in its coordinate space. 498 mCompatFrame.scale(mInvGlobalScale); 499 } 500 501 if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) { 502 final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo(); 503 mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight, 504 false); 505 } 506 507 if (WindowManagerService.localLOGV) { 508 //if ("com.google.android.youtube".equals(mAttrs.packageName) 509 // && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { 510 Slog.v(TAG, "Resolving (mRequestedWidth=" 511 + mRequestedWidth + ", mRequestedheight=" 512 + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph 513 + "): frame=" + mFrame.toShortString() 514 + " ci=" + contentInsets.toShortString() 515 + " vi=" + visibleInsets.toShortString()); 516 //} 517 } 518 } 519 getWindowMagnificationSpecLocked()520 MagnificationSpec getWindowMagnificationSpecLocked() { 521 MagnificationSpec spec = mDisplayContent.mMagnificationSpec; 522 if (spec != null && !spec.isNop()) { 523 if (mAttachedWindow != null) { 524 if (!mPolicy.canMagnifyWindowLw(mAttachedWindow.mAttrs)) { 525 return null; 526 } 527 } 528 if (!mPolicy.canMagnifyWindowLw(mAttrs)) { 529 return null; 530 } 531 } 532 return spec; 533 } 534 535 @Override getFrameLw()536 public Rect getFrameLw() { 537 return mFrame; 538 } 539 540 @Override getShownFrameLw()541 public RectF getShownFrameLw() { 542 return mShownFrame; 543 } 544 545 @Override getDisplayFrameLw()546 public Rect getDisplayFrameLw() { 547 return mDisplayFrame; 548 } 549 550 @Override getContentFrameLw()551 public Rect getContentFrameLw() { 552 return mContentFrame; 553 } 554 555 @Override getVisibleFrameLw()556 public Rect getVisibleFrameLw() { 557 return mVisibleFrame; 558 } 559 560 @Override getGivenInsetsPendingLw()561 public boolean getGivenInsetsPendingLw() { 562 return mGivenInsetsPending; 563 } 564 565 @Override getGivenContentInsetsLw()566 public Rect getGivenContentInsetsLw() { 567 return mGivenContentInsets; 568 } 569 570 @Override getGivenVisibleInsetsLw()571 public Rect getGivenVisibleInsetsLw() { 572 return mGivenVisibleInsets; 573 } 574 575 @Override getAttrs()576 public WindowManager.LayoutParams getAttrs() { 577 return mAttrs; 578 } 579 580 @Override getNeedsMenuLw(WindowManagerPolicy.WindowState bottom)581 public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) { 582 int index = -1; 583 WindowState ws = this; 584 WindowList windows = getWindowList(); 585 while (true) { 586 if ((ws.mAttrs.privateFlags 587 & WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY) != 0) { 588 return (ws.mAttrs.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0; 589 } 590 // If we reached the bottom of the range of windows we are considering, 591 // assume no menu is needed. 592 if (ws == bottom) { 593 return false; 594 } 595 // The current window hasn't specified whether menu key is needed; 596 // look behind it. 597 // First, we may need to determine the starting position. 598 if (index < 0) { 599 index = windows.indexOf(ws); 600 } 601 index--; 602 if (index < 0) { 603 return false; 604 } 605 ws = windows.get(index); 606 } 607 } 608 609 @Override getSystemUiVisibility()610 public int getSystemUiVisibility() { 611 return mSystemUiVisibility; 612 } 613 614 @Override getSurfaceLayer()615 public int getSurfaceLayer() { 616 return mLayer; 617 } 618 619 @Override getAppToken()620 public IApplicationToken getAppToken() { 621 return mAppToken != null ? mAppToken.appToken : null; 622 } 623 getDisplayId()624 public int getDisplayId() { 625 return mDisplayContent.getDisplayId(); 626 } 627 getInputDispatchingTimeoutNanos()628 public long getInputDispatchingTimeoutNanos() { 629 return mAppToken != null 630 ? mAppToken.inputDispatchingTimeoutNanos 631 : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS; 632 } 633 634 @Override hasAppShownWindows()635 public boolean hasAppShownWindows() { 636 return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed); 637 } 638 isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy)639 boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) { 640 if (dsdx < .99999f || dsdx > 1.00001f) return false; 641 if (dtdy < .99999f || dtdy > 1.00001f) return false; 642 if (dtdx < -.000001f || dtdx > .000001f) return false; 643 if (dsdy < -.000001f || dsdy > .000001f) return false; 644 return true; 645 } 646 prelayout()647 void prelayout() { 648 if (mEnforceSizeCompat) { 649 mGlobalScale = mService.mCompatibleScreenScale; 650 mInvGlobalScale = 1/mGlobalScale; 651 } else { 652 mGlobalScale = mInvGlobalScale = 1; 653 } 654 } 655 656 /** 657 * Is this window visible? It is not visible if there is no 658 * surface, or we are in the process of running an exit animation 659 * that will remove the surface, or its app token has been hidden. 660 */ 661 @Override isVisibleLw()662 public boolean isVisibleLw() { 663 final AppWindowToken atoken = mAppToken; 664 return mHasSurface && mPolicyVisibility && !mAttachedHidden 665 && (atoken == null || !atoken.hiddenRequested) 666 && !mExiting && !mDestroying; 667 } 668 669 /** 670 * Like {@link #isVisibleLw}, but also counts a window that is currently 671 * "hidden" behind the keyguard as visible. This allows us to apply 672 * things like window flags that impact the keyguard. 673 * XXX I am starting to think we need to have ANOTHER visibility flag 674 * for this "hidden behind keyguard" state rather than overloading 675 * mPolicyVisibility. Ungh. 676 */ 677 @Override isVisibleOrBehindKeyguardLw()678 public boolean isVisibleOrBehindKeyguardLw() { 679 if (mRootToken.waitingToShow && 680 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { 681 return false; 682 } 683 final AppWindowToken atoken = mAppToken; 684 final boolean animating = atoken != null 685 ? (atoken.mAppAnimator.animation != null) : false; 686 return mHasSurface && !mDestroying && !mExiting 687 && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) 688 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE 689 && !mRootToken.hidden) 690 || mWinAnimator.mAnimation != null || animating); 691 } 692 693 /** 694 * Is this window visible, ignoring its app token? It is not visible 695 * if there is no surface, or we are in the process of running an exit animation 696 * that will remove the surface. 697 */ isWinVisibleLw()698 public boolean isWinVisibleLw() { 699 final AppWindowToken atoken = mAppToken; 700 return mHasSurface && mPolicyVisibility && !mAttachedHidden 701 && (atoken == null || !atoken.hiddenRequested || atoken.mAppAnimator.animating) 702 && !mExiting && !mDestroying; 703 } 704 705 /** 706 * The same as isVisible(), but follows the current hidden state of 707 * the associated app token, not the pending requested hidden state. 708 */ isVisibleNow()709 boolean isVisibleNow() { 710 return mHasSurface && mPolicyVisibility && !mAttachedHidden 711 && !mRootToken.hidden && !mExiting && !mDestroying; 712 } 713 714 /** 715 * Can this window possibly be a drag/drop target? The test here is 716 * a combination of the above "visible now" with the check that the 717 * Input Manager uses when discarding windows from input consideration. 718 */ isPotentialDragTarget()719 boolean isPotentialDragTarget() { 720 return isVisibleNow() && !mRemoved 721 && mInputChannel != null && mInputWindowHandle != null; 722 } 723 724 /** 725 * Same as isVisible(), but we also count it as visible between the 726 * call to IWindowSession.add() and the first relayout(). 727 */ isVisibleOrAdding()728 boolean isVisibleOrAdding() { 729 final AppWindowToken atoken = mAppToken; 730 return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE)) 731 && mPolicyVisibility && !mAttachedHidden 732 && (atoken == null || !atoken.hiddenRequested) 733 && !mExiting && !mDestroying; 734 } 735 736 /** 737 * Is this window currently on-screen? It is on-screen either if it 738 * is visible or it is currently running an animation before no longer 739 * being visible. 740 */ isOnScreen()741 boolean isOnScreen() { 742 if (!mHasSurface || !mPolicyVisibility || mDestroying) { 743 return false; 744 } 745 final AppWindowToken atoken = mAppToken; 746 if (atoken != null) { 747 return ((!mAttachedHidden && !atoken.hiddenRequested) 748 || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null); 749 } 750 return !mAttachedHidden || mWinAnimator.mAnimation != null; 751 } 752 753 /** 754 * Like isOnScreen(), but we don't return true if the window is part 755 * of a transition that has not yet been started. 756 */ isReadyForDisplay()757 boolean isReadyForDisplay() { 758 if (mRootToken.waitingToShow && 759 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { 760 return false; 761 } 762 return mHasSurface && mPolicyVisibility && !mDestroying 763 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE 764 && !mRootToken.hidden) 765 || mWinAnimator.mAnimation != null 766 || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null))); 767 } 768 769 /** 770 * Like isReadyForDisplay(), but ignores any force hiding of the window due 771 * to the keyguard. 772 */ isReadyForDisplayIgnoringKeyguard()773 boolean isReadyForDisplayIgnoringKeyguard() { 774 if (mRootToken.waitingToShow && 775 mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { 776 return false; 777 } 778 final AppWindowToken atoken = mAppToken; 779 if (atoken == null && !mPolicyVisibility) { 780 // If this is not an app window, and the policy has asked to force 781 // hide, then we really do want to hide. 782 return false; 783 } 784 return mHasSurface && !mDestroying 785 && ((!mAttachedHidden && mViewVisibility == View.VISIBLE 786 && !mRootToken.hidden) 787 || mWinAnimator.mAnimation != null 788 || ((atoken != null) && (atoken.mAppAnimator.animation != null) 789 && !mWinAnimator.isDummyAnimation())); 790 } 791 792 /** 793 * Like isOnScreen, but returns false if the surface hasn't yet 794 * been drawn. 795 */ 796 @Override isDisplayedLw()797 public boolean isDisplayedLw() { 798 final AppWindowToken atoken = mAppToken; 799 return isDrawnLw() && mPolicyVisibility 800 && ((!mAttachedHidden && 801 (atoken == null || !atoken.hiddenRequested)) 802 || mWinAnimator.mAnimating 803 || (atoken != null && atoken.mAppAnimator.animation != null)); 804 } 805 806 /** 807 * Return true if this window (or a window it is attached to, but not 808 * considering its app token) is currently animating. 809 */ 810 @Override isAnimatingLw()811 public boolean isAnimatingLw() { 812 return mWinAnimator.mAnimation != null; 813 } 814 815 @Override isGoneForLayoutLw()816 public boolean isGoneForLayoutLw() { 817 final AppWindowToken atoken = mAppToken; 818 return mViewVisibility == View.GONE 819 || !mRelayoutCalled 820 || (atoken == null && mRootToken.hidden) 821 || (atoken != null && (atoken.hiddenRequested || atoken.hidden)) 822 || mAttachedHidden 823 || mExiting || mDestroying; 824 } 825 826 /** 827 * Returns true if the window has a surface that it has drawn a 828 * complete UI in to. 829 */ isDrawnLw()830 public boolean isDrawnLw() { 831 return mHasSurface && !mDestroying && 832 (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW 833 || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN); 834 } 835 836 /** 837 * Return true if the window is opaque and fully drawn. This indicates 838 * it may obscure windows behind it. 839 */ isOpaqueDrawn()840 boolean isOpaqueDrawn() { 841 return (mAttrs.format == PixelFormat.OPAQUE 842 || mAttrs.type == TYPE_WALLPAPER) 843 && isDrawnLw() && mWinAnimator.mAnimation == null 844 && (mAppToken == null || mAppToken.mAppAnimator.animation == null); 845 } 846 847 /** 848 * Return whether this window is wanting to have a translation 849 * animation applied to it for an in-progress move. (Only makes 850 * sense to call from performLayoutAndPlaceSurfacesLockedInner().) 851 */ shouldAnimateMove()852 boolean shouldAnimateMove() { 853 return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay() 854 && (mFrame.top != mLastFrame.top 855 || mFrame.left != mLastFrame.left) 856 && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove()); 857 } 858 isFullscreen(int screenWidth, int screenHeight)859 boolean isFullscreen(int screenWidth, int screenHeight) { 860 return mFrame.left <= 0 && mFrame.top <= 0 && 861 mFrame.right >= screenWidth && mFrame.bottom >= screenHeight; 862 } 863 isConfigChanged()864 boolean isConfigChanged() { 865 boolean configChanged = mConfiguration != mService.mCurConfiguration 866 && (mConfiguration == null 867 || (mConfiguration.diff(mService.mCurConfiguration) != 0)); 868 869 if (mAttrs.type == TYPE_KEYGUARD) { 870 // Retain configuration changed status until resetConfiguration called. 871 mConfigHasChanged |= configChanged; 872 configChanged = mConfigHasChanged; 873 } 874 875 return configChanged; 876 } 877 isConfigDiff(int mask)878 boolean isConfigDiff(int mask) { 879 return mConfiguration != mService.mCurConfiguration 880 && mConfiguration != null 881 && (mConfiguration.diff(mService.mCurConfiguration) & mask) != 0; 882 } 883 removeLocked()884 void removeLocked() { 885 disposeInputChannel(); 886 887 if (mAttachedWindow != null) { 888 if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow); 889 mAttachedWindow.mChildWindows.remove(this); 890 } 891 mWinAnimator.destroyDeferredSurfaceLocked(false); 892 mWinAnimator.destroySurfaceLocked(false); 893 mSession.windowRemovedLocked(); 894 try { 895 mClient.asBinder().unlinkToDeath(mDeathRecipient, 0); 896 } catch (RuntimeException e) { 897 // Ignore if it has already been removed (usually because 898 // we are doing this as part of processing a death note.) 899 } 900 } 901 setConfiguration(final Configuration newConfig)902 void setConfiguration(final Configuration newConfig) { 903 mConfiguration = newConfig; 904 mConfigHasChanged = false; 905 } 906 setInputChannel(InputChannel inputChannel)907 void setInputChannel(InputChannel inputChannel) { 908 if (mInputChannel != null) { 909 throw new IllegalStateException("Window already has an input channel."); 910 } 911 912 mInputChannel = inputChannel; 913 mInputWindowHandle.inputChannel = inputChannel; 914 } 915 disposeInputChannel()916 void disposeInputChannel() { 917 if (mInputChannel != null) { 918 mService.mInputManager.unregisterInputChannel(mInputChannel); 919 920 mInputChannel.dispose(); 921 mInputChannel = null; 922 } 923 924 mInputWindowHandle.inputChannel = null; 925 } 926 927 private class DeathRecipient implements IBinder.DeathRecipient { 928 @Override binderDied()929 public void binderDied() { 930 try { 931 synchronized(mService.mWindowMap) { 932 WindowState win = mService.windowForClientLocked(mSession, mClient, false); 933 Slog.i(TAG, "WIN DEATH: " + win); 934 if (win != null) { 935 mService.removeWindowLocked(mSession, win); 936 } 937 } 938 } catch (IllegalArgumentException ex) { 939 // This will happen if the window has already been 940 // removed. 941 } 942 } 943 } 944 945 /** Returns true if this window desires key events. 946 * TODO(cmautner): Is this the same as {@link WindowManagerService#canBeImeTarget} 947 */ canReceiveKeys()948 public final boolean canReceiveKeys() { 949 return isVisibleOrAdding() 950 && (mViewVisibility == View.VISIBLE) 951 && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0); 952 } 953 954 @Override hasDrawnLw()955 public boolean hasDrawnLw() { 956 return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN; 957 } 958 959 @Override showLw(boolean doAnimation)960 public boolean showLw(boolean doAnimation) { 961 return showLw(doAnimation, true); 962 } 963 showLw(boolean doAnimation, boolean requestAnim)964 boolean showLw(boolean doAnimation, boolean requestAnim) { 965 if (isHiddenFromUserLocked()) { 966 Slog.w(TAG, "current user violation " + mService.mCurrentUserId + " trying to display " 967 + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUid); 968 return false; 969 } 970 if (mPolicyVisibility && mPolicyVisibilityAfterAnim) { 971 // Already showing. 972 return false; 973 } 974 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this); 975 if (doAnimation) { 976 if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility=" 977 + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation); 978 if (!mService.okToDisplay()) { 979 doAnimation = false; 980 } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) { 981 // Check for the case where we are currently visible and 982 // not animating; we do not want to do animation at such a 983 // point to become visible when we already are. 984 doAnimation = false; 985 } 986 } 987 mPolicyVisibility = true; 988 mPolicyVisibilityAfterAnim = true; 989 if (doAnimation) { 990 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true); 991 } 992 if (requestAnim) { 993 mService.updateLayoutToAnimationLocked(); 994 } 995 return true; 996 } 997 998 @Override hideLw(boolean doAnimation)999 public boolean hideLw(boolean doAnimation) { 1000 return hideLw(doAnimation, true); 1001 } 1002 hideLw(boolean doAnimation, boolean requestAnim)1003 boolean hideLw(boolean doAnimation, boolean requestAnim) { 1004 if (doAnimation) { 1005 if (!mService.okToDisplay()) { 1006 doAnimation = false; 1007 } 1008 } 1009 boolean current = doAnimation ? mPolicyVisibilityAfterAnim 1010 : mPolicyVisibility; 1011 if (!current) { 1012 // Already hiding. 1013 return false; 1014 } 1015 if (doAnimation) { 1016 mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false); 1017 if (mWinAnimator.mAnimation == null) { 1018 doAnimation = false; 1019 } 1020 } 1021 if (doAnimation) { 1022 mPolicyVisibilityAfterAnim = false; 1023 } else { 1024 if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this); 1025 mPolicyVisibilityAfterAnim = false; 1026 mPolicyVisibility = false; 1027 // Window is no longer visible -- make sure if we were waiting 1028 // for it to be displayed before enabling the display, that 1029 // we allow the display to be enabled now. 1030 mService.enableScreenIfNeededLocked(); 1031 if (mService.mCurrentFocus == this) { 1032 mService.mFocusMayChange = true; 1033 } 1034 } 1035 if (requestAnim) { 1036 mService.updateLayoutToAnimationLocked(); 1037 } 1038 return true; 1039 } 1040 1041 @Override isAlive()1042 public boolean isAlive() { 1043 return mClient.asBinder().isBinderAlive(); 1044 } 1045 isClosing()1046 boolean isClosing() { 1047 return mExiting || (mService.mClosingApps.contains(mAppToken)); 1048 } 1049 1050 @Override isDefaultDisplay()1051 public boolean isDefaultDisplay() { 1052 return mDisplayContent.isDefaultDisplay; 1053 } 1054 setShowToOwnerOnlyLocked(boolean showToOwnerOnly)1055 public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) { 1056 mShowToOwnerOnly = showToOwnerOnly; 1057 } 1058 isHiddenFromUserLocked()1059 boolean isHiddenFromUserLocked() { 1060 // Attached windows are evaluated based on the window that they are attached to. 1061 WindowState win = this; 1062 while (win.mAttachedWindow != null) { 1063 win = win.mAttachedWindow; 1064 } 1065 if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW 1066 && win.mAppToken != null && win.mAppToken.showWhenLocked) { 1067 // Save some cycles by not calling getDisplayInfo unless it is an application 1068 // window intended for all users. 1069 final DisplayInfo displayInfo = win.mDisplayContent.getDisplayInfo(); 1070 if (win.mFrame.left <= 0 && win.mFrame.top <= 0 1071 && win.mFrame.right >= displayInfo.appWidth 1072 && win.mFrame.bottom >= displayInfo.appHeight) { 1073 // Is a fullscreen window, like the clock alarm. Show to everyone. 1074 return false; 1075 } 1076 } 1077 1078 return win.mShowToOwnerOnly 1079 && UserHandle.getUserId(win.mOwnerUid) != mService.mCurrentUserId; 1080 } 1081 applyInsets(Region outRegion, Rect frame, Rect inset)1082 private static void applyInsets(Region outRegion, Rect frame, Rect inset) { 1083 outRegion.set( 1084 frame.left + inset.left, frame.top + inset.top, 1085 frame.right - inset.right, frame.bottom - inset.bottom); 1086 } 1087 getTouchableRegion(Region outRegion)1088 public void getTouchableRegion(Region outRegion) { 1089 final Rect frame = mFrame; 1090 switch (mTouchableInsets) { 1091 default: 1092 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME: 1093 outRegion.set(frame); 1094 break; 1095 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT: 1096 applyInsets(outRegion, frame, mGivenContentInsets); 1097 break; 1098 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE: 1099 applyInsets(outRegion, frame, mGivenVisibleInsets); 1100 break; 1101 case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: { 1102 final Region givenTouchableRegion = mGivenTouchableRegion; 1103 outRegion.set(givenTouchableRegion); 1104 outRegion.translate(frame.left, frame.top); 1105 break; 1106 } 1107 } 1108 } 1109 getWindowList()1110 WindowList getWindowList() { 1111 return mDisplayContent.getWindowList(); 1112 } 1113 dump(PrintWriter pw, String prefix, boolean dumpAll)1114 void dump(PrintWriter pw, String prefix, boolean dumpAll) { 1115 pw.print(prefix); pw.print("mDisplayId="); pw.print(mDisplayContent.getDisplayId()); 1116 pw.print(" mSession="); pw.print(mSession); 1117 pw.print(" mClient="); pw.println(mClient.asBinder()); 1118 pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid); 1119 pw.print(" mShowToOwnerOnly="); pw.println(mShowToOwnerOnly); 1120 pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs); 1121 pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); 1122 pw.print(" h="); pw.print(mRequestedHeight); 1123 pw.print(" mLayoutSeq="); pw.println(mLayoutSeq); 1124 if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) { 1125 pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth); 1126 pw.print(" h="); pw.println(mLastRequestedHeight); 1127 } 1128 if (mAttachedWindow != null || mLayoutAttached) { 1129 pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow); 1130 pw.print(" mLayoutAttached="); pw.println(mLayoutAttached); 1131 } 1132 if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) { 1133 pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow); 1134 pw.print(" mIsWallpaper="); pw.print(mIsWallpaper); 1135 pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer); 1136 pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible); 1137 } 1138 if (dumpAll) { 1139 pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer); 1140 pw.print(" mSubLayer="); pw.print(mSubLayer); 1141 pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+"); 1142 pw.print((mTargetAppToken != null ? 1143 mTargetAppToken.mAppAnimator.animLayerAdjustment 1144 : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0))); 1145 pw.print("="); pw.print(mWinAnimator.mAnimLayer); 1146 pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer); 1147 } 1148 if (dumpAll) { 1149 pw.print(prefix); pw.print("mToken="); pw.println(mToken); 1150 pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); 1151 if (mAppToken != null) { 1152 pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken); 1153 } 1154 if (mTargetAppToken != null) { 1155 pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken); 1156 } 1157 pw.print(prefix); pw.print("mViewVisibility=0x"); 1158 pw.print(Integer.toHexString(mViewVisibility)); 1159 pw.print(" mHaveFrame="); pw.print(mHaveFrame); 1160 pw.print(" mObscured="); pw.println(mObscured); 1161 pw.print(prefix); pw.print("mSeq="); pw.print(mSeq); 1162 pw.print(" mSystemUiVisibility=0x"); 1163 pw.println(Integer.toHexString(mSystemUiVisibility)); 1164 } 1165 if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) { 1166 pw.print(prefix); pw.print("mPolicyVisibility="); 1167 pw.print(mPolicyVisibility); 1168 pw.print(" mPolicyVisibilityAfterAnim="); 1169 pw.print(mPolicyVisibilityAfterAnim); 1170 pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); 1171 } 1172 if (!mRelayoutCalled || mLayoutNeeded) { 1173 pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled); 1174 pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded); 1175 } 1176 if (mXOffset != 0 || mYOffset != 0) { 1177 pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset); 1178 pw.print(" y="); pw.println(mYOffset); 1179 } 1180 if (dumpAll) { 1181 pw.print(prefix); pw.print("mGivenContentInsets="); 1182 mGivenContentInsets.printShortString(pw); 1183 pw.print(" mGivenVisibleInsets="); 1184 mGivenVisibleInsets.printShortString(pw); 1185 pw.println(); 1186 if (mTouchableInsets != 0 || mGivenInsetsPending) { 1187 pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets); 1188 pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending); 1189 Region region = new Region(); 1190 getTouchableRegion(region); 1191 pw.print(prefix); pw.print("touchable region="); pw.println(region); 1192 } 1193 pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration); 1194 } 1195 pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface); 1196 pw.print(" mShownFrame="); mShownFrame.printShortString(pw); 1197 pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay()); 1198 if (dumpAll) { 1199 pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); 1200 pw.print(" last="); mLastFrame.printShortString(pw); 1201 pw.println(); 1202 pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw); 1203 pw.print(" last="); mLastSystemDecorRect.printShortString(pw); 1204 pw.println(); 1205 } 1206 if (mEnforceSizeCompat) { 1207 pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw); 1208 pw.println(); 1209 } 1210 if (dumpAll) { 1211 pw.print(prefix); pw.print("Frames: containing="); 1212 mContainingFrame.printShortString(pw); 1213 pw.print(" parent="); mParentFrame.printShortString(pw); 1214 pw.print(" display="); mDisplayFrame.printShortString(pw); 1215 pw.println(); 1216 pw.print(prefix); pw.print(" content="); mContentFrame.printShortString(pw); 1217 pw.print(" visible="); mVisibleFrame.printShortString(pw); 1218 pw.println(); 1219 pw.print(prefix); pw.print("Cur insets: content="); 1220 mContentInsets.printShortString(pw); 1221 pw.print(" visible="); mVisibleInsets.printShortString(pw); 1222 pw.println(); 1223 pw.print(prefix); pw.print("Lst insets: content="); 1224 mLastContentInsets.printShortString(pw); 1225 pw.print(" visible="); mLastVisibleInsets.printShortString(pw); 1226 pw.println(); 1227 } 1228 pw.print(prefix); pw.print(mWinAnimator); pw.println(":"); 1229 mWinAnimator.dump(pw, prefix + " ", dumpAll); 1230 if (mExiting || mRemoveOnExit || mDestroying || mRemoved) { 1231 pw.print(prefix); pw.print("mExiting="); pw.print(mExiting); 1232 pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit); 1233 pw.print(" mDestroying="); pw.print(mDestroying); 1234 pw.print(" mRemoved="); pw.println(mRemoved); 1235 } 1236 if (mOrientationChanging || mAppFreezing || mTurnOnScreen) { 1237 pw.print(prefix); pw.print("mOrientationChanging="); 1238 pw.print(mOrientationChanging); 1239 pw.print(" mAppFreezing="); pw.print(mAppFreezing); 1240 pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen); 1241 } 1242 if (mHScale != 1 || mVScale != 1) { 1243 pw.print(prefix); pw.print("mHScale="); pw.print(mHScale); 1244 pw.print(" mVScale="); pw.println(mVScale); 1245 } 1246 if (mWallpaperX != -1 || mWallpaperY != -1) { 1247 pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX); 1248 pw.print(" mWallpaperY="); pw.println(mWallpaperY); 1249 } 1250 if (mWallpaperXStep != -1 || mWallpaperYStep != -1) { 1251 pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep); 1252 pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep); 1253 } 1254 } 1255 makeInputChannelName()1256 String makeInputChannelName() { 1257 return Integer.toHexString(System.identityHashCode(this)) 1258 + " " + mAttrs.getTitle(); 1259 } 1260 1261 @Override toString()1262 public String toString() { 1263 if (mStringNameCache == null || mLastTitle != mAttrs.getTitle() 1264 || mWasExiting != mExiting) { 1265 mLastTitle = mAttrs.getTitle(); 1266 mWasExiting = mExiting; 1267 mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this)) 1268 + " u" + UserHandle.getUserId(mSession.mUid) 1269 + " " + mLastTitle + (mExiting ? " EXITING}" : "}"); 1270 } 1271 return mStringNameCache; 1272 } 1273 } 1274