Program: 196057
Project: 196057
Buggy source:
/** 
 * Calls   {@link CheckinAction#checkin(IntervalStats)} on the given {@link CheckinAction}for all   {@link IntervalStats} that haven't been checked-in.If any of the calls to  {@link CheckinAction#checkin(IntervalStats)} returns false or throwsan exception, the check-in will be aborted.
 * @param checkinAction The callback to run when checking-in {@link IntervalStats}.
 * @return true if the check-in succeeded.
 */
public boolean checkinDailyFiles(CheckinAction checkinAction){
synchronized (mLock) {
    final TimeSparseArray<AtomicFile> files=mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY];
    final int fileCount=files.size();
    int start=0;
    while (start < fileCount - 1) {
      if (!files.valueAt(start).getBaseFile().getName().endsWith("String_Node_Str")) {
        break;
      }
    }
    if (start == fileCount - 1) {
      return true;
    }
    try {
      IntervalStats stats=new IntervalStats();
      for (int i=start; i < fileCount - 1; i++) {
        UsageStatsXml.read(files.valueAt(i),stats);
        if (!checkinAction.checkin(stats)) {
          return false;
        }
      }
    }
 catch (    IOException e) {
      Slog.e(TAG,"String_Node_Str",e);
      return false;
    }
    for (int i=start; i < fileCount - 1; i++) {
      final AtomicFile file=files.valueAt(i);
      final File checkedInFile=new File(file.getBaseFile().getParent(),file.getBaseFile().getName() + "String_Node_Str");
      if (!file.getBaseFile().renameTo(checkedInFile)) {
        Slog.e(TAG,"String_Node_Str" + file.getBaseFile().getPath() + "String_Node_Str");
        return true;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Calls   {@link CheckinAction#checkin(IntervalStats)} on the given {@link CheckinAction}for all   {@link IntervalStats} that haven't been checked-in.If any of the calls to  {@link CheckinAction#checkin(IntervalStats)} returns false or throwsan exception, the check-in will be aborted.
 * @param checkinAction The callback to run when checking-in {@link IntervalStats}.
 * @return true if the check-in succeeded.
 */
public boolean checkinDailyFiles(CheckinAction checkinAction){
synchronized (mLock) {
    final TimeSparseArray<AtomicFile> files=mSortedStatFiles[UsageStatsManager.INTERVAL_DAILY];
    final int fileCount=files.size();
    int start=0;
    while (start < fileCount - 1) {
      if (!files.valueAt(start).getBaseFile().getName().endsWith("String_Node_Str")) {
        break;
      }
      start++;
    }
    if (start == fileCount - 1) {
      return true;
    }
    try {
      IntervalStats stats=new IntervalStats();
      for (int i=start; i < fileCount - 1; i++) {
        UsageStatsXml.read(files.valueAt(i),stats);
        if (!checkinAction.checkin(stats)) {
          return false;
        }
      }
    }
 catch (    IOException e) {
      Slog.e(TAG,"String_Node_Str",e);
      return false;
    }
    for (int i=start; i < fileCount - 1; i++) {
      final AtomicFile file=files.valueAt(i);
      final File checkedInFile=new File(file.getBaseFile().getParent(),file.getBaseFile().getName() + "String_Node_Str");
      if (!file.getBaseFile().renameTo(checkedInFile)) {
        Slog.e(TAG,"String_Node_Str" + file.getBaseFile().getPath() + "String_Node_Str");
        return true;
      }
    }
  }
  return true;
}