Program: 191417
Project: 191417
Buggy source:
private void resetAllStatsLocked(){
  mStartCount=0;
  initTimes(mClocks.uptimeMillis() * 1000,mClocks.elapsedRealtime() * 1000);
  mScreenOnTimer.reset(false);
  for (int i=0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) {
    mScreenBrightnessTimer[i].reset(false);
  }
  mInteractiveTimer.reset(false);
  mPowerSaveModeEnabledTimer.reset(false);
  mLongestLightIdleTime=0;
  mLongestFullIdleTime=0;
  mDeviceIdleModeLightTimer.reset(false);
  mDeviceIdleModeFullTimer.reset(false);
  mDeviceLightIdlingTimer.reset(false);
  mDeviceIdlingTimer.reset(false);
  mPhoneOnTimer.reset(false);
  mAudioOnTimer.reset(false);
  mVideoOnTimer.reset(false);
  mFlashlightOnTimer.reset(false);
  mCameraOnTimer.reset(false);
  mBluetoothScanTimer.reset(false);
  for (int i=0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
    mPhoneSignalStrengthsTimer[i].reset(false);
  }
  mPhoneSignalScanningTimer.reset(false);
  for (int i=0; i < NUM_DATA_CONNECTION_TYPES; i++) {
    mPhoneDataConnectionsTimer[i].reset(false);
  }
  for (int i=0; i < NUM_NETWORK_ACTIVITY_TYPES; i++) {
    mNetworkByteActivityCounters[i].reset(false);
    mNetworkPacketActivityCounters[i].reset(false);
  }
  mMobileRadioActiveTimer.reset(false);
  mMobileRadioActivePerAppTimer.reset(false);
  mMobileRadioActiveAdjustedTime.reset(false);
  mMobileRadioActiveUnknownTime.reset(false);
  mMobileRadioActiveUnknownCount.reset(false);
  mWifiOnTimer.reset(false);
  mGlobalWifiRunningTimer.reset(false);
  for (int i=0; i < NUM_WIFI_STATES; i++) {
    mWifiStateTimer[i].reset(false);
  }
  for (int i=0; i < NUM_WIFI_SUPPL_STATES; i++) {
    mWifiSupplStateTimer[i].reset(false);
  }
  for (int i=0; i < NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
    mWifiSignalStrengthsTimer[i].reset(false);
  }
  mWifiActivity.reset(false);
  mBluetoothActivity.reset(false);
  mModemActivity.reset(false);
  mNumConnectivityChange=mLoadedNumConnectivityChange=mUnpluggedNumConnectivityChange=0;
  for (int i=0; i < mUidStats.size(); i++) {
    if (mUidStats.valueAt(i).reset()) {
      mUidStats.remove(mUidStats.keyAt(i));
      i--;
    }
  }
  if (mKernelWakelockStats.size() > 0) {
    for (    SamplingTimer timer : mKernelWakelockStats.values()) {
      mOnBatteryScreenOffTimeBase.remove(timer);
    }
    mKernelWakelockStats.clear();
  }
  if (mWakeupReasonStats.size() > 0) {
    for (    SamplingTimer timer : mWakeupReasonStats.values()) {
      mOnBatteryTimeBase.remove(timer);
    }
    mWakeupReasonStats.clear();
  }
  mLastHistoryStepDetails=null;
  mLastStepCpuUserTime=mLastStepCpuSystemTime=0;
  mCurStepCpuUserTime=mCurStepCpuSystemTime=0;
  mLastStepCpuUserTime=mCurStepCpuUserTime=0;
  mLastStepCpuSystemTime=mCurStepCpuSystemTime=0;
  mLastStepStatUserTime=mCurStepStatUserTime=0;
  mLastStepStatSystemTime=mCurStepStatSystemTime=0;
  mLastStepStatIOWaitTime=mCurStepStatIOWaitTime=0;
  mLastStepStatIrqTime=mCurStepStatIrqTime=0;
  mLastStepStatSoftIrqTime=mCurStepStatSoftIrqTime=0;
  mLastStepStatIdleTime=mCurStepStatIdleTime=0;
  initDischarge();
  clearHistoryLocked();
}

