nus-yam/ex-repair huggingface dataset:
Program: 193059
Project: 193059
Buggy source:
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  if (event.mEventType != Event.CONFIGURATION_CHANGE) {
    mAppIdleRollingWindow.update(event.mPackage,event.mTimeStamp,event.mEventType);
    mAppIdleRollingWindow.updateBeginIdleTime(event.mPackage,deviceUsageTime);
  }
  notifyStatsChanged();
}
Program: 193060
Project: 193060
Buggy source:
long getSystemLastUsedTime(String packageName){
  final IntervalStats yearly=mCurrentStats[UsageStatsManager.INTERVAL_YEARLY];
  UsageStats packageUsage;
  if ((packageUsage=yearly.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}

Fixed version (ground truth):
long getSystemLastUsedTime(String packageName){
  UsageStats packageUsage;
  if ((packageUsage=mAppIdleRollingWindow.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}
Program: 193061
Project: 193061
Buggy source:
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  mAppIdleRollingWindow.updateBeginIdleTime(packageName,beginIdleTime);
  notifyStatsChanged();
}
Program: 193063
Project: 193063
Buggy source:
void onTimeChanged(long oldTime,long newTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
}

Fixed version (ground truth):
void onTimeChanged(long oldTime,long newTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
  refreshAppIdleRollingWindow(newTime);
}
Program: 193064
Project: 193064
Buggy source:
long getBeginIdleTime(String packageName){
  final IntervalStats yearly=mCurrentStats[UsageStatsManager.INTERVAL_YEARLY];
  UsageStats packageUsage;
  if ((packageUsage=yearly.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getBeginIdleTime();
  }
}

Fixed version (ground truth):
long getBeginIdleTime(String packageName){
  UsageStats packageUsage;
  if ((packageUsage=mAppIdleRollingWindow.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getBeginIdleTime();
  }
}
Program: 193065
Project: 193065
Buggy source:
void dump(IndentingPrintWriter pw,final long screenOnTime){
  for (int interval=0; interval < mCurrentStats.length; interval++) {
    pw.print("String_Node_Str");
    pw.print(intervalToString(interval));
    pw.println("String_Node_Str");
    printIntervalStats(pw,mCurrentStats[interval],screenOnTime,true);
  }
}

Fixed version (ground truth):
void dump(IndentingPrintWriter pw,final long screenOnTime){
  for (int interval=0; interval < mCurrentStats.length; interval++) {
    pw.print("String_Node_Str");
    pw.print(intervalToString(interval));
    pw.println("String_Node_Str");
    printIntervalStats(pw,mCurrentStats[interval],screenOnTime,true);
  }
  pw.println("String_Node_Str");
  printIntervalStats(pw,mAppIdleRollingWindow,screenOnTime,true);
}
Program: 193066
Project: 193066
Buggy source:
void setSystemLastUsedTime(String packageName,long lastUsedTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateSystemLastUsedTime(packageName,lastUsedTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void setSystemLastUsedTime(String packageName,long lastUsedTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateSystemLastUsedTime(packageName,lastUsedTime);
  }
  mAppIdleRollingWindow.updateSystemLastUsedTime(packageName,lastUsedTime);
  notifyStatsChanged();
}
Program: 193067
Project: 193067
Buggy source:
@Override public void combine(IntervalStats stats,boolean mutable,List<UsageEvents.Event> accumulatedResult){
  if (stats.events == null) {
    return;
  }
  final int startIndex=stats.events.closestIndexOnOrAfter(beginTime);
  if (startIndex < 0) {
    return;
  }
  final int size=stats.events.size();
  for (int i=startIndex; i < size; i++) {
    if (stats.events.keyAt(i) >= endTime) {
      return;
    }
    final UsageEvents.Event event=stats.events.valueAt(i);
    names.add(event.mPackage);
    if (event.mClass != null) {
      names.add(event.mClass);
    }
    accumulatedResult.add(event);
  }
}

Fixed version (ground truth):
@Override public void combine(IntervalStats stats,boolean mutable,List<IntervalStats> accumulatedResult){
  IntervalStats accum;
  if (accumulatedResult.isEmpty()) {
    accum=new IntervalStats();
    accum.beginTime=stats.beginTime;
    accumulatedResult.add(accum);
  }
 else {
    accum=accumulatedResult.get(0);
  }
  mergePackageStats(accum,stats);
}
Program: 193068
Project: 193068
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());
  }
}

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);
  }
  if (mDatabase.isNewUpdate()) {
    initializeDefaultsForApps(currentTimeMillis,deviceUsageTime,mDatabase.isFirstUpdate());
  }
  refreshAppIdleRollingWindow(currentTimeMillis);
}
Program: 193069
Project: 193069
Buggy source:
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  if (event.mEventType != Event.CONFIGURATION_CHANGE) {
    mAppIdleRollingWindow.update(event.mPackage,event.mTimeStamp,event.mEventType);
    mAppIdleRollingWindow.updateBeginIdleTime(event.mPackage,deviceUsageTime);
  }
  notifyStatsChanged();
}
Program: 193070
Project: 193070
Buggy source:
long getSystemLastUsedTime(String packageName){
  final IntervalStats yearly=mCurrentStats[UsageStatsManager.INTERVAL_YEARLY];
  UsageStats packageUsage;
  if ((packageUsage=yearly.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}

Fixed version (ground truth):
long getSystemLastUsedTime(String packageName){
  UsageStats packageUsage;
  if ((packageUsage=mAppIdleRollingWindow.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}
Program: 193071
Project: 193071
Buggy source:
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  mAppIdleRollingWindow.updateBeginIdleTime(packageName,beginIdleTime);
  notifyStatsChanged();
}
Program: 193073
Project: 193073
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) {
    final int sequence=intent.getIntExtra("String_Node_Str",0);
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + sequence + "String_Node_Str"+ mDelayedShowingSequence);
synchronized (KeyguardViewMediator.this) {
      doKeyguardLocked(null);
    }
  }
 else   if (DELAYED_LOCK_PROFILE_ACTION.equals(intent.getAction())) {
    int userId=intent.getIntExtra(Intent.EXTRA_USER_ID,0);
    if (userId != 0) {
synchronized (KeyguardViewMediator.this) {
        lockProfile(userId);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) {
    final int sequence=intent.getIntExtra("String_Node_Str",0);
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + sequence + "String_Node_Str"+ mDelayedShowingSequence);
synchronized (KeyguardViewMediator.this) {
      if (mDelayedShowingSequence == sequence) {
        doKeyguardLocked(null);
      }
    }
  }
 else   if (DELAYED_LOCK_PROFILE_ACTION.equals(intent.getAction())) {
    int userId=intent.getIntExtra(Intent.EXTRA_USER_ID,0);
    if (userId != 0) {
synchronized (KeyguardViewMediator.this) {
        lockProfile(userId);
      }
    }
  }
}
Program: 193074
Project: 193074
Buggy source:
public void keyguardDoneDrawing(){
  mHandler.sendEmptyMessage(KEYGUARD_DONE_DRAWING);
}

Fixed version (ground truth):
@Override public void keyguardDoneDrawing(){
  mHandler.sendEmptyMessage(KEYGUARD_DONE_DRAWING);
}
Program: 193075
Project: 193075
Buggy source:
public void onBootCompleted(){
  mUpdateMonitor.dispatchBootCompleted();
synchronized (this) {
    mBootCompleted=true;
    if (mBootSendUserPresent) {
      sendUserPresentBroadcast();
    }
  }
}

Fixed version (ground truth):
@Override public void onBootCompleted(){
  mUpdateMonitor.dispatchBootCompleted();
synchronized (this) {
    mBootCompleted=true;
    if (mBootSendUserPresent) {
      sendUserPresentBroadcast();
    }
  }
}
Program: 193076
Project: 193076
Buggy source:
private void updateLockScreenTimeout(){
synchronized (mScreenLockTimeout) {
    boolean enable=(mAllowLockscreenWhenOn && mAwake && mKeyguardDelegate != null && mKeyguardDelegate.isSecure());
    if (mLockScreenTimerActive != enable) {
      if (enable) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        mHandler.postDelayed(mScreenLockTimeout,mLockScreenTimeout);
      }
 else {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        mHandler.removeCallbacks(mScreenLockTimeout);
      }
      mLockScreenTimerActive=enable;
    }
  }
}

