Program: 192695
Project: 192695
Buggy source:
void init(final long currentTimeMillis,final long deviceUsageTime){
  mDatabase.init(currentTimeMillis);
  int nullCount=0;
  for (int i=0; i < mCurrentStats.length; i++) {
    mCurrentStats[i]=mDatabase.getLatestUsageStats(i);
    if (mCurrentStats[i] == null) {
      nullCount++;
    }
  }
  if (nullCount > 0) {
    if (nullCount != mCurrentStats.length) {
      Slog.w(TAG,mLogPrefix + "String_Node_Str");
    }
 else {
    }
    loadActiveStats(currentTimeMillis,false,false);
  }
 else {
    mDailyExpiryDate.setTimeInMillis(mCurrentStats[UsageStatsManager.INTERVAL_DAILY].beginTime);
    mDailyExpiryDate.addDays(1);
    mDailyExpiryDate.truncateToDay();
    Slog.i(TAG,mLogPrefix + "String_Node_Str" + sDateFormat.format(mDailyExpiryDate.getTimeInMillis())+ "String_Node_Str"+ mDailyExpiryDate.getTimeInMillis()+ "String_Node_Str");
  }
  for (  IntervalStats stat : mCurrentStats) {
    final int pkgCount=stat.packageStats.size();
    for (int i=0; i < pkgCount; i++) {
      UsageStats pkgStats=stat.packageStats.valueAt(i);
      if (pkgStats.mLastEvent == UsageEvents.Event.MOVE_TO_FOREGROUND || pkgStats.mLastEvent == UsageEvents.Event.CONTINUE_PREVIOUS_DAY) {
        stat.update(pkgStats.mPackageName,stat.lastTimeSaved,UsageEvents.Event.END_OF_DAY);
        notifyStatsChanged();
      }
    }
    stat.updateConfigurationStats(null,stat.lastTimeSaved);
  }
  if (mDatabase.isNewUpdate()) {
    initializeDefaultsForApps(currentTimeMillis,deviceUsageTime,mDatabase.isFirstUpdate());
  }
  refreshAppIdleRollingWindow(currentTimeMillis);
}

Fixed version (ground truth):
void init(final long currentTimeMillis,final long deviceUsageTime){
  mDatabase.init(currentTimeMillis);
  int nullCount=0;
  for (int i=0; i < mCurrentStats.length; i++) {
    mCurrentStats[i]=mDatabase.getLatestUsageStats(i);
    if (mCurrentStats[i] == null) {
      nullCount++;
    }
  }
  if (nullCount > 0) {
    if (nullCount != mCurrentStats.length) {
      Slog.w(TAG,mLogPrefix + "String_Node_Str");
    }
 else {
    }
    loadActiveStats(currentTimeMillis,false,false);
  }
 else {
    mDailyExpiryDate.setTimeInMillis(mCurrentStats[UsageStatsManager.INTERVAL_DAILY].beginTime);
    mDailyExpiryDate.addDays(1);
    mDailyExpiryDate.truncateToDay();
    Slog.i(TAG,mLogPrefix + "String_Node_Str" + sDateFormat.format(mDailyExpiryDate.getTimeInMillis())+ "String_Node_Str"+ mDailyExpiryDate.getTimeInMillis()+ "String_Node_Str");
  }
  for (  IntervalStats stat : mCurrentStats) {
    final int pkgCount=stat.packageStats.size();
    for (int i=0; i < pkgCount; i++) {
      UsageStats pkgStats=stat.packageStats.valueAt(i);
      if (pkgStats.mLastEvent == UsageEvents.Event.MOVE_TO_FOREGROUND || pkgStats.mLastEvent == UsageEvents.Event.CONTINUE_PREVIOUS_DAY) {
        stat.update(pkgStats.mPackageName,stat.lastTimeSaved,UsageEvents.Event.END_OF_DAY);
        notifyStatsChanged();
      }
    }
    stat.updateConfigurationStats(null,stat.lastTimeSaved);
  }
  refreshAppIdleRollingWindow(currentTimeMillis,deviceUsageTime);
  if (mDatabase.isNewUpdate()) {
    initializeDefaultsForApps(currentTimeMillis,deviceUsageTime,mDatabase.isFirstUpdate());
  }
}