Program: 198601
Project: 198601
Buggy source:
@SuppressWarnings("String_Node_Str") public void dumpCheckinLocked(Context context,PrintWriter pw,List<ApplicationInfo> apps,int flags,long histStart){
  prepareForDumpLocked();
  long now=getHistoryBaseTime() + SystemClock.elapsedRealtime();
  final boolean filtering=(flags & (DUMP_HISTORY_ONLY | DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) != 0;
  if ((flags & DUMP_INCLUDE_HISTORY) != 0 || (flags & DUMP_HISTORY_ONLY) != 0) {
    if (startIteratingHistoryLocked()) {
      try {
        for (int i=0; i < getHistoryStringPoolSize(); i++) {
          pw.print(BATTERY_STATS_CHECKIN_VERSION);
          pw.print(',');
          pw.print(HISTORY_STRING_POOL);
          pw.print(',');
          pw.print(i);
          pw.print("String_Node_Str");
          pw.print(getHistoryTagPoolUid(i));
          pw.print("String_Node_Str");
          String str=getHistoryTagPoolString(i);
          str=str.replace("String_Node_Str","String_Node_Str");
          str=str.replace("String_Node_Str","String_Node_Str");
          pw.print(str);
          pw.print("String_Node_Str");
          pw.println();
        }
        dumpHistoryLocked(pw,flags,histStart,true);
      }
  finally {
        finishIteratingHistoryLocked();
      }
    }
  }
  if (filtering && (flags & (DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) == 0) {
    return;
  }
  if (apps != null) {
    SparseArray<ArrayList<String>> uids=new SparseArray<ArrayList<String>>();
    for (int i=0; i < apps.size(); i++) {
      ApplicationInfo ai=apps.get(i);
      ArrayList<String> pkgs=uids.get(ai.uid);
      if (pkgs == null) {
        pkgs=new ArrayList<String>();
        uids.put(ai.uid,pkgs);
      }
      pkgs.add(ai.packageName);
    }
    SparseArray<? extends Uid> uidStats=getUidStats();
    final int NU=uidStats.size();
    String[] lineArgs=new String[2];
    for (int i=0; i < NU; i++) {
      int uid=uidStats.keyAt(i);
      ArrayList<String> pkgs=uids.get(uid);
      if (pkgs != null) {
        for (int j=0; j < pkgs.size(); j++) {
          lineArgs[0]=Integer.toString(uid);
          lineArgs[1]=pkgs.get(j);
          dumpLine(pw,0,"String_Node_Str",UID_DATA,(Object[])lineArgs);
        }
      }
    }
  }
  if (!filtering) {
    dumpDurationSteps(pw,DISCHARGE_STEP_DATA,getDischargeStepDurationsArray(),getNumDischargeStepDurations(),true);
    String[] lineArgs=new String[1];
    long timeRemaining=computeBatteryTimeRemaining(SystemClock.elapsedRealtime());
    if (timeRemaining >= 0) {
      lineArgs[0]=Long.toString(timeRemaining);
      dumpLine(pw,0,"String_Node_Str",DISCHARGE_TIME_REMAIN_DATA,(Object[])lineArgs);
    }
    dumpDurationSteps(pw,CHARGE_STEP_DATA,getChargeStepDurationsArray(),getNumChargeStepDurations(),true);
    timeRemaining=computeChargeTimeRemaining(SystemClock.elapsedRealtime());
    if (timeRemaining >= 0) {
      lineArgs[0]=Long.toString(timeRemaining);
      dumpLine(pw,0,"String_Node_Str",CHARGE_TIME_REMAIN_DATA,(Object[])lineArgs);
    }
  }
  if (!filtering || (flags & DUMP_CHARGED_ONLY) != 0) {
    dumpCheckinLocked(context,pw,STATS_SINCE_CHARGED,-1);
  }
  if (!filtering || (flags & DUMP_UNPLUGGED_ONLY) != 0) {
    dumpCheckinLocked(context,pw,STATS_SINCE_UNPLUGGED,-1);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void dumpCheckinLocked(Context context,PrintWriter pw,List<ApplicationInfo> apps,int flags,long histStart){
  prepareForDumpLocked();
  dumpLine(pw,0,"String_Node_Str",VERSION_DATA,"String_Node_Str",getParcelVersion(),getStartPlatformVersion(),getEndPlatformVersion());
  long now=getHistoryBaseTime() + SystemClock.elapsedRealtime();
  final boolean filtering=(flags & (DUMP_HISTORY_ONLY | DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) != 0;
  if ((flags & DUMP_INCLUDE_HISTORY) != 0 || (flags & DUMP_HISTORY_ONLY) != 0) {
    if (startIteratingHistoryLocked()) {
      try {
        for (int i=0; i < getHistoryStringPoolSize(); i++) {
          pw.print(BATTERY_STATS_CHECKIN_VERSION);
          pw.print(',');
          pw.print(HISTORY_STRING_POOL);
          pw.print(',');
          pw.print(i);
          pw.print("String_Node_Str");
          pw.print(getHistoryTagPoolUid(i));
          pw.print("String_Node_Str");
          String str=getHistoryTagPoolString(i);
          str=str.replace("String_Node_Str","String_Node_Str");
          str=str.replace("String_Node_Str","String_Node_Str");
          pw.print(str);
          pw.print("String_Node_Str");
          pw.println();
        }
        dumpHistoryLocked(pw,flags,histStart,true);
      }
  finally {
        finishIteratingHistoryLocked();
      }
    }
  }
  if (filtering && (flags & (DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) == 0) {
    return;
  }
  if (apps != null) {
    SparseArray<ArrayList<String>> uids=new SparseArray<ArrayList<String>>();
    for (int i=0; i < apps.size(); i++) {
      ApplicationInfo ai=apps.get(i);
      ArrayList<String> pkgs=uids.get(ai.uid);
      if (pkgs == null) {
        pkgs=new ArrayList<String>();
        uids.put(ai.uid,pkgs);
      }
      pkgs.add(ai.packageName);
    }
    SparseArray<? extends Uid> uidStats=getUidStats();
    final int NU=uidStats.size();
    String[] lineArgs=new String[2];
    for (int i=0; i < NU; i++) {
      int uid=uidStats.keyAt(i);
      ArrayList<String> pkgs=uids.get(uid);
      if (pkgs != null) {
        for (int j=0; j < pkgs.size(); j++) {
          lineArgs[0]=Integer.toString(uid);
          lineArgs[1]=pkgs.get(j);
          dumpLine(pw,0,"String_Node_Str",UID_DATA,(Object[])lineArgs);
        }
      }
    }
  }
  if (!filtering || (flags & DUMP_CHARGED_ONLY) != 0) {
    dumpDurationSteps(pw,DISCHARGE_STEP_DATA,getDischargeStepDurationsArray(),getNumDischargeStepDurations(),true);
    String[] lineArgs=new String[1];
    long timeRemaining=computeBatteryTimeRemaining(SystemClock.elapsedRealtime());
    if (timeRemaining >= 0) {
      lineArgs[0]=Long.toString(timeRemaining);
      dumpLine(pw,0,"String_Node_Str",DISCHARGE_TIME_REMAIN_DATA,(Object[])lineArgs);
    }
    dumpDurationSteps(pw,CHARGE_STEP_DATA,getChargeStepDurationsArray(),getNumChargeStepDurations(),true);
    timeRemaining=computeChargeTimeRemaining(SystemClock.elapsedRealtime());
    if (timeRemaining >= 0) {
      lineArgs[0]=Long.toString(timeRemaining);
      dumpLine(pw,0,"String_Node_Str",CHARGE_TIME_REMAIN_DATA,(Object[])lineArgs);
    }
    dumpCheckinLocked(context,pw,STATS_SINCE_CHARGED,-1);
  }
  if (!filtering || (flags & DUMP_UNPLUGGED_ONLY) != 0) {
    dumpCheckinLocked(context,pw,STATS_SINCE_UNPLUGGED,-1);
  }
}