Program: 199074
Project: 199074
Buggy source:
private void updateWindowsLocked(final int displayId){
  ++mAnimTransactionSequence;
  final WindowList windows=mService.getWindowListLocked(displayId);
  ArrayList<WindowStateAnimator> unForceHiding=null;
  boolean wallpaperInUnForceHiding=false;
  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) {
          winAnimator.mAnimation=new AlphaAnimation(1.0f,1.0f);
          winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
          winAnimator.mAnimationIsEntrance=false;
        }
      }
 else {
        mKeyguardGoingAway=false;
        winAnimator.clearAnimation();
      }
      break;
    }
  }
  mForceHiding=KEYGUARD_NOT_SHOWN;
  for (int i=windows.size() - 1; i >= 0; i--) {
    WindowState win=windows.get(i);
    WindowStateAnimator winAnimator=win.mWinAnimator;
    final int flags=winAnimator.mAttrFlags;
    if (winAnimator.mSurfaceControl != null) {
      final boolean wasAnimating=winAnimator.mWasAnimating;
      final boolean nowAnimating=winAnimator.stepAnimationLocked(mCurrentTime);
      if (WindowManagerService.DEBUG_WALLPAPER) {
        Slog.v(TAG,win + "String_Node_Str" + wasAnimating+ "String_Node_Str"+ nowAnimating);
      }
      if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == win) {
        mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
        setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
          mService.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
        }
      }
      if (mPolicy.isForceHiding(win.mAttrs)) {
        if (!wasAnimating && nowAnimating) {
          if (WindowManagerService.DEBUG_ANIM || WindowManagerService.DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
          mBulkUpdateParams|=SET_FORCE_HIDING_CHANGED;
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            mService.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) {
            if (winAnimator.mAnimationIsEntrance) {
              mForceHiding=KEYGUARD_ANIMATING_IN;
            }
 else {
              mForceHiding=KEYGUARD_ANIMATING_OUT;
            }
          }
 else {
            mForceHiding=win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;
          }
        }
        if (WindowManagerService.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 (mPolicy.canBeForceHidden(win,win.mAttrs)) {
        final boolean hideWhenLocked=(winAnimator.mAttrFlags & FLAG_SHOW_WHEN_LOCKED) == 0;
        final boolean changed;
        if (((mForceHiding == KEYGUARD_ANIMATING_IN) && (!winAnimator.isAnimating() || hideWhenLocked)) || ((mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked)) {
          changed=win.hideLw(false,false);
          if (WindowManagerService.DEBUG_VISIBILITY && changed)           Slog.v(TAG,"String_Node_Str" + win);
        }
 else {
          changed=win.showLw(false,false);
          if (WindowManagerService.DEBUG_VISIBILITY && changed)           Slog.v(TAG,"String_Node_Str" + win);
          if (changed) {
            if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 && win.isVisibleNow()) {
              if (unForceHiding == null) {
                unForceHiding=new ArrayList<WindowStateAnimator>();
              }
              unForceHiding.add(winAnimator);
              if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                wallpaperInUnForceHiding=true;
              }
            }
            final WindowState currentFocus=mService.mCurrentFocus;
            if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
              if (WindowManagerService.DEBUG_FOCUS_LIGHT)               Slog.v(TAG,"String_Node_Str");
              mService.mFocusMayChange=true;
            }
          }
        }
        if (changed && (flags & FLAG_SHOW_WALLPAPER) != 0) {
          mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
          setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            mService.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
          }
        }
      }
    }
    final AppWindowToken atoken=win.mAppToken;
    if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
      if (atoken == null || atoken.allDrawn) {
        if (winAnimator.performShowLocked()) {
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
          if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            mService.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 (unForceHiding != null) {
    boolean startKeyguardExit=true;
    for (int i=unForceHiding.size() - 1; i >= 0; i--) {
      Animation a=mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding);
      if (a != null) {
        final WindowStateAnimator winAnimator=unForceHiding.get(i);
        winAnimator.setAnimation(a);
        winAnimator.mAnimationIsEntrance=true;
        if (startKeyguardExit) {
          mPolicy.startKeyguardExitAnimation(mCurrentTime + a.getStartOffset(),a.getDuration());
          mKeyguardGoingAway=false;
          startKeyguardExit=false;
        }
      }
    }
  }
}

