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