Fixed version (ground truth):
private void updateLockScreenTimeout(){
synchronized (mScreenLockTimeout) {
    boolean enable=(mAllowLockscreenWhenOn && mAwake && mKeyguardDelegate != null && mKeyguardDelegate.isSecure());
    if (mLockScreenTimerActive != enable) {
      if (enable) {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        mHandler.removeCallbacks(mScreenLockTimeout);
        mHandler.postDelayed(mScreenLockTimeout,mLockScreenTimeout);
      }
 else {
        if (localLOGV)         Log.v(TAG,"String_Node_Str");
        mHandler.removeCallbacks(mScreenLockTimeout);
      }
      mLockScreenTimerActive=enable;
    }
  }
}
Program: 193077
Project: 193077
Buggy source:
void onTimeChanged(long oldTime,long newTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
}

Fixed version (ground truth):
void onTimeChanged(long oldTime,long newTime,boolean resetBeginIdleTime){
  persistActiveStats();
  mDatabase.onTimeChanged(newTime - oldTime);
  loadActiveStats(newTime,true,resetBeginIdleTime);
  refreshAppIdleRollingWindow(newTime);
}
Program: 193078
Project: 193078
Buggy source:
long getBeginIdleTime(String packageName){
  final IntervalStats yearly=mCurrentStats[UsageStatsManager.INTERVAL_YEARLY];
  UsageStats packageUsage;
  if ((packageUsage=yearly.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getBeginIdleTime();
  }
}

Fixed version (ground truth):
long getBeginIdleTime(String packageName){
  UsageStats packageUsage;
  if ((packageUsage=mAppIdleRollingWindow.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getBeginIdleTime();
  }
}
Program: 193079
Project: 193079
Buggy source:
void dump(IndentingPrintWriter pw,final long screenOnTime){
  for (int interval=0; interval < mCurrentStats.length; interval++) {
    pw.print("String_Node_Str");
    pw.print(intervalToString(interval));
    pw.println("String_Node_Str");
    printIntervalStats(pw,mCurrentStats[interval],screenOnTime,true);
  }
}

Fixed version (ground truth):
void dump(IndentingPrintWriter pw,final long screenOnTime){
  for (int interval=0; interval < mCurrentStats.length; interval++) {
    pw.print("String_Node_Str");
    pw.print(intervalToString(interval));
    pw.println("String_Node_Str");
    printIntervalStats(pw,mCurrentStats[interval],screenOnTime,true);
  }
  pw.println("String_Node_Str");
  printIntervalStats(pw,mAppIdleRollingWindow,screenOnTime,true);
}
Program: 193080
Project: 193080
Buggy source:
void setSystemLastUsedTime(String packageName,long lastUsedTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateSystemLastUsedTime(packageName,lastUsedTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void setSystemLastUsedTime(String packageName,long lastUsedTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateSystemLastUsedTime(packageName,lastUsedTime);
  }
  mAppIdleRollingWindow.updateSystemLastUsedTime(packageName,lastUsedTime);
  notifyStatsChanged();
}
Program: 193081
Project: 193081
Buggy source:
@Override public void combine(IntervalStats stats,boolean mutable,List<UsageEvents.Event> accumulatedResult){
  if (stats.events == null) {
    return;
  }
  final int startIndex=stats.events.closestIndexOnOrAfter(beginTime);
  if (startIndex < 0) {
    return;
  }
  final int size=stats.events.size();
  for (int i=startIndex; i < size; i++) {
    if (stats.events.keyAt(i) >= endTime) {
      return;
    }
    final UsageEvents.Event event=stats.events.valueAt(i);
    names.add(event.mPackage);
    if (event.mClass != null) {
      names.add(event.mClass);
    }
    accumulatedResult.add(event);
  }
}

Fixed version (ground truth):
@Override public void combine(IntervalStats stats,boolean mutable,List<IntervalStats> accumulatedResult){
  IntervalStats accum;
  if (accumulatedResult.isEmpty()) {
    accum=new IntervalStats();
    accum.beginTime=stats.beginTime;
    accumulatedResult.add(accum);
  }
 else {
    accum=accumulatedResult.get(0);
  }
  mergePackageStats(accum,stats);
}
Program: 193082
Project: 193082
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());
  }
}

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);
  }
  if (mDatabase.isNewUpdate()) {
    initializeDefaultsForApps(currentTimeMillis,deviceUsageTime,mDatabase.isFirstUpdate());
  }
  refreshAppIdleRollingWindow(currentTimeMillis);
}
Program: 193083
Project: 193083
Buggy source:
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
void reportEvent(UsageEvents.Event event,long deviceUsageTime){
  if (DEBUG) {
    Slog.d(TAG,mLogPrefix + "String_Node_Str" + event.mPackage+ "String_Node_Str"+ event.mTimeStamp+ "String_Node_Str"+ eventToString(event.mEventType));
  }
  if (event.mTimeStamp >= mDailyExpiryDate.getTimeInMillis()) {
    rolloverStats(event.mTimeStamp);
  }
  final IntervalStats currentDailyStats=mCurrentStats[UsageStatsManager.INTERVAL_DAILY];
  final Configuration newFullConfig=event.mConfiguration;
  if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE && currentDailyStats.activeConfiguration != null) {
    event.mConfiguration=Configuration.generateDelta(currentDailyStats.activeConfiguration,newFullConfig);
  }
  if (currentDailyStats.events == null) {
    currentDailyStats.events=new TimeSparseArray<>();
  }
  if (event.mEventType != UsageEvents.Event.SYSTEM_INTERACTION) {
    currentDailyStats.events.put(event.mTimeStamp,event);
  }
  for (  IntervalStats stats : mCurrentStats) {
    if (event.mEventType == UsageEvents.Event.CONFIGURATION_CHANGE) {
      stats.updateConfigurationStats(newFullConfig,event.mTimeStamp);
    }
 else {
      stats.update(event.mPackage,event.mTimeStamp,event.mEventType);
      stats.updateBeginIdleTime(event.mPackage,deviceUsageTime);
    }
  }
  if (event.mEventType != Event.CONFIGURATION_CHANGE) {
    mAppIdleRollingWindow.update(event.mPackage,event.mTimeStamp,event.mEventType);
    mAppIdleRollingWindow.updateBeginIdleTime(event.mPackage,deviceUsageTime);
  }
  notifyStatsChanged();
}
Program: 193084
Project: 193084
Buggy source:
long getSystemLastUsedTime(String packageName){
  final IntervalStats yearly=mCurrentStats[UsageStatsManager.INTERVAL_YEARLY];
  UsageStats packageUsage;
  if ((packageUsage=yearly.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}

Fixed version (ground truth):
long getSystemLastUsedTime(String packageName){
  UsageStats packageUsage;
  if ((packageUsage=mAppIdleRollingWindow.packageStats.get(packageName)) == null) {
    return -1;
  }
 else {
    return packageUsage.getLastTimeSystemUsed();
  }
}
Program: 193085
Project: 193085
Buggy source:
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  notifyStatsChanged();
}

Fixed version (ground truth):
/** 
 * Sets the beginIdleTime for each of the intervals.
 * @param beginIdleTime
 */
void setBeginIdleTime(String packageName,long beginIdleTime){
  for (  IntervalStats stats : mCurrentStats) {
    stats.updateBeginIdleTime(packageName,beginIdleTime);
  }
  mAppIdleRollingWindow.updateBeginIdleTime(packageName,beginIdleTime);
  notifyStatsChanged();
}
Program: 193087
Project: 193087
Buggy source:
@Override public boolean onPrepareOptionsMenu(Menu menu){
  super.onPrepareOptionsMenu(menu);
  final DocumentInfo cwd=getCurrentDirectory();
  final MenuItem createDir=menu.findItem(R.id.menu_create_dir);
  final MenuItem grid=menu.findItem(R.id.menu_grid);
  final MenuItem list=menu.findItem(R.id.menu_list);
  final MenuItem fileSize=menu.findItem(R.id.menu_file_size);
  final MenuItem settings=menu.findItem(R.id.menu_settings);
  boolean recents=cwd == null;
  boolean picking=mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE || mState.action == ACTION_PICK_COPY_DESTINATION;
  createDir.setVisible(picking && !recents && cwd.isCreateSupported());
  mSearchManager.showMenu(!picking);
  grid.setVisible(!(picking && recents));
  list.setVisible(!(picking && recents));
  fileSize.setVisible(fileSize.isVisible() && !picking);
  settings.setVisible(false);
  if (mState.action == ACTION_CREATE) {
    final FragmentManager fm=getFragmentManager();
    SaveFragment.get(fm).prepareForDirectory(cwd);
  }
  Menus.disableHiddenItems(menu);
  return true;
}

Fixed version (ground truth):
@Override public boolean onPrepareOptionsMenu(Menu menu){
  super.onPrepareOptionsMenu(menu);
  final DocumentInfo cwd=getCurrentDirectory();
  final MenuItem createDir=menu.findItem(R.id.menu_create_dir);
  final MenuItem grid=menu.findItem(R.id.menu_grid);
  final MenuItem list=menu.findItem(R.id.menu_list);
  final MenuItem fileSize=menu.findItem(R.id.menu_file_size);
  final MenuItem settings=menu.findItem(R.id.menu_settings);
  boolean recents=cwd == null;
  boolean picking=mState.action == ACTION_CREATE || mState.action == ACTION_OPEN_TREE || mState.action == ACTION_PICK_COPY_DESTINATION;
  createDir.setVisible(picking && !recents && cwd.isCreateSupported());
  mSearchManager.showMenu(!picking);
  if (picking && recents) {
    grid.setVisible(false);
    list.setVisible(false);
  }
  fileSize.setVisible(fileSize.isVisible() && !picking);
  settings.setVisible(false);
  if (mState.action == ACTION_CREATE) {
    final FragmentManager fm=getFragmentManager();
    SaveFragment.get(fm).prepareForDirectory(cwd);
  }
  Menus.disableHiddenItems(menu);
  return true;
}
Program: 193088
Project: 193088
Buggy source:
public void onResume(){
  restoreExitedViews();
}

Fixed version (ground truth):
public void onResume(){
  restoreExitedViews();
  restoreReenteringViews();
}
Program: 193089
Project: 193089
Buggy source:
private void startEnter(){
  if (mEnterActivityOptions.isReturning()) {
    if (mExitingToView != null) {
      mEnterTransitionCoordinator.viewInstancesReady(mExitingFrom,mExitingTo,mExitingToView);
    }
 else {
      mEnterTransitionCoordinator.namedViewsReady(mExitingFrom,mExitingTo);
    }
  }
 else {
    mEnterTransitionCoordinator.namedViewsReady(null,null);
    mEnteringNames=mEnterTransitionCoordinator.getAllSharedElementNames();
  }
  mExitingFrom=null;
  mExitingTo=null;
  mExitingToView=null;
  mEnterActivityOptions=null;
}

Fixed version (ground truth):
private void startEnter(){
  if (mEnterTransitionCoordinator.isReturning()) {
    if (mExitingToView != null) {
      mEnterTransitionCoordinator.viewInstancesReady(mExitingFrom,mExitingTo,mExitingToView);
    }
 else {
      mEnterTransitionCoordinator.namedViewsReady(mExitingFrom,mExitingTo);
    }
  }
 else {
    mEnterTransitionCoordinator.namedViewsReady(null,null);
    mEnteringNames=mEnterTransitionCoordinator.getAllSharedElementNames();
  }
  mExitingFrom=null;
  mExitingTo=null;
  mExitingToView=null;
  mEnterActivityOptions=null;
}
Program: 193090
Project: 193090
Buggy source:
private void triggerViewsReady(final ArrayMap<String,View> sharedElements){
  if (mAreViewsReady) {
    return;
  }
  mAreViewsReady=true;
  final ViewGroup decor=getDecor();
  if (decor == null || (decor.isAttachedToWindow() && (sharedElements.isEmpty() || !sharedElements.valueAt(0).isLayoutRequested()))) {
    viewsReady(sharedElements);
  }
 else {
    decor.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){
      @Override public boolean onPreDraw(){
        decor.getViewTreeObserver().removeOnPreDrawListener(this);
        viewsReady(sharedElements);
        return true;
      }
    }
);
  }
}

