Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 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 | |
Wale Ogunwale | 0c4a40ef | 2016-10-07 07:06:40 -0700 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
Robert Carr | 683e05d | 2018-04-18 15:11:04 -0700 | [diff] [blame] | 20 | import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; |
Louis Chang | 7501e33 | 2018-08-20 13:08:39 +0800 | [diff] [blame] | 21 | |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 22 | import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE; |
| 23 | import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS; |
| 24 | import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_WINDOW_MOVEMENT; |
lumark | 9bca6b4 | 2019-10-17 18:35:22 +0800 | [diff] [blame] | 25 | import static com.android.server.wm.WindowContainer.AnimationFlags.CHILDREN; |
| 26 | import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS; |
| 27 | import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION; |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 28 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 29 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
| 30 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; |
Yi Jin | 6c6e9ca | 2018-03-20 16:53:35 -0700 | [diff] [blame] | 31 | import static com.android.server.wm.WindowTokenProto.HASH_CODE; |
Yi Jin | 6c6e9ca | 2018-03-20 16:53:35 -0700 | [diff] [blame] | 32 | import static com.android.server.wm.WindowTokenProto.PAUSED; |
| 33 | import static com.android.server.wm.WindowTokenProto.WAITING_TO_SHOW; |
| 34 | import static com.android.server.wm.WindowTokenProto.WINDOWS; |
| 35 | import static com.android.server.wm.WindowTokenProto.WINDOW_CONTAINER; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 36 | |
Vishnu Nair | 04ab439 | 2018-01-10 11:00:06 -0800 | [diff] [blame] | 37 | import android.annotation.CallSuper; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 38 | import android.os.Debug; |
| 39 | import android.os.IBinder; |
Vishnu Nair | 04ab439 | 2018-01-10 11:00:06 -0800 | [diff] [blame] | 40 | import android.util.proto.ProtoOutputStream; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 41 | |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 42 | import com.android.server.protolog.common.ProtoLog; |
| 43 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 44 | import java.io.PrintWriter; |
Vishnu Nair | 04ab439 | 2018-01-10 11:00:06 -0800 | [diff] [blame] | 45 | import java.util.Comparator; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 46 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 47 | /** |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 48 | * Container of a set of related windows in the window manager. Often this is an AppWindowToken, |
| 49 | * which is the handle for an Activity that it uses to display windows. For nested windows, there is |
| 50 | * a WindowToken created for the parent window to manage its children. |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 51 | */ |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 52 | class WindowToken extends WindowContainer<WindowState> { |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 53 | private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowToken" : TAG_WM; |
| 54 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 55 | // The actual token. |
| 56 | final IBinder token; |
| 57 | |
| 58 | // The type of window this token is for, as per WindowManager.LayoutParams. |
| 59 | final int windowType; |
| 60 | |
Adrian Roos | 4bef62e | 2018-03-21 19:52:09 +0100 | [diff] [blame] | 61 | /** {@code true} if this holds the rounded corner overlay */ |
| 62 | final boolean mRoundedCornerOverlay; |
| 63 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 64 | // Set if this token was explicitly added by a client, so should |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 65 | // persist (not be removed) when all windows are removed. |
| 66 | boolean mPersistOnEmpty; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 67 | |
| 68 | // For printing. |
| 69 | String stringName; |
| 70 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 71 | // Is key dispatching paused for this token? |
| 72 | boolean paused = false; |
| 73 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 74 | // Temporary for finding which tokens no longer have visible windows. |
| 75 | boolean hasVisible; |
| 76 | |
| 77 | // Set to true when this token is in a pending transaction where it |
| 78 | // will be shown. |
| 79 | boolean waitingToShow; |
| 80 | |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 81 | /** The owner has {@link android.Manifest.permission#MANAGE_APP_TOKENS} */ |
| 82 | final boolean mOwnerCanManageAppTokens; |
| 83 | |
Wale Ogunwale | 07bcab7 | 2016-10-14 15:30:09 -0700 | [diff] [blame] | 84 | /** |
| 85 | * Compares two child window of this token and returns -1 if the first is lesser than the |
| 86 | * second in terms of z-order and 1 otherwise. |
| 87 | */ |
| 88 | private final Comparator<WindowState> mWindowComparator = |
| 89 | (WindowState newWindow, WindowState existingWindow) -> { |
| 90 | final WindowToken token = WindowToken.this; |
| 91 | if (newWindow.mToken != token) { |
| 92 | throw new IllegalArgumentException("newWindow=" + newWindow |
| 93 | + " is not a child of token=" + token); |
| 94 | } |
| 95 | |
| 96 | if (existingWindow.mToken != token) { |
| 97 | throw new IllegalArgumentException("existingWindow=" + existingWindow |
| 98 | + " is not a child of token=" + token); |
| 99 | } |
| 100 | |
| 101 | return isFirstChildWindowGreaterThanSecond(newWindow, existingWindow) ? 1 : -1; |
| 102 | }; |
| 103 | |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 104 | WindowToken(WindowManagerService service, IBinder _token, int type, boolean persistOnEmpty, |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 105 | DisplayContent dc, boolean ownerCanManageAppTokens) { |
Adrian Roos | 4bef62e | 2018-03-21 19:52:09 +0100 | [diff] [blame] | 106 | this(service, _token, type, persistOnEmpty, dc, ownerCanManageAppTokens, |
| 107 | false /* roundedCornersOverlay */); |
| 108 | } |
| 109 | |
| 110 | WindowToken(WindowManagerService service, IBinder _token, int type, boolean persistOnEmpty, |
| 111 | DisplayContent dc, boolean ownerCanManageAppTokens, boolean roundedCornerOverlay) { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 112 | super(service); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 113 | token = _token; |
| 114 | windowType = type; |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 115 | mPersistOnEmpty = persistOnEmpty; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 116 | mOwnerCanManageAppTokens = ownerCanManageAppTokens; |
Adrian Roos | 4bef62e | 2018-03-21 19:52:09 +0100 | [diff] [blame] | 117 | mRoundedCornerOverlay = roundedCornerOverlay; |
Wale Ogunwale | da8b827 | 2018-11-29 19:37:37 -0800 | [diff] [blame] | 118 | if (dc != null) { |
| 119 | onDisplayChanged(dc); |
| 120 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 121 | } |
| 122 | |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 123 | void removeAllWindowsIfPossible() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 124 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 125 | final WindowState win = mChildren.get(i); |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 126 | ProtoLog.w(WM_DEBUG_WINDOW_MOVEMENT, |
| 127 | "removeAllWindowsIfPossible: removing win=%s", win); |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 128 | win.removeIfPossible(); |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 129 | } |
| 130 | } |
| 131 | |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 132 | void setExiting() { |
chaviw | aec55ff5 | 2017-12-04 18:39:34 -0800 | [diff] [blame] | 133 | if (mChildren.size() == 0) { |
| 134 | super.removeImmediately(); |
| 135 | return; |
| 136 | } |
| 137 | |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 138 | // This token is exiting, so allow it to be removed when it no longer contains any windows. |
| 139 | mPersistOnEmpty = false; |
| 140 | |
Issei Suzuki | f2f6c91 | 2019-11-08 11:24:18 +0100 | [diff] [blame] | 141 | if (!isVisible()) { |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 142 | return; |
| 143 | } |
| 144 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 145 | final int count = mChildren.size(); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 146 | boolean changed = false; |
lumark | 9bca6b4 | 2019-10-17 18:35:22 +0800 | [diff] [blame] | 147 | final boolean delayed = isAnimating(TRANSITION | PARENTS | CHILDREN); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 148 | |
| 149 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 150 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 151 | changed |= win.onSetAppExiting(); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Issei Suzuki | f2f6c91 | 2019-11-08 11:24:18 +0100 | [diff] [blame] | 154 | final ActivityRecord app = asActivityRecord(); |
| 155 | if (app != null) { |
| 156 | app.setVisible(false); |
| 157 | } |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 158 | |
| 159 | if (changed) { |
Wale Ogunwale | 8b19de9 | 2018-11-29 19:58:26 -0800 | [diff] [blame] | 160 | mWmService.mWindowPlacerLocked.performSurfacePlacement(); |
| 161 | mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, false /*updateInputWindows*/); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 164 | if (delayed) { |
| 165 | mDisplayContent.mExitingTokens.add(this); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 169 | /** |
Riddle Hsu | b398da3 | 2019-01-21 21:48:16 +0800 | [diff] [blame] | 170 | * @return The scale for applications running in compatibility mode. Multiply the size in the |
| 171 | * application by this scale will be the size in the screen. |
| 172 | */ |
| 173 | float getSizeCompatScale() { |
| 174 | return mDisplayContent.mCompatibleScreenScale; |
| 175 | } |
| 176 | |
| 177 | /** |
Wale Ogunwale | 07bcab7 | 2016-10-14 15:30:09 -0700 | [diff] [blame] | 178 | * Returns true if the new window is considered greater than the existing window in terms of |
| 179 | * z-order. |
| 180 | */ |
| 181 | protected boolean isFirstChildWindowGreaterThanSecond(WindowState newWindow, |
| 182 | WindowState existingWindow) { |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 183 | // New window is considered greater if it has a higher or equal base layer. |
| 184 | return newWindow.mBaseLayer >= existingWindow.mBaseLayer; |
Wale Ogunwale | 07bcab7 | 2016-10-14 15:30:09 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Wale Ogunwale | 92fc372 | 2016-08-05 12:19:08 -0700 | [diff] [blame] | 187 | void addWindow(final WindowState win) { |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 188 | ProtoLog.d(WM_DEBUG_FOCUS, |
| 189 | "addWindow: win=%s Callers=%s", win, Debug.getCallers(5)); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 190 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 191 | if (win.isChildWindow()) { |
| 192 | // Child windows are added to their parent windows. |
Wale Ogunwale | b9a07c3 | 2016-10-12 14:55:56 -0700 | [diff] [blame] | 193 | return; |
| 194 | } |
Wale Ogunwale | b9a07c3 | 2016-10-12 14:55:56 -0700 | [diff] [blame] | 195 | if (!mChildren.contains(win)) { |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 196 | ProtoLog.v(WM_DEBUG_ADD_REMOVE, "Adding %s to %s", win, this); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 197 | addChild(win, mWindowComparator); |
Wale Ogunwale | 8b19de9 | 2018-11-29 19:58:26 -0800 | [diff] [blame] | 198 | mWmService.mWindowsChanged = true; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 199 | // TODO: Should we also be setting layout needed here and other places? |
Wale Ogunwale | b9a07c3 | 2016-10-12 14:55:56 -0700 | [diff] [blame] | 200 | } |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 203 | /** Returns true if the token windows list is empty. */ |
| 204 | boolean isEmpty() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 205 | return mChildren.isEmpty(); |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | WindowState getReplacingWindow() { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 209 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 210 | final WindowState win = mChildren.get(i); |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 211 | final WindowState replacing = win.getReplacingWindow(); |
| 212 | if (replacing != null) { |
| 213 | return replacing; |
Wale Ogunwale | e4da0c1 | 2016-07-29 12:47:02 -0700 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | return null; |
| 217 | } |
| 218 | |
Wale Ogunwale | 0c4a40ef | 2016-10-07 07:06:40 -0700 | [diff] [blame] | 219 | /** Return true if this token has a window that wants the wallpaper displayed behind it. */ |
| 220 | boolean windowsCanBeWallpaperTarget() { |
| 221 | for (int j = mChildren.size() - 1; j >= 0; j--) { |
| 222 | final WindowState w = mChildren.get(j); |
| 223 | if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) { |
| 224 | return true; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | return false; |
| 229 | } |
| 230 | |
Garfield Tan | e8d84ab | 2019-10-11 09:49:40 -0700 | [diff] [blame] | 231 | ActivityRecord asActivityRecord() { |
Wale Ogunwale | 2049dbf | 2016-08-02 21:05:23 -0700 | [diff] [blame] | 232 | // TODO: Not sure if this is the best way to handle this vs. using instanceof and casting. |
| 233 | // I am not an app window token! |
| 234 | return null; |
| 235 | } |
| 236 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 237 | @Override |
| 238 | void removeImmediately() { |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 239 | if (mDisplayContent != null) { |
| 240 | mDisplayContent.removeWindowToken(token); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 241 | } |
Wale Ogunwale | cfca258 | 2016-10-19 09:53:25 -0700 | [diff] [blame] | 242 | // Needs to occur after the token is removed from the display above to avoid attempt at |
| 243 | // duplicate removal of this window container from it's parent. |
| 244 | super.removeImmediately(); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 245 | } |
| 246 | |
Tiger Huang | 1e5b10a | 2018-07-30 20:19:51 +0800 | [diff] [blame] | 247 | @Override |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 248 | void onDisplayChanged(DisplayContent dc) { |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 249 | dc.reParentWindowToken(this); |
Robert Carr | da61ba9 | 2017-03-29 15:52:23 -0700 | [diff] [blame] | 250 | |
| 251 | // TODO(b/36740756): One day this should perhaps be hooked |
| 252 | // up with goodToGo, so we don't move a window |
| 253 | // to another display before the window behind |
| 254 | // it is ready. |
Robert Carr | da61ba9 | 2017-03-29 15:52:23 -0700 | [diff] [blame] | 255 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 256 | super.onDisplayChanged(dc); |
| 257 | } |
| 258 | |
Wale Ogunwale | 0d5609b | 2017-09-13 05:55:07 -0700 | [diff] [blame] | 259 | @CallSuper |
| 260 | @Override |
Nataniel Borges | 023ecb5 | 2019-01-16 14:15:43 -0800 | [diff] [blame] | 261 | public void writeToProto(ProtoOutputStream proto, long fieldId, |
| 262 | @WindowTraceLogLevel int logLevel) { |
| 263 | if (logLevel == WindowTraceLogLevel.CRITICAL && !isVisible()) { |
| 264 | return; |
| 265 | } |
| 266 | |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 267 | final long token = proto.start(fieldId); |
Nataniel Borges | 023ecb5 | 2019-01-16 14:15:43 -0800 | [diff] [blame] | 268 | super.writeToProto(proto, WINDOW_CONTAINER, logLevel); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 269 | proto.write(HASH_CODE, System.identityHashCode(this)); |
| 270 | for (int i = 0; i < mChildren.size(); i++) { |
| 271 | final WindowState w = mChildren.get(i); |
Nataniel Borges | 023ecb5 | 2019-01-16 14:15:43 -0800 | [diff] [blame] | 272 | w.writeToProto(proto, WINDOWS, logLevel); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 273 | } |
Vishnu Nair | 04ab439 | 2018-01-10 11:00:06 -0800 | [diff] [blame] | 274 | proto.write(WAITING_TO_SHOW, waitingToShow); |
| 275 | proto.write(PAUSED, paused); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 276 | proto.end(token); |
| 277 | } |
| 278 | |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 279 | void dump(PrintWriter pw, String prefix, boolean dumpAll) { |
| 280 | super.dump(pw, prefix, dumpAll); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 281 | pw.print(prefix); pw.print("windows="); pw.println(mChildren); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 282 | pw.print(prefix); pw.print("windowType="); pw.print(windowType); |
Issei Suzuki | 7b9e257 | 2019-11-14 16:19:54 +0100 | [diff] [blame] | 283 | pw.print(" hasVisible="); pw.println(hasVisible); |
Wale Ogunwale | 7a8889a | 2019-11-16 08:23:42 -0800 | [diff] [blame] | 284 | if (waitingToShow) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 285 | pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | |
| 289 | @Override |
| 290 | public String toString() { |
| 291 | if (stringName == null) { |
| 292 | StringBuilder sb = new StringBuilder(); |
| 293 | sb.append("WindowToken{"); |
| 294 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
Dianne Hackborn | ef03a7f | 2012-10-29 18:46:52 -0700 | [diff] [blame] | 295 | sb.append(" "); sb.append(token); sb.append('}'); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 296 | stringName = sb.toString(); |
| 297 | } |
| 298 | return stringName; |
| 299 | } |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 300 | |
| 301 | @Override |
| 302 | String getName() { |
| 303 | return toString(); |
| 304 | } |
David Stevens | 9440dc8 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 305 | |
Robert Carr | 683e05d | 2018-04-18 15:11:04 -0700 | [diff] [blame] | 306 | /** |
| 307 | * Return whether windows from this token can layer above the |
| 308 | * system bars, or in other words extend outside of the "Decor Frame" |
| 309 | */ |
| 310 | boolean canLayerAboveSystemBars() { |
Wale Ogunwale | 8b19de9 | 2018-11-29 19:58:26 -0800 | [diff] [blame] | 311 | int layer = mWmService.mPolicy.getWindowLayerFromTypeLw(windowType, |
Robert Carr | 683e05d | 2018-04-18 15:11:04 -0700 | [diff] [blame] | 312 | mOwnerCanManageAppTokens); |
Wale Ogunwale | 8b19de9 | 2018-11-29 19:58:26 -0800 | [diff] [blame] | 313 | int navLayer = mWmService.mPolicy.getWindowLayerFromTypeLw(TYPE_NAVIGATION_BAR, |
Robert Carr | 683e05d | 2018-04-18 15:11:04 -0700 | [diff] [blame] | 314 | mOwnerCanManageAppTokens); |
| 315 | return mOwnerCanManageAppTokens && (layer > navLayer); |
| 316 | } |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 317 | } |