Fixed version (ground truth):
private void resetAllStatsLocked(){
  final long uptimeMillis=mClocks.uptimeMillis();
  final long elapsedRealtimeMillis=mClocks.elapsedRealtime();
  mStartCount=0;
  initTimes(uptimeMillis * 1000,elapsedRealtimeMillis * 1000);
  mScreenOnTimer.reset(false);
  for (int i=0; i < NUM_SCREEN_BRIGHTNESS_BINS; i++) {
    mScreenBrightnessTimer[i].reset(false);
  }
  mInteractiveTimer.reset(false);
  mPowerSaveModeEnabledTimer.reset(false);
  mLastIdleTimeStart=elapsedRealtimeMillis;
  mLongestLightIdleTime=0;
  mLongestFullIdleTime=0;
  mDeviceIdleModeLightTimer.reset(false);
  mDeviceIdleModeFullTimer.reset(false);
  mDeviceLightIdlingTimer.reset(false);
  mDeviceIdlingTimer.reset(false);
  mPhoneOnTimer.reset(false);
  mAudioOnTimer.reset(false);
  mVideoOnTimer.reset(false);
  mFlashlightOnTimer.reset(false);
  mCameraOnTimer.reset(false);
  mBluetoothScanTimer.reset(false);
  for (int i=0; i < SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
    mPhoneSignalStrengthsTimer[i].reset(false);
  }
  mPhoneSignalScanningTimer.reset(false);
  for (int i=0; i < NUM_DATA_CONNECTION_TYPES; i++) {
    mPhoneDataConnectionsTimer[i].reset(false);
  }
  for (int i=0; i < NUM_NETWORK_ACTIVITY_TYPES; i++) {
    mNetworkByteActivityCounters[i].reset(false);
    mNetworkPacketActivityCounters[i].reset(false);
  }
  mMobileRadioActiveTimer.reset(false);
  mMobileRadioActivePerAppTimer.reset(false);
  mMobileRadioActiveAdjustedTime.reset(false);
  mMobileRadioActiveUnknownTime.reset(false);
  mMobileRadioActiveUnknownCount.reset(false);
  mWifiOnTimer.reset(false);
  mGlobalWifiRunningTimer.reset(false);
  for (int i=0; i < NUM_WIFI_STATES; i++) {
    mWifiStateTimer[i].reset(false);
  }
  for (int i=0; i < NUM_WIFI_SUPPL_STATES; i++) {
    mWifiSupplStateTimer[i].reset(false);
  }
  for (int i=0; i < NUM_WIFI_SIGNAL_STRENGTH_BINS; i++) {
    mWifiSignalStrengthsTimer[i].reset(false);
  }
  mWifiActivity.reset(false);
  mBluetoothActivity.reset(false);
  mModemActivity.reset(false);
  mNumConnectivityChange=mLoadedNumConnectivityChange=mUnpluggedNumConnectivityChange=0;
  for (int i=0; i < mUidStats.size(); i++) {
    if (mUidStats.valueAt(i).reset()) {
      mUidStats.remove(mUidStats.keyAt(i));
      i--;
    }
  }
  if (mKernelWakelockStats.size() > 0) {
    for (    SamplingTimer timer : mKernelWakelockStats.values()) {
      mOnBatteryScreenOffTimeBase.remove(timer);
    }
    mKernelWakelockStats.clear();
  }
  if (mWakeupReasonStats.size() > 0) {
    for (    SamplingTimer timer : mWakeupReasonStats.values()) {
      mOnBatteryTimeBase.remove(timer);
    }
    mWakeupReasonStats.clear();
  }
  mLastHistoryStepDetails=null;
  mLastStepCpuUserTime=mLastStepCpuSystemTime=0;
  mCurStepCpuUserTime=mCurStepCpuSystemTime=0;
  mLastStepCpuUserTime=mCurStepCpuUserTime=0;
  mLastStepCpuSystemTime=mCurStepCpuSystemTime=0;
  mLastStepStatUserTime=mCurStepStatUserTime=0;
  mLastStepStatSystemTime=mCurStepStatSystemTime=0;
  mLastStepStatIOWaitTime=mCurStepStatIOWaitTime=0;
  mLastStepStatIrqTime=mCurStepStatIrqTime=0;
  mLastStepStatSoftIrqTime=mCurStepStatSoftIrqTime=0;
  mLastStepStatIdleTime=mCurStepStatIdleTime=0;
  initDischarge();
  clearHistoryLocked();
}