Program: 193228
Project: 193228
Buggy source:
private void updateWindowsLocked(final int displayId){
  ++mAnimTransactionSequence;
  final WindowList windows=mService.getWindowListLocked(displayId);
  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;
        }
      }
 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.mSurfaceController != null && winAnimator.mSurfaceController.hasSurface()) {
      final boolean wasAnimating=winAnimator.mWasAnimating;
      final boolean nowAnimating=winAnimator.stepAnimationLocked(mCurrentTime);
      winAnimator.mWasAnimating=nowAnimating;
      mAnimating|=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,mKeyguardGoingAwayToNotificationShade);
            winAnimator.setAnimation(a,mPostKeyguardExitAnimation.getStartTime());
            winAnimator.mKeyguardGoingAwayAnimation=true;
          }
          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 == WindowStateAnimator.READY_TO_SHOW) {
      if (atoken == null || atoken.allDrawn || atoken.mAnimatingWithSavedSurface) {
        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 (!mKeyguardGoingAwayDisableWindowAnimations) {
      boolean first=true;
      for (int i=unForceHiding.size() - 1; i >= 0; i--) {
        final WindowStateAnimator winAnimator=unForceHiding.get(i);
        Animation a=mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding && !startingInUnForceHiding,mKeyguardGoingAwayToNotificationShade);
        if (a != null) {
          if (DEBUG_KEYGUARD)           Slog.v(TAG,"String_Node_Str" + winAnimator.mWin);
          winAnimator.setAnimation(a);
          winAnimator.mKeyguardGoingAwayAnimation=true;
          if (first) {
            mPostKeyguardExitAnimation=a;
            mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
            first=false;
          }
        }
      }
    }
 else     if (mKeyguardGoingAway) {
      mPolicy.startKeyguardExitAnimation(mCurrentTime,0);
      mKeyguardGoingAway=false;
    }
    if (!wallpaperInUnForceHiding && wallpaper != null && !mKeyguardGoingAwayDisableWindowAnimations) {
      if (DEBUG_KEYGUARD)       Slog.d(TAG,"String_Node_Str");
      Animation a=mPolicy.createForceHideWallpaperExitAnimation(mKeyguardGoingAwayToNotificationShade);
      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);
  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;
        }
      }
 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.mSurfaceController != null && winAnimator.mSurfaceController.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,mKeyguardGoingAwayToNotificationShade);
            winAnimator.setAnimation(a,mPostKeyguardExitAnimation.getStartTime());
            winAnimator.mKeyguardGoingAwayAnimation=true;
          }
          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 == WindowStateAnimator.READY_TO_SHOW) {
      if (atoken == null || atoken.allDrawn || atoken.mAnimatingWithSavedSurface) {
        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 (!mKeyguardGoingAwayDisableWindowAnimations) {
      boolean first=true;
      for (int i=unForceHiding.size() - 1; i >= 0; i--) {
        final WindowStateAnimator winAnimator=unForceHiding.get(i);
        Animation a=mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding && !startingInUnForceHiding,mKeyguardGoingAwayToNotificationShade);
        if (a != null) {
          if (DEBUG_KEYGUARD)           Slog.v(TAG,"String_Node_Str" + winAnimator.mWin);
          winAnimator.setAnimation(a);
          winAnimator.mKeyguardGoingAwayAnimation=true;
          if (first) {
            mPostKeyguardExitAnimation=a;
            mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
            first=false;
          }
        }
      }
    }
 else     if (mKeyguardGoingAway) {
      mPolicy.startKeyguardExitAnimation(mCurrentTime,0);
      mKeyguardGoingAway=false;
    }
    if (!wallpaperInUnForceHiding && wallpaper != null && !mKeyguardGoingAwayDisableWindowAnimations) {
      if (DEBUG_KEYGUARD)       Slog.d(TAG,"String_Node_Str");
      Animation a=mPolicy.createForceHideWallpaperExitAnimation(mKeyguardGoingAwayToNotificationShade);
      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;
    }
  }
}