Program: 191015
Project: 191015
Buggy source:
private void updateWindowsLocked(final int displayId){
  ++mAnimTransactionSequence;
  final WindowList windows=mService.getWindowListLocked(displayId);
  final boolean keyguardGoingAwayToShade=(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0;
  final boolean keyguardGoingAwayNoAnimation=(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS) != 0;
  final boolean keyguardGoingAwayWithWallpaper=(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER) != 0;
  if (mKeyguardGoingAway) {
    for (int i=windows.size() - 1; i >= 0; i--) {
      WindowState win=windows.get(i);
      if (!mPolicy.isKeyguardHostWindow(win.mAttrs)) {
        continue;
      }
      final WindowStateAnimator winAnimator=win.mWinAnimator;
      if ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
        if (!winAnimator.mAnimating) {
          if (DEBUG_KEYGUARD)           Slog.d(TAG,"String_Node_Str");
          winAnimator.mAnimation=new AlphaAnimation(1.0f,1.0f);
          winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
          winAnimator.mAnimationIsEntrance=false;
          winAnimator.mAnimationStartTime=-1;
          winAnimator.mKeyguardGoingAwayAnimation=true;
          winAnimator.mKeyguardGoingAwayWithWallpaper=keyguardGoingAwayWithWallpaper;
        }
      }
 else {
        if (DEBUG_KEYGUARD)         Slog.d(TAG,"String_Node_Str");
        mKeyguardGoingAway=false;
        winAnimator.clearAnimation();
      }
      break;
    }
  }
  mForceHiding=KEYGUARD_NOT_SHOWN;
  boolean wallpaperInUnForceHiding=false;
  boolean startingInUnForceHiding=false;
  ArrayList<WindowStateAnimator> unForceHiding=null;
  WindowState wallpaper=null;
  final WallpaperController wallpaperController=mService.mWallpaperControllerLocked;
  for (int i=windows.size() - 1; i >= 0; i--) {
    WindowState win=windows.get(i);
    WindowStateAnimator winAnimator=win.mWinAnimator;
    final int flags=win.mAttrs.flags;
    boolean canBeForceHidden=mPolicy.canBeForceHidden(win,win.mAttrs);
    boolean shouldBeForceHidden=shouldForceHide(win);
    if (winAnimator.hasSurface()) {
      final boolean wasAnimating=winAnimator.mWasAnimating;
      final boolean nowAnimating=winAnimator.stepAnimationLocked(mCurrentTime);
      winAnimator.mWasAnimating=nowAnimating;
      orAnimating(nowAnimating);
      if (DEBUG_WALLPAPER) {
        Slog.v(TAG,win + "String_Node_Str" + wasAnimating+ "String_Node_Str"+ nowAnimating);
      }
      if (wasAnimating && !winAnimator.mAnimating && wallpaperController.isWallpaperTarget(win)) {
        mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
        setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
        if (DEBUG_LAYOUT_REPEATS) {
          mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
        }
      }
      if (mPolicy.isForceHiding(win.mAttrs)) {
        if (!wasAnimating && nowAnimating) {
          if (DEBUG_KEYGUARD || DEBUG_ANIM || DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
          mBulkUpdateParams|=SET_FORCE_HIDING_CHANGED;
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (DEBUG_LAYOUT_REPEATS) {
            mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(displayId));
          }
          mService.mFocusMayChange=true;
        }
 else         if (mKeyguardGoingAway && !nowAnimating) {
          Slog.e(TAG,"String_Node_Str");
          mPolicy.startKeyguardExitAnimation(0,0);
          mKeyguardGoingAway=false;
        }
        if (win.isReadyForDisplay()) {
          if (nowAnimating && win.mWinAnimator.mKeyguardGoingAwayAnimation) {
            mForceHiding=KEYGUARD_ANIMATING_OUT;
          }
 else {
            mForceHiding=win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;
          }
        }
        if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)         Slog.v(TAG,"String_Node_Str" + forceHidingToString() + "String_Node_Str"+ win.mHasSurface+ "String_Node_Str"+ win.mPolicyVisibility+ "String_Node_Str"+ win.mDestroying+ "String_Node_Str"+ win.mAttachedHidden+ "String_Node_Str"+ win.mViewVisibility+ "String_Node_Str"+ win.mRootToken.hidden+ "String_Node_Str"+ win.mWinAnimator.mAnimation);
      }
 else       if (canBeForceHidden) {
        if (shouldBeForceHidden) {
          if (!win.hideLw(false,false)) {
            continue;
          }
          if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
        }
 else {
          boolean applyExistingExitAnimation=mPostKeyguardExitAnimation != null && !mPostKeyguardExitAnimation.hasEnded() && !winAnimator.mKeyguardGoingAwayAnimation && win.hasDrawnLw() && win.mAttachedWindow == null && !win.mIsImWindow && displayId == Display.DEFAULT_DISPLAY;
          if (!win.showLw(false,false) && !applyExistingExitAnimation) {
            continue;
          }
          final boolean visibleNow=win.isVisibleNow();
          if (!visibleNow) {
            win.hideLw(false,false);
            continue;
          }
          if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
          if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 && win.mAttachedWindow == null) {
            if (unForceHiding == null) {
              unForceHiding=new ArrayList<>();
            }
            unForceHiding.add(winAnimator);
            if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
              wallpaperInUnForceHiding=true;
            }
            if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
              startingInUnForceHiding=true;
            }
          }
 else           if (applyExistingExitAnimation) {
            if (DEBUG_KEYGUARD)             Slog.v(TAG,"String_Node_Str" + win);
            Animation a=mPolicy.createForceHideEnterAnimation(false,keyguardGoingAwayToShade);
            winAnimator.setAnimation(a,mPostKeyguardExitAnimation.getStartTime(),STACK_CLIP_BEFORE_ANIM);
            winAnimator.mKeyguardGoingAwayAnimation=true;
            winAnimator.mKeyguardGoingAwayWithWallpaper=keyguardGoingAwayWithWallpaper;
          }
          final WindowState currentFocus=mService.mCurrentFocus;
          if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
            if (DEBUG_FOCUS_LIGHT)             Slog.v(TAG,"String_Node_Str");
            mService.mFocusMayChange=true;
          }
        }
        if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
          mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
          setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (DEBUG_LAYOUT_REPEATS) {
            mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
          }
        }
      }
    }
 else     if (canBeForceHidden) {
      if (shouldBeForceHidden) {
        win.hideLw(false,false);
      }
 else {
        win.showLw(false,false);
      }
    }
    final AppWindowToken atoken=win.mAppToken;
    if (winAnimator.mDrawState == READY_TO_SHOW) {
      if (atoken == null || atoken.allDrawn) {
        if (winAnimator.performShowLocked()) {
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
          if (DEBUG_LAYOUT_REPEATS) {
            mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(displayId));
          }
        }
      }
    }
    final AppWindowAnimator appAnimator=winAnimator.mAppAnimator;
    if (appAnimator != null && appAnimator.thumbnail != null) {
      if (appAnimator.thumbnailTransactionSeq != mAnimTransactionSequence) {
        appAnimator.thumbnailTransactionSeq=mAnimTransactionSequence;
        appAnimator.thumbnailLayer=0;
      }
      if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) {
        appAnimator.thumbnailLayer=winAnimator.mAnimLayer;
      }
    }
    if (win.mIsWallpaper) {
      wallpaper=win;
    }
  }
  if (unForceHiding != null) {
    if (!keyguardGoingAwayNoAnimation) {
      boolean first=true;
      for (int i=unForceHiding.size() - 1; i >= 0; i--) {
        final WindowStateAnimator winAnimator=unForceHiding.get(i);
        Animation a=mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding && !startingInUnForceHiding,keyguardGoingAwayToShade);
        if (a != null) {
          if (DEBUG_KEYGUARD)           Slog.v(TAG,"String_Node_Str" + winAnimator.mWin);
          winAnimator.setAnimation(a,STACK_CLIP_BEFORE_ANIM);
          winAnimator.mKeyguardGoingAwayAnimation=true;
          winAnimator.mKeyguardGoingAwayWithWallpaper=keyguardGoingAwayWithWallpaper;
          if (first) {
            mPostKeyguardExitAnimation=a;
            mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
            first=false;
          }
        }
      }
    }
 else     if (mKeyguardGoingAway) {
      mPolicy.startKeyguardExitAnimation(mCurrentTime,0);
      mKeyguardGoingAway=false;
    }
    if (!wallpaperInUnForceHiding && wallpaper != null && !keyguardGoingAwayNoAnimation) {
      if (DEBUG_KEYGUARD)       Slog.d(TAG,"String_Node_Str");
      Animation a=mPolicy.createForceHideWallpaperExitAnimation(keyguardGoingAwayToShade);
      if (a != null) {
        wallpaper.mWinAnimator.setAnimation(a);
      }
    }
  }
  if (mPostKeyguardExitAnimation != null) {
    if (mKeyguardGoingAway) {
      mPolicy.startKeyguardExitAnimation(mCurrentTime + mPostKeyguardExitAnimation.getStartOffset(),mPostKeyguardExitAnimation.getDuration());
      mKeyguardGoingAway=false;
    }
 else     if (mPostKeyguardExitAnimation.hasEnded() || mCurrentTime - mPostKeyguardExitAnimation.getStartTime() > mPostKeyguardExitAnimation.getDuration()) {
      if (DEBUG_KEYGUARD)       Slog.v(TAG,"String_Node_Str");
      mPostKeyguardExitAnimation=null;
    }
  }
}

