Program: 194595
Project: 194595
Buggy source:
/** 
 * Reads the proc file, calling into the callback with a delta of time for each UID.
 * @param callback The callback to invoke for each line of the proc file. If null,the data is consumed and subsequent calls to readDelta will provide a fresh delta.
 */
public void readDelta(@Nullable Callback callback){
  long now=SystemClock.elapsedRealtime();
  try (BufferedReader reader=new BufferedReader(new FileReader(sProcFile))){
    TextUtils.SimpleStringSplitter splitter=new TextUtils.SimpleStringSplitter(' ');
    String line;
    while ((line=reader.readLine()) != null) {
      splitter.setString(line);
      final String uidStr=splitter.next();
      final int uid=Integer.parseInt(uidStr.substring(0,uidStr.length() - 1),10);
      final long userTimeUs=Long.parseLong(splitter.next(),10);
      final long systemTimeUs=Long.parseLong(splitter.next(),10);
      if (callback != null) {
        long userTimeDeltaUs=userTimeUs;
        long systemTimeDeltaUs=systemTimeUs;
        int index=mLastUserTimeUs.indexOfKey(uid);
        if (index >= 0) {
          userTimeDeltaUs-=mLastUserTimeUs.valueAt(index);
          systemTimeDeltaUs-=mLastSystemTimeUs.valueAt(index);
          final long timeDiffMs=(now - mLastTimeRead) * 1000;
          if (userTimeDeltaUs < 0 || systemTimeDeltaUs < 0 || userTimeDeltaUs > timeDiffMs || systemTimeDeltaUs > timeDiffMs) {
            StringBuilder sb=new StringBuilder("String_Node_Str");
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(timeDiffMs,sb);
            sb.append("String_Node_Str");
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(mLastUserTimeUs.valueAt(index) / 1000,sb);
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(mLastSystemTimeUs.valueAt(index) / 1000,sb);
            sb.append("String_Node_Str");
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(userTimeUs / 1000,sb);
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(systemTimeUs / 1000,sb);
            sb.append("String_Node_Str");
            sb.append("String_Node_Str").append(uid).append("String_Node_Str");
            TimeUtils.formatDuration(userTimeDeltaUs / 1000,sb);
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(systemTimeDeltaUs / 1000,sb);
            sb.append("String_Node_Str");
            Slog.wtf(TAG,sb.toString());
            userTimeDeltaUs=0;
            systemTimeDeltaUs=0;
          }
        }
        if (userTimeDeltaUs != 0 || systemTimeDeltaUs != 0) {
          callback.onUidCpuTime(uid,userTimeDeltaUs,systemTimeDeltaUs);
        }
      }
      mLastUserTimeUs.put(uid,userTimeUs);
      mLastSystemTimeUs.put(uid,systemTimeUs);
    }
  }
 catch (  IOException e) {
    Slog.e(TAG,"String_Node_Str",e);
  }
  mLastTimeRead=now;
}

Fixed version (ground truth):
/** 
 * Reads the proc file, calling into the callback with a delta of time for each UID.
 * @param callback The callback to invoke for each line of the proc file. If null,the data is consumed and subsequent calls to readDelta will provide a fresh delta.
 */
public void readDelta(@Nullable Callback callback){
  long nowUs=SystemClock.elapsedRealtime() * 1000;
  try (BufferedReader reader=new BufferedReader(new FileReader(sProcFile))){
    TextUtils.SimpleStringSplitter splitter=new TextUtils.SimpleStringSplitter(' ');
    String line;
    while ((line=reader.readLine()) != null) {
      splitter.setString(line);
      final String uidStr=splitter.next();
      final int uid=Integer.parseInt(uidStr.substring(0,uidStr.length() - 1),10);
      final long userTimeUs=Long.parseLong(splitter.next(),10);
      final long systemTimeUs=Long.parseLong(splitter.next(),10);
      if (callback != null) {
        long userTimeDeltaUs=userTimeUs;
        long systemTimeDeltaUs=systemTimeUs;
        int index=mLastUserTimeUs.indexOfKey(uid);
        if (index >= 0) {
          userTimeDeltaUs-=mLastUserTimeUs.valueAt(index);
          systemTimeDeltaUs-=mLastSystemTimeUs.valueAt(index);
          final long timeDiffUs=nowUs - mLastTimeReadUs;
          if (userTimeDeltaUs < 0 || systemTimeDeltaUs < 0 || userTimeDeltaUs > timeDiffUs || systemTimeDeltaUs > timeDiffUs) {
            StringBuilder sb=new StringBuilder("String_Node_Str");
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(timeDiffUs / 1000,sb);
            sb.append("String_Node_Str");
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(mLastUserTimeUs.valueAt(index) / 1000,sb);
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(mLastSystemTimeUs.valueAt(index) / 1000,sb);
            sb.append("String_Node_Str");
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(userTimeUs / 1000,sb);
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(systemTimeUs / 1000,sb);
            sb.append("String_Node_Str");
            sb.append("String_Node_Str").append(uid).append("String_Node_Str");
            TimeUtils.formatDuration(userTimeDeltaUs / 1000,sb);
            sb.append("String_Node_Str");
            TimeUtils.formatDuration(systemTimeDeltaUs / 1000,sb);
            sb.append("String_Node_Str");
            Slog.wtf(TAG,sb.toString());
            userTimeDeltaUs=0;
            systemTimeDeltaUs=0;
          }
        }
        if (userTimeDeltaUs != 0 || systemTimeDeltaUs != 0) {
          callback.onUidCpuTime(uid,userTimeDeltaUs,systemTimeDeltaUs);
        }
      }
      mLastUserTimeUs.put(uid,userTimeUs);
      mLastSystemTimeUs.put(uid,systemTimeUs);
    }
  }
 catch (  IOException e) {
    Slog.e(TAG,"String_Node_Str",e);
  }
  mLastTimeReadUs=nowUs;
}