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