Fixed version (ground truth):
private void updateWindowsLocked(final int displayId){
  ++mAnimTransactionSequence;
  final WindowList windows=mService.getWindowListLocked(displayId);
  ArrayList<WindowStateAnimator> unForceHiding=null;
  boolean wallpaperInUnForceHiding=false;
  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) {
          winAnimator.mAnimation=new AlphaAnimation(1.0f,1.0f);
          winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
          winAnimator.mAnimationIsEntrance=false;
        }
      }
 else {
        mKeyguardGoingAway=false;
        winAnimator.clearAnimation();
      }
      break;
    }
  }
  mForceHiding=KEYGUARD_NOT_SHOWN;
  for (int i=windows.size() - 1; i >= 0; i--) {
    WindowState win=windows.get(i);
    WindowStateAnimator winAnimator=win.mWinAnimator;
    final int flags=winAnimator.mAttrFlags;
    if (winAnimator.mSurfaceControl != null) {
      final boolean wasAnimating=winAnimator.mWasAnimating;
      final boolean nowAnimating=winAnimator.stepAnimationLocked(mCurrentTime);
      if (WindowManagerService.DEBUG_WALLPAPER) {
        Slog.v(TAG,win + "String_Node_Str" + wasAnimating+ "String_Node_Str"+ nowAnimating);
      }
      if (wasAnimating && !winAnimator.mAnimating && mService.mWallpaperTarget == win) {
        mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
        setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
        if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
          mService.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
        }
      }
      if (mPolicy.isForceHiding(win.mAttrs)) {
        if (!wasAnimating && nowAnimating) {
          if (WindowManagerService.DEBUG_ANIM || WindowManagerService.DEBUG_VISIBILITY)           Slog.v(TAG,"String_Node_Str" + win);
          mBulkUpdateParams|=SET_FORCE_HIDING_CHANGED;
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            mService.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) {
            if (winAnimator.mAnimationIsEntrance) {
              mForceHiding=KEYGUARD_ANIMATING_IN;
            }
 else {
              mForceHiding=KEYGUARD_ANIMATING_OUT;
            }
          }
 else {
            mForceHiding=win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;
          }
        }
        if (WindowManagerService.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 (mPolicy.canBeForceHidden(win,win.mAttrs)) {
        final boolean hideWhenLocked=(winAnimator.mAttrFlags & FLAG_SHOW_WHEN_LOCKED) == 0;
        final boolean changed;
        if (((mForceHiding == KEYGUARD_ANIMATING_IN) && (!winAnimator.isAnimating() || hideWhenLocked)) || ((mForceHiding == KEYGUARD_SHOWN) && hideWhenLocked)) {
          changed=win.hideLw(false,false);
          if (WindowManagerService.DEBUG_VISIBILITY && changed)           Slog.v(TAG,"String_Node_Str" + win);
        }
 else {
          changed=win.showLw(false,false);
          if (WindowManagerService.DEBUG_VISIBILITY && changed)           Slog.v(TAG,"String_Node_Str" + win);
          if (changed) {
            if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 && win.isVisibleNow()) {
              if (unForceHiding == null) {
                unForceHiding=new ArrayList<WindowStateAnimator>();
              }
              unForceHiding.add(winAnimator);
              if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                wallpaperInUnForceHiding=true;
              }
            }
            final WindowState currentFocus=mService.mCurrentFocus;
            if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
              if (WindowManagerService.DEBUG_FOCUS_LIGHT)               Slog.v(TAG,"String_Node_Str");
              mService.mFocusMayChange=true;
            }
          }
        }
        if (changed && (flags & FLAG_SHOW_WALLPAPER) != 0) {
          mBulkUpdateParams|=SET_WALLPAPER_MAY_CHANGE;
          setPendingLayoutChanges(Display.DEFAULT_DISPLAY,WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
          if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            mService.debugLayoutRepeats("String_Node_Str",getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
          }
        }
      }
    }
    final AppWindowToken atoken=win.mAppToken;
    if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) {
      if (atoken == null || atoken.allDrawn) {
        if (winAnimator.performShowLocked()) {
          setPendingLayoutChanges(displayId,WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
          if (WindowManagerService.DEBUG_LAYOUT_REPEATS) {
            mService.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 (unForceHiding != null) {
    boolean startKeyguardExit=true;
    for (int i=unForceHiding.size() - 1; i >= 0; i--) {
      Animation a=mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding);
      if (a != null) {
        final WindowStateAnimator winAnimator=unForceHiding.get(i);
        winAnimator.setAnimation(a);
        winAnimator.mAnimationIsEntrance=true;
        if (startKeyguardExit && mKeyguardGoingAway) {
          mPolicy.startKeyguardExitAnimation(mCurrentTime + a.getStartOffset(),a.getDuration());
          mKeyguardGoingAway=false;
          startKeyguardExit=false;
        }
      }
    }
  }
}