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