Fixed version (ground truth):
private void updateWindowsLocked(final int displayId){
  ++mAnimTransactionSequence;
  final WindowList windows=mService.getWindowListLocked(displayId);
  final boolean keyguardGoingAwayToShade=(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0;
  final boolean keyguardGoingAwayNoAnimation=(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS) != 0;
  final boolean keyguardGoingAwayWithWallpaper=(mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER) != 0;
  if (mKeyguardGoingAway) {
    for (int i=windows.size() - 1; i >= 0; i--) {
      WindowState win=windows.get(i);
      if (!mPolicy.isKeyguardHostWindow(win.mAttrs)) {
        continue;
      }
      final WindowStateAnimator winAnimator=win.mWinAnimator;
      if ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
        if (!winAnimator.mAnimating) {
          if (DEBUG_KEYGUARD)           Slog.d(TAG,"String_Node_Str");
          winAnimator.mAnimation=new AlphaAnimation(1.0f,1.0f);
          winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
          winAnimator.mAnimationIsEntrance=false;
          winAnimator.mAnimationStartTime=-1;
          winAnimator.mKeyguardGoingAwayAnimation=true;
          winAnimator.mKeyguardGoingAwayWithWallpaper=keyguardGoingAwayWithWallpaper;
        }
      }
 else {
        if (DEBUG_KEYGUARD)         Slog.d(TAG,"String_Node_Str");
        mKeyguardGoingAway=false;
        winAnimator.clearAnimation();
      }
      break;
    }
  }
  mForceHiding=KEYGUARD_NOT_SHOWN;
  boolean wallpaperInUnForceHiding=false;
  boolean startingInUnForceHiding=false;
  ArrayList<WindowStateAnimator> unForceHiding=null;
  WindowState wallpaper=null;
  final WallpaperController wallpaperController=mService.mWallpaperControllerLocked;
  for (int i=windows.size() - 1; i >= 0; i--) {
    WindowState win=windows.get(i);
    WindowStateAnimator winAnimator=win.mWinAnimator;
    final int flags=win.mAttrs.flags;
    boolean canBeForceHidden=mPolicy.canBeForceHidden(win,win.mAttrs);
    boolean shouldBeForceHidden=shouldForceHide(win);
    if (winAnimator.hasSurface()) {
      final boolean wasAnimating=winAnimator.mWasAnimating;
      final boolean nowAnimating=winAnimator.stepAnimationLocked(mCurrentTime);
      winAnimator.mWasAnimating=nowAnimating;
      orAnimating(nowAnimating);
      if (DEBUG_WALLPAPER) {
        Slog.v(TAG,win + "String_Node_Str" + wasAnimating+ "String_Node_Str"+ nowAnimating);
      }
      if (wasAnimating && !winAnimator.mAnimating && wallpaperController.isWallpaperTarget(win)) {
        mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
        setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
        if (DEBUG_LAYOUT_REPEATS) {
          mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
        }
      }
      if (mPolicy.isForceHiding(win.mAttrs)) {
        if (!wasAnimating && nowAnimating) {
          if (DEBUG_KEYGUARD || DEBUG_ANIM || DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
          mBulkUpdateParams|=SET_FORCE_HIDING_CHANGED;
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (DEBUG_LAYOUT_REPEATS) {
            mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(displayId));
          }
          mService.mFocusMayChange=true;
        }
 else         if (mKeyguardGoingAway && !nowAnimating) {
          Slog.e(TAG,"String_Node_Str");
          mPolicy.startKeyguardExitAnimation(0,0);
          mKeyguardGoingAway=false;
        }
        if (win.isReadyForDisplay()) {
          if (nowAnimating && win.mWinAnimator.mKeyguardGoingAwayAnimation) {
            mForceHiding=KEYGUARD_ANIMATING_OUT;
          }
 else {
            mForceHiding=win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;
          }
        }
        if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)         Slog.v(TAG,"String_Node_Str" + forceHidingToString() + "String_Node_Str"+ win.mHasSurface+ "String_Node_Str"+ win.mPolicyVisibility+ "String_Node_Str"+ win.mDestroying+ "String_Node_Str"+ win.mAttachedHidden+ "String_Node_Str"+ win.mViewVisibility+ "String_Node_Str"+ win.mRootToken.hidden+ "String_Node_Str"+ win.mWinAnimator.mAnimation);
      }
 else       if (canBeForceHidden) {
        if (shouldBeForceHidden) {
          if (!win.hideLw(false,false)) {
            continue;
          }
          if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
        }
 else {
          boolean applyExistingExitAnimation=mPostKeyguardExitAnimation != null && !mPostKeyguardExitAnimation.hasEnded() && !winAnimator.mKeyguardGoingAwayAnimation && win.hasDrawnLw() && win.mAttachedWindow == null && !win.mIsImWindow && displayId == Display.DEFAULT_DISPLAY;
          if (!win.showLw(false,false) && !applyExistingExitAnimation) {
            continue;
          }
          final boolean visibleNow=win.isVisibleNow();
          if (!visibleNow) {
            win.hideLw(false,false);
            continue;
          }
          if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
          if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 && win.mAttachedWindow == null) {
            if (unForceHiding == null) {
              unForceHiding=new ArrayList<>();
            }
            unForceHiding.add(winAnimator);
            if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
              wallpaperInUnForceHiding=true;
            }
            if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
              startingInUnForceHiding=true;
            }
          }
 else           if (applyExistingExitAnimation) {
            if (DEBUG_KEYGUARD)             Slog.v(TAG,"String_Node_Str" + win);
            Animation a=mPolicy.createForceHideEnterAnimation(false,keyguardGoingAwayToShade);
            winAnimator.setAnimation(a,mPostKeyguardExitAnimation.getStartTime(),STACK_CLIP_BEFORE_ANIM);
            winAnimator.mKeyguardGoingAwayAnimation=true;
            winAnimator.mKeyguardGoingAwayWithWallpaper=keyguardGoingAwayWithWallpaper;
          }
          final WindowState currentFocus=mService.mCurrentFocus;
          if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
            if (DEBUG_FOCUS_LIGHT)             Slog.v(TAG,"String_Node_Str");
            mService.mFocusMayChange=true;
          }
        }
        if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
          mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
          setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (DEBUG_LAYOUT_REPEATS) {
            mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
          }
        }
      }
    }
 else     if (canBeForceHidden) {
      if (shouldBeForceHidden) {
        win.hideLw(false,false);
      }
 else {
        win.showLw(false,false);
      }
    }
    final AppWindowToken atoken=win.mAppToken;
    if (winAnimator.mDrawState == READY_TO_SHOW) {
      if (atoken == null || atoken.allDrawn) {
        if (winAnimator.performShowLocked()) {
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
          if (DEBUG_LAYOUT_REPEATS) {
            mWindowPlacerLocked.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(displayId));
          }
        }
      }
    }
    final AppWindowAnimator appAnimator=winAnimator.mAppAnimator;
    if (appAnimator != null && appAnimator.thumbnail != null) {
      if (appAnimator.thumbnailTransactionSeq != mAnimTransactionSequence) {
        appAnimator.thumbnailTransactionSeq=mAnimTransactionSequence;
        appAnimator.thumbnailLayer=0;
      }
      if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) {
        appAnimator.thumbnailLayer=winAnimator.mAnimLayer;
      }
    }
    if (win.mIsWallpaper) {
      wallpaper=win;
    }
  }
  if (unForceHiding != null) {
    if (!keyguardGoingAwayNoAnimation) {
      boolean first=true;
      for (int i=unForceHiding.size() - 1; i >= 0; i--) {
        final WindowStateAnimator winAnimator=unForceHiding.get(i);
        Animation a=mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding && !startingInUnForceHiding,keyguardGoingAwayToShade);
        if (a != null) {
          if (DEBUG_KEYGUARD)           Slog.v(TAG,"String_Node_Str" + winAnimator.mWin);
          winAnimator.setAnimation(a,STACK_CLIP_BEFORE_ANIM);
          winAnimator.mKeyguardGoingAwayAnimation=true;
          winAnimator.mKeyguardGoingAwayWithWallpaper=keyguardGoingAwayWithWallpaper;
          if (first) {
            mPostKeyguardExitAnimation=a;
            mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
            first=false;
          }
        }
      }
    }
 else     if (mKeyguardGoingAway) {
      mPolicy.startKeyguardExitAnimation(mCurrentTime,0);
      mKeyguardGoingAway=false;
    }
    if (!wallpaperInUnForceHiding && wallpaper != null && !keyguardGoingAwayNoAnimation) {
      if (DEBUG_KEYGUARD)       Slog.d(TAG,"String_Node_Str");
      Animation a=mPolicy.createForceHideWallpaperExitAnimation(keyguardGoingAwayToShade);
      if (a != null) {
        wallpaper.mWinAnimator.setAnimation(a);
      }
    }
  }
  if (mPostKeyguardExitAnimation != null) {
    if (mKeyguardGoingAway) {
      mPolicy.startKeyguardExitAnimation(mCurrentTime + mPostKeyguardExitAnimation.getStartOffset(),mPostKeyguardExitAnimation.getDuration());
      mKeyguardGoingAway=false;
    }
 else     if (mPostKeyguardExitAnimation.hasEnded() || mCurrentTime - mPostKeyguardExitAnimation.getStartTime() > mPostKeyguardExitAnimation.getDuration()) {
      if (DEBUG_KEYGUARD)       Slog.v(TAG,"String_Node_Str");
      mPostKeyguardExitAnimation=null;
    }
  }
  final WindowState winShowWhenLocked=(WindowState)mPolicy.getWinShowWhenLockedLw();
  if (winShowWhenLocked != null) {
    mLastShowWinWhenLocked=winShowWhenLocked;
  }
}