Fixed version (ground truth):
private void triggerViewsReady(final ArrayMap<String,View> sharedElements){
  if (mAreViewsReady) {
    return;
  }
  mAreViewsReady=true;
  final ViewGroup decor=getDecor();
  if (decor == null || (decor.isAttachedToWindow() && (sharedElements.isEmpty() || !sharedElements.valueAt(0).isLayoutRequested()))) {
    viewsReady(sharedElements);
  }
 else {
    mViewsReadyListener=new ViewTreeObserver.OnPreDrawListener(){
      @Override public boolean onPreDraw(){
        mViewsReadyListener=null;
        decor.getViewTreeObserver().removeOnPreDrawListener(this);
        viewsReady(sharedElements);
        return true;
      }
    }
;
    decor.getViewTreeObserver().addOnPreDrawListener(mViewsReadyListener);
  }
}
Program: 193091
Project: 193091
Buggy source:
public void onResume(){
  restoreExitedViews();
}

Fixed version (ground truth):
public void onResume(){
  restoreExitedViews();
  restoreReenteringViews();
}
Program: 193092
Project: 193092
Buggy source:
private void startEnter(){
  if (mEnterActivityOptions.isReturning()) {
    if (mExitingToView != null) {
      mEnterTransitionCoordinator.viewInstancesReady(mExitingFrom,mExitingTo,mExitingToView);
    }
 else {
      mEnterTransitionCoordinator.namedViewsReady(mExitingFrom,mExitingTo);
    }
  }
 else {
    mEnterTransitionCoordinator.namedViewsReady(null,null);
    mEnteringNames=mEnterTransitionCoordinator.getAllSharedElementNames();
  }
  mExitingFrom=null;
  mExitingTo=null;
  mExitingToView=null;
  mEnterActivityOptions=null;
}

