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