PageRenderTime 38ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/services/core/java/com/android/server/wm/WindowSurfacePlacer.java

https://gitlab.com/amardeep434/nitro_base
Java | 1047 lines | 807 code | 123 blank | 117 comment | 259 complexity | 223ae389e451099ef9d3f2b5ca424f5a MD5 | raw file
  1. package com.android.server.wm;
  2. import static android.app.ActivityManagerInternal.APP_TRANSITION_SAVED_SURFACE;
  3. import static android.app.ActivityManagerInternal.APP_TRANSITION_STARTING_WINDOW;
  4. import static android.app.ActivityManagerInternal.APP_TRANSITION_TIMEOUT;
  5. import static android.app.ActivityManagerInternal.APP_TRANSITION_WINDOWS_DRAWN;
  6. import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
  7. import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
  8. import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
  9. import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
  10. import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE;
  11. import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
  12. import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
  13. import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
  14. import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
  15. import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
  16. import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
  17. import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
  18. import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
  19. import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
  20. import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
  21. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG;
  22. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
  23. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS;
  24. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
  25. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
  26. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
  27. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_POWER;
  28. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STARTING_WINDOW;
  29. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT;
  30. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
  31. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT;
  32. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_TRACE;
  33. import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_KEEP_SCREEN_ON;
  34. import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
  35. import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS;
  36. import static com.android.server.wm.WindowManagerDebugConfig.TAG_KEEP_SCREEN_ON;
  37. import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
  38. import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
  39. import static com.android.server.wm.WindowManagerService.H.DO_TRAVERSAL;
  40. import static com.android.server.wm.WindowManagerService.H.NOTIFY_ACTIVITY_DRAWN;
  41. import static com.android.server.wm.WindowManagerService.H.NOTIFY_APP_TRANSITION_STARTING;
  42. import static com.android.server.wm.WindowManagerService.H.NOTIFY_STARTING_WINDOW_DRAWN;
  43. import static com.android.server.wm.WindowManagerService.H.REPORT_LOSING_FOCUS;
  44. import static com.android.server.wm.WindowManagerService.H.REPORT_WINDOWS_CHANGE;
  45. import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION;
  46. import static com.android.server.wm.WindowManagerService.H.UPDATE_DOCKED_STACK_DIVIDER;
  47. import static com.android.server.wm.WindowManagerService.H.WINDOW_FREEZE_TIMEOUT;
  48. import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
  49. import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION;
  50. import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES;
  51. import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES;
  52. import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_NONE;
  53. import android.graphics.Bitmap;
  54. import android.graphics.Canvas;
  55. import android.graphics.PixelFormat;
  56. import android.graphics.Rect;
  57. import android.os.Debug;
  58. import android.os.PowerManager;
  59. import android.os.RemoteException;
  60. import android.os.SystemClock;
  61. import android.os.Trace;
  62. import android.provider.Settings;
  63. import android.util.ArraySet;
  64. import android.util.Slog;
  65. import android.view.Display;
  66. import android.view.DisplayInfo;
  67. import android.view.Surface;
  68. import android.view.SurfaceControl;
  69. import android.view.View;
  70. import android.view.WindowManager.LayoutParams;
  71. import android.view.animation.Animation;
  72. import com.android.server.wm.WindowManagerService.H;
  73. import java.io.PrintWriter;
  74. import java.util.ArrayList;
  75. /**
  76. * Positions windows and their surfaces.
  77. *
  78. * It sets positions of windows by calculating their frames and then applies this by positioning
  79. * surfaces according to these frames. Z layer is still assigned withing WindowManagerService.
  80. */
  81. class WindowSurfacePlacer {
  82. private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowSurfacePlacer" : TAG_WM;
  83. private final WindowManagerService mService;
  84. private final WallpaperController mWallpaperControllerLocked;
  85. private boolean mInLayout = false;
  86. /** Only do a maximum of 6 repeated layouts. After that quit */
  87. private int mLayoutRepeatCount;
  88. static final int SET_UPDATE_ROTATION = 1 << 0;
  89. static final int SET_WALLPAPER_MAY_CHANGE = 1 << 1;
  90. static final int SET_FORCE_HIDING_CHANGED = 1 << 2;
  91. static final int SET_ORIENTATION_CHANGE_COMPLETE = 1 << 3;
  92. static final int SET_TURN_ON_SCREEN = 1 << 4;
  93. static final int SET_WALLPAPER_ACTION_PENDING = 1 << 5;
  94. boolean mWallpaperMayChange = false;
  95. boolean mOrientationChangeComplete = true;
  96. boolean mWallpaperActionPending = false;
  97. private boolean mWallpaperForceHidingChanged = false;
  98. private Object mLastWindowFreezeSource = null;
  99. private Session mHoldScreen = null;
  100. private boolean mObscured = false;
  101. private boolean mSyswin = false;
  102. private float mScreenBrightness = -1;
  103. private float mButtonBrightness = -1;
  104. private long mUserActivityTimeout = -1;
  105. private boolean mUpdateRotation = false;
  106. private final Rect mTmpStartRect = new Rect();
  107. private final Rect mTmpContentRect = new Rect();
  108. // Set to true when the display contains content to show the user.
  109. // When false, the display manager may choose to mirror or blank the display.
  110. private boolean mDisplayHasContent = false;
  111. // Only set while traversing the default display based on its content.
  112. // Affects the behavior of mirroring on secondary displays.
  113. private boolean mObscureApplicationContentOnSecondaryDisplays = false;
  114. private float mPreferredRefreshRate = 0;
  115. private int mPreferredModeId = 0;
  116. private boolean mTraversalScheduled;
  117. private int mDeferDepth = 0;
  118. private boolean mSustainedPerformanceModeEnabled = false;
  119. private boolean mSustainedPerformanceModeCurrent = false;
  120. // Following variables are for debugging screen wakelock only.
  121. // Last window that requires screen wakelock
  122. WindowState mHoldScreenWindow = null;
  123. // Last window that obscures all windows below
  124. WindowState mObsuringWindow = null;
  125. private static final class LayerAndToken {
  126. public int layer;
  127. public AppWindowToken token;
  128. }
  129. private final LayerAndToken mTmpLayerAndToken = new LayerAndToken();
  130. private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>();
  131. public WindowSurfacePlacer(WindowManagerService service) {
  132. mService = service;
  133. mWallpaperControllerLocked = mService.mWallpaperControllerLocked;
  134. }
  135. /**
  136. * See {@link WindowManagerService#deferSurfaceLayout()}
  137. */
  138. void deferLayout() {
  139. mDeferDepth++;
  140. }
  141. /**
  142. * See {@link WindowManagerService#continueSurfaceLayout()}
  143. */
  144. void continueLayout() {
  145. mDeferDepth--;
  146. if (mDeferDepth <= 0) {
  147. performSurfacePlacement();
  148. }
  149. }
  150. final void performSurfacePlacement() {
  151. if (mDeferDepth > 0) {
  152. return;
  153. }
  154. int loopCount = 6;
  155. do {
  156. mTraversalScheduled = false;
  157. performSurfacePlacementLoop();
  158. mService.mH.removeMessages(DO_TRAVERSAL);
  159. loopCount--;
  160. } while (mTraversalScheduled && loopCount > 0);
  161. mWallpaperActionPending = false;
  162. }
  163. private void performSurfacePlacementLoop() {
  164. if (mInLayout) {
  165. if (DEBUG) {
  166. throw new RuntimeException("Recursive call!");
  167. }
  168. Slog.w(TAG, "performLayoutAndPlaceSurfacesLocked called while in layout. Callers="
  169. + Debug.getCallers(3));
  170. return;
  171. }
  172. if (mService.mWaitingForConfig) {
  173. // Our configuration has changed (most likely rotation), but we
  174. // don't yet have the complete configuration to report to
  175. // applications. Don't do any window layout until we have it.
  176. return;
  177. }
  178. if (!mService.mDisplayReady) {
  179. // Not yet initialized, nothing to do.
  180. return;
  181. }
  182. Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmLayout");
  183. mInLayout = true;
  184. boolean recoveringMemory = false;
  185. if (!mService.mForceRemoves.isEmpty()) {
  186. recoveringMemory = true;
  187. // Wait a little bit for things to settle down, and off we go.
  188. while (!mService.mForceRemoves.isEmpty()) {
  189. WindowState ws = mService.mForceRemoves.remove(0);
  190. Slog.i(TAG, "Force removing: " + ws);
  191. mService.removeWindowInnerLocked(ws);
  192. }
  193. Slog.w(TAG, "Due to memory failure, waiting a bit for next layout");
  194. Object tmp = new Object();
  195. synchronized (tmp) {
  196. try {
  197. tmp.wait(250);
  198. } catch (InterruptedException e) {
  199. }
  200. }
  201. }
  202. try {
  203. performSurfacePlacementInner(recoveringMemory);
  204. mInLayout = false;
  205. if (mService.needsLayout()) {
  206. if (++mLayoutRepeatCount < 6) {
  207. requestTraversal();
  208. } else {
  209. Slog.e(TAG, "Performed 6 layouts in a row. Skipping");
  210. mLayoutRepeatCount = 0;
  211. }
  212. } else {
  213. mLayoutRepeatCount = 0;
  214. }
  215. if (mService.mWindowsChanged && !mService.mWindowChangeListeners.isEmpty()) {
  216. mService.mH.removeMessages(REPORT_WINDOWS_CHANGE);
  217. mService.mH.sendEmptyMessage(REPORT_WINDOWS_CHANGE);
  218. }
  219. } catch (RuntimeException e) {
  220. mInLayout = false;
  221. Slog.wtf(TAG, "Unhandled exception while laying out windows", e);
  222. }
  223. Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
  224. }
  225. void debugLayoutRepeats(final String msg, int pendingLayoutChanges) {
  226. if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) {
  227. Slog.v(TAG, "Layouts looping: " + msg +
  228. ", mPendingLayoutChanges = 0x" + Integer.toHexString(pendingLayoutChanges));
  229. }
  230. }
  231. // "Something has changed! Let's make it correct now."
  232. private void performSurfacePlacementInner(boolean recoveringMemory) {
  233. if (DEBUG_WINDOW_TRACE) Slog.v(TAG, "performSurfacePlacementInner: entry. Called by "
  234. + Debug.getCallers(3));
  235. int i;
  236. boolean updateInputWindowsNeeded = false;
  237. if (mService.mFocusMayChange) {
  238. mService.mFocusMayChange = false;
  239. updateInputWindowsNeeded = mService.updateFocusedWindowLocked(
  240. UPDATE_FOCUS_WILL_PLACE_SURFACES, false /*updateInputWindows*/);
  241. }
  242. // Initialize state of exiting tokens.
  243. final int numDisplays = mService.mDisplayContents.size();
  244. for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
  245. final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
  246. for (i=displayContent.mExitingTokens.size()-1; i>=0; i--) {
  247. displayContent.mExitingTokens.get(i).hasVisible = false;
  248. }
  249. }
  250. for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
  251. // Initialize state of exiting applications.
  252. final AppTokenList exitingAppTokens =
  253. mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
  254. for (int tokenNdx = exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
  255. exitingAppTokens.get(tokenNdx).hasVisible = false;
  256. }
  257. }
  258. mHoldScreen = null;
  259. mHoldScreenWindow = null;
  260. mObsuringWindow = null;
  261. mScreenBrightness = -1;
  262. mButtonBrightness = -1;
  263. mUserActivityTimeout = -1;
  264. mObscureApplicationContentOnSecondaryDisplays = false;
  265. mSustainedPerformanceModeCurrent = false;
  266. mService.mTransactionSequence++;
  267. final DisplayContent defaultDisplay = mService.getDefaultDisplayContentLocked();
  268. final DisplayInfo defaultInfo = defaultDisplay.getDisplayInfo();
  269. final int defaultDw = defaultInfo.logicalWidth;
  270. final int defaultDh = defaultInfo.logicalHeight;
  271. if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
  272. ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces");
  273. SurfaceControl.openTransaction();
  274. try {
  275. applySurfaceChangesTransaction(recoveringMemory, numDisplays, defaultDw, defaultDh);
  276. } catch (RuntimeException e) {
  277. Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
  278. } finally {
  279. SurfaceControl.closeTransaction();
  280. if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
  281. "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces");
  282. }
  283. final WindowList defaultWindows = defaultDisplay.getWindowList();
  284. // If we are ready to perform an app transition, check through
  285. // all of the app tokens to be shown and see if they are ready
  286. // to go.
  287. if (mService.mAppTransition.isReady()) {
  288. defaultDisplay.pendingLayoutChanges |= handleAppTransitionReadyLocked(defaultWindows);
  289. if (DEBUG_LAYOUT_REPEATS)
  290. debugLayoutRepeats("after handleAppTransitionReadyLocked",
  291. defaultDisplay.pendingLayoutChanges);
  292. }
  293. if (!mService.mAnimator.mAppWindowAnimating && mService.mAppTransition.isRunning()) {
  294. // We have finished the animation of an app transition. To do
  295. // this, we have delayed a lot of operations like showing and
  296. // hiding apps, moving apps in Z-order, etc. The app token list
  297. // reflects the correct Z-order, but the window list may now
  298. // be out of sync with it. So here we will just rebuild the
  299. // entire app window list. Fun!
  300. defaultDisplay.pendingLayoutChanges |=
  301. mService.handleAnimatingStoppedAndTransitionLocked();
  302. if (DEBUG_LAYOUT_REPEATS)
  303. debugLayoutRepeats("after handleAnimStopAndXitionLock",
  304. defaultDisplay.pendingLayoutChanges);
  305. }
  306. if (mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0
  307. && !mService.mAppTransition.isReady()) {
  308. // At this point, there was a window with a wallpaper that
  309. // was force hiding other windows behind it, but now it
  310. // is going away. This may be simple -- just animate
  311. // away the wallpaper and its window -- or it may be
  312. // hard -- the wallpaper now needs to be shown behind
  313. // something that was hidden.
  314. defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT;
  315. if (DEBUG_LAYOUT_REPEATS)
  316. debugLayoutRepeats("after animateAwayWallpaperLocked",
  317. defaultDisplay.pendingLayoutChanges);
  318. }
  319. mWallpaperForceHidingChanged = false;
  320. if (mWallpaperMayChange) {
  321. if (DEBUG_WALLPAPER_LIGHT)
  322. Slog.v(TAG, "Wallpaper may change! Adjusting");
  323. defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
  324. if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("WallpaperMayChange",
  325. defaultDisplay.pendingLayoutChanges);
  326. }
  327. if (mService.mFocusMayChange) {
  328. mService.mFocusMayChange = false;
  329. if (mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,
  330. false /*updateInputWindows*/)) {
  331. updateInputWindowsNeeded = true;
  332. defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM;
  333. }
  334. }
  335. if (mService.needsLayout()) {
  336. defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT;
  337. if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("mLayoutNeeded",
  338. defaultDisplay.pendingLayoutChanges);
  339. }
  340. for (i = mService.mResizingWindows.size() - 1; i >= 0; i--) {
  341. WindowState win = mService.mResizingWindows.get(i);
  342. if (win.mAppFreezing) {
  343. // Don't remove this window until rotation has completed.
  344. continue;
  345. }
  346. // Discard the saved surface if window size is changed, it can't be reused.
  347. if (win.mAppToken != null) {
  348. win.mAppToken.destroySavedSurfaces();
  349. }
  350. win.reportResized();
  351. mService.mResizingWindows.remove(i);
  352. }
  353. if (DEBUG_ORIENTATION && mService.mDisplayFrozen) Slog.v(TAG,
  354. "With display frozen, orientationChangeComplete=" + mOrientationChangeComplete);
  355. if (mOrientationChangeComplete) {
  356. if (mService.mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
  357. mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_NONE;
  358. mService.mLastFinishedFreezeSource = mLastWindowFreezeSource;
  359. mService.mH.removeMessages(WINDOW_FREEZE_TIMEOUT);
  360. }
  361. mService.stopFreezingDisplayLocked();
  362. }
  363. // Destroy the surface of any windows that are no longer visible.
  364. boolean wallpaperDestroyed = false;
  365. i = mService.mDestroySurface.size();
  366. if (i > 0) {
  367. do {
  368. i--;
  369. WindowState win = mService.mDestroySurface.get(i);
  370. win.mDestroying = false;
  371. if (mService.mInputMethodWindow == win) {
  372. mService.mInputMethodWindow = null;
  373. }
  374. if (mWallpaperControllerLocked.isWallpaperTarget(win)) {
  375. wallpaperDestroyed = true;
  376. }
  377. win.destroyOrSaveSurface();
  378. } while (i > 0);
  379. mService.mDestroySurface.clear();
  380. }
  381. // Time to remove any exiting tokens?
  382. for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
  383. final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
  384. ArrayList<WindowToken> exitingTokens = displayContent.mExitingTokens;
  385. for (i = exitingTokens.size() - 1; i >= 0; i--) {
  386. WindowToken token = exitingTokens.get(i);
  387. if (!token.hasVisible) {
  388. exitingTokens.remove(i);
  389. if (token.windowType == TYPE_WALLPAPER) {
  390. mWallpaperControllerLocked.removeWallpaperToken(token);
  391. }
  392. }
  393. }
  394. }
  395. // Time to remove any exiting applications?
  396. for (int stackNdx = mService.mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
  397. // Initialize state of exiting applications.
  398. final AppTokenList exitingAppTokens =
  399. mService.mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
  400. for (i = exitingAppTokens.size() - 1; i >= 0; i--) {
  401. AppWindowToken token = exitingAppTokens.get(i);
  402. if (!token.hasVisible && !mService.mClosingApps.contains(token) &&
  403. (!token.mIsExiting || token.allAppWindows.isEmpty())) {
  404. // Make sure there is no animation running on this token,
  405. // so any windows associated with it will be removed as
  406. // soon as their animations are complete
  407. token.mAppAnimator.clearAnimation();
  408. token.mAppAnimator.animating = false;
  409. if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG,
  410. "performLayout: App token exiting now removed" + token);
  411. token.removeAppFromTaskLocked();
  412. }
  413. }
  414. }
  415. if (wallpaperDestroyed) {
  416. defaultDisplay.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
  417. defaultDisplay.layoutNeeded = true;
  418. }
  419. for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
  420. final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
  421. if (displayContent.pendingLayoutChanges != 0) {
  422. displayContent.layoutNeeded = true;
  423. }
  424. }
  425. // Finally update all input windows now that the window changes have stabilized.
  426. mService.mInputMonitor.updateInputWindowsLw(true /*force*/);
  427. mService.setHoldScreenLocked(mHoldScreen);
  428. if (!mService.mDisplayFrozen) {
  429. if (mScreenBrightness < 0 || mScreenBrightness > 1.0f) {
  430. mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1);
  431. } else {
  432. mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(
  433. toBrightnessOverride(mScreenBrightness));
  434. }
  435. if (mButtonBrightness < 0
  436. || mButtonBrightness > 1.0f) {
  437. mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1);
  438. } else {
  439. mService.mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(
  440. toBrightnessOverride(mButtonBrightness));
  441. }
  442. mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager(
  443. mUserActivityTimeout);
  444. }
  445. if (mSustainedPerformanceModeCurrent != mSustainedPerformanceModeEnabled) {
  446. mSustainedPerformanceModeEnabled = mSustainedPerformanceModeCurrent;
  447. mService.mPowerManagerInternal.powerHint(
  448. mService.mPowerManagerInternal.POWER_HINT_SUSTAINED_PERFORMANCE_MODE,
  449. (mSustainedPerformanceModeEnabled ? 1 : 0));
  450. }
  451. if (mService.mTurnOnScreen) {
  452. if (mService.mAllowTheaterModeWakeFromLayout
  453. || Settings.Global.getInt(mService.mContext.getContentResolver(),
  454. Settings.Global.THEATER_MODE_ON, 0) == 0) {
  455. if (DEBUG_VISIBILITY || DEBUG_POWER) {
  456. Slog.v(TAG, "Turning screen on after layout!");
  457. }
  458. mService.mPowerManager.wakeUp(SystemClock.uptimeMillis(),
  459. "android.server.wm:TURN_ON");
  460. }
  461. mService.mTurnOnScreen = false;
  462. }
  463. if (mUpdateRotation) {
  464. if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation");
  465. if (mService.updateRotationUncheckedLocked(false)) {
  466. mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION);
  467. } else {
  468. mUpdateRotation = false;
  469. }
  470. }
  471. if (mService.mWaitingForDrawnCallback != null ||
  472. (mOrientationChangeComplete && !defaultDisplay.layoutNeeded &&
  473. !mUpdateRotation)) {
  474. mService.checkDrawnWindowsLocked();
  475. }
  476. final int N = mService.mPendingRemove.size();
  477. if (N > 0) {
  478. if (mService.mPendingRemoveTmp.length < N) {
  479. mService.mPendingRemoveTmp = new WindowState[N+10];
  480. }
  481. mService.mPendingRemove.toArray(mService.mPendingRemoveTmp);
  482. mService.mPendingRemove.clear();
  483. DisplayContentList displayList = new DisplayContentList();
  484. for (i = 0; i < N; i++) {
  485. WindowState w = mService.mPendingRemoveTmp[i];
  486. mService.removeWindowInnerLocked(w);
  487. final DisplayContent displayContent = w.getDisplayContent();
  488. if (displayContent != null && !displayList.contains(displayContent)) {
  489. displayList.add(displayContent);
  490. }
  491. }
  492. for (DisplayContent displayContent : displayList) {
  493. mService.mLayersController.assignLayersLocked(displayContent.getWindowList());
  494. displayContent.layoutNeeded = true;
  495. }
  496. }
  497. // Remove all deferred displays stacks, tasks, and activities.
  498. for (int displayNdx = mService.mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
  499. mService.mDisplayContents.valueAt(displayNdx).checkForDeferredActions();
  500. }
  501. if (updateInputWindowsNeeded) {
  502. mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
  503. }
  504. mService.setFocusTaskRegionLocked();
  505. // Check to see if we are now in a state where the screen should
  506. // be enabled, because the window obscured flags have changed.
  507. mService.enableScreenIfNeededLocked();
  508. mService.scheduleAnimationLocked();
  509. mService.mWindowPlacerLocked.destroyPendingSurfaces();
  510. if (DEBUG_WINDOW_TRACE) Slog.e(TAG,
  511. "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating());
  512. }
  513. private void applySurfaceChangesTransaction(boolean recoveringMemory, int numDisplays,
  514. int defaultDw, int defaultDh) {
  515. if (mService.mWatermark != null) {
  516. mService.mWatermark.positionSurface(defaultDw, defaultDh);
  517. }
  518. if (mService.mStrictModeFlash != null) {
  519. mService.mStrictModeFlash.positionSurface(defaultDw, defaultDh);
  520. }
  521. if (mService.mCircularDisplayMask != null) {
  522. mService.mCircularDisplayMask.positionSurface(defaultDw, defaultDh,
  523. mService.mRotation);
  524. }
  525. if (mService.mEmulatorDisplayOverlay != null) {
  526. mService.mEmulatorDisplayOverlay.positionSurface(defaultDw, defaultDh,
  527. mService.mRotation);
  528. }
  529. boolean focusDisplayed = false;
  530. for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
  531. final DisplayContent displayContent = mService.mDisplayContents.valueAt(displayNdx);
  532. boolean updateAllDrawn = false;
  533. WindowList windows = displayContent.getWindowList();
  534. DisplayInfo displayInfo = displayContent.getDisplayInfo();
  535. final int displayId = displayContent.getDisplayId();
  536. final int dw = displayInfo.logicalWidth;
  537. final int dh = displayInfo.logicalHeight;
  538. final int innerDw = displayInfo.appWidth;
  539. final int innerDh = displayInfo.appHeight;
  540. final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
  541. // Reset for each display.
  542. mDisplayHasContent = false;
  543. mPreferredRefreshRate = 0;
  544. mPreferredModeId = 0;
  545. int repeats = 0;
  546. do {
  547. repeats++;
  548. if (repeats > 6) {
  549. Slog.w(TAG, "Animation repeat aborted after too many iterations");
  550. displayContent.layoutNeeded = false;
  551. break;
  552. }
  553. if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats(
  554. "On entry to LockedInner", displayContent.pendingLayoutChanges);
  555. if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 &&
  556. mWallpaperControllerLocked.adjustWallpaperWindows()) {
  557. mService.mLayersController.assignLayersLocked(windows);
  558. displayContent.layoutNeeded = true;
  559. }
  560. if (isDefaultDisplay
  561. && (displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) {
  562. if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout");
  563. if (mService.updateOrientationFromAppTokensLocked(true)) {
  564. displayContent.layoutNeeded = true;
  565. mService.mH.sendEmptyMessage(SEND_NEW_CONFIGURATION);
  566. }
  567. }
  568. if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_LAYOUT) != 0) {
  569. displayContent.layoutNeeded = true;
  570. }
  571. // FIRST LOOP: Perform a layout, if needed.
  572. if (repeats < LAYOUT_REPEAT_THRESHOLD) {
  573. performLayoutLockedInner(displayContent, repeats == 1,
  574. false /* updateInputWindows */);
  575. } else {
  576. Slog.w(TAG, "Layout repeat skipped after too many iterations");
  577. }
  578. // FIRST AND ONE HALF LOOP: Make WindowManagerPolicy think
  579. // it is animating.
  580. displayContent.pendingLayoutChanges = 0;
  581. if (isDefaultDisplay) {
  582. mService.mPolicy.beginPostLayoutPolicyLw(dw, dh);
  583. for (int i = windows.size() - 1; i >= 0; i--) {
  584. WindowState w = windows.get(i);
  585. if (w.mHasSurface) {
  586. mService.mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs,
  587. w.mAttachedWindow);
  588. }
  589. }
  590. displayContent.pendingLayoutChanges |=
  591. mService.mPolicy.finishPostLayoutPolicyLw();
  592. if (DEBUG_LAYOUT_REPEATS) debugLayoutRepeats("after finishPostLayoutPolicyLw",
  593. displayContent.pendingLayoutChanges);
  594. }
  595. } while (displayContent.pendingLayoutChanges != 0);
  596. mObscured = false;
  597. mSyswin = false;
  598. displayContent.resetDimming();
  599. // Only used if default window
  600. final boolean someoneLosingFocus = !mService.mLosingFocus.isEmpty();
  601. for (int i = windows.size() - 1; i >= 0; i--) {
  602. WindowState w = windows.get(i);
  603. final Task task = w.getTask();
  604. final boolean obscuredChanged = w.mObscured != mObscured;
  605. // Update effect.
  606. w.mObscured = mObscured;
  607. if (!mObscured) {
  608. handleNotObscuredLocked(w, displayInfo);
  609. }
  610. w.applyDimLayerIfNeeded();
  611. if (isDefaultDisplay && obscuredChanged
  612. && mWallpaperControllerLocked.isWallpaperTarget(w) && w.isVisibleLw()) {
  613. // This is the wallpaper target and its obscured state
  614. // changed... make sure the current wallaper's visibility
  615. // has been updated accordingly.
  616. mWallpaperControllerLocked.updateWallpaperVisibility();
  617. }
  618. final WindowStateAnimator winAnimator = w.mWinAnimator;
  619. // If the window has moved due to its containing content frame changing, then
  620. // notify the listeners and optionally animate it. Simply checking a change of
  621. // position is not enough, because being move due to dock divider is not a trigger
  622. // for animation.
  623. if (w.hasMoved()) {
  624. // Frame has moved, containing content frame has also moved, and we're not
  625. // currently animating... let's do something.
  626. final int left = w.mFrame.left;
  627. final int top = w.mFrame.top;
  628. final boolean adjustedForMinimizedDockOrIme = task != null
  629. && (task.mStack.isAdjustedForMinimizedDockedStack()
  630. || task.mStack.isAdjustedForIme());
  631. if ((w.mAttrs.privateFlags & PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0
  632. && !w.isDragResizing() && !adjustedForMinimizedDockOrIme
  633. && (task == null || w.getTask().mStack.hasMovementAnimations())
  634. && !w.mWinAnimator.mLastHidden) {
  635. winAnimator.setMoveAnimation(left, top);
  636. }
  637. //TODO (multidisplay): Accessibility supported only for the default display.
  638. if (mService.mAccessibilityController != null
  639. && displayId == Display.DEFAULT_DISPLAY) {
  640. mService.mAccessibilityController.onSomeWindowResizedOrMovedLocked();
  641. }
  642. try {
  643. w.mClient.moved(left, top);
  644. } catch (RemoteException e) {
  645. }
  646. w.mMovedByResize = false;
  647. }
  648. //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing");
  649. w.mContentChanged = false;
  650. // Moved from updateWindowsAndWallpaperLocked().
  651. if (w.mHasSurface) {
  652. // If we have recently synchronized a previous transaction for this
  653. // window ensure we don't push through an unsynchronized one now.
  654. winAnimator.deferToPendingTransaction();
  655. // Take care of the window being ready to display.
  656. final boolean committed = winAnimator.commitFinishDrawingLocked();
  657. if (isDefaultDisplay && committed) {
  658. if (w.mAttrs.type == TYPE_DREAM) {
  659. // HACK: When a dream is shown, it may at that
  660. // point hide the lock screen. So we need to
  661. // redo the layout to let the phone window manager
  662. // make this happen.
  663. displayContent.pendingLayoutChanges |=
  664. FINISH_LAYOUT_REDO_LAYOUT;
  665. if (DEBUG_LAYOUT_REPEATS) {
  666. debugLayoutRepeats("dream and commitFinishDrawingLocked true",
  667. displayContent.pendingLayoutChanges);
  668. }
  669. }
  670. if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
  671. if (DEBUG_WALLPAPER_LIGHT)
  672. Slog.v(TAG, "First draw done in potential wallpaper target " + w);
  673. mWallpaperMayChange = true;
  674. displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
  675. if (DEBUG_LAYOUT_REPEATS) {
  676. debugLayoutRepeats("wallpaper and commitFinishDrawingLocked true",
  677. displayContent.pendingLayoutChanges);
  678. }
  679. }
  680. }
  681. if (!winAnimator.isAnimationStarting() && !winAnimator.isWaitingForOpening()) {
  682. // Updates the shown frame before we set up the surface. This is needed
  683. // because the resizing could change the top-left position (in addition to
  684. // size) of the window. setSurfaceBoundariesLocked uses mShownPosition to
  685. // position the surface.
  686. //
  687. // If an animation is being started, we can't call this method because the
  688. // animation hasn't processed its initial transformation yet, but in general
  689. // we do want to update the position if the window is animating.
  690. winAnimator.computeShownFrameLocked();
  691. }
  692. winAnimator.setSurfaceBoundariesLocked(recoveringMemory);
  693. }
  694. final AppWindowToken atoken = w.mAppToken;
  695. if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) {
  696. Slog.d(TAG, "updateWindows: starting " + w
  697. + " isOnScreen=" + w.isOnScreen() + " allDrawn=" + atoken.allDrawn
  698. + " freezingScreen=" + atoken.mAppAnimator.freezingScreen);
  699. }
  700. if (atoken != null && (!atoken.allDrawn || !atoken.allDrawnExcludingSaved
  701. || atoken.mAppAnimator.freezingScreen)) {
  702. if (atoken.lastTransactionSequence != mService.mTransactionSequence) {
  703. atoken.lastTransactionSequence = mService.mTransactionSequence;
  704. atoken.numInterestingWindows = atoken.numDrawnWindows = 0;
  705. atoken.numInterestingWindowsExcludingSaved = 0;
  706. atoken.numDrawnWindowsExclusingSaved = 0;
  707. atoken.startingDisplayed = false;
  708. }
  709. if (!atoken.allDrawn && w.mightAffectAllDrawn(false /* visibleOnly */)) {
  710. if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
  711. Slog.v(TAG, "Eval win " + w + ": isDrawn="
  712. + w.isDrawnLw()
  713. + ", isAnimationSet=" + winAnimator.isAnimationSet());
  714. if (!w.isDrawnLw()) {
  715. Slog.v(TAG, "Not displayed: s="
  716. + winAnimator.mSurfaceController
  717. + " pv=" + w.mPolicyVisibility
  718. + " mDrawState=" + winAnimator.drawStateToString()
  719. + " ah=" + w.mAttachedHidden
  720. + " th=" + atoken.hiddenRequested
  721. + " a=" + winAnimator.mAnimating);
  722. }
  723. }
  724. if (w != atoken.startingWindow) {
  725. if (w.isInteresting()) {
  726. atoken.numInterestingWindows++;
  727. if (w.isDrawnLw()) {
  728. atoken.numDrawnWindows++;
  729. if (DEBUG_VISIBILITY || DEBUG_ORIENTATION)
  730. Slog.v(TAG, "tokenMayBeDrawn: " + atoken
  731. + " w=" + w + " numInteresting="
  732. + atoken.numInterestingWindows
  733. + " freezingScreen="
  734. + atoken.mAppAnimator.freezingScreen
  735. + " mAppFreezing=" + w.mAppFreezing);
  736. updateAllDrawn = true;
  737. }
  738. }
  739. } else if (w.isDrawnLw()) {
  740. mService.mH.sendEmptyMessage(NOTIFY_STARTING_WINDOW_DRAWN);
  741. atoken.startingDisplayed = true;
  742. }
  743. }
  744. if (!atoken.allDrawnExcludingSaved
  745. && w.mightAffectAllDrawn(true /* visibleOnly */)) {
  746. if (w != atoken.startingWindow && w.isInteresting()) {
  747. atoken.numInterestingWindowsExcludingSaved++;
  748. if (w.isDrawnLw() && !w.isAnimatingWithSavedSurface()) {
  749. atoken.numDrawnWindowsExclusingSaved++;
  750. if (DEBUG_VISIBILITY || DEBUG_ORIENTATION)
  751. Slog.v(TAG, "tokenMayBeDrawnExcludingSaved: " + atoken
  752. + " w=" + w + " numInteresting="
  753. + atoken.numInterestingWindowsExcludingSaved
  754. + " freezingScreen="
  755. + atoken.mAppAnimator.freezingScreen
  756. + " mAppFreezing=" + w.mAppFreezing);
  757. updateAllDrawn = true;
  758. }
  759. }
  760. }
  761. }
  762. if (isDefaultDisplay && someoneLosingFocus && w == mService.mCurrentFocus
  763. && w.isDisplayedLw()) {
  764. focusDisplayed = true;
  765. }
  766. mService.updateResizingWindows(w);
  767. }
  768. mService.mDisplayManagerInternal.setDisplayProperties(displayId,
  769. mDisplayHasContent,
  770. mPreferredRefreshRate,
  771. mPreferredModeId,
  772. true /* inTraversal, must call performTraversalInTrans... below */);
  773. mService.getDisplayContentLocked(displayId).stopDimmingIfNeeded();
  774. if (updateAllDrawn) {
  775. updateAllDrawnLocked(displayContent);
  776. }
  777. }
  778. if (focusDisplayed) {
  779. mService.mH.sendEmptyMessage(REPORT_LOSING_FOCUS);
  780. }
  781. // Give the display manager a chance to adjust properties
  782. // like display rotation if it needs to.
  783. mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager();
  784. }
  785. boolean isInLayout() {
  786. return mInLayout;
  787. }
  788. final void performLayoutLockedInner(final DisplayContent displayContent,
  789. boolean initial, boolean updateInputWindows) {
  790. if (!displayContent.layoutNeeded) {
  791. return;
  792. }
  793. displayContent.layoutNeeded = false;
  794. WindowList windows = displayContent.getWindowList();
  795. boolean isDefaultDisplay = displayContent.isDefaultDisplay;
  796. DisplayInfo displayInfo = displayContent.getDisplayInfo();
  797. final int dw = displayInfo.logicalWidth;
  798. final int dh = displayInfo.logicalHeight;
  799. if (mService.mInputConsumer != null) {
  800. mService.mInputConsumer.layout(dw, dh);
  801. }
  802. if (mService.mWallpaperInputConsumer != null) {
  803. mService.mWallpaperInputConsumer.layout(dw, dh);
  804. }
  805. final int N = windows.size();
  806. int i;
  807. if (DEBUG_LAYOUT) {
  808. Slog.v(TAG, "-------------------------------------");
  809. Slog.v(TAG, "performLayout: needed="
  810. + displayContent.layoutNeeded + " dw=" + dw + " dh=" + dh);
  811. }
  812. mService.mPolicy.beginLayoutLw(isDefaultDisplay, dw, dh, mService.mRotation,
  813. mService.mCurConfiguration.uiMode);
  814. if (isDefaultDisplay) {
  815. // Not needed on non-default displays.
  816. mService.mSystemDecorLayer = mService.mPolicy.getSystemDecorLayerLw();
  817. mService.mScreenRect.set(0, 0, dw, dh);
  818. }
  819. mService.mPolicy.getContentRectLw(mTmpContentRect);
  820. displayContent.resize(mTmpContentRect);
  821. int seq = mService.mLayoutSeq+1;
  822. if (seq < 0) seq = 0;
  823. mService.mLayoutSeq = seq;
  824. boolean behindDream = false;
  825. // First perform layout of any root windows (not attached
  826. // to another window).
  827. int topAttached = -1;
  828. for (i = N-1; i >= 0; i--) {
  829. final WindowState win = windows.get(i);
  830. // Don't do layout of a window if it is not visible, or
  831. // soon won't be visible, to avoid wasting time and funky
  832. // changes while a window is animating away.
  833. final boolean gone = (behindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs))
  834. || win.isGoneForLayoutLw();
  835. if (DEBUG_LAYOUT && !win.mLayoutAttached) {
  836. Slog.v(TAG, "1ST PASS " + win
  837. + ": gone=" + gone + " mHaveFrame=" + win.mHaveFrame
  838. + " mLayoutAttached=" + win.mLayoutAttached
  839. + " screen changed=" + win.isConfigChanged());
  840. final AppWindowToken atoken = win.mAppToken;
  841. if (gone) Slog.v(TAG, " GONE: mViewVisibility="
  842. + win.mViewVisibility + " mRelayoutCalled="
  843. + win.mRelayoutCalled + " hidden="
  844. + win.mRootToken.hidden + " hiddenRequested="
  845. + (atoken != null && atoken.hiddenRequested)
  846. + " mAttachedHidden=" + win.mAttachedHidden);
  847. else Slog.v(TAG, " VIS: mViewVisibility="
  848. + win.mViewVisibility + " mRelayoutCalled="
  849. + win.mRelayoutCalled + " hidden="
  850. + win.mRootToken.hidden + " hiddenRequested="
  851. + (atoken != null && atoken.hiddenRequested)
  852. + " mAttachedHidden=" + win.mAttachedHidden);
  853. }
  854. // If this view is GONE, then skip it -- keep the current
  855. // frame, and let the caller know so they can ignore it
  856. // if they want. (We do the normal layout for INVISIBLE
  857. // windows, since that means "perform layout as normal,
  858. // just don't display").
  859. if (!gone || !win.mHaveFrame || win.mLayoutNeeded
  860. || ((win.isConfigChanged() || win.setReportResizeHints())
  861. && !win.isGoneForLayoutLw() &&
  862. ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 ||
  863. (win.mHasSurface && win.mAppToken != null &&
  864. win.mAppToken.layoutConfigChanges)))) {
  865. if (!win.mLayoutAttached) {
  866. if (initial) {
  867. //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
  868. win.mContentChanged = false;
  869. }
  870. if (win.mAttrs.type == TYPE_DREAM) {
  871. // Don't layout windows behind a dream, so that if it
  872. // does stuff like hide the status bar we won't get a
  873. // bad transition when it goes away.
  874. behindDream = true;
  875. }
  876. win.mLayoutNeeded = false;
  877. win.prelayout();
  878. mService.mPolicy.layoutWindowLw(win, null);
  879. win.mLayoutSeq = seq;
  880. // Window frames may have changed. Update dim layer with the new bounds.
  881. final Task task = win.getTask();
  882. if (task != null) {
  883. displayContent.mDimLayerController.updateDimLayer(task);
  884. }
  885. if (DEBUG_LAYOUT) Slog.v(TAG,
  886. " LAYOUT: mFrame="
  887. + win.mFrame + " mContainingFrame="
  888. + win.mContainingFrame + " mDisplayFrame="
  889. + win.mDisplayFrame);
  890. } else {
  891. if (topAttached < 0) topAttached = i;
  892. }
  893. }
  894. }
  895. boolean attachedBehindDream = false;
  896. // Now perform layout of attached windows, which usually
  897. // depend on the position of the window they are attached to.
  898. // XXX does not deal with windows that are attached to windows
  899. // that are themselves attached.
  900. for (i = topAttached; i >= 0; i--) {
  901. final WindowState win = windows.get(i);
  902. if (win.mLayoutAttached) {
  903. if (DEBUG_LAYOUT) Slog.v(TAG,
  904. "2ND PASS " + win + " mHaveFrame=" + win.mHaveFrame + " mViewVisibility="
  905. + win.mViewVisibility + " mRelayoutCalled=" + win.mRelayoutCalled);
  906. // If this view is GONE, then skip it -- keep the current
  907. // frame, and let the caller know so they can ignore it
  908. // if they want. (We do the normal layout for INVISIBLE
  909. // windows, since that means "perform layout as normal,
  910. // just don't display").
  911. if (attachedBehindDream && mService.mPolicy.canBeForceHidden(win, win.mAttrs)) {
  912. continue;
  913. }
  914. if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled)
  915. || !win.mHaveFrame || win.mLayoutNeeded) {
  916. if (initial) {
  917. //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial");
  918. win.mContentChanged = false;
  919. }
  920. win.mLayoutNeeded = false;
  921. win.prelayout();
  922. mService.mPolicy.layoutWindowLw(win, win.mAttachedWindow);
  923. win.mLayoutSeq = seq;
  924. if (DEBUG_LAYOUT) Slog.v(TAG,