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