Fixed version (ground truth):
private void startEnter(){
  if (mEnterTransitionCoordinator.isReturning()) {
    if (mExitingToView != null) {
      mEnterTransitionCoordinator.viewInstancesReady(mExitingFrom,mExitingTo,mExitingToView);
    }
 else {
      mEnterTransitionCoordinator.namedViewsReady(mExitingFrom,mExitingTo);
    }
  }
 else {
    mEnterTransitionCoordinator.namedViewsReady(null,null);
    mEnteringNames=mEnterTransitionCoordinator.getAllSharedElementNames();
  }
  mExitingFrom=null;
  mExitingTo=null;
  mExitingToView=null;
  mEnterActivityOptions=null;
}
Program: 193093
Project: 193093
Buggy source:
private void triggerViewsReady(final ArrayMap<String,View> sharedElements){
  if (mAreViewsReady) {
    return;
  }
  mAreViewsReady=true;
  final ViewGroup decor=getDecor();
  if (decor == null || (decor.isAttachedToWindow() && (sharedElements.isEmpty() || !sharedElements.valueAt(0).isLayoutRequested()))) {
    viewsReady(sharedElements);
  }
 else {
    decor.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){
      @Override public boolean onPreDraw(){
        decor.getViewTreeObserver().removeOnPreDrawListener(this);
        viewsReady(sharedElements);
        return true;
      }
    }
);
  }
}

