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