Program: 194127
Project: 194127
Buggy source:
private final void performLayoutAndPlaceSurfacesLockedInner(boolean recoveringMemory){
  if (DEBUG_WINDOW_TRACE) {
    Slog.v(TAG,"String_Node_Str" + Debug.getCallers(3));
  }
  int i;
  boolean updateInputWindowsNeeded=false;
  if (mFocusMayChange) {
    mFocusMayChange=false;
    updateInputWindowsNeeded=updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,false);
  }
  final int numDisplays=mDisplayContents.size();
  for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
    final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
    for (i=displayContent.mExitingTokens.size() - 1; i >= 0; i--) {
      displayContent.mExitingTokens.get(i).hasVisible=false;
    }
  }
  for (int stackNdx=mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
    final AppTokenList exitingAppTokens=mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
    for (int tokenNdx=exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
      exitingAppTokens.get(tokenNdx).hasVisible=false;
    }
  }
  mInnerFields.mHoldScreen=null;
  mInnerFields.mScreenBrightness=-1;
  mInnerFields.mButtonBrightness=-1;
  mInnerFields.mUserActivityTimeout=-1;
  mInnerFields.mObscureApplicationContentOnSecondaryDisplays=false;
  mTransactionSequence++;
  final DisplayContent defaultDisplay=getDefaultDisplayContentLocked();
  final DisplayInfo defaultInfo=defaultDisplay.getDisplayInfo();
  final int defaultDw=defaultInfo.logicalWidth;
  final int defaultDh=defaultInfo.logicalHeight;
  if (SHOW_LIGHT_TRANSACTIONS)   Slog.i(TAG,"String_Node_Str");
  SurfaceControl.openTransaction();
  try {
    if (mWatermark != null) {
      mWatermark.positionSurface(defaultDw,defaultDh);
    }
    if (mStrictModeFlash != null) {
      mStrictModeFlash.positionSurface(defaultDw,defaultDh);
    }
    if (mCircularDisplayMask != null) {
      mCircularDisplayMask.positionSurface(defaultDw,defaultDh,mRotation);
    }
    if (mEmulatorDisplayOverlay != null) {
      mEmulatorDisplayOverlay.positionSurface(defaultDw,defaultDh,mRotation);
    }
    boolean focusDisplayed=false;
    for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
      final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
      boolean updateAllDrawn=false;
      WindowList windows=displayContent.getWindowList();
      DisplayInfo displayInfo=displayContent.getDisplayInfo();
      final int displayId=displayContent.getDisplayId();
      final int dw=displayInfo.logicalWidth;
      final int dh=displayInfo.logicalHeight;
      final int innerDw=displayInfo.appWidth;
      final int innerDh=displayInfo.appHeight;
      final boolean isDefaultDisplay=(displayId == Display.DEFAULT_DISPLAY);
      mInnerFields.mDisplayHasContent=false;
      mInnerFields.mPreferredRefreshRate=0;
      mInnerFields.mPreferredModeId=0;
      int repeats=0;
      do {
        repeats++;
        if (repeats > 6) {
          Slog.w(TAG,"String_Node_Str");
          displayContent.layoutNeeded=false;
          break;
        }
        if (DEBUG_LAYOUT_REPEATS)         debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
        if ((displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0 && adjustWallpaperWindowsLocked()) {
          assignLayersLocked(windows);
          displayContent.layoutNeeded=true;
        }
        if (isDefaultDisplay && (displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
          if (DEBUG_LAYOUT)           Slog.v(TAG,"String_Node_Str");
          if (updateOrientationFromAppTokensLocked(true)) {
            displayContent.layoutNeeded=true;
            mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
          }
        }
        if ((displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
          displayContent.layoutNeeded=true;
        }
        if (repeats < 4) {
          performLayoutLockedInner(displayContent,repeats == 1,false);
        }
 else {
          Slog.w(TAG,"String_Node_Str");
        }
        displayContent.pendingLayoutChanges=0;
        if (isDefaultDisplay) {
          mPolicy.beginPostLayoutPolicyLw(dw,dh);
          for (i=windows.size() - 1; i >= 0; i--) {
            WindowState w=windows.get(i);
            if (w.mHasSurface) {
              mPolicy.applyPostLayoutPolicyLw(w,w.mAttrs,w.mAttachedWindow);
            }
          }
          displayContent.pendingLayoutChanges|=mPolicy.finishPostLayoutPolicyLw();
          if (DEBUG_LAYOUT_REPEATS)           debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
        }
      }
 while (displayContent.pendingLayoutChanges != 0);
      mInnerFields.mObscured=false;
      mInnerFields.mSyswin=false;
      displayContent.resetDimming();
      final boolean someoneLosingFocus=!mLosingFocus.isEmpty();
      final int N=windows.size();
      for (i=N - 1; i >= 0; i--) {
        WindowState w=windows.get(i);
        final TaskStack stack=w.getStack();
        if (stack == null && w.getAttrs().type != TYPE_PRIVATE_PRESENTATION) {
          continue;
        }
        final boolean obscuredChanged=w.mObscured != mInnerFields.mObscured;
        w.mObscured=mInnerFields.mObscured;
        if (!mInnerFields.mObscured) {
          handleNotObscuredLocked(w,innerDw,innerDh);
        }
        if (stack != null && !stack.testDimmingTag()) {
          handleFlagDimBehind(w);
        }
        if (isDefaultDisplay && obscuredChanged && (mWallpaperTarget == w)&& w.isVisibleLw()) {
          updateWallpaperVisibilityLocked();
        }
        final WindowStateAnimator winAnimator=w.mWinAnimator;
        if (w.hasMoved()) {
          final int left=w.mFrame.left;
          final int top=w.mFrame.top;
          if ((w.mAttrs.privateFlags & PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0) {
            Animation a=AnimationUtils.loadAnimation(mContext,com.android.internal.R.anim.window_move_from_decor);
            winAnimator.setAnimation(a);
            winAnimator.mAnimDw=w.mLastFrame.left - left;
            winAnimator.mAnimDh=w.mLastFrame.top - top;
            winAnimator.mAnimateMove=true;
            winAnimator.mAnimatingMove=true;
          }
          if (mAccessibilityController != null && displayId == Display.DEFAULT_DISPLAY) {
            mAccessibilityController.onSomeWindowResizedOrMovedLocked();
          }
          try {
            w.mClient.moved(left,top);
          }
 catch (          RemoteException e) {
          }
        }
        w.mContentChanged=false;
        if (w.mHasSurface && !w.isHiddenFromUserLocked()) {
          final boolean committed=winAnimator.commitFinishDrawingLocked();
          if (isDefaultDisplay && committed) {
            if (w.mAttrs.type == TYPE_DREAM) {
              displayContent.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
              if (DEBUG_LAYOUT_REPEATS) {
                debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
              }
            }
            if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
              if (DEBUG_WALLPAPER_LIGHT)               Slog.v(TAG,"String_Node_Str" + w);
              mInnerFields.mWallpaperMayChange=true;
              displayContent.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
              if (DEBUG_LAYOUT_REPEATS) {
                debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
              }
            }
          }
          winAnimator.setSurfaceBoundariesLocked(recoveringMemory);
        }
        if (!w.isHiddenFromUserLocked()) {
          final AppWindowToken atoken=w.mAppToken;
          if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) {
            Slog.d(TAG,"String_Node_Str" + w + "String_Node_Str"+ w.isOnScreen()+ "String_Node_Str"+ atoken.allDrawn+ "String_Node_Str"+ atoken.mAppAnimator.freezingScreen);
          }
          if (atoken != null && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) {
            if (atoken.lastTransactionSequence != mTransactionSequence) {
              atoken.lastTransactionSequence=mTransactionSequence;
              atoken.numInterestingWindows=atoken.numDrawnWindows=0;
              atoken.startingDisplayed=false;
            }
            if ((w.isOnScreenIgnoringKeyguard() || winAnimator.mAttrType == TYPE_BASE_APPLICATION) && !w.mExiting && !w.mDestroying) {
              if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
                Slog.v(TAG,"String_Node_Str" + w + "String_Node_Str"+ w.isDrawnLw()+ "String_Node_Str"+ winAnimator.isAnimating());
                if (!w.isDrawnLw()) {
                  Slog.v(TAG,"String_Node_Str" + winAnimator.mSurfaceControl + "String_Node_Str"+ w.mPolicyVisibility+ "String_Node_Str"+ winAnimator.drawStateToString()+ "String_Node_Str"+ w.mAttachedHidden+ "String_Node_Str"+ atoken.hiddenRequested+ "String_Node_Str"+ winAnimator.mAnimating);
                }
              }
              if (w != atoken.startingWindow) {
                if (!atoken.mAppAnimator.freezingScreen || !w.mAppFreezing) {
                  atoken.numInterestingWindows++;
                  if (w.isDrawnLw()) {
                    atoken.numDrawnWindows++;
                    if (DEBUG_VISIBILITY || DEBUG_ORIENTATION)                     Slog.v(TAG,"String_Node_Str" + atoken + "String_Node_Str"+ atoken.mAppAnimator.freezingScreen+ "String_Node_Str"+ w.mAppFreezing);
                    updateAllDrawn=true;
                  }
                }
              }
 else               if (w.isDrawnLw()) {
                atoken.startingDisplayed=true;
              }
            }
          }
        }
        if (isDefaultDisplay && someoneLosingFocus && (w == mCurrentFocus)&& w.isDisplayedLw()) {
          focusDisplayed=true;
        }
        updateResizingWindows(w);
      }
      mDisplayManagerInternal.setDisplayProperties(displayId,mInnerFields.mDisplayHasContent,mInnerFields.mPreferredRefreshRate,mInnerFields.mPreferredModeId,true);
      getDisplayContentLocked(displayId).stopDimmingIfNeeded();
      if (updateAllDrawn) {
        updateAllDrawnLocked(displayContent);
      }
    }
    if (focusDisplayed) {
      mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
    }
    mDisplayManagerInternal.performTraversalInTransactionFromWindowManager();
  }
 catch (  RuntimeException e) {
    Slog.wtf(TAG,"String_Node_Str",e);
  }
 finally {
    SurfaceControl.closeTransaction();
    if (SHOW_LIGHT_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str");
  }
  final WindowList defaultWindows=defaultDisplay.getWindowList();
  if (mAppTransition.isReady()) {
    defaultDisplay.pendingLayoutChanges|=handleAppTransitionReadyLocked(defaultWindows);
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  if (!mAnimator.mAppWindowAnimating && mAppTransition.isRunning()) {
    defaultDisplay.pendingLayoutChanges|=handleAnimatingStoppedAndTransitionLocked();
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  if (mInnerFields.mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0 && !mAppTransition.isReady()) {
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  mInnerFields.mWallpaperForceHidingChanged=false;
  if (mInnerFields.mWallpaperMayChange) {
    if (DEBUG_WALLPAPER_LIGHT)     Slog.v(TAG,"String_Node_Str");
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  if (mFocusMayChange) {
    mFocusMayChange=false;
    if (updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,false)) {
      updateInputWindowsNeeded=true;
      defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
    }
  }
  if (needsLayout()) {
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  for (i=mResizingWindows.size() - 1; i >= 0; i--) {
    WindowState win=mResizingWindows.get(i);
    if (win.mAppFreezing) {
      continue;
    }
    win.reportResized();
    mResizingWindows.remove(i);
  }
  if (DEBUG_ORIENTATION && mDisplayFrozen)   Slog.v(TAG,"String_Node_Str" + mInnerFields.mOrientationChangeComplete);
  if (mInnerFields.mOrientationChangeComplete) {
    if (mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
      mWindowsFreezingScreen=WINDOWS_FREEZING_SCREENS_NONE;
      mLastFinishedFreezeSource=mInnerFields.mLastWindowFreezeSource;
      mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
    }
    stopFreezingDisplayLocked();
  }
  boolean wallpaperDestroyed=false;
  i=mDestroySurface.size();
  if (i > 0) {
    do {
      i--;
      WindowState win=mDestroySurface.get(i);
      win.mDestroying=false;
      if (mInputMethodWindow == win) {
        mInputMethodWindow=null;
      }
      if (win == mWallpaperTarget) {
        wallpaperDestroyed=true;
      }
      win.mWinAnimator.destroySurfaceLocked();
    }
 while (i > 0);
    mDestroySurface.clear();
  }
  for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
    final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
    ArrayList<WindowToken> exitingTokens=displayContent.mExitingTokens;
    for (i=exitingTokens.size() - 1; i >= 0; i--) {
      WindowToken token=exitingTokens.get(i);
      if (!token.hasVisible) {
        exitingTokens.remove(i);
        if (token.windowType == TYPE_WALLPAPER) {
          mWallpaperTokens.remove(token);
        }
      }
    }
  }
  for (int stackNdx=mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
    final AppTokenList exitingAppTokens=mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
    for (i=exitingAppTokens.size() - 1; i >= 0; i--) {
      AppWindowToken token=exitingAppTokens.get(i);
      if (!token.hasVisible && !mClosingApps.contains(token) && (!token.mIsExiting || token.allAppWindows.isEmpty())) {
        token.mAppAnimator.clearAnimation();
        token.mAppAnimator.animating=false;
        if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT)         Slog.v(TAG,"String_Node_Str" + token);
        token.removeAppFromTaskLocked();
      }
    }
  }
  if (wallpaperDestroyed) {
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
    defaultDisplay.layoutNeeded=true;
  }
  for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
    final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
    if (displayContent.pendingLayoutChanges != 0) {
      displayContent.layoutNeeded=true;
    }
  }
  mInputMonitor.updateInputWindowsLw(true);
  setHoldScreenLocked(mInnerFields.mHoldScreen);
  if (!mDisplayFrozen) {
    if (mInnerFields.mScreenBrightness < 0 || mInnerFields.mScreenBrightness > 1.0f) {
      mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1);
    }
 else {
      mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(toBrightnessOverride(mInnerFields.mScreenBrightness));
    }
    if (mInnerFields.mButtonBrightness < 0 || mInnerFields.mButtonBrightness > 1.0f) {
      mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1);
    }
 else {
      mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(toBrightnessOverride(mInnerFields.mButtonBrightness));
    }
    mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager(mInnerFields.mUserActivityTimeout);
  }
  if (mTurnOnScreen) {
    if (mAllowTheaterModeWakeFromLayout || Settings.Global.getInt(mContext.getContentResolver(),Settings.Global.THEATER_MODE_ON,0) == 0) {
      if (DEBUG_VISIBILITY || DEBUG_POWER) {
        Slog.v(TAG,"String_Node_Str");
      }
      mPowerManager.wakeUp(SystemClock.uptimeMillis(),"String_Node_Str");
    }
    mTurnOnScreen=false;
  }
  if (mInnerFields.mUpdateRotation) {
    if (DEBUG_ORIENTATION)     Slog.d(TAG,"String_Node_Str");
    if (updateRotationUncheckedLocked(false)) {
      mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
    }
 else {
      mInnerFields.mUpdateRotation=false;
    }
  }
  if (mWaitingForDrawnCallback != null || (mInnerFields.mOrientationChangeComplete && !defaultDisplay.layoutNeeded && !mInnerFields.mUpdateRotation)) {
    checkDrawnWindowsLocked();
  }
  final int N=mPendingRemove.size();
  if (N > 0) {
    if (mPendingRemoveTmp.length < N) {
      mPendingRemoveTmp=new WindowState[N + 10];
    }
    mPendingRemove.toArray(mPendingRemoveTmp);
    mPendingRemove.clear();
    DisplayContentList displayList=new DisplayContentList();
    for (i=0; i < N; i++) {
      WindowState w=mPendingRemoveTmp[i];
      removeWindowInnerLocked(w);
      final DisplayContent displayContent=w.getDisplayContent();
      if (displayContent != null && !displayList.contains(displayContent)) {
        displayList.add(displayContent);
      }
    }
    for (    DisplayContent displayContent : displayList) {
      assignLayersLocked(displayContent.getWindowList());
      displayContent.layoutNeeded=true;
    }
  }
  for (int displayNdx=mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
    mDisplayContents.valueAt(displayNdx).checkForDeferredActions();
  }
  if (updateInputWindowsNeeded) {
    mInputMonitor.updateInputWindowsLw(false);
  }
  setFocusedStackFrame();
  enableScreenIfNeededLocked();
  scheduleAnimationLocked();
  if (DEBUG_WINDOW_TRACE) {
    Slog.e(TAG,"String_Node_Str" + mAnimator.mAnimating);
  }
}

