blob: 1700bca2e51bfeb449df6301da92ac9276b0404f [file] [log] [blame]
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001/*
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
17package com.android.server.wm;
18
19import android.app.AppOpsManager;
20import android.content.res.Configuration;
21import android.graphics.Rect;
22import android.os.Binder;
23import android.os.Debug;
24import android.os.ParcelFileDescriptor;
25import android.os.PowerManager;
26import android.os.RemoteException;
27import android.os.SystemClock;
28import android.os.UserHandle;
29import android.provider.Settings;
30import android.util.EventLog;
31import android.util.Slog;
Wale Ogunwalee05f5012016-09-16 16:27:29 -070032import android.util.SparseIntArray;
33import android.view.Display;
34import android.view.DisplayInfo;
35import android.view.InputChannel;
36import android.view.WindowManager;
37import com.android.internal.util.ArrayUtils;
38import com.android.server.EventLogTags;
39import com.android.server.input.InputWindowHandle;
40
41import java.io.FileDescriptor;
42import java.io.PrintWriter;
43import java.util.ArrayList;
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -070044import java.util.LinkedList;
Wale Ogunwalee05f5012016-09-16 16:27:29 -070045
46import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
47import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
48import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
49import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
Wale Ogunwalee05f5012016-09-16 16:27:29 -070050import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE;
51import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
52import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
53import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
54import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
55import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
56import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
57import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
58import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
59import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
60import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
61import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY;
62import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEEP_SCREEN_ON;
63import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
64import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
65import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
66import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_POWER;
67import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK;
Wale Ogunwalee05f5012016-09-16 16:27:29 -070068import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT;
69import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
70import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT;
71import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_TRACE;
72import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
73import static com.android.server.wm.WindowManagerDebugConfig.SHOW_SURFACE_ALLOC;
74import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS;
75import static com.android.server.wm.WindowManagerDebugConfig.TAG_KEEP_SCREEN_ON;
76import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
77import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
Wale Ogunwalee05f5012016-09-16 16:27:29 -070078import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS;
79import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION;
80import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
81import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES;
82import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
83import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_NONE;
84import static com.android.server.wm.WindowManagerService.H.WINDOW_FREEZE_TIMEOUT;
85import static com.android.server.wm.WindowManagerService.logSurface;
86import static com.android.server.wm.WindowSurfacePlacer.SET_FORCE_HIDING_CHANGED;
87import static com.android.server.wm.WindowSurfacePlacer.SET_ORIENTATION_CHANGE_COMPLETE;
88import static com.android.server.wm.WindowSurfacePlacer.SET_TURN_ON_SCREEN;
89import static com.android.server.wm.WindowSurfacePlacer.SET_UPDATE_ROTATION;
90import static com.android.server.wm.WindowSurfacePlacer.SET_WALLPAPER_ACTION_PENDING;
91import static com.android.server.wm.WindowSurfacePlacer.SET_WALLPAPER_MAY_CHANGE;
92
93/** Root {@link WindowContainer} for the device. */
94// TODO: Several methods in here are accessing children of this container's children through various
95// references (WindowList I am looking at you :/). See if we can delegate instead.
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -070096class RootWindowContainer extends WindowContainer<DisplayContent> {
Wale Ogunwalee05f5012016-09-16 16:27:29 -070097 private static final String TAG = TAG_WITH_CLASS_NAME ? "RootWindowContainer" : TAG_WM;
98
99 WindowManagerService mService;
100
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700101 private boolean mWallpaperForceHidingChanged = false;
102 private Object mLastWindowFreezeSource = null;
103 private Session mHoldScreen = null;
104 private float mScreenBrightness = -1;
105 private float mButtonBrightness = -1;
106 private long mUserActivityTimeout = -1;
107 private boolean mUpdateRotation = false;
108 private boolean mObscured = false;
109 boolean mSyswin = false;
110 // Set to true when the display contains content to show the user.
111 // When false, the display manager may choose to mirror or blank the display.
112 private boolean mDisplayHasContent = false;
113 private float mPreferredRefreshRate = 0;
114 private int mPreferredModeId = 0;
115 // Following variables are for debugging screen wakelock only.
116 // Last window that requires screen wakelock
117 WindowState mHoldScreenWindow = null;
118 // Last window that obscures all windows below
119 WindowState mObsuringWindow = null;
120 // Only set while traversing the default display based on its content.
121 // Affects the behavior of mirroring on secondary displays.
122 private boolean mObscureApplicationContentOnSecondaryDisplays = false;
123
124 private boolean mSustainedPerformanceModeEnabled = false;
125 private boolean mSustainedPerformanceModeCurrent = false;
126
127 boolean mWallpaperMayChange = false;
Robert Carr11c26c22016-09-23 12:40:27 -0700128 // During an orientation change, we track whether all windows have rendered
129 // at the new orientation, and this will be false from changing orientation until that occurs.
130 // For seamless rotation cases this always stays true, as the windows complete their orientation
131 // changes 1 by 1 without disturbing global state.
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700132 boolean mOrientationChangeComplete = true;
133 boolean mWallpaperActionPending = false;
134
135 private final ArrayList<Integer> mChangedStackList = new ArrayList();
136
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -0700137 private final LinkedList<AppWindowToken> mTmpUpdateAllDrawn = new LinkedList();
138
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700139 // State for the RemoteSurfaceTrace system used in testing. If this is enabled SurfaceControl
140 // instances will be replaced with an instance that writes a binary representation of all
141 // commands to mSurfaceTraceFd.
142 boolean mSurfaceTraceEnabled;
143 ParcelFileDescriptor mSurfaceTraceFd;
144 RemoteEventTrace mRemoteEventTrace;
145
146 RootWindowContainer(WindowManagerService service) {
147 mService = service;
148 }
149
150 WindowState computeFocusedWindow() {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700151 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700152 for (int i = 0; i < count; i++) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700153 final DisplayContent dc = mChildren.get(i);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700154 final WindowState win = dc.findFocusedWindow();
155 if (win != null) {
156 return win;
157 }
158 }
159 return null;
160 }
161
162 /**
163 * Retrieve the DisplayContent for the specified displayId. Will create a new DisplayContent if
164 * there is a Display for the displayId.
165 *
166 * @param displayId The display the caller is interested in.
167 * @return The DisplayContent associated with displayId or null if there is no Display for it.
168 */
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700169 DisplayContent getDisplayContentOrCreate(int displayId) {
170 DisplayContent dc = getDisplayContent(displayId);
171
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700172 if (dc == null) {
173 final Display display = mService.mDisplayManager.getDisplay(displayId);
174 if (display != null) {
175 dc = createDisplayContent(display);
176 }
177 }
178 return dc;
179 }
180
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700181 private DisplayContent getDisplayContent(int displayId) {
182 for (int i = mChildren.size() - 1; i >= 0; --i) {
183 final DisplayContent current = mChildren.get(i);
184 if (current.getDisplayId() == displayId) {
185 return current;
186 }
187 }
188 return null;
189 }
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700190
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700191 private DisplayContent createDisplayContent(final Display display) {
192 final DisplayContent dc = new DisplayContent(display, mService);
193 final int displayId = display.getDisplayId();
194
195 if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display);
196 addChild(dc, null);
197
198 final DisplayInfo displayInfo = dc.getDisplayInfo();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700199 final Rect rect = new Rect();
200 mService.mDisplaySettings.getOverscanLocked(displayInfo.name, displayInfo.uniqueId, rect);
201 displayInfo.overscanLeft = rect.left;
202 displayInfo.overscanTop = rect.top;
203 displayInfo.overscanRight = rect.right;
204 displayInfo.overscanBottom = rect.bottom;
205 if (mService.mDisplayManagerInternal != null) {
206 mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(
207 displayId, displayInfo);
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700208 mService.configureDisplayPolicyLocked(dc);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700209
210 // TODO(multi-display): Create an input channel for each display with touch capability.
211 if (displayId == Display.DEFAULT_DISPLAY) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700212 dc.mTapDetector = new TaskTapPointerEventListener(
213 mService, dc);
214 mService.registerPointerEventListener(dc.mTapDetector);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700215 mService.registerPointerEventListener(mService.mMousePositionTracker);
216 }
217 }
218
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700219 return dc;
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700220 }
221
222 /** Adds the input stack id to the input display id and returns the bounds of the added stack.*/
223 Rect addStackToDisplay(int stackId, int displayId, boolean onTop) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700224 final DisplayContent dc = getDisplayContent(displayId);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700225 if (dc == null) {
226 Slog.w(TAG_WM, "addStackToDisplay: Trying to add stackId=" + stackId
227 + " to unknown displayId=" + displayId + " callers=" + Debug.getCallers(6));
228 return null;
229 }
230
231 boolean attachedToDisplay = false;
232 TaskStack stack = mService.mStackIdToStack.get(stackId);
233 if (stack == null) {
234 if (DEBUG_STACK) Slog.d(TAG_WM, "attachStack: stackId=" + stackId);
235
236 stack = dc.getStackById(stackId);
237 if (stack != null) {
Wale Ogunwaleba51ca22016-09-23 06:06:54 -0700238 // It's already attached to the display...clear mDeferRemoval and move stack to
239 // appropriate z-order on display as needed.
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700240 stack.mDeferRemoval = false;
Wale Ogunwaleba51ca22016-09-23 06:06:54 -0700241 dc.moveStack(stack, onTop);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700242 attachedToDisplay = true;
243 } else {
244 stack = new TaskStack(mService, stackId);
245 }
246
247 mService.mStackIdToStack.put(stackId, stack);
248 if (stackId == DOCKED_STACK_ID) {
249 mService.getDefaultDisplayContentLocked().mDividerControllerLocked
250 .notifyDockedStackExistsChanged(true);
251 }
252 }
Wale Ogunwaleba51ca22016-09-23 06:06:54 -0700253
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700254 if (!attachedToDisplay) {
255 stack.attachDisplayContent(dc);
Wale Ogunwaleba51ca22016-09-23 06:06:54 -0700256 dc.attachStack(stack, onTop);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700257 }
Wale Ogunwaleba51ca22016-09-23 06:06:54 -0700258
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700259 if (stack.getRawFullscreen()) {
260 return null;
261 }
Wale Ogunwaleba51ca22016-09-23 06:06:54 -0700262 final Rect bounds = new Rect();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700263 stack.getRawBounds(bounds);
264 return bounds;
265 }
266
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700267 boolean isLayoutNeeded() {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700268 final int numDisplays = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700269 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700270 final DisplayContent displayContent = mChildren.get(displayNdx);
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700271 if (displayContent.isLayoutNeeded()) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700272 return true;
273 }
274 }
275 return false;
276 }
277
278 void getWindows(WindowList output) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700279 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700280 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700281 final DisplayContent dc = mChildren.get(i);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700282 output.addAll(dc.getWindowList());
283 }
284 }
285
286 void getWindows(WindowList output, boolean visibleOnly, boolean appsOnly) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700287 final int numDisplays = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700288 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700289 final WindowList windowList = mChildren.get(displayNdx).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700290 for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
291 final WindowState w = windowList.get(winNdx);
292 if ((!visibleOnly || w.mWinAnimator.getShown())
293 && (!appsOnly || w.mAppToken != null)) {
294 output.add(w);
295 }
296 }
297 }
298 }
299
300 void getWindowsByName(WindowList output, String name) {
301 int objectId = 0;
302 // See if this is an object ID.
303 try {
304 objectId = Integer.parseInt(name, 16);
305 name = null;
306 } catch (RuntimeException e) {
307 }
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700308 final int numDisplays = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700309 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700310 final WindowList windowList = mChildren.get(displayNdx).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700311 for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
312 final WindowState w = windowList.get(winNdx);
313 if (name != null) {
314 if (w.mAttrs.getTitle().toString().contains(name)) {
315 output.add(w);
316 }
317 } else if (System.identityHashCode(w) == objectId) {
318 output.add(w);
319 }
320 }
321 }
322 }
323
324 WindowState findWindow(int hashCode) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700325 final int numDisplays = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700326 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700327 final WindowList windows = mChildren.get(displayNdx).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700328 final int numWindows = windows.size();
329 for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
330 final WindowState w = windows.get(winNdx);
331 if (System.identityHashCode(w) == hashCode) {
332 return w;
333 }
334 }
335 }
336
337 return null;
338 }
339
340 // TODO: Users would have their own window containers under the display container?
341 void switchUser() {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700342 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700343 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700344 final DisplayContent dc = mChildren.get(i);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700345 dc.switchUser();
346 }
347 }
348
Andrii Kulian441e4492016-09-29 15:25:00 -0700349 /** Set new config and return array of ids of stacks that were changed during update. */
350 int[] setGlobalConfigurationIfNeeded(Configuration newConfiguration) {
351 final boolean configChanged = getConfiguration().diff(newConfiguration) != 0;
352 if (!configChanged) {
353 return null;
354 }
355 onConfigurationChanged(newConfiguration);
356 return updateStackBoundsAfterConfigChange();
357 }
358
359 @Override
360 void onConfigurationChanged(Configuration newParentConfig) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700361 prepareFreezingTaskBounds();
Andrii Kulian441e4492016-09-29 15:25:00 -0700362 super.onConfigurationChanged(newParentConfig);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700363
364 mService.mPolicy.onConfigurationChanged();
Andrii Kulian441e4492016-09-29 15:25:00 -0700365 }
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700366
Andrii Kulian441e4492016-09-29 15:25:00 -0700367 /**
368 * Callback used to trigger bounds update after configuration change and get ids of stacks whose
369 * bounds were updated.
370 */
371 int[] updateStackBoundsAfterConfigChange() {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700372 mChangedStackList.clear();
373
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700374 final int numDisplays = mChildren.size();
375 for (int i = 0; i < numDisplays; ++i) {
376 final DisplayContent dc = mChildren.get(i);
Andrii Kulian441e4492016-09-29 15:25:00 -0700377 dc.updateStackBoundsAfterConfigChange(mChangedStackList);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700378 }
379
380 return mChangedStackList.isEmpty() ? null : ArrayUtils.convertToIntArray(mChangedStackList);
381 }
382
383 private void prepareFreezingTaskBounds() {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700384 for (int i = mChildren.size() - 1; i >= 0; i--) {
385 mChildren.get(i).prepareFreezingTaskBounds();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700386 }
387 }
388
389 void setSecureSurfaceState(int userId, boolean disabled) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700390 for (int i = mChildren.size() - 1; i >= 0; --i) {
391 final WindowList windows = mChildren.get(i).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700392 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
393 final WindowState win = windows.get(winNdx);
394 if (win.mHasSurface && userId == UserHandle.getUserId(win.mOwnerUid)) {
395 win.mWinAnimator.setSecureLocked(disabled);
396 }
397 }
398 }
399 }
400
401 void updateAppOpsState() {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700402 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700403 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700404 final WindowList windows = mChildren.get(i).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700405 final int numWindows = windows.size();
406 for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
407 final WindowState win = windows.get(winNdx);
408 if (win.mAppOp == AppOpsManager.OP_NONE) {
409 continue;
410 }
411 final int mode = mService.mAppOps.checkOpNoThrow(win.mAppOp, win.getOwningUid(),
412 win.getOwningPackage());
413 win.setAppOpVisibilityLw(mode == AppOpsManager.MODE_ALLOWED ||
414 mode == AppOpsManager.MODE_DEFAULT);
415 }
416 }
417 }
418
419 boolean canShowStrictModeViolation(int pid) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700420 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700421 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700422 final WindowList windows = mChildren.get(i).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700423 final int numWindows = windows.size();
424 for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
425 final WindowState ws = windows.get(winNdx);
426 if (ws.mSession.mPid == pid && ws.isVisibleLw()) {
427 return true;
428 }
429 }
430 }
431 return false;
432 }
433
434 void closeSystemDialogs(String reason) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700435 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700436 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700437 final WindowList windows = mChildren.get(i).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700438 final int numWindows = windows.size();
439 for (int j = 0; j < numWindows; ++j) {
440 final WindowState w = windows.get(j);
441 if (w.mHasSurface) {
442 try {
443 w.mClient.closeSystemDialogs(reason);
444 } catch (RemoteException e) {
445 }
446 }
447 }
448 }
449 }
450
451 void removeReplacedWindows() {
452 if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION removeReplacedWindows");
453 mService.openSurfaceTransaction();
454 try {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700455 for (int i = mChildren.size() - 1; i >= 0; i--) {
456 DisplayContent dc = mChildren.get(i);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700457 final WindowList windows = dc.getWindowList();
458 for (int j = windows.size() - 1; j >= 0; j--) {
459 final WindowState win = windows.get(j);
460 final AppWindowToken aToken = win.mAppToken;
461 if (aToken != null) {
462 aToken.removeReplacedWindowIfNeeded(win);
463 }
464 }
465 }
466 } finally {
467 mService.closeSurfaceTransaction();
468 if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION removeReplacedWindows");
469 }
470 }
471
472 boolean hasPendingLayoutChanges(WindowAnimator animator) {
473 boolean hasChanges = false;
474
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700475 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700476 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700477 final DisplayContent dc = mChildren.get(i);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700478 final int pendingChanges = animator.getPendingLayoutChanges(dc.getDisplayId());
479 if ((pendingChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
480 animator.mBulkUpdateParams |= SET_WALLPAPER_ACTION_PENDING;
481 }
482 if (pendingChanges != 0) {
483 hasChanges = true;
484 }
485 }
486
487 return hasChanges;
488 }
489
490 void updateInputWindows(InputMonitor inputMonitor, WindowState inputFocus, boolean inDrag) {
491 boolean addInputConsumerHandle = mService.mInputConsumer != null;
492 boolean addWallpaperInputConsumerHandle = mService.mWallpaperInputConsumer != null;
493 final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
494 boolean disableWallpaperTouchEvents = false;
495
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700496 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700497 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700498 final DisplayContent dc = mChildren.get(i);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700499 final WindowList windows = dc.getWindowList();
500 for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
501 final WindowState child = windows.get(winNdx);
502 final InputChannel inputChannel = child.mInputChannel;
503 final InputWindowHandle inputWindowHandle = child.mInputWindowHandle;
504 if (inputChannel == null || inputWindowHandle == null || child.mRemoved
505 || child.isAdjustedForMinimizedDock()) {
506 // Skip this window because it cannot possibly receive input.
507 continue;
508 }
509 if (addInputConsumerHandle
510 && inputWindowHandle.layer <= mService.mInputConsumer.mWindowHandle.layer) {
511 inputMonitor.addInputWindowHandle(mService.mInputConsumer.mWindowHandle);
512 addInputConsumerHandle = false;
513 }
514
515 if (addWallpaperInputConsumerHandle) {
516 if (child.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER &&
517 child.isVisibleLw()) {
518 // Add the wallpaper input consumer above the first visible wallpaper.
519 inputMonitor.addInputWindowHandle(
520 mService.mWallpaperInputConsumer.mWindowHandle);
521 addWallpaperInputConsumerHandle = false;
522 }
523 }
524
525 final int flags = child.mAttrs.flags;
526 final int privateFlags = child.mAttrs.privateFlags;
527 final int type = child.mAttrs.type;
528
529 final boolean hasFocus = child == inputFocus;
530 final boolean isVisible = child.isVisibleLw();
531 if ((privateFlags
532 & WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS)
533 != 0) {
534 disableWallpaperTouchEvents = true;
535 }
536 final boolean hasWallpaper = wallpaperController.isWallpaperTarget(child)
537 && (privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD) == 0
538 && !disableWallpaperTouchEvents;
539 final boolean onDefaultDisplay = (child.getDisplayId() == Display.DEFAULT_DISPLAY);
540
541 // If there's a drag in progress and 'child' is a potential drop target,
542 // make sure it's been told about the drag
543 if (inDrag && isVisible && onDefaultDisplay) {
544 mService.mDragState.sendDragStartedIfNeededLw(child);
545 }
546
547 inputMonitor.addInputWindowHandle(
548 inputWindowHandle, child, flags, type, isVisible, hasFocus, hasWallpaper);
549 }
550 }
551
552 if (addWallpaperInputConsumerHandle) {
553 // No visible wallpaper found, add the wallpaper input consumer at the end.
554 inputMonitor.addInputWindowHandle(mService.mWallpaperInputConsumer.mWindowHandle);
555 }
556 }
557
558 boolean reclaimSomeSurfaceMemory(WindowStateAnimator winAnimator, String operation,
559 boolean secure) {
560 final WindowSurfaceController surfaceController = winAnimator.mSurfaceController;
561 boolean leakedSurface = false;
562 boolean killedApps = false;
563
564 EventLog.writeEvent(EventLogTags.WM_NO_SURFACE_MEMORY, winAnimator.mWin.toString(),
565 winAnimator.mSession.mPid, operation);
566
567 final long callingIdentity = Binder.clearCallingIdentity();
568 try {
569 // There was some problem... first, do a sanity check of the window list to make sure
570 // we haven't left any dangling surfaces around.
571
572 Slog.i(TAG_WM, "Out of memory for surface! Looking for leaks...");
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700573 final int numDisplays = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700574 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700575 final WindowList windows = mChildren.get(displayNdx).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700576 final int numWindows = windows.size();
577 for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
578 final WindowState ws = windows.get(winNdx);
579 final WindowStateAnimator wsa = ws.mWinAnimator;
580 if (wsa.mSurfaceController == null) {
581 continue;
582 }
583 if (!mService.mSessions.contains(wsa.mSession)) {
584 Slog.w(TAG_WM, "LEAKED SURFACE (session doesn't exist): "
585 + ws + " surface=" + wsa.mSurfaceController
586 + " token=" + ws.mToken
587 + " pid=" + ws.mSession.mPid
588 + " uid=" + ws.mSession.mUid);
589 wsa.destroySurface();
590 mService.mForceRemoves.add(ws);
591 leakedSurface = true;
592 } else if (ws.mAppToken != null && ws.mAppToken.clientHidden) {
593 Slog.w(TAG_WM, "LEAKED SURFACE (app token hidden): "
594 + ws + " surface=" + wsa.mSurfaceController
595 + " token=" + ws.mAppToken
596 + " saved=" + ws.hasSavedSurface());
597 if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", false);
598 wsa.destroySurface();
599 leakedSurface = true;
600 }
601 }
602 }
603
604 if (!leakedSurface) {
605 Slog.w(TAG_WM, "No leaked surfaces; killing applications!");
606 SparseIntArray pidCandidates = new SparseIntArray();
607 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700608 final WindowList windows = mChildren.get(displayNdx).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700609 final int numWindows = windows.size();
610 for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
611 final WindowState ws = windows.get(winNdx);
612 if (mService.mForceRemoves.contains(ws)) {
613 continue;
614 }
615 WindowStateAnimator wsa = ws.mWinAnimator;
616 if (wsa.mSurfaceController != null) {
617 pidCandidates.append(wsa.mSession.mPid, wsa.mSession.mPid);
618 }
619 }
620 if (pidCandidates.size() > 0) {
621 int[] pids = new int[pidCandidates.size()];
622 for (int i = 0; i < pids.length; i++) {
623 pids[i] = pidCandidates.keyAt(i);
624 }
625 try {
626 if (mService.mActivityManager.killPids(pids, "Free memory", secure)) {
627 killedApps = true;
628 }
629 } catch (RemoteException e) {
630 }
631 }
632 }
633 }
634
635 if (leakedSurface || killedApps) {
636 // We managed to reclaim some memory, so get rid of the trouble surface and ask the
637 // app to request another one.
638 Slog.w(TAG_WM,
639 "Looks like we have reclaimed some memory, clearing surface for retry.");
640 if (surfaceController != null) {
641 if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) logSurface(winAnimator.mWin,
642 "RECOVER DESTROY", false);
643 winAnimator.destroySurface();
644 mService.scheduleRemoveStartingWindowLocked(winAnimator.mWin.mAppToken);
645 }
646
647 try {
648 winAnimator.mWin.mClient.dispatchGetNewSurface();
649 } catch (RemoteException e) {
650 }
651 }
652 } finally {
653 Binder.restoreCallingIdentity(callingIdentity);
654 }
655
656 return leakedSurface || killedApps;
657 }
658
659 // "Something has changed! Let's make it correct now."
660 // TODO: Super crazy long method that should be broken down...
661 void performSurfacePlacement(boolean recoveringMemory) {
662 if (DEBUG_WINDOW_TRACE) Slog.v(TAG, "performSurfacePlacementInner: entry. Called by "
663 + Debug.getCallers(3));
664
665 int i;
666 boolean updateInputWindowsNeeded = false;
667
668 if (mService.mFocusMayChange) {
669 mService.mFocusMayChange = false;
670 updateInputWindowsNeeded = mService.updateFocusedWindowLocked(
671 UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/);
672 }
673
674 // Initialize state of exiting tokens.
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700675 final int numDisplays = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700676 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700677 final DisplayContent displayContent = mChildren.get(displayNdx);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700678 for (i = displayContent.mExitingTokens.size() - 1; i >= 0; i--) {
679 displayContent.mExitingTokens.get(i).hasVisible = false;
680 }
681 }
682
683 for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
684 // Initialize state of exiting applications.
685 final AppTokenList exitingAppTokens =
686 mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
687 for (int tokenNdx = exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
688 exitingAppTokens.get(tokenNdx).hasVisible = false;
689 }
690 }
691
692 mHoldScreen = null;
693 mScreenBrightness = -1;
694 mButtonBrightness = -1;
695 mUserActivityTimeout = -1;
696 mObscureApplicationContentOnSecondaryDisplays = false;
697 mSustainedPerformanceModeCurrent = false;
698 mService.mTransactionSequence++;
699
700 // TODO(multi-display):
701 final DisplayContent defaultDisplay = mService.getDefaultDisplayContentLocked();
702 final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo();
703 final int defaultDw = defaultInfo.logicalWidth;
704 final int defaultDh = defaultInfo.logicalHeight;
705
706 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
707 ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces");
708 mService.openSurfaceTransaction();
709 try {
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -0700710 applySurfaceChangesTransaction(recoveringMemory, defaultDw, defaultDh);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700711 } catch (RuntimeException e) {
712 Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
713 } finally {
714 mService.closeSurfaceTransaction();
715 if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
716 "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces");
717 }
718
719 final WindowList defaultWindows = defaultDisplay.getWindowList();
720 final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked;
721
722 // If we are ready to perform an app transition, check through all of the app tokens to be
723 // shown and see if they are ready to go.
724 if (mService.mAppTransition.isReady()) {
725 defaultDisplay.pendingLayoutChanges |=
726 surfacePlacer.handleAppTransitionReadyLocked(defaultWindows);
727 if (DEBUG_LAYOUT_REPEATS)
728 surfacePlacer.debugLayoutRepeats("after handleAppTransitionReadyLocked",
729 defaultDisplay.pendingLayoutChanges);
730 }
731
732 if (!mService.mAnimator.mAppWindowAnimating && mService.mAppTransition.isRunning()) {
733 // We have finished the animation of an app transition. To do this, we have delayed a
734 // lot of operations like showing and hiding apps, moving apps in Z-order, etc. The app
735 // token list reflects the correct Z-order, but the window list may now be out of sync
736 // with it. So here we will just rebuild the entire app window list. Fun!
737 defaultDisplay.pendingLayoutChanges |=
738 mService.handleAnimatingStoppedAndTransitionLocked();
739 if (DEBUG_LAYOUT_REPEATS)
740 surfacePlacer.debugLayoutRepeats("after handleAnimStopAndXitionLock",
741 defaultDisplay.pendingLayoutChanges);
742 }
743
744 if (mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0
745 && !mService.mAppTransition.isReady()) {
746 // At this point, there was a window with a wallpaper that was force hiding other
747 // windows behind it, but now it is going away. This may be simple -- just animate away
748 // the wallpaper and its window -- or it may be hard -- the wallpaper now needs to be
749 // shown behind something that was hidden.
750 defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT;
751 if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats(
752 "after animateAwayWallpaperLocked", defaultDisplay.pendingLayoutChanges);
753 }
754 mWallpaperForceHidingChanged = false;
755
756 if (mWallpaperMayChange) {
757 if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "Wallpaper may change! Adjusting");
758 defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
759 if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("WallpaperMayChange",
760 defaultDisplay.pendingLayoutChanges);
761 }
762
763 if (mService.mFocusMayChange) {
764 mService.mFocusMayChange = false;
765 if (mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,
766 false /*updateInputWindows*/)) {
767 updateInputWindowsNeeded = true;
768 defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM;
769 }
770 }
771
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700772 if (isLayoutNeeded()) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700773 defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT;
774 if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("mLayoutNeeded",
775 defaultDisplay.pendingLayoutChanges);
776 }
777
778 for (i = mService.mResizingWindows.size() - 1; i >= 0; i--) {
779 WindowState win = mService.mResizingWindows.get(i);
780 if (win.mAppFreezing) {
781 // Don't remove this window until rotation has completed.
782 continue;
783 }
784 // Discard the saved surface if window size is changed, it can't be reused.
785 if (win.mAppToken != null) {
786 win.mAppToken.destroySavedSurfaces();
787 }
788 win.reportResized();
789 mService.mResizingWindows.remove(i);
790 }
791
792 if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG,
793 "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete);
794 if (mOrientationChangeComplete) {
795 if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
796 mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE;
797 mService.mLastFinishedFreezeSource = mLastWindowFreezeSource;
798 mService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT);
799 }
800 mService.stopFreezingDisplayLocked();
801 }
802
803 // Destroy the surface of any windows that are no longer visible.
804 boolean wallpaperDestroyed = false;
805 i = mService.mDestroySurface.size();
806 if (i > 0) {
807 do {
808 i--;
809 WindowState win = mService.mDestroySurface.get(i);
810 win.mDestroying = false;
811 if (mService.mInputMethodWindow == win) {
812 mService.mInputMethodWindow = null;
813 }
814 if (mService.mWallpaperControllerLocked.isWallpaperTarget(win)) {
815 wallpaperDestroyed = true;
816 }
817 win.destroyOrSaveSurface();
818 } while (i > 0);
819 mService.mDestroySurface.clear();
820 }
821
822 // Time to remove any exiting tokens?
823 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700824 final DisplayContent displayContent = mChildren.get(displayNdx);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700825 ArrayList<WindowToken> exitingTokens = displayContent.mExitingTokens;
826 for (i = exitingTokens.size() - 1; i >= 0; i--) {
827 WindowToken token = exitingTokens.get(i);
828 if (!token.hasVisible) {
829 exitingTokens.remove(i);
830 if (token.windowType == TYPE_WALLPAPER) {
831 mService.mWallpaperControllerLocked.removeWallpaperToken(token);
832 }
833 }
834 }
835 }
836
837 // Time to remove any exiting applications?
838 for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
839 // Initialize state of exiting applications.
840 final AppTokenList exitingAppTokens =
841 mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
842 for (i = exitingAppTokens.size() - 1; i >= 0; i--) {
843 final AppWindowToken token = exitingAppTokens.get(i);
844 if (!token.hasVisible && !mService.mClosingApps.contains(token) &&
845 (!token.mIsExiting || token.isEmpty())) {
846 // Make sure there is no animation running on this token, so any windows
847 // associated with it will be removed as soon as their animations are complete
848 token.mAppAnimator.clearAnimation();
849 token.mAppAnimator.animating = false;
850 if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG,
851 "performLayout: App token exiting now removed" + token);
852 token.removeIfPossible();
853 }
854 }
855 }
856
857 if (wallpaperDestroyed) {
858 defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700859 defaultDisplay.setLayoutNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700860 }
861
862 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700863 final DisplayContent displayContent = mChildren.get(displayNdx);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700864 if (displayContent.pendingLayoutChanges != 0) {
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700865 displayContent.setLayoutNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700866 }
867 }
868
869 // Finally update all input windows now that the window changes have stabilized.
870 mService.mInputMonitor.updateInputWindowsLw(true /*force*/);
871
872 mService.setHoldScreenLocked(mHoldScreen);
873 if (!mService.mDisplayFrozen) {
874 if (mScreenBrightness < 0 || mScreenBrightness > 1.0f) {
875 mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1);
876 } else {
877 mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(
878 toBrightnessOverride(mScreenBrightness));
879 }
880 if (mButtonBrightness < 0 || mButtonBrightness > 1.0f) {
881 mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1);
882 } else {
883 mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(
884 toBrightnessOverride(mButtonBrightness));
885 }
886 mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager(
887 mUserActivityTimeout);
888 }
889
890 if (mSustainedPerformanceModeCurrent != mSustainedPerformanceModeEnabled) {
891 mSustainedPerformanceModeEnabled = mSustainedPerformanceModeCurrent;
892 mService.mPowerManagerInternal.powerHint(
893 mService.mPowerManagerInternal.POWER_HINT_SUSTAINED_PERFORMANCE_MODE,
894 (mSustainedPerformanceModeEnabled ? 1 : 0));
895 }
896
897 if (mService.mTurnOnScreen) {
898 if (mService.mAllowTheaterModeWakeFromLayout
899 || Settings.Global.getInt(mService.mContext.getContentResolver(),
900 Settings.Global.THEATER_MODE_ON, 0) == 0) {
901 if (DEBUG_VISIBILITY || DEBUG_POWER) {
902 Slog.v(TAG, "Turning screen on after layout!");
903 }
904 mService.mPowerManager.wakeUp(SystemClock.uptimeMillis(),
905 "android.server.wm:TURN_ON");
906 }
907 mService.mTurnOnScreen = false;
908 }
909
910 if (mUpdateRotation) {
911 if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation");
912 if (mService.updateRotationUncheckedLocked(false)) {
913 mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION);
914 } else {
915 mUpdateRotation = false;
916 }
917 }
918
919 if (mService.mWaitingForDrawnCallback != null ||
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700920 (mOrientationChangeComplete && !defaultDisplay.isLayoutNeeded()
921 && !mUpdateRotation)) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700922 mService.checkDrawnWindowsLocked();
923 }
924
925 final int N = mService.mPendingRemove.size();
926 if (N > 0) {
927 if (mService.mPendingRemoveTmp.length < N) {
928 mService.mPendingRemoveTmp = new WindowState[N+10];
929 }
930 mService.mPendingRemove.toArray(mService.mPendingRemoveTmp);
931 mService.mPendingRemove.clear();
932 DisplayContentList displayList = new DisplayContentList();
933 for (i = 0; i < N; i++) {
934 final WindowState w = mService.mPendingRemoveTmp[i];
935 w.removeImmediately();
936 final DisplayContent displayContent = w.getDisplayContent();
937 if (displayContent != null && !displayList.contains(displayContent)) {
938 displayList.add(displayContent);
939 }
940 }
941
942 for (DisplayContent displayContent : displayList) {
943 mService.mLayersController.assignLayersLocked(displayContent.getWindowList());
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700944 displayContent.setLayoutNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700945 }
946 }
947
948 // Remove all deferred displays stacks, tasks, and activities.
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700949 for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) {
950 mChildren.get(displayNdx).checkCompleteDeferredRemoval();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700951 }
952
953 if (updateInputWindowsNeeded) {
954 mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
955 }
956 mService.setFocusTaskRegionLocked();
957
958 // Check to see if we are now in a state where the screen should
959 // be enabled, because the window obscured flags have changed.
960 mService.enableScreenIfNeededLocked();
961
962 mService.scheduleAnimationLocked();
963 mService.mWindowPlacerLocked.destroyPendingSurfaces();
964
965 if (DEBUG_WINDOW_TRACE) Slog.e(TAG,
966 "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating());
967 }
968
969 // TODO: Super crazy long method that should be broken down...
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -0700970 private void applySurfaceChangesTransaction(boolean recoveringMemory, int defaultDw, int defaultDh) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700971 mHoldScreenWindow = null;
972 mObsuringWindow = null;
973
974 if (mService.mWatermark != null) {
975 mService.mWatermark.positionSurface(defaultDw, defaultDh);
976 }
977 if (mService.mStrictModeFlash != null) {
978 mService.mStrictModeFlash.positionSurface(defaultDw, defaultDh);
979 }
980 if (mService.mCircularDisplayMask != null) {
981 mService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh, mService.mRotation);
982 }
983 if (mService.mEmulatorDisplayOverlay != null) {
984 mService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh,
985 mService.mRotation);
986 }
987
988 boolean focusDisplayed = false;
989
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700990 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700991 for (int j = 0; j < count; ++j) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -0700992 final DisplayContent dc = mChildren.get(j);
Wale Ogunwalee05f5012016-09-16 16:27:29 -0700993 WindowList windows = dc.getWindowList();
994 DisplayInfo displayInfo = dc.getDisplayInfo();
995 final int displayId = dc.getDisplayId();
996 final int dw = displayInfo.logicalWidth;
997 final int dh = displayInfo.logicalHeight;
998 final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
999 final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked;
1000
1001 // Reset for each display.
1002 mDisplayHasContent = false;
1003 mPreferredRefreshRate = 0;
1004 mPreferredModeId = 0;
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001005 mTmpUpdateAllDrawn.clear();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001006
1007 int repeats = 0;
1008 do {
1009 repeats++;
1010 if (repeats > 6) {
1011 Slog.w(TAG, "Animation repeat aborted after too many iterations");
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -07001012 dc.clearLayoutNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001013 break;
1014 }
1015
1016 if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats(
1017 "On entry to LockedInner", dc.pendingLayoutChanges);
1018
1019 if ((dc.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0
1020 && mService.mWallpaperControllerLocked.adjustWallpaperWindows()) {
1021 mService.mLayersController.assignLayersLocked(windows);
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -07001022 dc.setLayoutNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001023 }
1024
1025 if (isDefaultDisplay
1026 && (dc.pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) {
1027 if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout");
1028 if (mService.updateOrientationFromAppTokensLocked(true)) {
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -07001029 dc.setLayoutNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001030 mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION);
1031 }
1032 }
1033
1034 if ((dc.pendingLayoutChanges & FINISH_LAYOUT_REDO_LAYOUT) != 0) {
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -07001035 dc.setLayoutNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001036 }
1037
1038 // FIRST LOOP: Perform a layout, if needed.
1039 if (repeats < LAYOUT_REPEAT_THRESHOLD) {
1040 surfacePlacer.performLayoutLockedInner(dc, repeats == 1,
1041 false /* updateInputWindows */);
1042 } else {
1043 Slog.w(TAG, "Layout repeat skipped after too many iterations");
1044 }
1045
1046 // FIRST AND ONE HALF LOOP: Make WindowManagerPolicy think
1047 // it is animating.
1048 dc.pendingLayoutChanges = 0;
1049
1050 if (isDefaultDisplay) {
1051 mService.mPolicy.beginPostLayoutPolicyLw(dw, dh);
1052 for (int i = windows.size() - 1; i >= 0; i--) {
1053 WindowState w = windows.get(i);
1054 if (w.mHasSurface) {
1055 mService.mPolicy.applyPostLayoutPolicyLw(
1056 w, w.mAttrs, w.getParentWindow());
1057 }
1058 }
1059 dc.pendingLayoutChanges |=
1060 mService.mPolicy.finishPostLayoutPolicyLw();
1061 if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats(
1062 "after finishPostLayoutPolicyLw", dc.pendingLayoutChanges);
1063 }
1064 } while (dc.pendingLayoutChanges != 0);
1065
1066 mObscured = false;
1067 mSyswin = false;
1068 dc.resetDimming();
1069
1070 // Only used if default window
1071 final boolean someoneLosingFocus = !mService.mLosingFocus.isEmpty();
1072
1073 for (int i = windows.size() - 1; i >= 0; i--) {
1074 WindowState w = windows.get(i);
1075 final Task task = w.getTask();
1076 final boolean obscuredChanged = w.mObscured != mObscured;
1077
1078 // Update effect.
1079 w.mObscured = mObscured;
1080 if (!mObscured) {
1081 handleNotObscuredLocked(w, displayInfo);
1082 }
1083
1084 w.applyDimLayerIfNeeded();
1085
1086 if (isDefaultDisplay && obscuredChanged && w.isVisibleLw()
1087 && mService.mWallpaperControllerLocked.isWallpaperTarget(w)) {
1088 // This is the wallpaper target and its obscured state changed... make sure the
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001089 // current wallpaper's visibility has been updated accordingly.
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001090 mService.mWallpaperControllerLocked.updateWallpaperVisibility();
1091 }
1092
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001093 w.handleWindowMovedIfNeeded();
1094
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001095 final WindowStateAnimator winAnimator = w.mWinAnimator;
1096
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001097 //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
1098 w.mContentChanged = false;
1099
1100 // Moved from updateWindowsAndWallpaperLocked().
1101 if (w.mHasSurface) {
1102 // Take care of the window being ready to display.
1103 final boolean committed = winAnimator.commitFinishDrawingLocked();
1104 if (isDefaultDisplay && committed) {
1105 if (w.mAttrs.type == TYPE_DREAM) {
1106 // HACK: When a dream is shown, it may at that point hide the lock
1107 // screen. So we need to redo the layout to let the phone window manager
1108 // make this happen.
1109 dc.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT;
1110 if (DEBUG_LAYOUT_REPEATS) {
1111 surfacePlacer.debugLayoutRepeats(
1112 "dream and commitFinishDrawingLocked true",
1113 dc.pendingLayoutChanges);
1114 }
1115 }
1116 if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
1117 if (DEBUG_WALLPAPER_LIGHT)
1118 Slog.v(TAG, "First draw done in potential wallpaper target " + w);
1119 mWallpaperMayChange = true;
1120 dc.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
1121 if (DEBUG_LAYOUT_REPEATS) {
1122 surfacePlacer.debugLayoutRepeats(
1123 "wallpaper and commitFinishDrawingLocked true",
1124 dc.pendingLayoutChanges);
1125 }
1126 }
1127 }
1128 if (!winAnimator.isAnimationStarting() && !winAnimator.isWaitingForOpening()) {
1129 // Updates the shown frame before we set up the surface. This is needed
1130 // because the resizing could change the top-left position (in addition to
1131 // size) of the window. setSurfaceBoundariesLocked uses mShownPosition to
1132 // position the surface.
1133 //
1134 // If an animation is being started, we can't call this method because the
1135 // animation hasn't processed its initial transformation yet, but in general
1136 // we do want to update the position if the window is animating.
1137 winAnimator.computeShownFrameLocked();
1138 }
1139 winAnimator.setSurfaceBoundariesLocked(recoveringMemory);
1140 }
1141
1142 final AppWindowToken atoken = w.mAppToken;
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001143 if (atoken != null) {
1144 final boolean updateAllDrawn = atoken.updateDrawnWindowStates(w);
1145 if (updateAllDrawn && !mTmpUpdateAllDrawn.contains(atoken)) {
1146 mTmpUpdateAllDrawn.add(atoken);
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001147 }
1148 }
1149
1150 if (isDefaultDisplay && someoneLosingFocus && w == mService.mCurrentFocus
1151 && w.isDisplayedLw()) {
1152 focusDisplayed = true;
1153 }
1154
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001155 w.updateResizingWindowIfNeeded();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001156 }
1157
1158 mService.mDisplayManagerInternal.setDisplayProperties(displayId,
1159 mDisplayHasContent,
1160 mPreferredRefreshRate,
1161 mPreferredModeId,
1162 true /* inTraversal, must call performTraversalInTrans... below */);
1163
1164 dc.stopDimmingIfNeeded();
1165
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001166 while (!mTmpUpdateAllDrawn.isEmpty()) {
1167 final AppWindowToken atoken = mTmpUpdateAllDrawn.removeLast();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001168 // See if any windows have been drawn, so they (and others associated with them)
1169 // can now be shown.
Wale Ogunwale9d9d8f12016-09-28 15:29:59 -07001170 atoken.updateAllDrawn(dc);
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001171 }
1172 }
1173
1174 if (focusDisplayed) {
1175 mService.mH.sendEmptyMessage(REPORT_LOSING_FOCUS);
1176 }
1177
1178 // Give the display manager a chance to adjust properties
1179 // like display rotation if it needs to.
1180 mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager();
1181 }
1182
1183 /**
1184 * @param w WindowState this method is applied to.
1185 * @param dispInfo info of the display that the window's obscuring state is checked against.
1186 */
1187 private void handleNotObscuredLocked(final WindowState w, final DisplayInfo dispInfo) {
1188 final WindowManager.LayoutParams attrs = w.mAttrs;
1189 final int attrFlags = attrs.flags;
1190 final boolean canBeSeen = w.isDisplayedLw();
1191 final int privateflags = attrs.privateFlags;
1192
1193 if (canBeSeen && w.isObscuringFullscreen(dispInfo)) {
1194 // This window completely covers everything behind it,
1195 // so we want to leave all of them as undimmed (for
1196 // performance reasons).
1197 if (!mObscured) {
1198 mObsuringWindow = w;
1199 }
1200
1201 mObscured = true;
1202 }
1203
1204 if (w.mHasSurface && canBeSeen) {
1205 if ((attrFlags & FLAG_KEEP_SCREEN_ON) != 0) {
1206 mHoldScreen = w.mSession;
1207 mHoldScreenWindow = w;
1208 } else if (DEBUG_KEEP_SCREEN_ON && w == mService.mLastWakeLockHoldingWindow) {
1209 Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked: " + w + " was holding "
1210 + "screen wakelock but no longer has FLAG_KEEP_SCREEN_ON!!! called by"
1211 + Debug.getCallers(10));
1212 }
1213 if (!mSyswin && w.mAttrs.screenBrightness >= 0 && mScreenBrightness < 0) {
1214 mScreenBrightness = w.mAttrs.screenBrightness;
1215 }
1216 if (!mSyswin && w.mAttrs.buttonBrightness >= 0 && mButtonBrightness < 0) {
1217 mButtonBrightness = w.mAttrs.buttonBrightness;
1218 }
1219 if (!mSyswin && w.mAttrs.userActivityTimeout >= 0 && mUserActivityTimeout < 0) {
1220 mUserActivityTimeout = w.mAttrs.userActivityTimeout;
1221 }
1222
1223 final int type = attrs.type;
1224 if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR
1225 || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
1226 mSyswin = true;
1227 }
1228
1229 // This function assumes that the contents of the default display are processed first
1230 // before secondary displays.
1231 final DisplayContent displayContent = w.getDisplayContent();
1232 if (displayContent != null && displayContent.isDefaultDisplay) {
1233 // While a dream or keyguard is showing, obscure ordinary application content on
1234 // secondary displays (by forcibly enabling mirroring unless there is other content
1235 // we want to show) but still allow opaque keyguard dialogs to be shown.
1236 if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
1237 mObscureApplicationContentOnSecondaryDisplays = true;
1238 }
1239 mDisplayHasContent = true;
1240 } else if (displayContent != null &&
1241 (!mObscureApplicationContentOnSecondaryDisplays
1242 || (mObscured && type == TYPE_KEYGUARD_DIALOG))) {
1243 // Allow full screen keyguard presentation dialogs to be seen.
1244 mDisplayHasContent = true;
1245 }
1246 if (mPreferredRefreshRate == 0 && w.mAttrs.preferredRefreshRate != 0) {
1247 mPreferredRefreshRate = w.mAttrs.preferredRefreshRate;
1248 }
1249 if (mPreferredModeId == 0 && w.mAttrs.preferredDisplayModeId != 0) {
1250 mPreferredModeId = w.mAttrs.preferredDisplayModeId;
1251 }
1252 if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) {
1253 mSustainedPerformanceModeCurrent = true;
1254 }
1255 }
1256 }
1257
1258 boolean copyAnimToLayoutParams() {
1259 boolean doRequest = false;
1260
1261 final int bulkUpdateParams = mService.mAnimator.mBulkUpdateParams;
1262 if ((bulkUpdateParams & SET_UPDATE_ROTATION) != 0) {
1263 mUpdateRotation = true;
1264 doRequest = true;
1265 }
1266 if ((bulkUpdateParams & SET_WALLPAPER_MAY_CHANGE) != 0) {
1267 mWallpaperMayChange = true;
1268 doRequest = true;
1269 }
1270 if ((bulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0) {
1271 mWallpaperForceHidingChanged = true;
1272 doRequest = true;
1273 }
1274 if ((bulkUpdateParams & SET_ORIENTATION_CHANGE_COMPLETE) == 0) {
1275 mOrientationChangeComplete = false;
1276 } else {
1277 mOrientationChangeComplete = true;
1278 mLastWindowFreezeSource = mService.mAnimator.mLastWindowFreezeSource;
1279 if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
1280 doRequest = true;
1281 }
1282 }
1283 if ((bulkUpdateParams & SET_TURN_ON_SCREEN) != 0) {
1284 mService.mTurnOnScreen = true;
1285 }
1286 if ((bulkUpdateParams & SET_WALLPAPER_ACTION_PENDING) != 0) {
1287 mWallpaperActionPending = true;
1288 }
1289
1290 return doRequest;
1291 }
1292
1293 private static int toBrightnessOverride(float value) {
1294 return (int)(value * PowerManager.BRIGHTNESS_ON);
1295 }
1296
1297 void enableSurfaceTrace(ParcelFileDescriptor pfd) {
1298 final FileDescriptor fd = pfd.getFileDescriptor();
1299 if (mSurfaceTraceEnabled) {
1300 disableSurfaceTrace();
1301 }
1302 mSurfaceTraceEnabled = true;
1303 mRemoteEventTrace = new RemoteEventTrace(mService, fd);
1304 mSurfaceTraceFd = pfd;
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001305 for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) {
1306 final DisplayContent dc = mChildren.get(displayNdx);
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001307 dc.enableSurfaceTrace(fd);
1308 }
1309 }
1310
1311 void disableSurfaceTrace() {
1312 mSurfaceTraceEnabled = false;
1313 mRemoteEventTrace = null;
1314 mSurfaceTraceFd = null;
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001315 for (int displayNdx = mChildren.size() - 1; displayNdx >= 0; --displayNdx) {
1316 final DisplayContent dc = mChildren.get(displayNdx);
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001317 dc.disableSurfaceTrace();
1318 }
1319 }
1320
1321 void dumpDisplayContents(PrintWriter pw) {
1322 pw.println("WINDOW MANAGER DISPLAY CONTENTS (dumpsys window displays)");
1323 if (mService.mDisplayReady) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001324 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001325 for (int i = 0; i < count; ++i) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001326 final DisplayContent displayContent = mChildren.get(i);
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001327 displayContent.dump(" ", pw);
1328 }
1329 } else {
1330 pw.println(" NO DISPLAY");
1331 }
1332 }
1333
1334 void dumpLayoutNeededDisplayIds(PrintWriter pw) {
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -07001335 if (!isLayoutNeeded()) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001336 return;
1337 }
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -07001338 pw.print(" mLayoutNeeded on displays=");
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001339 final int count = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001340 for (int displayNdx = 0; displayNdx < count; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001341 final DisplayContent displayContent = mChildren.get(displayNdx);
Wale Ogunwale2b06bfc2016-09-28 14:17:05 -07001342 if (displayContent.isLayoutNeeded()) {
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001343 pw.print(displayContent.getDisplayId());
1344 }
1345 }
1346 pw.println();
1347 }
1348
1349 void dumpWindowsNoHeader(PrintWriter pw, boolean dumpAll, ArrayList<WindowState> windows) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001350 final int numDisplays = mChildren.size();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001351 for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
Wale Ogunwaleeaabfab2016-09-16 17:19:52 -07001352 final WindowList windowList = mChildren.get(displayNdx).getWindowList();
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001353 for (int winNdx = windowList.size() - 1; winNdx >= 0; --winNdx) {
1354 final WindowState w = windowList.get(winNdx);
1355 if (windows == null || windows.contains(w)) {
1356 pw.println(" Window #" + winNdx + " " + w + ":");
1357 w.dump(pw, " ", dumpAll || windows != null);
1358 }
1359 }
1360 }
1361 }
Wale Ogunwaleba51ca22016-09-23 06:06:54 -07001362
1363 @Override
1364 String getName() {
1365 return "ROOT";
1366 }
Wale Ogunwalee05f5012016-09-16 16:27:29 -07001367}