Program: 192393
Project: 192393
Buggy source:
@Override protected void dump(FileDescriptor fd,PrintWriter pw,String[] args){
  if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
    pw.println("String_Node_Str" + Binder.getCallingPid() + "String_Node_Str"+ Binder.getCallingUid()+ "String_Node_Str"+ android.Manifest.permission.DUMP);
    return;
  }
  int flags=0;
  boolean useCheckinFormat=false;
  boolean isRealCheckin=false;
  boolean noOutput=false;
  boolean writeData=false;
  long historyStart=-1;
  int reqUid=-1;
  if (args != null) {
    for (int i=0; i < args.length; i++) {
      String arg=args[i];
      if ("String_Node_Str".equals(arg)) {
        useCheckinFormat=true;
        isRealCheckin=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_HISTORY_ONLY;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_HISTORY_ONLY;
        i++;
        if (i >= args.length) {
          pw.println("String_Node_Str");
          dumpHelp(pw);
          return;
        }
        historyStart=Long.parseLong(args[i]);
        writeData=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        useCheckinFormat=true;
        flags|=BatteryStats.DUMP_INCLUDE_HISTORY;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_CHARGED_ONLY;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_DAILY_ONLY;
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mStats) {
          mStats.resetAllStatsCmdLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
        updateExternalStats("String_Node_Str",BatteryStatsImpl.ExternalStatsSync.UPDATE_ALL);
      }
 else       if ("String_Node_Str".equals(arg)) {
        updateExternalStats("String_Node_Str",BatteryStatsImpl.ExternalStatsSync.UPDATE_ALL);
synchronized (mStats) {
          mStats.writeSyncLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mStats) {
          mStats.recordDailyStatsLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mStats) {
          mStats.readDailyStatsLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
      }
 else       if ("String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
        i=doEnableOrDisable(pw,i,args,true);
        if (i < 0) {
          return;
        }
        pw.println("String_Node_Str" + args[i]);
        return;
      }
 else       if ("String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
        i=doEnableOrDisable(pw,i,args,false);
        if (i < 0) {
          return;
        }
        pw.println("String_Node_Str" + args[i]);
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
        dumpHelp(pw);
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_VERBOSE;
      }
 else       if (arg.length() > 0 && arg.charAt(0) == '-') {
        pw.println("String_Node_Str" + arg);
        dumpHelp(pw);
        return;
      }
 else {
        try {
          reqUid=mContext.getPackageManager().getPackageUidAsUser(arg,UserHandle.getCallingUserId());
        }
 catch (        PackageManager.NameNotFoundException e) {
          pw.println("String_Node_Str" + arg);
          dumpHelp(pw);
          return;
        }
      }
    }
  }
  if (noOutput) {
    return;
  }
  long ident=Binder.clearCallingIdentity();
  try {
    if (BatteryStatsHelper.checkWifiOnly(mContext)) {
      flags|=BatteryStats.DUMP_DEVICE_WIFI_ONLY;
    }
    updateExternalStats("String_Node_Str",BatteryStatsImpl.ExternalStatsSync.UPDATE_ALL);
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
  if (reqUid >= 0) {
    if ((flags & (BatteryStats.DUMP_HISTORY_ONLY | BatteryStats.DUMP_CHARGED_ONLY)) == 0) {
      flags|=BatteryStats.DUMP_CHARGED_ONLY;
      flags&=~BatteryStats.DUMP_INCLUDE_HISTORY;
    }
  }
  if (useCheckinFormat) {
    List<ApplicationInfo> apps=mContext.getPackageManager().getInstalledApplications(0);
    if (isRealCheckin) {
synchronized (mStats.mCheckinFile) {
        if (mStats.mCheckinFile.exists()) {
          try {
            byte[] raw=mStats.mCheckinFile.readFully();
            if (raw != null) {
              Parcel in=Parcel.obtain();
              in.unmarshall(raw,0,raw.length);
              in.setDataPosition(0);
              BatteryStatsImpl checkinStats=new BatteryStatsImpl(null,mStats.mHandler,null);
              checkinStats.readSummaryFromParcel(in);
              in.recycle();
              checkinStats.dumpCheckinLocked(mContext,pw,apps,flags,historyStart);
              mStats.mCheckinFile.delete();
              return;
            }
          }
 catch (          IOException|ParcelFormatException e) {
            Slog.w(TAG,"String_Node_Str" + mStats.mCheckinFile.getBaseFile(),e);
          }
        }
      }
    }
synchronized (mStats) {
      mStats.dumpCheckinLocked(mContext,pw,apps,flags,historyStart);
      if (writeData) {
        mStats.writeAsyncLocked();
      }
    }
  }
 else {
synchronized (mStats) {
      mStats.dumpLocked(mContext,pw,flags,reqUid,historyStart);
      if (writeData) {
        mStats.writeAsyncLocked();
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void dump(FileDescriptor fd,PrintWriter pw,String[] args){
  if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
    pw.println("String_Node_Str" + Binder.getCallingPid() + "String_Node_Str"+ Binder.getCallingUid()+ "String_Node_Str"+ android.Manifest.permission.DUMP);
    return;
  }
  int flags=0;
  boolean useCheckinFormat=false;
  boolean isRealCheckin=false;
  boolean noOutput=false;
  boolean writeData=false;
  long historyStart=-1;
  int reqUid=-1;
  if (args != null) {
    for (int i=0; i < args.length; i++) {
      String arg=args[i];
      if ("String_Node_Str".equals(arg)) {
        useCheckinFormat=true;
        isRealCheckin=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_HISTORY_ONLY;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_HISTORY_ONLY;
        i++;
        if (i >= args.length) {
          pw.println("String_Node_Str");
          dumpHelp(pw);
          return;
        }
        historyStart=Long.parseLong(args[i]);
        writeData=true;
      }
 else       if ("String_Node_Str".equals(arg)) {
        useCheckinFormat=true;
        flags|=BatteryStats.DUMP_INCLUDE_HISTORY;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_CHARGED_ONLY;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_DAILY_ONLY;
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mStats) {
          mStats.resetAllStatsCmdLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
        updateExternalStats("String_Node_Str",BatteryStatsImpl.ExternalStatsSync.UPDATE_ALL);
      }
 else       if ("String_Node_Str".equals(arg)) {
        updateExternalStats("String_Node_Str",BatteryStatsImpl.ExternalStatsSync.UPDATE_ALL);
synchronized (mStats) {
          mStats.writeSyncLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mStats) {
          mStats.recordDailyStatsLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
      }
 else       if ("String_Node_Str".equals(arg)) {
synchronized (mStats) {
          mStats.readDailyStatsLocked();
          pw.println("String_Node_Str");
          noOutput=true;
        }
      }
 else       if ("String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
        i=doEnableOrDisable(pw,i,args,true);
        if (i < 0) {
          return;
        }
        pw.println("String_Node_Str" + args[i]);
        return;
      }
 else       if ("String_Node_Str".equals(arg) || "String_Node_Str".equals(arg)) {
        i=doEnableOrDisable(pw,i,args,false);
        if (i < 0) {
          return;
        }
        pw.println("String_Node_Str" + args[i]);
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
        dumpHelp(pw);
        return;
      }
 else       if ("String_Node_Str".equals(arg)) {
        flags|=BatteryStats.DUMP_VERBOSE;
      }
 else       if (arg.length() > 0 && arg.charAt(0) == '-') {
        pw.println("String_Node_Str" + arg);
        dumpHelp(pw);
        return;
      }
 else {
        try {
          reqUid=mContext.getPackageManager().getPackageUidAsUser(arg,UserHandle.getCallingUserId());
        }
 catch (        PackageManager.NameNotFoundException e) {
          pw.println("String_Node_Str" + arg);
          dumpHelp(pw);
          return;
        }
      }
    }
  }
  if (noOutput) {
    return;
  }
  long ident=Binder.clearCallingIdentity();
  try {
    if (BatteryStatsHelper.checkWifiOnly(mContext)) {
      flags|=BatteryStats.DUMP_DEVICE_WIFI_ONLY;
    }
    updateExternalStats("String_Node_Str",BatteryStatsImpl.ExternalStatsSync.UPDATE_ALL);
  }
  finally {
    Binder.restoreCallingIdentity(ident);
  }
  if (reqUid >= 0) {
    if ((flags & (BatteryStats.DUMP_HISTORY_ONLY | BatteryStats.DUMP_CHARGED_ONLY)) == 0) {
      flags|=BatteryStats.DUMP_CHARGED_ONLY;
      flags&=~BatteryStats.DUMP_INCLUDE_HISTORY;
    }
  }
  if (useCheckinFormat) {
    List<ApplicationInfo> apps=mContext.getPackageManager().getInstalledApplications(PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_ALL);
    if (isRealCheckin) {
synchronized (mStats.mCheckinFile) {
        if (mStats.mCheckinFile.exists()) {
          try {
            byte[] raw=mStats.mCheckinFile.readFully();
            if (raw != null) {
              Parcel in=Parcel.obtain();
              in.unmarshall(raw,0,raw.length);
              in.setDataPosition(0);
              BatteryStatsImpl checkinStats=new BatteryStatsImpl(null,mStats.mHandler,null);
              checkinStats.readSummaryFromParcel(in);
              in.recycle();
              checkinStats.dumpCheckinLocked(mContext,pw,apps,flags,historyStart);
              mStats.mCheckinFile.delete();
              return;
            }
          }
 catch (          IOException|ParcelFormatException e) {
            Slog.w(TAG,"String_Node_Str" + mStats.mCheckinFile.getBaseFile(),e);
          }
        }
      }
    }
synchronized (mStats) {
      mStats.dumpCheckinLocked(mContext,pw,apps,flags,historyStart);
      if (writeData) {
        mStats.writeAsyncLocked();
      }
    }
  }
 else {
synchronized (mStats) {
      mStats.dumpLocked(mContext,pw,flags,reqUid,historyStart);
      if (writeData) {
        mStats.writeAsyncLocked();
      }
    }
  }
}