@@ -608,6 +608,9 @@ class LayoutAndSurfaceFields {
608608 }
609609 LayoutAndSurfaceFields mInnerFields = new LayoutAndSurfaceFields ();
610610
611+ /** Only do a maximum of 6 repeated layouts. After that quit */
612+ private int mLayoutRepeatCount ;
613+
611614 private final class AnimationRunnable implements Runnable {
612615 @ Override
613616 public void run () {
@@ -1917,7 +1920,7 @@ boolean updateWallpaperOffsetLocked(WindowState wallpaperWin, int dw, int dh,
19171920 rawChanged = true ;
19181921 }
19191922
1920- if (rawChanged && (wallpaperWin .getAttrs () .privateFlags &
1923+ if (rawChanged && (wallpaperWin .mAttrs .privateFlags &
19211924 WindowManager .LayoutParams .PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS ) != 0 ) {
19221925 try {
19231926 if (DEBUG_WALLPAPER ) Slog .v (TAG , "Report new wp offset "
@@ -2316,7 +2319,7 @@ public void removeWindowLocked(Session session, WindowState win) {
23162319 if (wasVisible ) {
23172320
23182321 int transit = WindowManagerPolicy .TRANSIT_EXIT ;
2319- if (win .getAttrs () .type == TYPE_APPLICATION_STARTING ) {
2322+ if (win .mAttrs .type == TYPE_APPLICATION_STARTING ) {
23202323 transit = WindowManagerPolicy .TRANSIT_PREVIEW_DONE ;
23212324 }
23222325 // Try starting an animation.
@@ -2790,7 +2793,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
27902793 // Try starting an animation; if there isn't one, we
27912794 // can destroy the surface right away.
27922795 int transit = WindowManagerPolicy .TRANSIT_EXIT ;
2793- if (win .getAttrs () .type == TYPE_APPLICATION_STARTING ) {
2796+ if (win .mAttrs .type == TYPE_APPLICATION_STARTING ) {
27942797 transit = WindowManagerPolicy .TRANSIT_PREVIEW_DONE ;
27952798 }
27962799 if (!win .mSurfacePendingDestroy && win .isWinVisibleLw () &&
@@ -7575,10 +7578,25 @@ private final void performLayoutAndPlaceSurfacesLocked() {
75757578
75767579 } else {
75777580 mInLayout = false ;
7578- if (mLayoutNeeded ) {
7581+ }
7582+
7583+ if (mLayoutNeeded ) {
7584+ if (++mLayoutRepeatCount < 6 ) {
75797585 requestTraversalLocked ();
7586+ } else {
7587+ Slog .e (TAG , "Performed 6 layouts in a row. Skipping" );
7588+ mLayoutRepeatCount = 0 ;
75807589 }
7590+ } else {
7591+ mLayoutRepeatCount = 0 ;
7592+ }
7593+
7594+ if (mAnimator .mAnimating ) {
7595+ // Do this even if requestTraversalLocked was called above so we get a frame drawn
7596+ // at the proper time as well as the one drawn early.
7597+ scheduleAnimationLocked ();
75817598 }
7599+
75827600 if (mWindowsChanged && !mWindowChangeListeners .isEmpty ()) {
75837601 mH .removeMessages (H .REPORT_WINDOWS_CHANGE );
75847602 mH .sendMessage (mH .obtainMessage (H .REPORT_WINDOWS_CHANGE ));
@@ -8366,13 +8384,15 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
83668384 mLayoutNeeded = true ;
83678385 }
83688386 }
8387+
83698388 if ((mPendingLayoutChanges & WindowManagerPolicy .FINISH_LAYOUT_REDO_CONFIG ) != 0 ) {
83708389 if (DEBUG_LAYOUT ) Slog .v (TAG , "Computing new config from layout" );
83718390 if (updateOrientationFromAppTokensLocked (true )) {
83728391 mLayoutNeeded = true ;
83738392 mH .sendEmptyMessage (H .SEND_NEW_CONFIGURATION );
83748393 }
83758394 }
8395+
83768396 if ((mPendingLayoutChanges & WindowManagerPolicy .FINISH_LAYOUT_REDO_LAYOUT ) != 0 ) {
83778397 mLayoutNeeded = true ;
83788398 }
@@ -8584,8 +8604,6 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
85848604 }
85858605 }
85868606
8587- boolean needRelayout = false ;
8588-
85898607 if (!mAnimator .mAnimating && mAppTransitionRunning ) {
85908608 // We have finished the animation of an app transition. To do
85918609 // this, we have delayed a lot of operations like showing and
@@ -8594,7 +8612,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
85948612 // be out of sync with it. So here we will just rebuild the
85958613 // entire app window list. Fun!
85968614 mAppTransitionRunning = false ;
8597- needRelayout = true ;
8615+ mLayoutNeeded = true ;
85988616 rebuildAppWindowListLocked ();
85998617 assignLayersLocked ();
86008618 // Clear information about apps that were moving.
@@ -8605,19 +8623,10 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
86058623 mH .sendEmptyMessage (H .REPORT_LOSING_FOCUS );
86068624 }
86078625 if (wallpaperDestroyed ) {
8608- needRelayout = adjustWallpaperWindowsLocked () != 0 ;
8609- }
8610- if ((mPendingLayoutChanges & (
8611- WindowManagerPolicy .FINISH_LAYOUT_REDO_WALLPAPER |
8612- ADJUST_WALLPAPER_LAYERS_CHANGED |
8613- WindowManagerPolicy .FINISH_LAYOUT_REDO_CONFIG |
8614- WindowManagerPolicy .FINISH_LAYOUT_REDO_LAYOUT )) != 0 ) {
8615- needRelayout = true ;
8626+ mLayoutNeeded |= adjustWallpaperWindowsLocked () != 0 ;
86168627 }
8617- if (needRelayout ) {
8618- requestTraversalLocked ();
8619- } else if (mAnimator .mAnimating ) {
8620- scheduleAnimationLocked ();
8628+ if (mPendingLayoutChanges != 0 ) {
8629+ mLayoutNeeded = true ;
86218630 }
86228631
86238632 // Finally update all input windows now that the window changes have stabilized.
@@ -8660,7 +8669,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(
86608669 }
86618670 }
86628671
8663- if (mInnerFields .mOrientationChangeComplete && !needRelayout &&
8672+ if (mInnerFields .mOrientationChangeComplete && !mLayoutNeeded &&
86648673 !mInnerFields .mUpdateRotation ) {
86658674 checkDrawnWindowsLocked ();
86668675 }
0 commit comments