Fixed version (ground truth):
private void triggerViewsReady(final ArrayMap<String,View> sharedElements){
  if (mAreViewsReady) {
    return;
  }
  mAreViewsReady=true;
  final ViewGroup decor=getDecor();
  if (decor == null || (decor.isAttachedToWindow() && (sharedElements.isEmpty() || !sharedElements.valueAt(0).isLayoutRequested()))) {
    viewsReady(sharedElements);
  }
 else {
    mViewsReadyListener=new ViewTreeObserver.OnPreDrawListener(){
      @Override public boolean onPreDraw(){
        mViewsReadyListener=null;
        decor.getViewTreeObserver().removeOnPreDrawListener(this);
        viewsReady(sharedElements);
        return true;
      }
    }
;
    decor.getViewTreeObserver().addOnPreDrawListener(mViewsReadyListener);
  }
}
Program: 193098
Project: 193098
Buggy source:
/** 
 * Dismisses Recents directly to Home without checking whether it is currently visible.
 */
void dismissRecentsToHome(boolean animated){
  if (animated) {
    ReferenceCountedTrigger exitTrigger=new ReferenceCountedTrigger(null,mFinishLaunchHomeRunnable,null);
    mRecentsView.startExitToHomeAnimation(new ViewAnimation.TaskViewExitContext(exitTrigger));
  }
 else {
    mFinishLaunchHomeRunnable.run();
  }
}

