Program: 197975
Project: 197975
Buggy source:
@SuppressWarnings("String_Node_Str") void writeToParcelLocked(Parcel out,boolean inclUids,int flags){
  pullPendingStateUpdatesLocked();
  final long uSecUptime=SystemClock.uptimeMillis() * 1000;
  final long uSecRealtime=SystemClock.elapsedRealtime() * 1000;
  final long batteryRealtime=mOnBatteryTimeBase.getRealtime(uSecRealtime);
  final long batteryScreenOffRealtime=mOnBatteryScreenOffTimeBase.getRealtime(uSecRealtime);
  out.writeInt(MAGIC);
  writeHistory(out,true,false);
  out.writeInt(mStartCount);
  out.writeLong(mStartClockTime);
  out.writeString(mStartPlatformVersion);
  out.writeString(mEndPlatformVersion);
  out.writeLong(mUptime);
  out.writeLong(mUptimeStart);
  out.writeLong(mRealtime);
  out.writeLong(mRealtimeStart);
  out.writeInt(mOnBattery ? 1 : 0);
  mOnBatteryTimeBase.writeToParcel(out,uSecUptime,uSecRealtime);
  mOnBatteryScreenOffTimeBase.writeToParcel(out,uSecUptime,uSecRealtime);
  mScreenOnTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) {
    mScreenBrightnessTimer[i].writeToParcel(out,uSecRealtime);
  }
  mInteractiveTimer.writeToParcel(out,uSecRealtime);
  mLowPowerModeEnabledTimer.writeToParcel(out,uSecRealtime);
  mPhoneOnTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
    mPhoneSignalStrengthsTimer[i].writeToParcel(out,uSecRealtime);
  }
  mPhoneSignalScanningTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_DATA_CONNECTION_TYPES; i++) {
    mPhoneDataConnectionsTimer[i].writeToParcel(out,uSecRealtime);
  }
  for (int i=0; i < NUM_NETWORK_ACTIVITY_TYPES; i++) {
    mNetworkByteActivityCounters[i].writeToParcel(out);
    mNetworkPacketActivityCounters[i].writeToParcel(out);
  }
  mMobileRadioActiveTimer.writeToParcel(out,uSecRealtime);
  mMobileRadioActivePerAppTimer.writeToParcel(out,uSecRealtime);
  mMobileRadioActiveAdjustedTime.writeToParcel(out);
  mMobileRadioActiveUnknownTime.writeToParcel(out);
  mMobileRadioActiveUnknownCount.writeToParcel(out);
  mWifiOnTimer.writeToParcel(out,uSecRealtime);
  mGlobalWifiRunningTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_WIFI_STATES; i++) {
    mWifiStateTimer[i].writeToParcel(out,uSecRealtime);
  }
  for (int i=0; i < NUM_WIFI_SUPPL_STATES; i++) {
    mWifiSupplStateTimer[i].writeToParcel(out,uSecRealtime);
  }
  for (int i=0; i < NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
    mWifiSignalStrengthsTimer[i].writeToParcel(out,uSecRealtime);
  }
  mBluetoothOnTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_BLUETOOTH_STATES; i++) {
    mBluetoothStateTimer[i].writeToParcel(out,uSecRealtime);
  }
  mFlashlightOnTimer.writeToParcel(out,uSecRealtime);
  out.writeInt(mDischargeUnplugLevel);
  out.writeInt(mDischargePlugLevel);
  out.writeInt(mDischargeCurrentLevel);
  out.writeInt(mCurrentBatteryLevel);
  out.writeInt(mLowDischargeAmountSinceCharge);
  out.writeInt(mHighDischargeAmountSinceCharge);
  out.writeInt(mDischargeAmountScreenOn);
  out.writeInt(mDischargeAmountScreenOnSinceCharge);
  out.writeInt(mDischargeAmountScreenOff);
  out.writeInt(mDischargeAmountScreenOffSinceCharge);
  out.writeInt(mNumDischargeStepDurations);
  out.writeLongArray(mDischargeStepDurations);
  out.writeInt(mNumChargeStepDurations);
  out.writeLongArray(mChargeStepDurations);
  out.writeLong(mLastWriteTime);
  out.writeInt(getBluetoothPingCount());
  if (inclUids) {
    out.writeInt(mKernelWakelockStats.size());
    for (    Map.Entry<String,SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
      SamplingTimer kwlt=ent.getValue();
      if (kwlt != null) {
        out.writeInt(1);
        out.writeString(ent.getKey());
        kwlt.writeToParcel(out,uSecRealtime);
      }
 else {
        out.writeInt(0);
      }
    }
    out.writeInt(mWakeupReasonStats.size());
    for (    Map.Entry<String,LongSamplingCounter> ent : mWakeupReasonStats.entrySet()) {
      LongSamplingCounter counter=ent.getValue();
      if (counter != null) {
        out.writeInt(1);
        out.writeString(ent.getKey());
        counter.writeToParcel(out);
      }
 else {
        out.writeInt(0);
      }
    }
  }
 else {
    out.writeInt(0);
  }
  out.writeInt(sNumSpeedSteps);
  if (inclUids) {
    int size=mUidStats.size();
    out.writeInt(size);
    for (int i=0; i < size; i++) {
      out.writeInt(mUidStats.keyAt(i));
      Uid uid=mUidStats.valueAt(i);
      uid.writeToParcelLocked(out,uSecRealtime);
    }
  }
 else {
    out.writeInt(0);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") void writeToParcelLocked(Parcel out,boolean inclUids,int flags){
  pullPendingStateUpdatesLocked();
  long startClockTime=getStartClockTime();
  final long uSecUptime=SystemClock.uptimeMillis() * 1000;
  final long uSecRealtime=SystemClock.elapsedRealtime() * 1000;
  final long batteryRealtime=mOnBatteryTimeBase.getRealtime(uSecRealtime);
  final long batteryScreenOffRealtime=mOnBatteryScreenOffTimeBase.getRealtime(uSecRealtime);
  out.writeInt(MAGIC);
  writeHistory(out,true,false);
  out.writeInt(mStartCount);
  out.writeLong(startClockTime);
  out.writeString(mStartPlatformVersion);
  out.writeString(mEndPlatformVersion);
  out.writeLong(mUptime);
  out.writeLong(mUptimeStart);
  out.writeLong(mRealtime);
  out.writeLong(mRealtimeStart);
  out.writeInt(mOnBattery ? 1 : 0);
  mOnBatteryTimeBase.writeToParcel(out,uSecUptime,uSecRealtime);
  mOnBatteryScreenOffTimeBase.writeToParcel(out,uSecUptime,uSecRealtime);
  mScreenOnTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) {
    mScreenBrightnessTimer[i].writeToParcel(out,uSecRealtime);
  }
  mInteractiveTimer.writeToParcel(out,uSecRealtime);
  mLowPowerModeEnabledTimer.writeToParcel(out,uSecRealtime);
  mPhoneOnTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
    mPhoneSignalStrengthsTimer[i].writeToParcel(out,uSecRealtime);
  }
  mPhoneSignalScanningTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_DATA_CONNECTION_TYPES; i++) {
    mPhoneDataConnectionsTimer[i].writeToParcel(out,uSecRealtime);
  }
  for (int i=0; i < NUM_NETWORK_ACTIVITY_TYPES; i++) {
    mNetworkByteActivityCounters[i].writeToParcel(out);
    mNetworkPacketActivityCounters[i].writeToParcel(out);
  }
  mMobileRadioActiveTimer.writeToParcel(out,uSecRealtime);
  mMobileRadioActivePerAppTimer.writeToParcel(out,uSecRealtime);
  mMobileRadioActiveAdjustedTime.writeToParcel(out);
  mMobileRadioActiveUnknownTime.writeToParcel(out);
  mMobileRadioActiveUnknownCount.writeToParcel(out);
  mWifiOnTimer.writeToParcel(out,uSecRealtime);
  mGlobalWifiRunningTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_WIFI_STATES; i++) {
    mWifiStateTimer[i].writeToParcel(out,uSecRealtime);
  }
  for (int i=0; i < NUM_WIFI_SUPPL_STATES; i++) {
    mWifiSupplStateTimer[i].writeToParcel(out,uSecRealtime);
  }
  for (int i=0; i < NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
    mWifiSignalStrengthsTimer[i].writeToParcel(out,uSecRealtime);
  }
  mBluetoothOnTimer.writeToParcel(out,uSecRealtime);
  for (int i=0; i < NUM_BLUETOOTH_STATES; i++) {
    mBluetoothStateTimer[i].writeToParcel(out,uSecRealtime);
  }
  mFlashlightOnTimer.writeToParcel(out,uSecRealtime);
  out.writeInt(mDischargeUnplugLevel);
  out.writeInt(mDischargePlugLevel);
  out.writeInt(mDischargeCurrentLevel);
  out.writeInt(mCurrentBatteryLevel);
  out.writeInt(mLowDischargeAmountSinceCharge);
  out.writeInt(mHighDischargeAmountSinceCharge);
  out.writeInt(mDischargeAmountScreenOn);
  out.writeInt(mDischargeAmountScreenOnSinceCharge);
  out.writeInt(mDischargeAmountScreenOff);
  out.writeInt(mDischargeAmountScreenOffSinceCharge);
  out.writeInt(mNumDischargeStepDurations);
  out.writeLongArray(mDischargeStepDurations);
  out.writeInt(mNumChargeStepDurations);
  out.writeLongArray(mChargeStepDurations);
  out.writeLong(mLastWriteTime);
  out.writeInt(getBluetoothPingCount());
  if (inclUids) {
    out.writeInt(mKernelWakelockStats.size());
    for (    Map.Entry<String,SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
      SamplingTimer kwlt=ent.getValue();
      if (kwlt != null) {
        out.writeInt(1);
        out.writeString(ent.getKey());
        kwlt.writeToParcel(out,uSecRealtime);
      }
 else {
        out.writeInt(0);
      }
    }
    out.writeInt(mWakeupReasonStats.size());
    for (    Map.Entry<String,LongSamplingCounter> ent : mWakeupReasonStats.entrySet()) {
      LongSamplingCounter counter=ent.getValue();
      if (counter != null) {
        out.writeInt(1);
        out.writeString(ent.getKey());
        counter.writeToParcel(out);
      }
 else {
        out.writeInt(0);
      }
    }
  }
 else {
    out.writeInt(0);
  }
  out.writeInt(sNumSpeedSteps);
  if (inclUids) {
    int size=mUidStats.size();
    out.writeInt(size);
    for (int i=0; i < size; i++) {
      out.writeInt(mUidStats.keyAt(i));
      Uid uid=mUidStats.valueAt(i);
      uid.writeToParcelLocked(out,uSecRealtime);
    }
  }
 else {
    out.writeInt(0);
  }
}