Program: 1956
Project: 1956
Buggy source:
private boolean updateFocusedWindowLocked(int mode,boolean updateInputWindows){
  WindowState newFocus=computeFocusedWindowLocked();
  if (mCurrentFocus != newFocus) {
    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER,"String_Node_Str");
    mH.removeMessages(H.REPORT_FOCUS_CHANGE);
    mH.sendEmptyMessage(H.REPORT_FOCUS_CHANGE);
    if (localLOGV)     Slog.v(TAG,"String_Node_Str" + mCurrentFocus + "String_Node_Str"+ newFocus);
    final WindowState oldFocus=mCurrentFocus;
    mCurrentFocus=newFocus;
    mLosingFocus.remove(newFocus);
    int focusChanged=mPolicy.focusChangedLw(oldFocus,newFocus);
    final DisplayContent displayContent=getDefaultDisplayContentLocked();
    final WindowState imWindow=mInputMethodWindow;
    if (newFocus != imWindow && oldFocus != imWindow) {
      if (moveInputMethodWindowsIfNeededLocked(mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS && mode != UPDATE_FOCUS_WILL_PLACE_SURFACES)) {
        displayContent.layoutNeeded=true;
      }
      if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
        performLayoutLockedInner(displayContent,true,updateInputWindows);
        focusChanged&=~WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
      }
 else       if (mode == UPDATE_FOCUS_WILL_PLACE_SURFACES) {
        assignLayersLocked(displayContent.getWindowList());
      }
    }
    if ((focusChanged & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
      displayContent.layoutNeeded=true;
      if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
        performLayoutLockedInner(displayContent,true,updateInputWindows);
      }
    }
    if (mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS) {
      finishUpdateFocusedWindowAfterAssignLayersLocked(updateInputWindows);
    }
    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean updateFocusedWindowLocked(int mode,boolean updateInputWindows){
  WindowState newFocus=computeFocusedWindowLocked();
  if (mCurrentFocus != newFocus) {
    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER,"String_Node_Str");
    mH.removeMessages(H.REPORT_FOCUS_CHANGE);
    mH.sendEmptyMessage(H.REPORT_FOCUS_CHANGE);
    final DisplayContent displayContent=getDefaultDisplayContentLocked();
    final boolean imWindowChanged=moveInputMethodWindowsIfNeededLocked(mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS && mode != UPDATE_FOCUS_WILL_PLACE_SURFACES);
    if (imWindowChanged) {
      displayContent.layoutNeeded=true;
      newFocus=computeFocusedWindowLocked();
    }
    if (localLOGV)     Slog.v(TAG,"String_Node_Str" + mCurrentFocus + "String_Node_Str"+ newFocus);
    final WindowState oldFocus=mCurrentFocus;
    mCurrentFocus=newFocus;
    mLosingFocus.remove(newFocus);
    int focusChanged=mPolicy.focusChangedLw(oldFocus,newFocus);
    final WindowState imWindow=mInputMethodWindow;
    if (imWindowChanged && oldFocus != imWindow) {
      if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
        performLayoutLockedInner(displayContent,true,updateInputWindows);
        focusChanged&=~WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
      }
 else       if (mode == UPDATE_FOCUS_WILL_PLACE_SURFACES) {
        assignLayersLocked(displayContent.getWindowList());
      }
    }
    if ((focusChanged & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
      displayContent.layoutNeeded=true;
      if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
        performLayoutLockedInner(displayContent,true,updateInputWindows);
      }
    }
    if (mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS) {
      finishUpdateFocusedWindowAfterAssignLayersLocked(updateInputWindows);
    }
    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
    return true;
  }
  return false;
}