Fixed version (ground truth):
/** 
 * Dismisses Recents directly to Home without checking whether it is currently visible.
 */
void dismissRecentsToHome(boolean animated){
  if (animated) {
    ReferenceCountedTrigger exitTrigger=new ReferenceCountedTrigger();
    exitTrigger.increment();
    exitTrigger.addLastDecrementRunnable(mFinishLaunchHomeRunnable);
    exitTrigger.addLastDecrementRunnable(new Runnable(){
      @Override public void run(){
        Recents.getSystemServices().sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
      }
    }
);
    mRecentsView.startExitToHomeAnimation(new ViewAnimation.TaskViewExitContext(exitTrigger));
    exitTrigger.decrement();
  }
 else {
    mFinishLaunchHomeRunnable.run();
    Recents.getSystemServices().sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
  }
}
Program: 193100
Project: 193100
Buggy source:
@Override protected void onDestroy(){
  super.onDestroy();
  if (mFinishedOnStartup) {
    return;
  }
  unregisterReceiver(mSystemBroadcastReceiver);
  mPackageMonitor.unregister();
  if (!RecentsDebugFlags.Static.DisableSearchBar) {
    mAppWidgetHost.stopListening();
  }
  EventBus.getDefault().unregister(this);
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  super.onDestroy();
  if (mFinishedOnStartup) {
    return;
  }
  unregisterReceiver(mSystemBroadcastReceiver);
  mPackageMonitor.unregister();
  if (RecentsDebugFlags.Static.EnableSearchBar) {
    mAppWidgetHost.stopListening();
  }
  EventBus.getDefault().unregister(this);
}
Program: 193101
Project: 193101
Buggy source:
@Override public void toggleRecents(){
  if (mFastAltTabTrigger.isDozing()) {
    return;
  }
  mDraggingInRecents=false;
  mTriggeredFromAltTab=false;
  try {
    SystemServicesProxy ssp=Recents.getSystemServices();
    ActivityManager.RunningTaskInfo topTask=ssp.getTopMostTask();
    MutableBoolean isTopTaskHome=new MutableBoolean(true);
    if (topTask != null && ssp.isRecentsTopMost(topTask,isTopTaskHome)) {
      RecentsConfiguration config=Recents.getConfiguration();
      RecentsActivityLaunchState launchState=config.getLaunchState();
      RecentsDebugFlags flags=Recents.getDebugFlags();
      if (!launchState.launchedWithAltTab) {
        EventBus.getDefault().post(new IterateRecentsEvent());
      }
 else {
        if ((SystemClock.elapsedRealtime() - mLastToggleTime) < MIN_TOGGLE_DELAY_MS) {
          return;
        }
        EventBus.getDefault().post(new ToggleRecentsEvent());
        mLastToggleTime=SystemClock.elapsedRealtime();
      }
      return;
    }
 else {
      if ((SystemClock.elapsedRealtime() - mLastToggleTime) < MIN_TOGGLE_DELAY_MS) {
        return;
      }
      startRecentsActivity(topTask,isTopTaskHome.value,true);
      mLastToggleTime=SystemClock.elapsedRealtime();
    }
  }
 catch (  ActivityNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public void toggleRecents(){
  if (mFastAltTabTrigger.isDozing()) {
    return;
  }
  mDraggingInRecents=false;
  mTriggeredFromAltTab=false;
  try {
    SystemServicesProxy ssp=Recents.getSystemServices();
    ActivityManager.RunningTaskInfo topTask=ssp.getTopMostTask();
    MutableBoolean isTopTaskHome=new MutableBoolean(true);
    if (topTask != null && ssp.isRecentsTopMost(topTask,isTopTaskHome)) {
      RecentsConfiguration config=Recents.getConfiguration();
      RecentsActivityLaunchState launchState=config.getLaunchState();
      RecentsDebugFlags flags=Recents.getDebugFlags();
      if (!launchState.launchedWithAltTab) {
        EventBus.getDefault().post(new IterateRecentsEvent());
      }
 else {
        if ((SystemClock.elapsedRealtime() - mLastToggleTime) < MIN_TOGGLE_DELAY_MS) {
          return;
        }
        EventBus.getDefault().post(new ToggleRecentsEvent());
        mLastToggleTime=SystemClock.elapsedRealtime();
      }
      return;
    }
 else {
      if ((SystemClock.elapsedRealtime() - mLastToggleTime) < MIN_TOGGLE_DELAY_MS) {
        return;
      }
      startRecentsActivity(topTask,isTopTaskHome.value,true);
      ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
      mLastToggleTime=SystemClock.elapsedRealtime();
    }
  }
 catch (  ActivityNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 193103
Project: 193103
Buggy source:
/** 
 * Returns the package name of the home activity. 
 */
public String getHomeActivityPackageName(){
  if (mPm == null)   return null;
  if (RecentsDebugFlags.Static.EnableSystemServicesProxy)   return null;
  ArrayList<ResolveInfo> homeActivities=new ArrayList<ResolveInfo>();
  ComponentName defaultHomeActivity=mPm.getHomeActivities(homeActivities);
  if (defaultHomeActivity != null) {
    return defaultHomeActivity.getPackageName();
  }
 else   if (homeActivities.size() == 1) {
    ResolveInfo info=homeActivities.get(0);
    if (info.activityInfo != null) {
      return info.activityInfo.packageName;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the package name of the home activity. 
 */
public String getHomeActivityPackageName(){
  if (mPm == null)   return null;
  if (RecentsDebugFlags.Static.EnableSystemServicesProxy)   return null;
  ArrayList<ResolveInfo> homeActivities=new ArrayList<>();
  ComponentName defaultHomeActivity=mPm.getHomeActivities(homeActivities);
  if (defaultHomeActivity != null) {
    return defaultHomeActivity.getPackageName();
  }
 else   if (homeActivities.size() == 1) {
    ResolveInfo info=homeActivities.get(0);
    if (info.activityInfo != null) {
      return info.activityInfo.packageName;
    }
  }
  return null;
}
Program: 193104
Project: 193104
Buggy source:
/** 
 * Returns the first Recents widget from the same package as the global assist activity.
 */
private AppWidgetProviderInfo resolveSearchAppWidget(){
  if (mAssistComponent == null)   return null;
  List<AppWidgetProviderInfo> widgets=mAwm.getInstalledProviders(AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX);
  for (  AppWidgetProviderInfo info : widgets) {
    if (info.provider.getPackageName().equals(mAssistComponent.getPackageName())) {
      return info;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the first Recents widget from the same package as the global assist activity.
 */
public AppWidgetProviderInfo resolveSearchAppWidget(){
  if (mAssistComponent == null)   return null;
  List<AppWidgetProviderInfo> widgets=mAwm.getInstalledProviders(AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX);
  for (  AppWidgetProviderInfo info : widgets) {
    if (info.provider.getPackageName().equals(mAssistComponent.getPackageName())) {
      return info;
    }
  }
  return null;
}
Program: 193105
Project: 193105
Buggy source:
/** 
 * Shows the task stack and hides the empty view.
 */
public void hideEmptyView(){
  mEmptyView.setVisibility(View.INVISIBLE);
  mTaskStackView.setVisibility(View.VISIBLE);
  if (!RecentsDebugFlags.Static.DisableSearchBar && (mSearchBar != null)) {
    mSearchBar.setVisibility(View.VISIBLE);
  }
  mTaskStackView.bringToFront();
  if (mSearchBar != null) {
    mSearchBar.bringToFront();
  }
  mHistoryButton.bringToFront();
}

Fixed version (ground truth):
/** 
 * Shows the task stack and hides the empty view.
 */
public void hideEmptyView(){
  mEmptyView.setVisibility(View.INVISIBLE);
  mTaskStackView.setVisibility(View.VISIBLE);
  if (RecentsDebugFlags.Static.EnableSearchBar && (mSearchBar != null)) {
    mSearchBar.setVisibility(View.VISIBLE);
  }
  mTaskStackView.bringToFront();
  if (mSearchBar != null) {
    mSearchBar.bringToFront();
  }
  mHistoryButton.bringToFront();
}
Program: 193106
Project: 193106
Buggy source:
/** 
 * Hides the task stack and shows the empty view.
 */
public void showEmptyView(){
  if (!RecentsDebugFlags.Static.DisableSearchBar && (mSearchBar != null)) {
    mSearchBar.setVisibility(View.INVISIBLE);
  }
  mTaskStackView.setVisibility(View.INVISIBLE);
  mEmptyView.setVisibility(View.VISIBLE);
  mEmptyView.bringToFront();
  mHistoryButton.bringToFront();
}

Fixed version (ground truth):
/** 
 * Hides the task stack and shows the empty view.
 */
public void showEmptyView(){
  if (RecentsDebugFlags.Static.EnableSearchBar && (mSearchBar != null)) {
    mSearchBar.setVisibility(View.INVISIBLE);
  }
  mTaskStackView.setVisibility(View.INVISIBLE);
  mEmptyView.setVisibility(View.VISIBLE);
  mEmptyView.bringToFront();
  mHistoryButton.bringToFront();
}
Program: 193108
Project: 193108
Buggy source:
protected void toggleRecents(){
  if (mRecents != null) {
    sendCloseSystemWindows(mContext,SYSTEM_DIALOG_REASON_RECENT_APPS);
    mRecents.toggleRecents(mDisplay,mLayoutDirection,getStatusBarView());
  }
}

Fixed version (ground truth):
protected void toggleRecents(){
  if (mRecents != null) {
    mRecents.toggleRecents(mDisplay,mLayoutDirection,getStatusBarView());
  }
}