Fixed version (ground truth):
private final void performLayoutAndPlaceSurfacesLockedInner(boolean recoveringMemory){
  if (DEBUG_WINDOW_TRACE) {
    Slog.v(TAG,"String_Node_Str" + Debug.getCallers(3));
  }
  int i;
  boolean updateInputWindowsNeeded=false;
  if (mFocusMayChange) {
    mFocusMayChange=false;
    updateInputWindowsNeeded=updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES,false);
  }
  final int numDisplays=mDisplayContents.size();
  for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
    final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
    for (i=displayContent.mExitingTokens.size() - 1; i >= 0; i--) {
      displayContent.mExitingTokens.get(i).hasVisible=false;
    }
  }
  for (int stackNdx=mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
    final AppTokenList exitingAppTokens=mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
    for (int tokenNdx=exitingAppTokens.size() - 1; tokenNdx >= 0; --tokenNdx) {
      exitingAppTokens.get(tokenNdx).hasVisible=false;
    }
  }
  mInnerFields.mHoldScreen=null;
  mInnerFields.mScreenBrightness=-1;
  mInnerFields.mButtonBrightness=-1;
  mInnerFields.mUserActivityTimeout=-1;
  mInnerFields.mObscureApplicationContentOnSecondaryDisplays=false;
  mTransactionSequence++;
  final DisplayContent defaultDisplay=getDefaultDisplayContentLocked();
  final DisplayInfo defaultInfo=defaultDisplay.getDisplayInfo();
  final int defaultDw=defaultInfo.logicalWidth;
  final int defaultDh=defaultInfo.logicalHeight;
  if (SHOW_LIGHT_TRANSACTIONS)   Slog.i(TAG,"String_Node_Str");
  SurfaceControl.openTransaction();
  try {
    if (mWatermark != null) {
      mWatermark.positionSurface(defaultDw,defaultDh);
    }
    if (mStrictModeFlash != null) {
      mStrictModeFlash.positionSurface(defaultDw,defaultDh);
    }
    if (mCircularDisplayMask != null) {
      mCircularDisplayMask.positionSurface(defaultDw,defaultDh,mRotation);
    }
    if (mEmulatorDisplayOverlay != null) {
      mEmulatorDisplayOverlay.positionSurface(defaultDw,defaultDh,mRotation);
    }
    boolean focusDisplayed=false;
    for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
      final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
      boolean updateAllDrawn=false;
      WindowList windows=displayContent.getWindowList();
      DisplayInfo displayInfo=displayContent.getDisplayInfo();
      final int displayId=displayContent.getDisplayId();
      final int dw=displayInfo.logicalWidth;
      final int dh=displayInfo.logicalHeight;
      final int innerDw=displayInfo.appWidth;
      final int innerDh=displayInfo.appHeight;
      final boolean isDefaultDisplay=(displayId == Display.DEFAULT_DISPLAY);
      mInnerFields.mDisplayHasContent=false;
      mInnerFields.mPreferredRefreshRate=0;
      mInnerFields.mPreferredModeId=0;
      int repeats=0;
      do {
        repeats++;
        if (repeats > 6) {
          Slog.w(TAG,"String_Node_Str");
          displayContent.layoutNeeded=false;
          break;
        }
        if (DEBUG_LAYOUT_REPEATS)         debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
        if ((displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0 && adjustWallpaperWindowsLocked()) {
          assignLayersLocked(windows);
          displayContent.layoutNeeded=true;
        }
        if (isDefaultDisplay && (displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
          if (DEBUG_LAYOUT)           Slog.v(TAG,"String_Node_Str");
          if (updateOrientationFromAppTokensLocked(true)) {
            displayContent.layoutNeeded=true;
            mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
          }
        }
        if ((displayContent.pendingLayoutChanges & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
          displayContent.layoutNeeded=true;
        }
        if (repeats < 4) {
          performLayoutLockedInner(displayContent,repeats == 1,false);
        }
 else {
          Slog.w(TAG,"String_Node_Str");
        }
        displayContent.pendingLayoutChanges=0;
        if (isDefaultDisplay) {
          mPolicy.beginPostLayoutPolicyLw(dw,dh);
          for (i=windows.size() - 1; i >= 0; i--) {
            WindowState w=windows.get(i);
            if (w.mHasSurface) {
              mPolicy.applyPostLayoutPolicyLw(w,w.mAttrs,w.mAttachedWindow);
            }
          }
          displayContent.pendingLayoutChanges|=mPolicy.finishPostLayoutPolicyLw();
          if (DEBUG_LAYOUT_REPEATS)           debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
        }
      }
 while (displayContent.pendingLayoutChanges != 0);
      mInnerFields.mObscured=false;
      mInnerFields.mSyswin=false;
      displayContent.resetDimming();
      final boolean someoneLosingFocus=!mLosingFocus.isEmpty();
      final int N=windows.size();
      for (i=N - 1; i >= 0; i--) {
        WindowState w=windows.get(i);
        final TaskStack stack=w.getStack();
        if (stack == null && w.getAttrs().type != TYPE_PRIVATE_PRESENTATION) {
          continue;
        }
        final boolean obscuredChanged=w.mObscured != mInnerFields.mObscured;
        w.mObscured=mInnerFields.mObscured;
        if (!mInnerFields.mObscured) {
          handleNotObscuredLocked(w,innerDw,innerDh);
        }
        if (stack != null && !stack.testDimmingTag()) {
          handleFlagDimBehind(w);
        }
        if (isDefaultDisplay && obscuredChanged && (mWallpaperTarget == w)&& w.isVisibleLw()) {
          updateWallpaperVisibilityLocked();
        }
        final WindowStateAnimator winAnimator=w.mWinAnimator;
        if (w.hasMoved()) {
          final int left=w.mFrame.left;
          final int top=w.mFrame.top;
          if ((w.mAttrs.privateFlags & PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0) {
            Animation a=AnimationUtils.loadAnimation(mContext,com.android.internal.R.anim.window_move_from_decor);
            winAnimator.setAnimation(a);
            winAnimator.mAnimDw=w.mLastFrame.left - left;
            winAnimator.mAnimDh=w.mLastFrame.top - top;
            winAnimator.mAnimateMove=true;
            winAnimator.mAnimatingMove=true;
          }
          if (mAccessibilityController != null && displayId == Display.DEFAULT_DISPLAY) {
            mAccessibilityController.onSomeWindowResizedOrMovedLocked();
          }
          try {
            w.mClient.moved(left,top);
          }
 catch (          RemoteException e) {
          }
        }
        w.mContentChanged=false;
        if (w.mHasSurface) {
          final boolean committed=winAnimator.commitFinishDrawingLocked();
          if (isDefaultDisplay && committed) {
            if (w.mAttrs.type == TYPE_DREAM) {
              displayContent.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
              if (DEBUG_LAYOUT_REPEATS) {
                debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
              }
            }
            if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
              if (DEBUG_WALLPAPER_LIGHT)               Slog.v(TAG,"String_Node_Str" + w);
              mInnerFields.mWallpaperMayChange=true;
              displayContent.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
              if (DEBUG_LAYOUT_REPEATS) {
                debugLayoutRepeats("String_Node_Str",displayContent.pendingLayoutChanges);
              }
            }
          }
          winAnimator.setSurfaceBoundariesLocked(recoveringMemory);
          final AppWindowToken atoken=w.mAppToken;
          if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) {
            Slog.d(TAG,"String_Node_Str" + w + "String_Node_Str"+ w.isOnScreen()+ "String_Node_Str"+ atoken.allDrawn+ "String_Node_Str"+ atoken.mAppAnimator.freezingScreen);
          }
          if (atoken != null && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) {
            if (atoken.lastTransactionSequence != mTransactionSequence) {
              atoken.lastTransactionSequence=mTransactionSequence;
              atoken.numInterestingWindows=atoken.numDrawnWindows=0;
              atoken.startingDisplayed=false;
            }
            if ((w.isOnScreenIgnoringKeyguard() || winAnimator.mAttrType == TYPE_BASE_APPLICATION) && !w.mExiting && !w.mDestroying) {
              if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
                Slog.v(TAG,"String_Node_Str" + w + "String_Node_Str"+ w.isDrawnLw()+ "String_Node_Str"+ winAnimator.isAnimating());
                if (!w.isDrawnLw()) {
                  Slog.v(TAG,"String_Node_Str" + winAnimator.mSurfaceControl + "String_Node_Str"+ w.mPolicyVisibility+ "String_Node_Str"+ winAnimator.drawStateToString()+ "String_Node_Str"+ w.mAttachedHidden+ "String_Node_Str"+ atoken.hiddenRequested+ "String_Node_Str"+ winAnimator.mAnimating);
                }
              }
              if (w != atoken.startingWindow) {
                if (!atoken.mAppAnimator.freezingScreen || !w.mAppFreezing) {
                  atoken.numInterestingWindows++;
                  if (w.isDrawnLw()) {
                    atoken.numDrawnWindows++;
                    if (DEBUG_VISIBILITY || DEBUG_ORIENTATION)                     Slog.v(TAG,"String_Node_Str" + atoken + "String_Node_Str"+ atoken.mAppAnimator.freezingScreen+ "String_Node_Str"+ w.mAppFreezing);
                    updateAllDrawn=true;
                  }
                }
              }
 else               if (w.isDrawnLw()) {
                atoken.startingDisplayed=true;
              }
            }
          }
        }
        if (isDefaultDisplay && someoneLosingFocus && (w == mCurrentFocus)&& w.isDisplayedLw()) {
          focusDisplayed=true;
        }
        updateResizingWindows(w);
      }
      mDisplayManagerInternal.setDisplayProperties(displayId,mInnerFields.mDisplayHasContent,mInnerFields.mPreferredRefreshRate,mInnerFields.mPreferredModeId,true);
      getDisplayContentLocked(displayId).stopDimmingIfNeeded();
      if (updateAllDrawn) {
        updateAllDrawnLocked(displayContent);
      }
    }
    if (focusDisplayed) {
      mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
    }
    mDisplayManagerInternal.performTraversalInTransactionFromWindowManager();
  }
 catch (  RuntimeException e) {
    Slog.wtf(TAG,"String_Node_Str",e);
  }
 finally {
    SurfaceControl.closeTransaction();
    if (SHOW_LIGHT_TRANSACTIONS)     Slog.i(TAG,"String_Node_Str");
  }
  final WindowList defaultWindows=defaultDisplay.getWindowList();
  if (mAppTransition.isReady()) {
    defaultDisplay.pendingLayoutChanges|=handleAppTransitionReadyLocked(defaultWindows);
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  if (!mAnimator.mAppWindowAnimating && mAppTransition.isRunning()) {
    defaultDisplay.pendingLayoutChanges|=handleAnimatingStoppedAndTransitionLocked();
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  if (mInnerFields.mWallpaperForceHidingChanged && defaultDisplay.pendingLayoutChanges == 0 && !mAppTransition.isReady()) {
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  mInnerFields.mWallpaperForceHidingChanged=false;
  if (mInnerFields.mWallpaperMayChange) {
    if (DEBUG_WALLPAPER_LIGHT)     Slog.v(TAG,"String_Node_Str");
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  if (mFocusMayChange) {
    mFocusMayChange=false;
    if (updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES,false)) {
      updateInputWindowsNeeded=true;
      defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
    }
  }
  if (needsLayout()) {
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
    if (DEBUG_LAYOUT_REPEATS)     debugLayoutRepeats("String_Node_Str",defaultDisplay.pendingLayoutChanges);
  }
  for (i=mResizingWindows.size() - 1; i >= 0; i--) {
    WindowState win=mResizingWindows.get(i);
    if (win.mAppFreezing) {
      continue;
    }
    win.reportResized();
    mResizingWindows.remove(i);
  }
  if (DEBUG_ORIENTATION && mDisplayFrozen)   Slog.v(TAG,"String_Node_Str" + mInnerFields.mOrientationChangeComplete);
  if (mInnerFields.mOrientationChangeComplete) {
    if (mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_NONE) {
      mWindowsFreezingScreen=WINDOWS_FREEZING_SCREENS_NONE;
      mLastFinishedFreezeSource=mInnerFields.mLastWindowFreezeSource;
      mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
    }
    stopFreezingDisplayLocked();
  }
  boolean wallpaperDestroyed=false;
  i=mDestroySurface.size();
  if (i > 0) {
    do {
      i--;
      WindowState win=mDestroySurface.get(i);
      win.mDestroying=false;
      if (mInputMethodWindow == win) {
        mInputMethodWindow=null;
      }
      if (win == mWallpaperTarget) {
        wallpaperDestroyed=true;
      }
      win.mWinAnimator.destroySurfaceLocked();
    }
 while (i > 0);
    mDestroySurface.clear();
  }
  for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
    final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
    ArrayList<WindowToken> exitingTokens=displayContent.mExitingTokens;
    for (i=exitingTokens.size() - 1; i >= 0; i--) {
      WindowToken token=exitingTokens.get(i);
      if (!token.hasVisible) {
        exitingTokens.remove(i);
        if (token.windowType == TYPE_WALLPAPER) {
          mWallpaperTokens.remove(token);
        }
      }
    }
  }
  for (int stackNdx=mStackIdToStack.size() - 1; stackNdx >= 0; --stackNdx) {
    final AppTokenList exitingAppTokens=mStackIdToStack.valueAt(stackNdx).mExitingAppTokens;
    for (i=exitingAppTokens.size() - 1; i >= 0; i--) {
      AppWindowToken token=exitingAppTokens.get(i);
      if (!token.hasVisible && !mClosingApps.contains(token) && (!token.mIsExiting || token.allAppWindows.isEmpty())) {
        token.mAppAnimator.clearAnimation();
        token.mAppAnimator.animating=false;
        if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT)         Slog.v(TAG,"String_Node_Str" + token);
        token.removeAppFromTaskLocked();
      }
    }
  }
  if (wallpaperDestroyed) {
    defaultDisplay.pendingLayoutChanges|=WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
    defaultDisplay.layoutNeeded=true;
  }
  for (int displayNdx=0; displayNdx < numDisplays; ++displayNdx) {
    final DisplayContent displayContent=mDisplayContents.valueAt(displayNdx);
    if (displayContent.pendingLayoutChanges != 0) {
      displayContent.layoutNeeded=true;
    }
  }
  mInputMonitor.updateInputWindowsLw(true);
  setHoldScreenLocked(mInnerFields.mHoldScreen);
  if (!mDisplayFrozen) {
    if (mInnerFields.mScreenBrightness < 0 || mInnerFields.mScreenBrightness > 1.0f) {
      mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(-1);
    }
 else {
      mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(toBrightnessOverride(mInnerFields.mScreenBrightness));
    }
    if (mInnerFields.mButtonBrightness < 0 || mInnerFields.mButtonBrightness > 1.0f) {
      mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(-1);
    }
 else {
      mPowerManagerInternal.setButtonBrightnessOverrideFromWindowManager(toBrightnessOverride(mInnerFields.mButtonBrightness));
    }
    mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager(mInnerFields.mUserActivityTimeout);
  }
  if (mTurnOnScreen) {
    if (mAllowTheaterModeWakeFromLayout || Settings.Global.getInt(mContext.getContentResolver(),Settings.Global.THEATER_MODE_ON,0) == 0) {
      if (DEBUG_VISIBILITY || DEBUG_POWER) {
        Slog.v(TAG,"String_Node_Str");
      }
      mPowerManager.wakeUp(SystemClock.uptimeMillis(),"String_Node_Str");
    }
    mTurnOnScreen=false;
  }
  if (mInnerFields.mUpdateRotation) {
    if (DEBUG_ORIENTATION)     Slog.d(TAG,"String_Node_Str");
    if (updateRotationUncheckedLocked(false)) {
      mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
    }
 else {
      mInnerFields.mUpdateRotation=false;
    }
  }
  if (mWaitingForDrawnCallback != null || (mInnerFields.mOrientationChangeComplete && !defaultDisplay.layoutNeeded && !mInnerFields.mUpdateRotation)) {
    checkDrawnWindowsLocked();
  }
  final int N=mPendingRemove.size();
  if (N > 0) {
    if (mPendingRemoveTmp.length < N) {
      mPendingRemoveTmp=new WindowState[N + 10];
    }
    mPendingRemove.toArray(mPendingRemoveTmp);
    mPendingRemove.clear();
    DisplayContentList displayList=new DisplayContentList();
    for (i=0; i < N; i++) {
      WindowState w=mPendingRemoveTmp[i];
      removeWindowInnerLocked(w);
      final DisplayContent displayContent=w.getDisplayContent();
      if (displayContent != null && !displayList.contains(displayContent)) {
        displayList.add(displayContent);
      }
    }
    for (    DisplayContent displayContent : displayList) {
      assignLayersLocked(displayContent.getWindowList());
      displayContent.layoutNeeded=true;
    }
  }
  for (int displayNdx=mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
    mDisplayContents.valueAt(displayNdx).checkForDeferredActions();
  }
  if (updateInputWindowsNeeded) {
    mInputMonitor.updateInputWindowsLw(false);
  }
  setFocusedStackFrame();
  enableScreenIfNeededLocked();
  scheduleAnimationLocked();
  if (DEBUG_WINDOW_TRACE) {
    Slog.e(TAG,"String_Node_Str" + mAnimator.mAnimating);
  }
}