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