Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 19 | import android.content.res.Configuration; |
| 20 | import android.graphics.Rect; |
Ruchi Kandoi | 0d43404 | 2016-10-03 09:12:02 -0700 | [diff] [blame] | 21 | import android.hardware.power.V1_0.PowerHint; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 22 | import android.os.Binder; |
| 23 | import android.os.Debug; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 24 | import android.os.IBinder; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 25 | import android.os.ParcelFileDescriptor; |
| 26 | import android.os.PowerManager; |
| 27 | import android.os.RemoteException; |
| 28 | import android.os.SystemClock; |
| 29 | import android.os.UserHandle; |
| 30 | import android.provider.Settings; |
| 31 | import android.util.EventLog; |
| 32 | import android.util.Slog; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 33 | import android.util.SparseIntArray; |
| 34 | import android.view.Display; |
| 35 | import android.view.DisplayInfo; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 36 | import android.view.WindowManager; |
| 37 | import com.android.internal.util.ArrayUtils; |
| 38 | import com.android.server.EventLogTags; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 39 | |
| 40 | import java.io.FileDescriptor; |
| 41 | import java.io.PrintWriter; |
| 42 | import java.util.ArrayList; |
| 43 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 44 | import static android.app.AppOpsManager.MODE_ALLOWED; |
| 45 | import static android.app.AppOpsManager.MODE_DEFAULT; |
| 46 | import static android.app.AppOpsManager.OP_NONE; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 47 | import static android.view.Display.DEFAULT_DISPLAY; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 48 | import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 49 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 50 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE; |
| 51 | import static android.view.WindowManager.LayoutParams.TYPE_DREAM; |
| 52 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 53 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 54 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; |
| 55 | import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | 879ff72 | 2016-11-04 18:08:17 -0700 | [diff] [blame] | 56 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 57 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
| 58 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY; |
| 59 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEEP_SCREEN_ON; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 60 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
| 61 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
| 62 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_POWER; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 63 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT; |
| 64 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; |
| 65 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT; |
| 66 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_TRACE; |
| 67 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS; |
| 68 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_SURFACE_ALLOC; |
| 69 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS; |
| 70 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_KEEP_SCREEN_ON; |
| 71 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 72 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 73 | import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS; |
| 74 | import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 75 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES; |
| 76 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
| 77 | import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_NONE; |
| 78 | import static com.android.server.wm.WindowManagerService.H.WINDOW_FREEZE_TIMEOUT; |
| 79 | import static com.android.server.wm.WindowManagerService.logSurface; |
| 80 | import static com.android.server.wm.WindowSurfacePlacer.SET_FORCE_HIDING_CHANGED; |
| 81 | import static com.android.server.wm.WindowSurfacePlacer.SET_ORIENTATION_CHANGE_COMPLETE; |
| 82 | import static com.android.server.wm.WindowSurfacePlacer.SET_TURN_ON_SCREEN; |
| 83 | import static com.android.server.wm.WindowSurfacePlacer.SET_UPDATE_ROTATION; |
| 84 | import static com.android.server.wm.WindowSurfacePlacer.SET_WALLPAPER_ACTION_PENDING; |
| 85 | import static com.android.server.wm.WindowSurfacePlacer.SET_WALLPAPER_MAY_CHANGE; |
| 86 | |
| 87 | /** Root {@link WindowContainer} for the device. */ |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 88 | class RootWindowContainer extends WindowContainer<DisplayContent> { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 89 | private static final String TAG = TAG_WITH_CLASS_NAME ? "RootWindowContainer" : TAG_WM; |
| 90 | |
| 91 | WindowManagerService mService; |
| 92 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 93 | private boolean mWallpaperForceHidingChanged = false; |
| 94 | private Object mLastWindowFreezeSource = null; |
| 95 | private Session mHoldScreen = null; |
| 96 | private float mScreenBrightness = -1; |
| 97 | private float mButtonBrightness = -1; |
| 98 | private long mUserActivityTimeout = -1; |
| 99 | private boolean mUpdateRotation = false; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 100 | // Following variables are for debugging screen wakelock only. |
| 101 | // Last window that requires screen wakelock |
| 102 | WindowState mHoldScreenWindow = null; |
| 103 | // Last window that obscures all windows below |
Wale Ogunwale | d4a00a0 | 2016-10-10 11:29:17 -0700 | [diff] [blame] | 104 | WindowState mObscuringWindow = null; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 105 | // Only set while traversing the default display based on its content. |
| 106 | // Affects the behavior of mirroring on secondary displays. |
| 107 | private boolean mObscureApplicationContentOnSecondaryDisplays = false; |
| 108 | |
| 109 | private boolean mSustainedPerformanceModeEnabled = false; |
| 110 | private boolean mSustainedPerformanceModeCurrent = false; |
| 111 | |
| 112 | boolean mWallpaperMayChange = false; |
Robert Carr | 11c26c2 | 2016-09-23 12:40:27 -0700 | [diff] [blame] | 113 | // During an orientation change, we track whether all windows have rendered |
| 114 | // at the new orientation, and this will be false from changing orientation until that occurs. |
| 115 | // For seamless rotation cases this always stays true, as the windows complete their orientation |
| 116 | // changes 1 by 1 without disturbing global state. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 117 | boolean mOrientationChangeComplete = true; |
| 118 | boolean mWallpaperActionPending = false; |
| 119 | |
| 120 | private final ArrayList<Integer> mChangedStackList = new ArrayList(); |
| 121 | |
| 122 | // State for the RemoteSurfaceTrace system used in testing. If this is enabled SurfaceControl |
| 123 | // instances will be replaced with an instance that writes a binary representation of all |
| 124 | // commands to mSurfaceTraceFd. |
| 125 | boolean mSurfaceTraceEnabled; |
| 126 | ParcelFileDescriptor mSurfaceTraceFd; |
| 127 | RemoteEventTrace mRemoteEventTrace; |
| 128 | |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 129 | private final WindowLayersController mLayersController; |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 130 | final WallpaperController mWallpaperController; |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 131 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 132 | RootWindowContainer(WindowManagerService service) { |
| 133 | mService = service; |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 134 | mLayersController = new WindowLayersController(mService); |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 135 | mWallpaperController = new WallpaperController(mService); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | WindowState computeFocusedWindow() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 139 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 140 | for (int i = 0; i < count; i++) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 141 | final DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 142 | final WindowState win = dc.findFocusedWindow(); |
| 143 | if (win != null) { |
| 144 | return win; |
| 145 | } |
| 146 | } |
| 147 | return null; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Retrieve the DisplayContent for the specified displayId. Will create a new DisplayContent if |
| 152 | * there is a Display for the displayId. |
| 153 | * |
| 154 | * @param displayId The display the caller is interested in. |
| 155 | * @return The DisplayContent associated with displayId or null if there is no Display for it. |
| 156 | */ |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 157 | DisplayContent getDisplayContentOrCreate(int displayId) { |
| 158 | DisplayContent dc = getDisplayContent(displayId); |
| 159 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 160 | if (dc == null) { |
| 161 | final Display display = mService.mDisplayManager.getDisplay(displayId); |
| 162 | if (display != null) { |
| 163 | dc = createDisplayContent(display); |
| 164 | } |
| 165 | } |
| 166 | return dc; |
| 167 | } |
| 168 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 169 | DisplayContent getDisplayContent(int displayId) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 170 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 171 | final DisplayContent current = mChildren.get(i); |
| 172 | if (current.getDisplayId() == displayId) { |
| 173 | return current; |
| 174 | } |
| 175 | } |
| 176 | return null; |
| 177 | } |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 178 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 179 | private DisplayContent createDisplayContent(final Display display) { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 180 | final DisplayContent dc = new DisplayContent(display, mService, mLayersController, |
| 181 | mWallpaperController); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 182 | final int displayId = display.getDisplayId(); |
| 183 | |
| 184 | if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display); |
| 185 | addChild(dc, null); |
| 186 | |
| 187 | final DisplayInfo displayInfo = dc.getDisplayInfo(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 188 | final Rect rect = new Rect(); |
| 189 | mService.mDisplaySettings.getOverscanLocked(displayInfo.name, displayInfo.uniqueId, rect); |
| 190 | displayInfo.overscanLeft = rect.left; |
| 191 | displayInfo.overscanTop = rect.top; |
| 192 | displayInfo.overscanRight = rect.right; |
| 193 | displayInfo.overscanBottom = rect.bottom; |
| 194 | if (mService.mDisplayManagerInternal != null) { |
| 195 | mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager( |
| 196 | displayId, displayInfo); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 197 | mService.configureDisplayPolicyLocked(dc); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 198 | |
| 199 | // TODO(multi-display): Create an input channel for each display with touch capability. |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 200 | if (displayId == DEFAULT_DISPLAY) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 201 | dc.mTapDetector = new TaskTapPointerEventListener( |
| 202 | mService, dc); |
| 203 | mService.registerPointerEventListener(dc.mTapDetector); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 204 | mService.registerPointerEventListener(mService.mMousePositionTracker); |
| 205 | } |
| 206 | } |
| 207 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 208 | return dc; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 211 | boolean isLayoutNeeded() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 212 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 213 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 214 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 215 | if (displayContent.isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 216 | return true; |
| 217 | } |
| 218 | } |
| 219 | return false; |
| 220 | } |
| 221 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame^] | 222 | void getWindowsByName(ArrayList<WindowState> output, String name) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 223 | int objectId = 0; |
| 224 | // See if this is an object ID. |
| 225 | try { |
| 226 | objectId = Integer.parseInt(name, 16); |
| 227 | name = null; |
| 228 | } catch (RuntimeException e) { |
| 229 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 230 | |
| 231 | getWindowsByName(output, name, objectId); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame^] | 234 | private void getWindowsByName(ArrayList<WindowState> output, String name, int objectId) { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 235 | forAllWindows((w) -> { |
| 236 | if (name != null) { |
| 237 | if (w.mAttrs.getTitle().toString().contains(name)) { |
| 238 | output.add(w); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 239 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 240 | } else if (System.identityHashCode(w) == objectId) { |
| 241 | output.add(w); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 242 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 243 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 246 | /** |
| 247 | * Returns the app window token for the input binder if it exist in the system. |
| 248 | * NOTE: Only one AppWindowToken is allowed to exist in the system for a binder token, since |
| 249 | * AppWindowToken represents an activity which can only exist on one display. |
| 250 | */ |
| 251 | AppWindowToken getAppWindowToken(IBinder binder) { |
| 252 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 253 | final DisplayContent dc = mChildren.get(i); |
| 254 | final AppWindowToken atoken = dc.getAppWindowToken(binder); |
| 255 | if (atoken != null) { |
| 256 | return atoken; |
| 257 | } |
| 258 | } |
| 259 | return null; |
| 260 | } |
| 261 | |
| 262 | /** Returns the display object the input window token is currently mapped on. */ |
| 263 | DisplayContent getWindowTokenDisplay(WindowToken token) { |
| 264 | if (token == null) { |
| 265 | return null; |
| 266 | } |
| 267 | |
| 268 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 269 | final DisplayContent dc = mChildren.get(i); |
| 270 | final WindowToken current = dc.getWindowToken(token.token); |
| 271 | if (current == token) { |
| 272 | return dc; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | return null; |
| 277 | } |
| 278 | |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 279 | /** |
| 280 | * Set new display override config and return array of ids of stacks that were changed during |
| 281 | * update. If called for the default display, global configuration will also be updated. |
| 282 | */ |
| 283 | int[] setDisplayOverrideConfigurationIfNeeded(Configuration newConfiguration, int displayId) { |
| 284 | final DisplayContent displayContent = getDisplayContent(displayId); |
| 285 | if (displayContent == null) { |
| 286 | throw new IllegalArgumentException("Display not found for id: " + displayId); |
| 287 | } |
| 288 | |
| 289 | final Configuration currentConfig = displayContent.getOverrideConfiguration(); |
| 290 | final boolean configChanged = currentConfig.diff(newConfiguration) != 0; |
| 291 | if (!configChanged) { |
| 292 | return null; |
| 293 | } |
| 294 | displayContent.onOverrideConfigurationChanged(currentConfig); |
| 295 | |
| 296 | if (displayId == DEFAULT_DISPLAY) { |
| 297 | // Override configuration of the default display duplicates global config. In this case |
| 298 | // we also want to update the global config. |
| 299 | return setGlobalConfigurationIfNeeded(newConfiguration); |
| 300 | } else { |
| 301 | return updateStackBoundsAfterConfigChange(displayId); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | private int[] setGlobalConfigurationIfNeeded(Configuration newConfiguration) { |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 306 | final boolean configChanged = getConfiguration().diff(newConfiguration) != 0; |
| 307 | if (!configChanged) { |
| 308 | return null; |
| 309 | } |
| 310 | onConfigurationChanged(newConfiguration); |
| 311 | return updateStackBoundsAfterConfigChange(); |
| 312 | } |
| 313 | |
| 314 | @Override |
| 315 | void onConfigurationChanged(Configuration newParentConfig) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 316 | prepareFreezingTaskBounds(); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 317 | super.onConfigurationChanged(newParentConfig); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 318 | |
| 319 | mService.mPolicy.onConfigurationChanged(); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 320 | } |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 321 | |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 322 | /** |
| 323 | * Callback used to trigger bounds update after configuration change and get ids of stacks whose |
| 324 | * bounds were updated. |
| 325 | */ |
Wale Ogunwale | d4a00a0 | 2016-10-10 11:29:17 -0700 | [diff] [blame] | 326 | private int[] updateStackBoundsAfterConfigChange() { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 327 | mChangedStackList.clear(); |
| 328 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 329 | final int numDisplays = mChildren.size(); |
| 330 | for (int i = 0; i < numDisplays; ++i) { |
| 331 | final DisplayContent dc = mChildren.get(i); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 332 | dc.updateStackBoundsAfterConfigChange(mChangedStackList); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | return mChangedStackList.isEmpty() ? null : ArrayUtils.convertToIntArray(mChangedStackList); |
| 336 | } |
| 337 | |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 338 | /** Same as {@link #updateStackBoundsAfterConfigChange()} but only for a specific display. */ |
| 339 | private int[] updateStackBoundsAfterConfigChange(int displayId) { |
| 340 | mChangedStackList.clear(); |
| 341 | |
| 342 | final DisplayContent dc = getDisplayContent(displayId); |
| 343 | dc.updateStackBoundsAfterConfigChange(mChangedStackList); |
| 344 | |
| 345 | return mChangedStackList.isEmpty() ? null : ArrayUtils.convertToIntArray(mChangedStackList); |
| 346 | } |
| 347 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 348 | private void prepareFreezingTaskBounds() { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 349 | for (int i = mChildren.size() - 1; i >= 0; i--) { |
| 350 | mChildren.get(i).prepareFreezingTaskBounds(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 351 | } |
| 352 | } |
| 353 | |
| 354 | void setSecureSurfaceState(int userId, boolean disabled) { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 355 | forAllWindows((w) -> { |
| 356 | if (w.mHasSurface && userId == UserHandle.getUserId(w.mOwnerUid)) { |
| 357 | w.mWinAnimator.setSecureLocked(disabled); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 358 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 359 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | void updateAppOpsState() { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 363 | forAllWindows((w) -> { |
| 364 | if (w.mAppOp == OP_NONE) { |
| 365 | return; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 366 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 367 | final int mode = mService.mAppOps.checkOpNoThrow(w.mAppOp, w.getOwningUid(), |
| 368 | w.getOwningPackage()); |
| 369 | w.setAppOpVisibilityLw(mode == MODE_ALLOWED || mode == MODE_DEFAULT); |
| 370 | }, false /* traverseTopToBottom */); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | boolean canShowStrictModeViolation(int pid) { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 374 | final WindowState win = getWindow((w) -> w.mSession.mPid == pid && w.isVisibleLw()); |
| 375 | return win != null; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | void closeSystemDialogs(String reason) { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 379 | forAllWindows((w) -> { |
| 380 | if (w.mHasSurface) { |
| 381 | try { |
| 382 | w.mClient.closeSystemDialogs(reason); |
| 383 | } catch (RemoteException e) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 384 | } |
| 385 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 386 | }, false /* traverseTopToBottom */); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | void removeReplacedWindows() { |
| 390 | if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION removeReplacedWindows"); |
| 391 | mService.openSurfaceTransaction(); |
| 392 | try { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 393 | forAllWindows((w) -> { |
| 394 | final AppWindowToken aToken = w.mAppToken; |
| 395 | if (aToken != null) { |
| 396 | aToken.removeReplacedWindowIfNeeded(w); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 397 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 398 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 399 | } finally { |
| 400 | mService.closeSurfaceTransaction(); |
| 401 | if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION removeReplacedWindows"); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | boolean hasPendingLayoutChanges(WindowAnimator animator) { |
| 406 | boolean hasChanges = false; |
| 407 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 408 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 409 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 410 | final DisplayContent dc = mChildren.get(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 411 | final int pendingChanges = animator.getPendingLayoutChanges(dc.getDisplayId()); |
| 412 | if ((pendingChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0) { |
| 413 | animator.mBulkUpdateParams |= SET_WALLPAPER_ACTION_PENDING; |
| 414 | } |
| 415 | if (pendingChanges != 0) { |
| 416 | hasChanges = true; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | return hasChanges; |
| 421 | } |
| 422 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 423 | boolean reclaimSomeSurfaceMemory(WindowStateAnimator winAnimator, String operation, |
| 424 | boolean secure) { |
| 425 | final WindowSurfaceController surfaceController = winAnimator.mSurfaceController; |
| 426 | boolean leakedSurface = false; |
| 427 | boolean killedApps = false; |
| 428 | |
| 429 | EventLog.writeEvent(EventLogTags.WM_NO_SURFACE_MEMORY, winAnimator.mWin.toString(), |
| 430 | winAnimator.mSession.mPid, operation); |
| 431 | |
| 432 | final long callingIdentity = Binder.clearCallingIdentity(); |
| 433 | try { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 434 | // There was some problem...first, do a sanity check of the window list to make sure |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 435 | // we haven't left any dangling surfaces around. |
| 436 | |
| 437 | Slog.i(TAG_WM, "Out of memory for surface! Looking for leaks..."); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 438 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 439 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 440 | leakedSurface |= mChildren.get(displayNdx).destroyLeakedSurfaces(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | if (!leakedSurface) { |
| 444 | Slog.w(TAG_WM, "No leaked surfaces; killing applications!"); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 445 | final SparseIntArray pidCandidates = new SparseIntArray(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 446 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 447 | mChildren.get(displayNdx).forAllWindows((w) -> { |
| 448 | if (mService.mForceRemoves.contains(w)) { |
| 449 | return; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 450 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 451 | final WindowStateAnimator wsa = w.mWinAnimator; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 452 | if (wsa.mSurfaceController != null) { |
| 453 | pidCandidates.append(wsa.mSession.mPid, wsa.mSession.mPid); |
| 454 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 455 | }, false /* traverseTopToBottom */); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 456 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 457 | if (pidCandidates.size() > 0) { |
| 458 | int[] pids = new int[pidCandidates.size()]; |
| 459 | for (int i = 0; i < pids.length; i++) { |
| 460 | pids[i] = pidCandidates.keyAt(i); |
| 461 | } |
| 462 | try { |
| 463 | if (mService.mActivityManager.killPids(pids, "Free memory", secure)) { |
| 464 | killedApps = true; |
| 465 | } |
| 466 | } catch (RemoteException e) { |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | if (leakedSurface || killedApps) { |
| 473 | // We managed to reclaim some memory, so get rid of the trouble surface and ask the |
| 474 | // app to request another one. |
| 475 | Slog.w(TAG_WM, |
| 476 | "Looks like we have reclaimed some memory, clearing surface for retry."); |
| 477 | if (surfaceController != null) { |
| 478 | if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) logSurface(winAnimator.mWin, |
| 479 | "RECOVER DESTROY", false); |
| 480 | winAnimator.destroySurface(); |
| 481 | mService.scheduleRemoveStartingWindowLocked(winAnimator.mWin.mAppToken); |
| 482 | } |
| 483 | |
| 484 | try { |
| 485 | winAnimator.mWin.mClient.dispatchGetNewSurface(); |
| 486 | } catch (RemoteException e) { |
| 487 | } |
| 488 | } |
| 489 | } finally { |
| 490 | Binder.restoreCallingIdentity(callingIdentity); |
| 491 | } |
| 492 | |
| 493 | return leakedSurface || killedApps; |
| 494 | } |
| 495 | |
| 496 | // "Something has changed! Let's make it correct now." |
| 497 | // TODO: Super crazy long method that should be broken down... |
| 498 | void performSurfacePlacement(boolean recoveringMemory) { |
| 499 | if (DEBUG_WINDOW_TRACE) Slog.v(TAG, "performSurfacePlacementInner: entry. Called by " |
| 500 | + Debug.getCallers(3)); |
| 501 | |
| 502 | int i; |
| 503 | boolean updateInputWindowsNeeded = false; |
| 504 | |
| 505 | if (mService.mFocusMayChange) { |
| 506 | mService.mFocusMayChange = false; |
| 507 | updateInputWindowsNeeded = mService.updateFocusedWindowLocked( |
| 508 | UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/); |
| 509 | } |
| 510 | |
| 511 | // Initialize state of exiting tokens. |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 512 | final int numDisplays = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 513 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 514 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 515 | for (i = displayContent.mExitingTokens.size() - 1; i >= 0; i--) { |
| 516 | displayContent.mExitingTokens.get(i).hasVisible = false; |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 521 | // Initialize state of exiting applications. |
| 522 | final AppTokenList exitingAppTokens = |
| 523 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 524 | for (int tokenNdx = exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) { |
| 525 | exitingAppTokens.get(tokenNdx).hasVisible = false; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | mHoldScreen = null; |
| 530 | mScreenBrightness = -1; |
| 531 | mButtonBrightness = -1; |
| 532 | mUserActivityTimeout = -1; |
| 533 | mObscureApplicationContentOnSecondaryDisplays = false; |
| 534 | mSustainedPerformanceModeCurrent = false; |
| 535 | mService.mTransactionSequence++; |
| 536 | |
| 537 | // TODO(multi-display): |
| 538 | final DisplayContent defaultDisplay = mService.getDefaultDisplayContentLocked(); |
| 539 | final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo(); |
| 540 | final int defaultDw = defaultInfo.logicalWidth; |
| 541 | final int defaultDh = defaultInfo.logicalHeight; |
| 542 | |
| 543 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
| 544 | ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces"); |
| 545 | mService.openSurfaceTransaction(); |
| 546 | try { |
Wale Ogunwale | 9d9d8f1 | 2016-09-28 15:29:59 -0700 | [diff] [blame] | 547 | applySurfaceChangesTransaction(recoveringMemory, defaultDw, defaultDh); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 548 | } catch (RuntimeException e) { |
| 549 | Slog.wtf(TAG, "Unhandled exception in Window Manager", e); |
| 550 | } finally { |
| 551 | mService.closeSurfaceTransaction(); |
| 552 | if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, |
| 553 | "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces"); |
| 554 | } |
| 555 | |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 556 | final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked; |
| 557 | |
| 558 | // If we are ready to perform an app transition, check through all of the app tokens to be |
| 559 | // shown and see if they are ready to go. |
| 560 | if (mService.mAppTransition.isReady()) { |
| 561 | defaultDisplay.pendingLayoutChanges |= |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 562 | surfacePlacer.handleAppTransitionReadyLocked(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 563 | if (DEBUG_LAYOUT_REPEATS) |
| 564 | surfacePlacer.debugLayoutRepeats("after handleAppTransitionReadyLocked", |
| 565 | defaultDisplay.pendingLayoutChanges); |
| 566 | } |
| 567 | |
| 568 | if (!mService.mAnimator.mAppWindowAnimating && mService.mAppTransition.isRunning()) { |
| 569 | // We have finished the animation of an app transition. To do this, we have delayed a |
| 570 | // lot of operations like showing and hiding apps, moving apps in Z-order, etc. The app |
| 571 | // token list reflects the correct Z-order, but the window list may now be out of sync |
| 572 | // with it. So here we will just rebuild the entire app window list. Fun! |
| 573 | defaultDisplay.pendingLayoutChanges |= |
| 574 | mService.handleAnimatingStoppedAndTransitionLocked(); |
| 575 | if (DEBUG_LAYOUT_REPEATS) |
| 576 | surfacePlacer.debugLayoutRepeats("after handleAnimStopAndXitionLock", |
| 577 | defaultDisplay.pendingLayoutChanges); |
| 578 | } |
| 579 | |
| 580 | if (mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0 |
| 581 | && !mService.mAppTransition.isReady()) { |
| 582 | // At this point, there was a window with a wallpaper that was force hiding other |
| 583 | // windows behind it, but now it is going away. This may be simple -- just animate away |
| 584 | // the wallpaper and its window -- or it may be hard -- the wallpaper now needs to be |
| 585 | // shown behind something that was hidden. |
| 586 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 587 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats( |
| 588 | "after animateAwayWallpaperLocked", defaultDisplay.pendingLayoutChanges); |
| 589 | } |
| 590 | mWallpaperForceHidingChanged = false; |
| 591 | |
| 592 | if (mWallpaperMayChange) { |
| 593 | if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "Wallpaper may change! Adjusting"); |
| 594 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 595 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("WallpaperMayChange", |
| 596 | defaultDisplay.pendingLayoutChanges); |
| 597 | } |
| 598 | |
| 599 | if (mService.mFocusMayChange) { |
| 600 | mService.mFocusMayChange = false; |
| 601 | if (mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, |
| 602 | false /*updateInputWindows*/)) { |
| 603 | updateInputWindowsNeeded = true; |
| 604 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM; |
| 605 | } |
| 606 | } |
| 607 | |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 608 | if (isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 609 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 610 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("mLayoutNeeded", |
| 611 | defaultDisplay.pendingLayoutChanges); |
| 612 | } |
| 613 | |
| 614 | for (i = mService.mResizingWindows.size() - 1; i >= 0; i--) { |
| 615 | WindowState win = mService.mResizingWindows.get(i); |
| 616 | if (win.mAppFreezing) { |
| 617 | // Don't remove this window until rotation has completed. |
| 618 | continue; |
| 619 | } |
| 620 | // Discard the saved surface if window size is changed, it can't be reused. |
| 621 | if (win.mAppToken != null) { |
| 622 | win.mAppToken.destroySavedSurfaces(); |
| 623 | } |
| 624 | win.reportResized(); |
| 625 | mService.mResizingWindows.remove(i); |
| 626 | } |
| 627 | |
| 628 | if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG, |
| 629 | "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete); |
| 630 | if (mOrientationChangeComplete) { |
| 631 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 632 | mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE; |
| 633 | mService.mLastFinishedFreezeSource = mLastWindowFreezeSource; |
| 634 | mService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT); |
| 635 | } |
| 636 | mService.stopFreezingDisplayLocked(); |
| 637 | } |
| 638 | |
| 639 | // Destroy the surface of any windows that are no longer visible. |
| 640 | boolean wallpaperDestroyed = false; |
| 641 | i = mService.mDestroySurface.size(); |
| 642 | if (i > 0) { |
| 643 | do { |
| 644 | i--; |
| 645 | WindowState win = mService.mDestroySurface.get(i); |
| 646 | win.mDestroying = false; |
| 647 | if (mService.mInputMethodWindow == win) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame^] | 648 | mService.setInputMethodWindowLocked(null); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 649 | } |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 650 | if (win.getDisplayContent().mWallpaperController.isWallpaperTarget(win)) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 651 | wallpaperDestroyed = true; |
| 652 | } |
| 653 | win.destroyOrSaveSurface(); |
| 654 | } while (i > 0); |
| 655 | mService.mDestroySurface.clear(); |
| 656 | } |
| 657 | |
| 658 | // Time to remove any exiting tokens? |
| 659 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 660 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 661 | ArrayList<WindowToken> exitingTokens = displayContent.mExitingTokens; |
| 662 | for (i = exitingTokens.size() - 1; i >= 0; i--) { |
| 663 | WindowToken token = exitingTokens.get(i); |
| 664 | if (!token.hasVisible) { |
| 665 | exitingTokens.remove(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | // Time to remove any exiting applications? |
| 671 | for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) { |
| 672 | // Initialize state of exiting applications. |
| 673 | final AppTokenList exitingAppTokens = |
| 674 | mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens; |
| 675 | for (i = exitingAppTokens.size() - 1; i >= 0; i--) { |
| 676 | final AppWindowToken token = exitingAppTokens.get(i); |
| 677 | if (!token.hasVisible && !mService.mClosingApps.contains(token) && |
| 678 | (!token.mIsExiting || token.isEmpty())) { |
| 679 | // Make sure there is no animation running on this token, so any windows |
| 680 | // associated with it will be removed as soon as their animations are complete |
| 681 | token.mAppAnimator.clearAnimation(); |
| 682 | token.mAppAnimator.animating = false; |
| 683 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, |
| 684 | "performLayout: App token exiting now removed" + token); |
| 685 | token.removeIfPossible(); |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | if (wallpaperDestroyed) { |
| 691 | defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 692 | defaultDisplay.setLayoutNeeded(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 696 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 697 | if (displayContent.pendingLayoutChanges != 0) { |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 698 | displayContent.setLayoutNeeded(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | |
| 702 | // Finally update all input windows now that the window changes have stabilized. |
| 703 | mService.mInputMonitor.updateInputWindowsLw(true /*force*/); |
| 704 | |
| 705 | mService.setHoldScreenLocked(mHoldScreen); |
| 706 | if (!mService.mDisplayFrozen) { |
| 707 | if (mScreenBrightness < 0 || mScreenBrightness > 1.0f) { |
| 708 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1); |
| 709 | } else { |
| 710 | mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager( |
| 711 | toBrightnessOverride(mScreenBrightness)); |
| 712 | } |
| 713 | if (mButtonBrightness < 0 || mButtonBrightness > 1.0f) { |
| 714 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1); |
| 715 | } else { |
| 716 | mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager( |
| 717 | toBrightnessOverride(mButtonBrightness)); |
| 718 | } |
| 719 | mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager( |
| 720 | mUserActivityTimeout); |
| 721 | } |
| 722 | |
| 723 | if (mSustainedPerformanceModeCurrent != mSustainedPerformanceModeEnabled) { |
| 724 | mSustainedPerformanceModeEnabled = mSustainedPerformanceModeCurrent; |
| 725 | mService.mPowerManagerInternal.powerHint( |
Ruchi Kandoi | 0d43404 | 2016-10-03 09:12:02 -0700 | [diff] [blame] | 726 | PowerHint.SUSTAINED_PERFORMANCE, |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 727 | (mSustainedPerformanceModeEnabled ? 1 : 0)); |
| 728 | } |
| 729 | |
| 730 | if (mService.mTurnOnScreen) { |
| 731 | if (mService.mAllowTheaterModeWakeFromLayout |
| 732 | || Settings.Global.getInt(mService.mContext.getContentResolver(), |
| 733 | Settings.Global.THEATER_MODE_ON, 0) == 0) { |
| 734 | if (DEBUG_VISIBILITY || DEBUG_POWER) { |
| 735 | Slog.v(TAG, "Turning screen on after layout!"); |
| 736 | } |
| 737 | mService.mPowerManager.wakeUp(SystemClock.uptimeMillis(), |
| 738 | "android.server.wm:TURN_ON"); |
| 739 | } |
| 740 | mService.mTurnOnScreen = false; |
| 741 | } |
| 742 | |
| 743 | if (mUpdateRotation) { |
| 744 | if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); |
Andrii Kulian | 5406e7a | 2016-10-21 11:55:23 -0700 | [diff] [blame] | 745 | // TODO(multi-display): Update rotation for different displays separately. |
| 746 | final int displayId = defaultDisplay.getDisplayId(); |
| 747 | if (mService.updateRotationUncheckedLocked(false, displayId)) { |
| 748 | mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, displayId).sendToTarget(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 749 | } else { |
| 750 | mUpdateRotation = false; |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | if (mService.mWaitingForDrawnCallback != null || |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 755 | (mOrientationChangeComplete && !defaultDisplay.isLayoutNeeded() |
| 756 | && !mUpdateRotation)) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 757 | mService.checkDrawnWindowsLocked(); |
| 758 | } |
| 759 | |
| 760 | final int N = mService.mPendingRemove.size(); |
| 761 | if (N > 0) { |
| 762 | if (mService.mPendingRemoveTmp.length < N) { |
| 763 | mService.mPendingRemoveTmp = new WindowState[N+10]; |
| 764 | } |
| 765 | mService.mPendingRemove.toArray(mService.mPendingRemoveTmp); |
| 766 | mService.mPendingRemove.clear(); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 767 | ArrayList<DisplayContent> displayList = new ArrayList(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 768 | for (i = 0; i < N; i++) { |
| 769 | final WindowState w = mService.mPendingRemoveTmp[i]; |
| 770 | w.removeImmediately(); |
| 771 | final DisplayContent displayContent = w.getDisplayContent(); |
| 772 | if (displayContent != null && !displayList.contains(displayContent)) { |
| 773 | displayList.add(displayContent); |
| 774 | } |
| 775 | } |
| 776 | |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 777 | for (int j = displayList.size() - 1; j >= 0; --j) { |
| 778 | final DisplayContent dc = displayList.get(j); |
| 779 | dc.assignWindowLayers(true /*setLayoutNeeded*/); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 780 | } |
| 781 | } |
| 782 | |
| 783 | // Remove all deferred displays stacks, tasks, and activities. |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 784 | for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { |
| 785 | mChildren.get(displayNdx).checkCompleteDeferredRemoval(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | if (updateInputWindowsNeeded) { |
| 789 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 790 | } |
| 791 | mService.setFocusTaskRegionLocked(); |
| 792 | |
| 793 | // Check to see if we are now in a state where the screen should |
| 794 | // be enabled, because the window obscured flags have changed. |
| 795 | mService.enableScreenIfNeededLocked(); |
| 796 | |
| 797 | mService.scheduleAnimationLocked(); |
| 798 | mService.mWindowPlacerLocked.destroyPendingSurfaces(); |
| 799 | |
| 800 | if (DEBUG_WINDOW_TRACE) Slog.e(TAG, |
| 801 | "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating()); |
| 802 | } |
| 803 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 804 | private void applySurfaceChangesTransaction(boolean recoveringMemory, int defaultDw, |
| 805 | int defaultDh) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 806 | mHoldScreenWindow = null; |
Wale Ogunwale | d4a00a0 | 2016-10-10 11:29:17 -0700 | [diff] [blame] | 807 | mObscuringWindow = null; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 808 | |
| 809 | if (mService.mWatermark != null) { |
| 810 | mService.mWatermark.positionSurface(defaultDw, defaultDh); |
| 811 | } |
| 812 | if (mService.mStrictModeFlash != null) { |
| 813 | mService.mStrictModeFlash.positionSurface(defaultDw, defaultDh); |
| 814 | } |
| 815 | if (mService.mCircularDisplayMask != null) { |
| 816 | mService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh, mService.mRotation); |
| 817 | } |
| 818 | if (mService.mEmulatorDisplayOverlay != null) { |
| 819 | mService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh, |
| 820 | mService.mRotation); |
| 821 | } |
| 822 | |
| 823 | boolean focusDisplayed = false; |
| 824 | |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 825 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 826 | for (int j = 0; j < count; ++j) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 827 | final DisplayContent dc = mChildren.get(j); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 828 | focusDisplayed |= dc.applySurfaceChangesTransaction(recoveringMemory); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | if (focusDisplayed) { |
| 832 | mService.mH.sendEmptyMessage(REPORT_LOSING_FOCUS); |
| 833 | } |
| 834 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 835 | // Give the display manager a chance to adjust properties like display rotation if it needs |
| 836 | // to. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 837 | mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager(); |
| 838 | } |
| 839 | |
| 840 | /** |
| 841 | * @param w WindowState this method is applied to. |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 842 | * @param obscured True if there is a window on top of this obscuring the display. |
| 843 | * @param syswin System window? |
| 844 | * @return True when the display contains content to show the user. When false, the display |
| 845 | * manager may choose to mirror or blank the display. |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 846 | */ |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 847 | boolean handleNotObscuredLocked(WindowState w, boolean obscured, boolean syswin) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 848 | final WindowManager.LayoutParams attrs = w.mAttrs; |
| 849 | final int attrFlags = attrs.flags; |
| 850 | final boolean canBeSeen = w.isDisplayedLw(); |
| 851 | final int privateflags = attrs.privateFlags; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 852 | boolean displayHasContent = false; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 853 | |
| 854 | if (w.mHasSurface && canBeSeen) { |
| 855 | if ((attrFlags & FLAG_KEEP_SCREEN_ON) != 0) { |
| 856 | mHoldScreen = w.mSession; |
| 857 | mHoldScreenWindow = w; |
| 858 | } else if (DEBUG_KEEP_SCREEN_ON && w == mService.mLastWakeLockHoldingWindow) { |
| 859 | Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked: " + w + " was holding " |
| 860 | + "screen wakelock but no longer has FLAG_KEEP_SCREEN_ON!!! called by" |
| 861 | + Debug.getCallers(10)); |
| 862 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 863 | if (!syswin && w.mAttrs.screenBrightness >= 0 && mScreenBrightness < 0) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 864 | mScreenBrightness = w.mAttrs.screenBrightness; |
| 865 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 866 | if (!syswin && w.mAttrs.buttonBrightness >= 0 && mButtonBrightness < 0) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 867 | mButtonBrightness = w.mAttrs.buttonBrightness; |
| 868 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 869 | if (!syswin && w.mAttrs.userActivityTimeout >= 0 && mUserActivityTimeout < 0) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 870 | mUserActivityTimeout = w.mAttrs.userActivityTimeout; |
| 871 | } |
| 872 | |
| 873 | final int type = attrs.type; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 874 | // This function assumes that the contents of the default display are processed first |
| 875 | // before secondary displays. |
| 876 | final DisplayContent displayContent = w.getDisplayContent(); |
| 877 | if (displayContent != null && displayContent.isDefaultDisplay) { |
| 878 | // While a dream or keyguard is showing, obscure ordinary application content on |
| 879 | // secondary displays (by forcibly enabling mirroring unless there is other content |
| 880 | // we want to show) but still allow opaque keyguard dialogs to be shown. |
| 881 | if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
| 882 | mObscureApplicationContentOnSecondaryDisplays = true; |
| 883 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 884 | displayHasContent = true; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 885 | } else if (displayContent != null && |
| 886 | (!mObscureApplicationContentOnSecondaryDisplays |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 887 | || (obscured && type == TYPE_KEYGUARD_DIALOG))) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 888 | // Allow full screen keyguard presentation dialogs to be seen. |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 889 | displayHasContent = true; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 890 | } |
| 891 | if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) { |
| 892 | mSustainedPerformanceModeCurrent = true; |
| 893 | } |
| 894 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 895 | |
| 896 | return displayHasContent; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | boolean copyAnimToLayoutParams() { |
| 900 | boolean doRequest = false; |
| 901 | |
| 902 | final int bulkUpdateParams = mService.mAnimator.mBulkUpdateParams; |
| 903 | if ((bulkUpdateParams & SET_UPDATE_ROTATION) != 0) { |
| 904 | mUpdateRotation = true; |
| 905 | doRequest = true; |
| 906 | } |
| 907 | if ((bulkUpdateParams & SET_WALLPAPER_MAY_CHANGE) != 0) { |
| 908 | mWallpaperMayChange = true; |
| 909 | doRequest = true; |
| 910 | } |
| 911 | if ((bulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0) { |
| 912 | mWallpaperForceHidingChanged = true; |
| 913 | doRequest = true; |
| 914 | } |
| 915 | if ((bulkUpdateParams & SET_ORIENTATION_CHANGE_COMPLETE) == 0) { |
| 916 | mOrientationChangeComplete = false; |
| 917 | } else { |
| 918 | mOrientationChangeComplete = true; |
| 919 | mLastWindowFreezeSource = mService.mAnimator.mLastWindowFreezeSource; |
| 920 | if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) { |
| 921 | doRequest = true; |
| 922 | } |
| 923 | } |
| 924 | if ((bulkUpdateParams & SET_TURN_ON_SCREEN) != 0) { |
| 925 | mService.mTurnOnScreen = true; |
| 926 | } |
| 927 | if ((bulkUpdateParams & SET_WALLPAPER_ACTION_PENDING) != 0) { |
| 928 | mWallpaperActionPending = true; |
| 929 | } |
| 930 | |
| 931 | return doRequest; |
| 932 | } |
| 933 | |
| 934 | private static int toBrightnessOverride(float value) { |
| 935 | return (int)(value * PowerManager.BRIGHTNESS_ON); |
| 936 | } |
| 937 | |
| 938 | void enableSurfaceTrace(ParcelFileDescriptor pfd) { |
| 939 | final FileDescriptor fd = pfd.getFileDescriptor(); |
| 940 | if (mSurfaceTraceEnabled) { |
| 941 | disableSurfaceTrace(); |
| 942 | } |
| 943 | mSurfaceTraceEnabled = true; |
| 944 | mRemoteEventTrace = new RemoteEventTrace(mService, fd); |
| 945 | mSurfaceTraceFd = pfd; |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 946 | for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { |
| 947 | final DisplayContent dc = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 948 | dc.enableSurfaceTrace(fd); |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | void disableSurfaceTrace() { |
| 953 | mSurfaceTraceEnabled = false; |
| 954 | mRemoteEventTrace = null; |
| 955 | mSurfaceTraceFd = null; |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 956 | for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) { |
| 957 | final DisplayContent dc = mChildren.get(displayNdx); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 958 | dc.disableSurfaceTrace(); |
| 959 | } |
| 960 | } |
| 961 | |
| 962 | void dumpDisplayContents(PrintWriter pw) { |
| 963 | pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)"); |
| 964 | if (mService.mDisplayReady) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 965 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 966 | for (int i = 0; i < count; ++i) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 967 | final DisplayContent displayContent = mChildren.get(i); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 968 | displayContent.dump(" ", pw); |
| 969 | } |
| 970 | } else { |
| 971 | pw.println(" NO DISPLAY"); |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | void dumpLayoutNeededDisplayIds(PrintWriter pw) { |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 976 | if (!isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 977 | return; |
| 978 | } |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 979 | pw.print(" mLayoutNeeded on displays="); |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 980 | final int count = mChildren.size(); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 981 | for (int displayNdx = 0; displayNdx < count; ++displayNdx) { |
Wale Ogunwale | eaabfab | 2016-09-16 17:19:52 -0700 | [diff] [blame] | 982 | final DisplayContent displayContent = mChildren.get(displayNdx); |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 983 | if (displayContent.isLayoutNeeded()) { |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 984 | pw.print(displayContent.getDisplayId()); |
| 985 | } |
| 986 | } |
| 987 | pw.println(); |
| 988 | } |
| 989 | |
| 990 | void dumpWindowsNoHeader(PrintWriter pw, boolean dumpAll, ArrayList<WindowState> windows) { |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 991 | final int[] index = new int[1]; |
| 992 | forAllWindows((w) -> { |
| 993 | if (windows == null || windows.contains(w)) { |
| 994 | pw.println(" Window #" + index[0] + " " + w + ":"); |
| 995 | w.dump(pw, " ", dumpAll || windows != null); |
| 996 | index[0] = index[0] + 1; |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 997 | } |
Wale Ogunwale | d188096 | 2016-11-08 10:31:59 -0800 | [diff] [blame] | 998 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 999 | } |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1000 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 1001 | void dumpTokens(PrintWriter pw, boolean dumpAll) { |
| 1002 | pw.println(" All tokens:"); |
| 1003 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 1004 | mChildren.get(i).dumpTokens(pw, dumpAll); |
| 1005 | } |
| 1006 | } |
| 1007 | |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1008 | @Override |
| 1009 | String getName() { |
| 1010 | return "ROOT"; |
| 1011 | } |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1012 | } |