1 /* 2 * Copyright (C) 2012 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.app.ActivityManager.StackId.DOCKED_STACK_ID; 20 import static android.app.ActivityManager.StackId.HOME_STACK_ID; 21 import static android.app.ActivityManager.StackId.PINNED_STACK_ID; 22 import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 23 import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; 24 import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; 25 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; 26 import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; 27 import static com.android.server.wm.WindowState.RESIZE_HANDLE_WIDTH_IN_DP; 28 29 import android.app.ActivityManager.StackId; 30 import android.graphics.Rect; 31 import android.graphics.Region; 32 import android.graphics.Region.Op; 33 import android.util.DisplayMetrics; 34 import android.util.Slog; 35 import android.view.Display; 36 import android.view.DisplayInfo; 37 import android.view.Surface; 38 39 import java.io.PrintWriter; 40 import java.util.ArrayList; 41 42 class DisplayContentList extends ArrayList<DisplayContent> { 43 } 44 45 /** 46 * Utility class for keeping track of the WindowStates and other pertinent contents of a 47 * particular Display. 48 * 49 * IMPORTANT: No method from this class should ever be used without holding 50 * WindowManagerService.mWindowMap. 51 */ 52 class DisplayContent { 53 54 /** Unique identifier of this stack. */ 55 private final int mDisplayId; 56 57 /** Z-ordered (bottom-most first) list of all Window objects. Assigned to an element 58 * from mDisplayWindows; */ 59 private final WindowList mWindows = new WindowList(); 60 61 int mInitialDisplayWidth = 0; 62 int mInitialDisplayHeight = 0; 63 int mInitialDisplayDensity = 0; 64 int mBaseDisplayWidth = 0; 65 int mBaseDisplayHeight = 0; 66 int mBaseDisplayDensity = 0; 67 boolean mDisplayScalingDisabled; 68 private final DisplayInfo mDisplayInfo = new DisplayInfo(); 69 private final Display mDisplay; 70 private final DisplayMetrics mDisplayMetrics = new DisplayMetrics(); 71 72 Rect mBaseDisplayRect = new Rect(); 73 Rect mContentRect = new Rect(); 74 75 // Accessed directly by all users. 76 boolean layoutNeeded; 77 int pendingLayoutChanges; 78 final boolean isDefaultDisplay; 79 80 /** Window tokens that are in the process of exiting, but still on screen for animations. */ 81 final ArrayList<WindowToken> mExitingTokens = new ArrayList<>(); 82 83 /** Array containing all TaskStacks on this display. Array 84 * is stored in display order with the current bottom stack at 0. */ 85 private final ArrayList<TaskStack> mStacks = new ArrayList<>(); 86 87 /** A special TaskStack with id==HOME_STACK_ID that moves to the bottom whenever any TaskStack 88 * (except a future lockscreen TaskStack) moves to the top. */ 89 private TaskStack mHomeStack = null; 90 91 /** Detect user tapping outside of current focused task bounds .*/ 92 TaskTapPointerEventListener mTapDetector; 93 94 /** Detect user tapping outside of current focused stack bounds .*/ 95 Region mTouchExcludeRegion = new Region(); 96 97 /** Detect user tapping in a non-resizeable task in docked or fullscreen stack .*/ 98 Region mNonResizeableRegion = new Region(); 99 100 /** Save allocating when calculating rects */ 101 private final Rect mTmpRect = new Rect(); 102 private final Rect mTmpRect2 = new Rect(); 103 private final Region mTmpRegion = new Region(); 104 105 /** For gathering Task objects in order. */ 106 final ArrayList<Task> mTmpTaskHistory = new ArrayList<Task>(); 107 108 final WindowManagerService mService; 109 110 /** Remove this display when animation on it has completed. */ 111 boolean mDeferredRemoval; 112 113 final DockedStackDividerController mDividerControllerLocked; 114 115 final DimLayerController mDimLayerController; 116 117 final ArrayList<WindowState> mTapExcludedWindows = new ArrayList<>(); 118 119 /** 120 * @param display May not be null. 121 * @param service You know. 122 */ DisplayContent(Display display, WindowManagerService service)123 DisplayContent(Display display, WindowManagerService service) { 124 mDisplay = display; 125 mDisplayId = display.getDisplayId(); 126 display.getDisplayInfo(mDisplayInfo); 127 display.getMetrics(mDisplayMetrics); 128 isDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY; 129 mService = service; 130 initializeDisplayBaseInfo(); 131 mDividerControllerLocked = new DockedStackDividerController(service, this); 132 mDimLayerController = new DimLayerController(this); 133 } 134 getDisplayId()135 int getDisplayId() { 136 return mDisplayId; 137 } 138 getWindowList()139 WindowList getWindowList() { 140 return mWindows; 141 } 142 getDisplay()143 Display getDisplay() { 144 return mDisplay; 145 } 146 getDisplayInfo()147 DisplayInfo getDisplayInfo() { 148 return mDisplayInfo; 149 } 150 getDisplayMetrics()151 DisplayMetrics getDisplayMetrics() { 152 return mDisplayMetrics; 153 } 154 getDockedDividerController()155 DockedStackDividerController getDockedDividerController() { 156 return mDividerControllerLocked; 157 } 158 159 /** 160 * Returns true if the specified UID has access to this display. 161 */ hasAccess(int uid)162 public boolean hasAccess(int uid) { 163 return mDisplay.hasAccess(uid); 164 } 165 isPrivate()166 public boolean isPrivate() { 167 return (mDisplay.getFlags() & Display.FLAG_PRIVATE) != 0; 168 } 169 getStacks()170 ArrayList<TaskStack> getStacks() { 171 return mStacks; 172 } 173 174 /** 175 * Retrieve the tasks on this display in stack order from the bottommost TaskStack up. 176 * @return All the Tasks, in order, on this display. 177 */ getTasks()178 ArrayList<Task> getTasks() { 179 mTmpTaskHistory.clear(); 180 final int numStacks = mStacks.size(); 181 for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) { 182 mTmpTaskHistory.addAll(mStacks.get(stackNdx).getTasks()); 183 } 184 return mTmpTaskHistory; 185 } 186 getHomeStack()187 TaskStack getHomeStack() { 188 if (mHomeStack == null && mDisplayId == Display.DEFAULT_DISPLAY) { 189 Slog.e(TAG_WM, "getHomeStack: Returning null from this=" + this); 190 } 191 return mHomeStack; 192 } 193 getStackById(int stackId)194 TaskStack getStackById(int stackId) { 195 for (int i = mStacks.size() - 1; i >= 0; --i) { 196 final TaskStack stack = mStacks.get(i); 197 if (stack.mStackId == stackId) { 198 return stack; 199 } 200 } 201 return null; 202 } 203 updateDisplayInfo()204 void updateDisplayInfo() { 205 mDisplay.getDisplayInfo(mDisplayInfo); 206 mDisplay.getMetrics(mDisplayMetrics); 207 for (int i = mStacks.size() - 1; i >= 0; --i) { 208 mStacks.get(i).updateDisplayInfo(null); 209 } 210 } 211 initializeDisplayBaseInfo()212 void initializeDisplayBaseInfo() { 213 // Bootstrap the default logical display from the display manager. 214 final DisplayInfo newDisplayInfo = 215 mService.mDisplayManagerInternal.getDisplayInfo(mDisplayId); 216 if (newDisplayInfo != null) { 217 mDisplayInfo.copyFrom(newDisplayInfo); 218 } 219 mBaseDisplayWidth = mInitialDisplayWidth = mDisplayInfo.logicalWidth; 220 mBaseDisplayHeight = mInitialDisplayHeight = mDisplayInfo.logicalHeight; 221 mBaseDisplayDensity = mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi; 222 mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight); 223 } 224 getLogicalDisplayRect(Rect out)225 void getLogicalDisplayRect(Rect out) { 226 // Uses same calculation as in LogicalDisplay#configureDisplayInTransactionLocked. 227 final int orientation = mDisplayInfo.rotation; 228 boolean rotated = (orientation == Surface.ROTATION_90 229 || orientation == Surface.ROTATION_270); 230 final int physWidth = rotated ? mBaseDisplayHeight : mBaseDisplayWidth; 231 final int physHeight = rotated ? mBaseDisplayWidth : mBaseDisplayHeight; 232 int width = mDisplayInfo.logicalWidth; 233 int left = (physWidth - width) / 2; 234 int height = mDisplayInfo.logicalHeight; 235 int top = (physHeight - height) / 2; 236 out.set(left, top, left + width, top + height); 237 } 238 getContentRect(Rect out)239 void getContentRect(Rect out) { 240 out.set(mContentRect); 241 } 242 243 /** Refer to {@link WindowManagerService#attachStack(int, int, boolean)} */ attachStack(TaskStack stack, boolean onTop)244 void attachStack(TaskStack stack, boolean onTop) { 245 if (stack.mStackId == HOME_STACK_ID) { 246 if (mHomeStack != null) { 247 throw new IllegalArgumentException("attachStack: HOME_STACK_ID (0) not first."); 248 } 249 mHomeStack = stack; 250 } 251 if (onTop) { 252 mStacks.add(stack); 253 } else { 254 mStacks.add(0, stack); 255 } 256 layoutNeeded = true; 257 } 258 moveStack(TaskStack stack, boolean toTop)259 void moveStack(TaskStack stack, boolean toTop) { 260 if (StackId.isAlwaysOnTop(stack.mStackId) && !toTop) { 261 // This stack is always-on-top silly... 262 Slog.w(TAG_WM, "Ignoring move of always-on-top stack=" + stack + " to bottom"); 263 return; 264 } 265 266 if (!mStacks.remove(stack)) { 267 Slog.wtf(TAG_WM, "moving stack that was not added: " + stack, new Throwable()); 268 } 269 270 int addIndex = toTop ? mStacks.size() : 0; 271 272 if (toTop 273 && mService.isStackVisibleLocked(PINNED_STACK_ID) 274 && stack.mStackId != PINNED_STACK_ID) { 275 // The pinned stack is always the top most stack (always-on-top) when it is visible. 276 // So, stack is moved just below the pinned stack. 277 addIndex--; 278 TaskStack topStack = mStacks.get(addIndex); 279 if (topStack.mStackId != PINNED_STACK_ID) { 280 throw new IllegalStateException("Pinned stack isn't top stack??? " + mStacks); 281 } 282 } 283 mStacks.add(addIndex, stack); 284 } 285 detachStack(TaskStack stack)286 void detachStack(TaskStack stack) { 287 mDimLayerController.removeDimLayerUser(stack); 288 mStacks.remove(stack); 289 } 290 291 /** 292 * Propagate the new bounds to all child stacks. 293 * @param contentRect The bounds to apply at the top level. 294 */ resize(Rect contentRect)295 void resize(Rect contentRect) { 296 mContentRect.set(contentRect); 297 } 298 taskIdFromPoint(int x, int y)299 int taskIdFromPoint(int x, int y) { 300 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 301 TaskStack stack = mStacks.get(stackNdx); 302 stack.getBounds(mTmpRect); 303 if (!mTmpRect.contains(x, y) || stack.isAdjustedForMinimizedDockedStack()) { 304 continue; 305 } 306 final ArrayList<Task> tasks = stack.getTasks(); 307 for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) { 308 final Task task = tasks.get(taskNdx); 309 final WindowState win = task.getTopVisibleAppMainWindow(); 310 if (win == null) { 311 continue; 312 } 313 // We need to use the task's dim bounds (which is derived from the visible 314 // bounds of its apps windows) for any touch-related tests. Can't use 315 // the task's original bounds because it might be adjusted to fit the 316 // content frame. For example, the presence of the IME adjusting the 317 // windows frames when the app window is the IME target. 318 task.getDimBounds(mTmpRect); 319 if (mTmpRect.contains(x, y)) { 320 return task.mTaskId; 321 } 322 } 323 } 324 return -1; 325 } 326 327 /** 328 * Find the task whose outside touch area (for resizing) (x, y) falls within. 329 * Returns null if the touch doesn't fall into a resizing area. 330 */ findTaskForControlPoint(int x, int y)331 Task findTaskForControlPoint(int x, int y) { 332 final int delta = mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, mDisplayMetrics); 333 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 334 TaskStack stack = mStacks.get(stackNdx); 335 if (!StackId.isTaskResizeAllowed(stack.mStackId)) { 336 break; 337 } 338 final ArrayList<Task> tasks = stack.getTasks(); 339 for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) { 340 final Task task = tasks.get(taskNdx); 341 if (task.isFullscreen()) { 342 return null; 343 } 344 345 // We need to use the task's dim bounds (which is derived from the visible 346 // bounds of its apps windows) for any touch-related tests. Can't use 347 // the task's original bounds because it might be adjusted to fit the 348 // content frame. One example is when the task is put to top-left quadrant, 349 // the actual visible area would not start at (0,0) after it's adjusted 350 // for the status bar. 351 task.getDimBounds(mTmpRect); 352 mTmpRect.inset(-delta, -delta); 353 if (mTmpRect.contains(x, y)) { 354 mTmpRect.inset(delta, delta); 355 if (!mTmpRect.contains(x, y)) { 356 return task; 357 } 358 // User touched inside the task. No need to look further, 359 // focus transfer will be handled in ACTION_UP. 360 return null; 361 } 362 } 363 } 364 return null; 365 } 366 setTouchExcludeRegion(Task focusedTask)367 void setTouchExcludeRegion(Task focusedTask) { 368 mTouchExcludeRegion.set(mBaseDisplayRect); 369 final int delta = mService.dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, mDisplayMetrics); 370 boolean addBackFocusedTask = false; 371 mNonResizeableRegion.setEmpty(); 372 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 373 TaskStack stack = mStacks.get(stackNdx); 374 final ArrayList<Task> tasks = stack.getTasks(); 375 for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) { 376 final Task task = tasks.get(taskNdx); 377 AppWindowToken token = task.getTopVisibleAppToken(); 378 if (token == null || !token.isVisible()) { 379 continue; 380 } 381 382 /** 383 * Exclusion region is the region that TapDetector doesn't care about. 384 * Here we want to remove all non-focused tasks from the exclusion region. 385 * We also remove the outside touch area for resizing for all freeform 386 * tasks (including the focused). 387 * 388 * We save the focused task region once we find it, and add it back at the end. 389 */ 390 391 task.getDimBounds(mTmpRect); 392 393 if (task == focusedTask) { 394 addBackFocusedTask = true; 395 mTmpRect2.set(mTmpRect); 396 } 397 398 final boolean isFreeformed = task.inFreeformWorkspace(); 399 if (task != focusedTask || isFreeformed) { 400 if (isFreeformed) { 401 // If the task is freeformed, enlarge the area to account for outside 402 // touch area for resize. 403 mTmpRect.inset(-delta, -delta); 404 // Intersect with display content rect. If we have system decor (status bar/ 405 // navigation bar), we want to exclude that from the tap detection. 406 // Otherwise, if the app is partially placed under some system button (eg. 407 // Recents, Home), pressing that button would cause a full series of 408 // unwanted transfer focus/resume/pause, before we could go home. 409 mTmpRect.intersect(mContentRect); 410 } 411 mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE); 412 } 413 if (task.isTwoFingerScrollMode()) { 414 stack.getBounds(mTmpRect); 415 mNonResizeableRegion.op(mTmpRect, Region.Op.UNION); 416 break; 417 } 418 } 419 } 420 // If we removed the focused task above, add it back and only leave its 421 // outside touch area in the exclusion. TapDectector is not interested in 422 // any touch inside the focused task itself. 423 if (addBackFocusedTask) { 424 mTouchExcludeRegion.op(mTmpRect2, Region.Op.UNION); 425 } 426 final WindowState inputMethod = mService.mInputMethodWindow; 427 if (inputMethod != null && inputMethod.isVisibleLw()) { 428 // If the input method is visible and the user is typing, we don't want these touch 429 // events to be intercepted and used to change focus. This would likely cause a 430 // disappearance of the input method. 431 inputMethod.getTouchableRegion(mTmpRegion); 432 mTouchExcludeRegion.op(mTmpRegion, Region.Op.UNION); 433 } 434 for (int i = mTapExcludedWindows.size() - 1; i >= 0; i--) { 435 WindowState win = mTapExcludedWindows.get(i); 436 win.getTouchableRegion(mTmpRegion); 437 mTouchExcludeRegion.op(mTmpRegion, Region.Op.UNION); 438 } 439 if (getDockedStackVisibleForUserLocked() != null) { 440 mDividerControllerLocked.getTouchRegion(mTmpRect); 441 mTmpRegion.set(mTmpRect); 442 mTouchExcludeRegion.op(mTmpRegion, Op.UNION); 443 } 444 if (mTapDetector != null) { 445 mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion, mNonResizeableRegion); 446 } 447 } 448 switchUserStacks()449 void switchUserStacks() { 450 final WindowList windows = getWindowList(); 451 for (int i = 0; i < windows.size(); i++) { 452 final WindowState win = windows.get(i); 453 if (win.isHiddenFromUserLocked()) { 454 if (DEBUG_VISIBILITY) Slog.w(TAG_WM, "user changing, hiding " + win 455 + ", attrs=" + win.mAttrs.type + ", belonging to " + win.mOwnerUid); 456 win.hideLw(false); 457 } 458 } 459 460 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 461 mStacks.get(stackNdx).switchUser(); 462 } 463 } 464 resetAnimationBackgroundAnimator()465 void resetAnimationBackgroundAnimator() { 466 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 467 mStacks.get(stackNdx).resetAnimationBackgroundAnimator(); 468 } 469 } 470 animateDimLayers()471 boolean animateDimLayers() { 472 return mDimLayerController.animateDimLayers(); 473 } 474 resetDimming()475 void resetDimming() { 476 mDimLayerController.resetDimming(); 477 } 478 isDimming()479 boolean isDimming() { 480 return mDimLayerController.isDimming(); 481 } 482 stopDimmingIfNeeded()483 void stopDimmingIfNeeded() { 484 mDimLayerController.stopDimmingIfNeeded(); 485 } 486 close()487 void close() { 488 mDimLayerController.close(); 489 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 490 mStacks.get(stackNdx).close(); 491 } 492 } 493 isAnimating()494 boolean isAnimating() { 495 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 496 final TaskStack stack = mStacks.get(stackNdx); 497 if (stack.isAnimating()) { 498 return true; 499 } 500 } 501 return false; 502 } 503 checkForDeferredActions()504 void checkForDeferredActions() { 505 boolean animating = false; 506 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 507 final TaskStack stack = mStacks.get(stackNdx); 508 if (stack.isAnimating()) { 509 animating = true; 510 } else { 511 if (stack.mDeferDetach) { 512 mService.detachStackLocked(this, stack); 513 } 514 final ArrayList<Task> tasks = stack.getTasks(); 515 for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) { 516 final Task task = tasks.get(taskNdx); 517 AppTokenList tokens = task.mAppTokens; 518 for (int tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) { 519 AppWindowToken wtoken = tokens.get(tokenNdx); 520 if (wtoken.mIsExiting) { 521 wtoken.removeAppFromTaskLocked(); 522 } 523 } 524 } 525 } 526 } 527 if (!animating && mDeferredRemoval) { 528 mService.onDisplayRemoved(mDisplayId); 529 } 530 } 531 rotateBounds(int oldRotation, int newRotation, Rect bounds)532 void rotateBounds(int oldRotation, int newRotation, Rect bounds) { 533 final int rotationDelta = DisplayContent.deltaRotation(oldRotation, newRotation); 534 getLogicalDisplayRect(mTmpRect); 535 switch (rotationDelta) { 536 case Surface.ROTATION_0: 537 mTmpRect2.set(bounds); 538 break; 539 case Surface.ROTATION_90: 540 mTmpRect2.top = mTmpRect.bottom - bounds.right; 541 mTmpRect2.left = bounds.top; 542 mTmpRect2.right = mTmpRect2.left + bounds.height(); 543 mTmpRect2.bottom = mTmpRect2.top + bounds.width(); 544 break; 545 case Surface.ROTATION_180: 546 mTmpRect2.top = mTmpRect.bottom - bounds.bottom; 547 mTmpRect2.left = mTmpRect.right - bounds.right; 548 mTmpRect2.right = mTmpRect2.left + bounds.width(); 549 mTmpRect2.bottom = mTmpRect2.top + bounds.height(); 550 break; 551 case Surface.ROTATION_270: 552 mTmpRect2.top = bounds.left; 553 mTmpRect2.left = mTmpRect.right - bounds.bottom; 554 mTmpRect2.right = mTmpRect2.left + bounds.height(); 555 mTmpRect2.bottom = mTmpRect2.top + bounds.width(); 556 break; 557 } 558 bounds.set(mTmpRect2); 559 } 560 deltaRotation(int oldRotation, int newRotation)561 static int deltaRotation(int oldRotation, int newRotation) { 562 int delta = newRotation - oldRotation; 563 if (delta < 0) delta += 4; 564 return delta; 565 } 566 dump(String prefix, PrintWriter pw)567 public void dump(String prefix, PrintWriter pw) { 568 pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId); 569 final String subPrefix = " " + prefix; 570 pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x"); 571 pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity); 572 pw.print("dpi"); 573 if (mInitialDisplayWidth != mBaseDisplayWidth 574 || mInitialDisplayHeight != mBaseDisplayHeight 575 || mInitialDisplayDensity != mBaseDisplayDensity) { 576 pw.print(" base="); 577 pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight); 578 pw.print(" "); pw.print(mBaseDisplayDensity); pw.print("dpi"); 579 } 580 if (mDisplayScalingDisabled) { 581 pw.println(" noscale"); 582 } 583 pw.print(" cur="); 584 pw.print(mDisplayInfo.logicalWidth); 585 pw.print("x"); pw.print(mDisplayInfo.logicalHeight); 586 pw.print(" app="); 587 pw.print(mDisplayInfo.appWidth); 588 pw.print("x"); pw.print(mDisplayInfo.appHeight); 589 pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth); 590 pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight); 591 pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth); 592 pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight); 593 pw.print(subPrefix); pw.print("deferred="); pw.print(mDeferredRemoval); 594 pw.print(" layoutNeeded="); pw.println(layoutNeeded); 595 596 pw.println(); 597 pw.println(" Application tokens in top down Z order:"); 598 for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { 599 final TaskStack stack = mStacks.get(stackNdx); 600 stack.dump(prefix + " ", pw); 601 } 602 603 pw.println(); 604 if (!mExitingTokens.isEmpty()) { 605 pw.println(); 606 pw.println(" Exiting tokens:"); 607 for (int i = mExitingTokens.size() - 1; i >= 0; i--) { 608 WindowToken token = mExitingTokens.get(i); 609 pw.print(" Exiting #"); pw.print(i); 610 pw.print(' '); pw.print(token); 611 pw.println(':'); 612 token.dump(pw, " "); 613 } 614 } 615 pw.println(); 616 mDimLayerController.dump(prefix + " ", pw); 617 pw.println(); 618 mDividerControllerLocked.dump(prefix + " ", pw); 619 } 620 621 @Override toString()622 public String toString() { 623 return "Display " + mDisplayId + " info=" + mDisplayInfo + " stacks=" + mStacks; 624 } 625 626 /** 627 * @return The docked stack, but only if it is visible, and {@code null} otherwise. 628 */ getDockedStackLocked()629 TaskStack getDockedStackLocked() { 630 final TaskStack stack = mService.mStackIdToStack.get(DOCKED_STACK_ID); 631 return (stack != null && stack.isVisibleLocked()) ? stack : null; 632 } 633 634 /** 635 * Like {@link #getDockedStackLocked}, but also returns the docked stack if it's currently not 636 * visible, as long as it's not hidden because the current user doesn't have any tasks there. 637 */ getDockedStackVisibleForUserLocked()638 TaskStack getDockedStackVisibleForUserLocked() { 639 final TaskStack stack = mService.mStackIdToStack.get(DOCKED_STACK_ID); 640 return (stack != null && stack.isVisibleForUserLocked()) ? stack : null; 641 } 642 643 /** 644 * Find the visible, touch-deliverable window under the given point 645 */ getTouchableWinAtPointLocked(float xf, float yf)646 WindowState getTouchableWinAtPointLocked(float xf, float yf) { 647 WindowState touchedWin = null; 648 final int x = (int) xf; 649 final int y = (int) yf; 650 651 for (int i = mWindows.size() - 1; i >= 0; i--) { 652 WindowState window = mWindows.get(i); 653 final int flags = window.mAttrs.flags; 654 if (!window.isVisibleLw()) { 655 continue; 656 } 657 if ((flags & FLAG_NOT_TOUCHABLE) != 0) { 658 continue; 659 } 660 661 window.getVisibleBounds(mTmpRect); 662 if (!mTmpRect.contains(x, y)) { 663 continue; 664 } 665 666 window.getTouchableRegion(mTmpRegion); 667 668 final int touchFlags = flags & (FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL); 669 if (mTmpRegion.contains(x, y) || touchFlags == 0) { 670 touchedWin = window; 671 break; 672 } 673 } 674 675 return touchedWin; 676 } 677 } 678