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