nus-yam/ex-repair huggingface dataset:
Program: 191627
Project: 191627
Buggy source:
public void pinShortcuts(@NonNull ShortcutService s,@UserIdInt int packageUserId,@NonNull String packageName,@NonNull List<String> ids){
  final ShortcutPackage packageShortcuts=s.getPackageShortcutsLocked(packageName,packageUserId);
  final PackageWithUser pu=PackageWithUser.of(packageUserId,packageName);
  final int idSize=ids.size();
  if (idSize == 0) {
    mPinnedShortcuts.remove(pu);
  }
 else {
    final ArraySet<String> prevSet=mPinnedShortcuts.get(pu);
    final ArraySet<String> newSet=new ArraySet<>();
    for (int i=0; i < idSize; i++) {
      final String id=ids.get(i);
      final ShortcutInfo si=packageShortcuts.findShortcutById(id);
      if (si == null) {
        continue;
      }
      if (si.isDynamic() || (prevSet != null && prevSet.contains(id))) {
        newSet.add(id);
      }
    }
    mPinnedShortcuts.put(pu,newSet);
  }
  packageShortcuts.refreshPinnedFlags(s);
}

Fixed version (ground truth):
public void pinShortcuts(@UserIdInt int packageUserId,@NonNull String packageName,@NonNull List<String> ids){
  final ShortcutPackage packageShortcuts=mShortcutUser.getPackageShortcutsIfExists(packageName);
  if (packageShortcuts == null) {
    return;
  }
  final PackageWithUser pu=PackageWithUser.of(packageUserId,packageName);
  final int idSize=ids.size();
  if (idSize == 0) {
    mPinnedShortcuts.remove(pu);
  }
 else {
    final ArraySet<String> prevSet=mPinnedShortcuts.get(pu);
    final ArraySet<String> newSet=new ArraySet<>();
    for (int i=0; i < idSize; i++) {
      final String id=ids.get(i);
      final ShortcutInfo si=packageShortcuts.findShortcutById(id);
      if (si == null) {
        continue;
      }
      if (si.isDynamic() || (prevSet != null && prevSet.contains(id))) {
        newSet.add(id);
      }
    }
    mPinnedShortcuts.put(pu,newSet);
  }
  packageShortcuts.refreshPinnedFlags();
}
Program: 191628
Project: 191628
Buggy source:
/** 
 * Called when the new package can't receive the backup, due to signature or version mismatch.
 */
@Override protected void onRestoreBlocked(ShortcutService s){
  final ArrayList<PackageWithUser> pinnedPackages=new ArrayList<>(mPinnedShortcuts.keySet());
  mPinnedShortcuts.clear();
  for (int i=pinnedPackages.size() - 1; i >= 0; i--) {
    final PackageWithUser pu=pinnedPackages.get(i);
    s.getPackageShortcutsLocked(pu.packageName,pu.userId).refreshPinnedFlags(s);
  }
}

Fixed version (ground truth):
/** 
 * Called when the new package can't receive the backup, due to signature or version mismatch.
 */
@Override protected void onRestoreBlocked(){
  final ArrayList<PackageWithUser> pinnedPackages=new ArrayList<>(mPinnedShortcuts.keySet());
  mPinnedShortcuts.clear();
  for (int i=pinnedPackages.size() - 1; i >= 0; i--) {
    final PackageWithUser pu=pinnedPackages.get(i);
    final ShortcutPackage p=mShortcutUser.getPackageShortcutsIfExists(pu.packageName);
    if (p != null) {
      p.refreshPinnedFlags();
    }
  }
}
Program: 191629
Project: 191629
Buggy source:
public void dump(@NonNull ShortcutService s,@NonNull PrintWriter pw,@NonNull String prefix){
  pw.println();
  pw.print(prefix);
  pw.print("String_Node_Str");
  pw.print(getPackageName());
  pw.print("String_Node_Str");
  pw.print(getPackageUserId());
  pw.print("String_Node_Str");
  pw.print(getOwnerUserId());
  pw.println();
  getPackageInfo().dump(s,pw,prefix + "String_Node_Str");
  pw.println();
  final int size=mPinnedShortcuts.size();
  for (int i=0; i < size; i++) {
    pw.println();
    final PackageWithUser pu=mPinnedShortcuts.keyAt(i);
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.print(pu.packageName);
    pw.print("String_Node_Str");
    pw.println(pu.userId);
    final ArraySet<String> ids=mPinnedShortcuts.valueAt(i);
    final int idSize=ids.size();
    for (int j=0; j < idSize; j++) {
      pw.print(prefix);
      pw.print("String_Node_Str");
      pw.print(ids.valueAt(j));
      pw.println();
    }
  }
}

Fixed version (ground truth):
public void dump(@NonNull PrintWriter pw,@NonNull String prefix){
  pw.println();
  pw.print(prefix);
  pw.print("String_Node_Str");
  pw.print(getPackageName());
  pw.print("String_Node_Str");
  pw.print(getPackageUserId());
  pw.print("String_Node_Str");
  pw.print(getOwnerUserId());
  pw.println();
  getPackageInfo().dump(pw,prefix + "String_Node_Str");
  pw.println();
  final int size=mPinnedShortcuts.size();
  for (int i=0; i < size; i++) {
    pw.println();
    final PackageWithUser pu=mPinnedShortcuts.keyAt(i);
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.print(pu.packageName);
    pw.print("String_Node_Str");
    pw.println(pu.userId);
    final ArraySet<String> ids=mPinnedShortcuts.valueAt(i);
    final int idSize=ids.size();
    for (int j=0; j < idSize; j++) {
      pw.print(prefix);
      pw.print("String_Node_Str");
      pw.print(ids.valueAt(j));
      pw.println();
    }
  }
}
Program: 191630
Project: 191630
Buggy source:
@Override protected void onRestored(ShortcutService s){
}

Fixed version (ground truth):
@Override protected void onRestored(){
}
Program: 191631
Project: 191631
Buggy source:
private int getVisualTypeForHeight(float viewHeight){
  boolean noExpandedChild=mExpandedChild == null;
  if (!noExpandedChild && viewHeight == mExpandedChild.getHeight()) {
    return VISIBLE_TYPE_EXPANDED;
  }
  if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) {
    return VISIBLE_TYPE_SINGLELINE;
  }
  if (mIsHeadsUp && mHeadsUpChild != null) {
    if (viewHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
      return VISIBLE_TYPE_HEADSUP;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
 else {
    if (noExpandedChild || (viewHeight <= mContractedChild.getHeight() && (!mIsChildInGroup || !mContainingNotification.isExpanded(true)))) {
      return VISIBLE_TYPE_CONTRACTED;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
}

Fixed version (ground truth):
private int getVisualTypeForHeight(float viewHeight){
  boolean noExpandedChild=mExpandedChild == null;
  if (!noExpandedChild && viewHeight == mExpandedChild.getHeight()) {
    return VISIBLE_TYPE_EXPANDED;
  }
  if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) {
    return VISIBLE_TYPE_SINGLELINE;
  }
  if (mIsHeadsUp && mHeadsUpChild != null) {
    if (viewHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
      return VISIBLE_TYPE_HEADSUP;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
 else {
    if (noExpandedChild || (viewHeight <= mContractedChild.getHeight() && (!mIsChildInGroup || isGroupExpanded() || !mContainingNotification.isExpanded(true)))) {
      return VISIBLE_TYPE_CONTRACTED;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
}
Program: 191633
Project: 191633
Buggy source:
private int getVisualTypeForHeight(float viewHeight){
  boolean noExpandedChild=mExpandedChild == null;
  if (!noExpandedChild && viewHeight == mExpandedChild.getHeight()) {
    return VISIBLE_TYPE_EXPANDED;
  }
  if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) {
    return VISIBLE_TYPE_SINGLELINE;
  }
  if (mIsHeadsUp && mHeadsUpChild != null) {
    if (viewHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
      return VISIBLE_TYPE_HEADSUP;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
 else {
    if (noExpandedChild || (viewHeight <= mContractedChild.getHeight() && (!mIsChildInGroup || !mContainingNotification.isExpanded(true)))) {
      return VISIBLE_TYPE_CONTRACTED;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
}

Fixed version (ground truth):
private int getVisualTypeForHeight(float viewHeight){
  boolean noExpandedChild=mExpandedChild == null;
  if (!noExpandedChild && viewHeight == mExpandedChild.getHeight()) {
    return VISIBLE_TYPE_EXPANDED;
  }
  if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) {
    return VISIBLE_TYPE_SINGLELINE;
  }
  if (mIsHeadsUp && mHeadsUpChild != null) {
    if (viewHeight <= mHeadsUpChild.getHeight() || noExpandedChild) {
      return VISIBLE_TYPE_HEADSUP;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
 else {
    if (noExpandedChild || (viewHeight <= mContractedChild.getHeight() && (!mIsChildInGroup || isGroupExpanded() || !mContainingNotification.isExpanded(true)))) {
      return VISIBLE_TYPE_CONTRACTED;
    }
 else {
      return VISIBLE_TYPE_EXPANDED;
    }
  }
}
Program: 191636
Project: 191636
Buggy source:
public void preloadRecents(){
  SystemServicesProxy ssp=Recents.getSystemServices();
  MutableBoolean isHomeStackVisible=new MutableBoolean(true);
  if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
    ActivityManager.RunningTaskInfo runningTask=ssp.getRunningTask();
    RecentsTaskLoader loader=Recents.getTaskLoader();
    sInstanceLoadPlan=loader.createLoadPlan(mContext);
    sInstanceLoadPlan.preloadRawTasks(isHomeStackVisible.value);
    loader.preloadTasks(sInstanceLoadPlan,runningTask.id,isHomeStackVisible.value);
    TaskStack stack=sInstanceLoadPlan.getTaskStack();
    if (stack.getTaskCount() > 0) {
      preloadIcon(runningTask);
      updateHeaderBarLayout(stack,null);
    }
  }
}

Fixed version (ground truth):
public void preloadRecents(){
  SystemServicesProxy ssp=Recents.getSystemServices();
  MutableBoolean isHomeStackVisible=new MutableBoolean(true);
  if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
    ActivityManager.RunningTaskInfo runningTask=ssp.getRunningTask();
    RecentsTaskLoader loader=Recents.getTaskLoader();
    sInstanceLoadPlan=loader.createLoadPlan(mContext);
    sInstanceLoadPlan.preloadRawTasks(!isHomeStackVisible.value);
    loader.preloadTasks(sInstanceLoadPlan,runningTask.id,!isHomeStackVisible.value);
    TaskStack stack=sInstanceLoadPlan.getTaskStack();
    if (stack.getTaskCount() > 0) {
      preloadIcon(runningTask);
      updateHeaderBarLayout(stack,null);
    }
  }
}
Program: 191637
Project: 191637
Buggy source:
public RecentsImpl(Context context){
  mContext=context;
  mHandler=new Handler();
  ForegroundThread.get();
  mTaskStackListener=new TaskStackListenerImpl();
  SystemServicesProxy ssp=Recents.getSystemServices();
  ssp.registerTaskStackListener(mTaskStackListener);
  LayoutInflater inflater=LayoutInflater.from(mContext);
  mDummyStackView=new TaskStackView(mContext);
  mHeaderBar=(TaskViewHeader)inflater.inflate(R.layout.recents_task_view_header,null,false);
  reloadResources();
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan plan=loader.createLoadPlan(mContext);
  loader.preloadTasks(plan,-1,true);
  RecentsTaskLoadPlan.Options launchOpts=new RecentsTaskLoadPlan.Options();
  launchOpts.numVisibleTasks=loader.getIconCacheSize();
  launchOpts.numVisibleTaskThumbnails=loader.getThumbnailCacheSize();
  launchOpts.onlyLoadForCache=true;
  loader.loadTasks(mContext,plan,launchOpts);
}

Fixed version (ground truth):
public RecentsImpl(Context context){
  mContext=context;
  mHandler=new Handler();
  ForegroundThread.get();
  mTaskStackListener=new TaskStackListenerImpl();
  SystemServicesProxy ssp=Recents.getSystemServices();
  ssp.registerTaskStackListener(mTaskStackListener);
  LayoutInflater inflater=LayoutInflater.from(mContext);
  mDummyStackView=new TaskStackView(mContext);
  mHeaderBar=(TaskViewHeader)inflater.inflate(R.layout.recents_task_view_header,null,false);
  reloadResources();
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan plan=loader.createLoadPlan(mContext);
  loader.preloadTasks(plan,-1,false);
  RecentsTaskLoadPlan.Options launchOpts=new RecentsTaskLoadPlan.Options();
  launchOpts.numVisibleTasks=loader.getIconCacheSize();
  launchOpts.numVisibleTaskThumbnails=loader.getThumbnailCacheSize();
  launchOpts.onlyLoadForCache=true;
  loader.loadTasks(mContext,plan,launchOpts);
}
Program: 191639
Project: 191639
Buggy source:
@Override public void onTaskStackChanged(){
  RecentsConfiguration config=Recents.getConfiguration();
  if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
    RecentsTaskLoader loader=Recents.getTaskLoader();
    SystemServicesProxy ssp=Recents.getSystemServices();
    ActivityManager.RunningTaskInfo runningTaskInfo=ssp.getRunningTask();
    RecentsTaskLoadPlan plan=loader.createLoadPlan(mContext);
    loader.preloadTasks(plan,-1,true);
    RecentsTaskLoadPlan.Options launchOpts=new RecentsTaskLoadPlan.Options();
    if (runningTaskInfo != null) {
      launchOpts.runningTaskId=runningTaskInfo.id;
    }
    launchOpts.numVisibleTasks=2;
    launchOpts.numVisibleTaskThumbnails=2;
    launchOpts.onlyLoadForCache=true;
    launchOpts.onlyLoadPausedActivities=true;
    loader.loadTasks(mContext,plan,launchOpts);
  }
}

Fixed version (ground truth):
@Override public void onTaskStackChanged(){
  RecentsConfiguration config=Recents.getConfiguration();
  if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
    RecentsTaskLoader loader=Recents.getTaskLoader();
    SystemServicesProxy ssp=Recents.getSystemServices();
    ActivityManager.RunningTaskInfo runningTaskInfo=ssp.getRunningTask();
    RecentsTaskLoadPlan plan=loader.createLoadPlan(mContext);
    loader.preloadTasks(plan,-1,false);
    RecentsTaskLoadPlan.Options launchOpts=new RecentsTaskLoadPlan.Options();
    if (runningTaskInfo != null) {
      launchOpts.runningTaskId=runningTaskInfo.id;
    }
    launchOpts.numVisibleTasks=2;
    launchOpts.numVisibleTaskThumbnails=2;
    launchOpts.onlyLoadForCache=true;
    launchOpts.onlyLoadPausedActivities=true;
    loader.loadTasks(mContext,plan,launchOpts);
  }
}
Program: 191642
Project: 191642
Buggy source:
/** 
 * An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent to most-recent order.
 */
public synchronized void preloadRawTasks(boolean isHomeStackVisible){
  int currentUserId=UserHandle.USER_CURRENT;
  updateCurrentQuietProfilesCache(currentUserId);
  SystemServicesProxy ssp=Recents.getSystemServices();
  mRawTasks=ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(),currentUserId,isHomeStackVisible,mCurrentQuietProfiles);
  Collections.reverse(mRawTasks);
}

Fixed version (ground truth):
/** 
 * An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent to most-recent order.
 */
public synchronized void preloadRawTasks(boolean includeFrontMostExcludedTask){
  int currentUserId=UserHandle.USER_CURRENT;
  updateCurrentQuietProfilesCache(currentUserId);
  SystemServicesProxy ssp=Recents.getSystemServices();
  mRawTasks=ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(),currentUserId,includeFrontMostExcludedTask,mCurrentQuietProfiles);
  Collections.reverse(mRawTasks);
}
Program: 191643
Project: 191643
Buggy source:
/** 
 * Preloads recents tasks using the specified plan to store the output. 
 */
public void preloadTasks(RecentsTaskLoadPlan plan,int runningTaskId,boolean isHomeStackVisible){
  plan.preloadPlan(this,runningTaskId,isHomeStackVisible);
}

Fixed version (ground truth):
/** 
 * Preloads recents tasks using the specified plan to store the output. 
 */
public void preloadTasks(RecentsTaskLoadPlan plan,int runningTaskId,boolean includeFrontMostExcludedTask){
  plan.preloadPlan(this,runningTaskId,includeFrontMostExcludedTask);
}
Program: 191644
Project: 191644
Buggy source:
private void updateRecentsTasks(){
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan plan=RecentsImpl.consumeInstanceLoadPlan();
  if (plan == null) {
    plan=loader.createLoadPlan(this);
  }
  RecentsConfiguration config=Recents.getConfiguration();
  RecentsActivityLaunchState launchState=config.getLaunchState();
  if (!plan.hasTasks()) {
    loader.preloadTasks(plan,-1,launchState.launchedFromHome);
  }
  mLaunchedFromHome=launchState.launchedFromHome;
  TaskStack stack=plan.getTaskStack();
  RecentsTaskLoadPlan.Options loadOpts=new RecentsTaskLoadPlan.Options();
  loadOpts.runningTaskId=launchState.launchedToTaskId;
  loadOpts.numVisibleTasks=stack.getStackTaskCount();
  loadOpts.numVisibleTaskThumbnails=stack.getStackTaskCount();
  loader.loadTasks(this,plan,loadOpts);
  mRecentsView.setTaskStack(stack);
  List stackTasks=stack.getStackTasks();
  Collections.reverse(stackTasks);
  if (mTaskStackViewAdapter == null) {
    mTaskStackViewAdapter=new TaskStackHorizontalViewAdapter(stackTasks);
    mTaskStackHorizontalGridView=mRecentsView.setTaskStackViewAdapter(mTaskStackViewAdapter);
  }
 else {
    mTaskStackViewAdapter.setNewStackTasks(stackTasks);
  }
  if (launchState.launchedToTaskId != -1) {
    ArrayList<Task> tasks=stack.getStackTasks();
    int taskCount=tasks.size();
    for (int i=0; i < taskCount; i++) {
      Task t=tasks.get(i);
      if (t.key.id == launchState.launchedToTaskId) {
        t.isLaunchTarget=true;
        break;
      }
    }
  }
}

Fixed version (ground truth):
private void updateRecentsTasks(){
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan plan=RecentsImpl.consumeInstanceLoadPlan();
  if (plan == null) {
    plan=loader.createLoadPlan(this);
  }
  RecentsConfiguration config=Recents.getConfiguration();
  RecentsActivityLaunchState launchState=config.getLaunchState();
  if (!plan.hasTasks()) {
    loader.preloadTasks(plan,-1,!launchState.launchedFromHome);
  }
  mLaunchedFromHome=launchState.launchedFromHome;
  TaskStack stack=plan.getTaskStack();
  RecentsTaskLoadPlan.Options loadOpts=new RecentsTaskLoadPlan.Options();
  loadOpts.runningTaskId=launchState.launchedToTaskId;
  loadOpts.numVisibleTasks=stack.getStackTaskCount();
  loadOpts.numVisibleTaskThumbnails=stack.getStackTaskCount();
  loader.loadTasks(this,plan,loadOpts);
  mRecentsView.setTaskStack(stack);
  List stackTasks=stack.getStackTasks();
  Collections.reverse(stackTasks);
  if (mTaskStackViewAdapter == null) {
    mTaskStackViewAdapter=new TaskStackHorizontalViewAdapter(stackTasks);
    mTaskStackHorizontalGridView=mRecentsView.setTaskStackViewAdapter(mTaskStackViewAdapter);
  }
 else {
    mTaskStackViewAdapter.setNewStackTasks(stackTasks);
  }
  if (launchState.launchedToTaskId != -1) {
    ArrayList<Task> tasks=stack.getStackTasks();
    int taskCount=tasks.size();
    for (int i=0; i < taskCount; i++) {
      Task t=tasks.get(i);
      if (t.key.id == launchState.launchedToTaskId) {
        t.isLaunchTarget=true;
        break;
      }
    }
  }
}
Program: 191646
Project: 191646
Buggy source:
private boolean shouldShowOnKeyguard(StatusBarNotification sbn){
  return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey());
}

Fixed version (ground truth):
public boolean shouldShowOnKeyguard(StatusBarNotification sbn){
  return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey());
}
Program: 191647
Project: 191647
Buggy source:
/** 
 * @param maximum the maximum to return at most
 * @return the maximum keyguard notifications that can fit on the screen
 */
public int computeMaxKeyguardNotifications(int maximum){
  float minPadding=mClockPositionAlgorithm.getMinStackScrollerPadding(getHeight(),mKeyguardStatusView.getHeight());
  int notificationPadding=Math.max(1,getResources().getDimensionPixelSize(R.dimen.notification_divider_height));
  final int overflowheight=getResources().getDimensionPixelSize(R.dimen.notification_summary_height);
  float bottomStackSize=mNotificationStackScroller.getKeyguardBottomStackSize();
  float availableSpace=mNotificationStackScroller.getHeight() - minPadding - overflowheight- bottomStackSize;
  int count=0;
  for (int i=0; i < mNotificationStackScroller.getChildCount(); i++) {
    ExpandableView child=(ExpandableView)mNotificationStackScroller.getChildAt(i);
    if (!(child instanceof ExpandableNotificationRow)) {
      continue;
    }
    boolean suppressedSummary=mGroupManager.isSummaryOfSuppressedGroup(((ExpandableNotificationRow)child).getStatusBarNotification());
    if (suppressedSummary) {
      continue;
    }
    availableSpace-=child.getMinHeight() + notificationPadding;
    if (availableSpace >= 0 && count < maximum) {
      count++;
    }
 else {
      return count;
    }
  }
  return count;
}

Fixed version (ground truth):
/** 
 * @param maximum the maximum to return at most
 * @return the maximum keyguard notifications that can fit on the screen
 */
public int computeMaxKeyguardNotifications(int maximum){
  float minPadding=mClockPositionAlgorithm.getMinStackScrollerPadding(getHeight(),mKeyguardStatusView.getHeight());
  int notificationPadding=Math.max(1,getResources().getDimensionPixelSize(R.dimen.notification_divider_height));
  final int overflowheight=getResources().getDimensionPixelSize(R.dimen.notification_summary_height);
  float bottomStackSize=mNotificationStackScroller.getKeyguardBottomStackSize();
  float availableSpace=mNotificationStackScroller.getHeight() - minPadding - overflowheight- bottomStackSize;
  int count=0;
  for (int i=0; i < mNotificationStackScroller.getChildCount(); i++) {
    ExpandableView child=(ExpandableView)mNotificationStackScroller.getChildAt(i);
    if (!(child instanceof ExpandableNotificationRow)) {
      continue;
    }
    ExpandableNotificationRow row=(ExpandableNotificationRow)child;
    boolean suppressedSummary=mGroupManager.isSummaryOfSuppressedGroup(row.getStatusBarNotification());
    if (suppressedSummary) {
      continue;
    }
    if (!mStatusBar.shouldShowOnKeyguard(row.getStatusBarNotification())) {
      continue;
    }
    if (row.isRemoved()) {
      continue;
    }
    availableSpace-=child.getMinHeight() + notificationPadding;
    if (availableSpace >= 0 && count < maximum) {
      count++;
    }
 else {
      return count;
    }
  }
  return count;
}
Program: 191648
Project: 191648
Buggy source:
/** 
 * Ensures that the group children are cancelled immediately when the group summary is cancelled instead of waiting for the notification manager to send all cancels. Otherwise this could lead to flickers. This also ensures that the animation looks nice and only consists of a single disappear animation instead of multiple.
 * @param key the key of the notification was removed
 * @param ranking the current ranking
 */
private void handleGroupSummaryRemoved(String key,RankingMap ranking){
  Entry entry=mNotificationData.get(key);
  if (entry != null && entry.row != null && entry.row.isSummaryWithChildren()) {
    if (entry.notification.getOverrideGroupKey() != null && !entry.row.isDismissed()) {
      return;
    }
    entry.row.setRemoved(true);
    List<ExpandableNotificationRow> notificationChildren=entry.row.getNotificationChildren();
    ArrayList<ExpandableNotificationRow> toRemove=new ArrayList<>(notificationChildren);
    for (int i=0; i < toRemove.size(); i++) {
      toRemove.get(i).setKeepInParent(true);
    }
    for (int i=0; i < toRemove.size(); i++) {
      removeNotification(toRemove.get(i).getStatusBarNotification().getKey(),ranking);
      mStackScroller.removeViewStateForView(toRemove.get(i));
    }
  }
}

Fixed version (ground truth):
/** 
 * Ensures that the group children are cancelled immediately when the group summary is cancelled instead of waiting for the notification manager to send all cancels. Otherwise this could lead to flickers. This also ensures that the animation looks nice and only consists of a single disappear animation instead of multiple.
 * @param key the key of the notification was removed
 * @param ranking the current ranking
 */
private void handleGroupSummaryRemoved(String key,RankingMap ranking){
  Entry entry=mNotificationData.get(key);
  if (entry != null && entry.row != null && entry.row.isSummaryWithChildren()) {
    if (entry.notification.getOverrideGroupKey() != null && !entry.row.isDismissed()) {
      return;
    }
    entry.row.setRemoved(true);
    List<ExpandableNotificationRow> notificationChildren=entry.row.getNotificationChildren();
    ArrayList<ExpandableNotificationRow> toRemove=new ArrayList<>(notificationChildren);
    for (int i=0; i < toRemove.size(); i++) {
      toRemove.get(i).setKeepInParent(true);
      toRemove.get(i).setRemoved(true);
    }
    for (int i=0; i < toRemove.size(); i++) {
      removeNotification(toRemove.get(i).getStatusBarNotification().getKey(),ranking);
      mStackScroller.removeViewStateForView(toRemove.get(i));
    }
  }
}
Program: 191649
Project: 191649
Buggy source:
@Override protected void onLayout(boolean changed,int l,int t,int r,int b){
  int childCount=Math.min(mChildren.size(),NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
  for (int i=0; i < childCount; i++) {
    View child=mChildren.get(i);
    if (child.getVisibility() == View.GONE) {
      continue;
    }
    child.layout(0,0,child.getMeasuredWidth(),child.getMeasuredHeight());
    mDividers.get(i).layout(0,0,getWidth(),mDividerHeight);
  }
  if (mOverflowNumber != null) {
    mOverflowNumber.layout(getWidth() - mOverflowNumber.getMeasuredWidth(),0,getWidth(),mOverflowNumber.getMeasuredHeight());
  }
}

Fixed version (ground truth):
@Override protected void onLayout(boolean changed,int l,int t,int r,int b){
  int childCount=Math.min(mChildren.size(),NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
  for (int i=0; i < childCount; i++) {
    View child=mChildren.get(i);
    child.layout(0,0,child.getMeasuredWidth(),child.getMeasuredHeight());
    mDividers.get(i).layout(0,0,getWidth(),mDividerHeight);
  }
  if (mOverflowNumber != null) {
    mOverflowNumber.layout(getWidth() - mOverflowNumber.getMeasuredWidth(),0,getWidth(),mOverflowNumber.getMeasuredHeight());
  }
}
Program: 191651
Project: 191651
Buggy source:
@Override protected void onLayout(boolean changed,int l,int t,int r,int b){
  float centerX=getWidth() / 2.0f;
  for (int i=0; i < getChildCount(); i++) {
    View child=getChildAt(i);
    if (child.getVisibility() == GONE) {
      continue;
    }
    float width=child.getMeasuredWidth();
    float height=child.getMeasuredHeight();
    child.layout((int)(centerX - width / 2.0f),0,(int)(centerX + width / 2.0f),(int)height);
  }
  setMaxLayoutHeight(getHeight());
  updateContentHeight();
  clampScrollPosition();
  if (mRequestViewResizeAnimationOnLayout) {
    requestAnimationOnViewResize(null);
    mRequestViewResizeAnimationOnLayout=false;
  }
  requestChildrenUpdate();
  updateFirstAndLastBackgroundViews();
}

Fixed version (ground truth):
@Override protected void onLayout(boolean changed,int l,int t,int r,int b){
  float centerX=getWidth() / 2.0f;
  for (int i=0; i < getChildCount(); i++) {
    View child=getChildAt(i);
    float width=child.getMeasuredWidth();
    float height=child.getMeasuredHeight();
    child.layout((int)(centerX - width / 2.0f),0,(int)(centerX + width / 2.0f),(int)height);
  }
  setMaxLayoutHeight(getHeight());
  updateContentHeight();
  clampScrollPosition();
  if (mRequestViewResizeAnimationOnLayout) {
    requestAnimationOnViewResize(null);
    mRequestViewResizeAnimationOnLayout=false;
  }
  requestChildrenUpdate();
  updateFirstAndLastBackgroundViews();
}
Program: 191652
Project: 191652
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  measureChildren(widthMeasureSpec,heightMeasureSpec);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  final int size=getChildCount();
  for (int i=0; i < size; i++) {
    measureChild(getChildAt(i),widthMeasureSpec,heightMeasureSpec);
  }
}
Program: 191657
Project: 191657
Buggy source:
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
}

Fixed version (ground truth):
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
  mIsolatedEntries.remove(removed.key);
}
Program: 191661
Project: 191661
Buggy source:
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(getTransientView(0));
  }
}

Fixed version (ground truth):
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(viewGroup.getTransientView(0));
  }
}
Program: 191662
Project: 191662
Buggy source:
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(getTransientView(0));
  }
}

Fixed version (ground truth):
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(viewGroup.getTransientView(0));
  }
}
Program: 191663
Project: 191663
Buggy source:
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(getTransientView(0));
  }
}

Fixed version (ground truth):
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(viewGroup.getTransientView(0));
  }
}
Program: 191664
Project: 191664
Buggy source:
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(getTransientView(0));
  }
}

Fixed version (ground truth):
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(viewGroup.getTransientView(0));
  }
}
Program: 191665
Project: 191665
Buggy source:
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(getTransientView(0));
  }
}

Fixed version (ground truth):
private void clearTransientViews(ViewGroup viewGroup){
  while (viewGroup != null && viewGroup.getTransientViewCount() != 0) {
    viewGroup.removeTransientView(viewGroup.getTransientView(0));
  }
}
Program: 191666
Project: 191666
Buggy source:
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
}

Fixed version (ground truth):
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
  mIsolatedEntries.remove(removed.key);
}
Program: 191668
Project: 191668
Buggy source:
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
}

Fixed version (ground truth):
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
  mIsolatedEntries.remove(removed.key);
}
Program: 191670
Project: 191670
Buggy source:
private void updateHideSensitiveForChild(View child){
  if (mAmbientState.isHideSensitive() && child instanceof ExpandableView) {
    ExpandableView expandableView=(ExpandableView)child;
    expandableView.setHideSensitiveForIntrinsicHeight(true);
  }
}

Fixed version (ground truth):
private void updateHideSensitiveForChild(View child){
  if (child instanceof ExpandableView) {
    ExpandableView expandableView=(ExpandableView)child;
    expandableView.setHideSensitiveForIntrinsicHeight(mAmbientState.isHideSensitive());
  }
}
Program: 191671
Project: 191671
Buggy source:
private void updateHideSensitiveForChild(View child){
  if (mAmbientState.isHideSensitive() && child instanceof ExpandableView) {
    ExpandableView expandableView=(ExpandableView)child;
    expandableView.setHideSensitiveForIntrinsicHeight(true);
  }
}

Fixed version (ground truth):
private void updateHideSensitiveForChild(View child){
  if (child instanceof ExpandableView) {
    ExpandableView expandableView=(ExpandableView)child;
    expandableView.setHideSensitiveForIntrinsicHeight(mAmbientState.isHideSensitive());
  }
}
Program: 191672
Project: 191672
Buggy source:
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
}

Fixed version (ground truth):
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
  mIsolatedEntries.remove(removed.key);
}
Program: 191674
Project: 191674
Buggy source:
public void onEntryUpdated(NotificationData.Entry entry,StatusBarNotification oldNotification){
  if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
    onEntryRemovedInternal(entry,oldNotification);
  }
  onEntryAdded(entry);
  if (isIsolated(entry.notification)) {
    mIsolatedEntries.put(entry.key,entry.notification);
    String oldKey=oldNotification.getGroupKey();
    String newKey=entry.notification.getGroupKey();
    if (!oldKey.equals(newKey)) {
      updateSuppression(mGroupMap.get(oldKey));
      updateSuppression(mGroupMap.get(newKey));
    }
  }
}

Fixed version (ground truth):
public void onEntryUpdated(NotificationData.Entry entry,StatusBarNotification oldNotification){
  if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
    onEntryRemovedInternal(entry,oldNotification);
  }
  onEntryAdded(entry);
  if (isIsolated(entry.notification)) {
    mIsolatedEntries.put(entry.key,entry.notification);
    String oldKey=oldNotification.getGroupKey();
    String newKey=entry.notification.getGroupKey();
    if (!oldKey.equals(newKey)) {
      updateSuppression(mGroupMap.get(oldKey));
      updateSuppression(mGroupMap.get(newKey));
    }
  }
 else   if (!isGroupChild(oldNotification) && isGroupChild(entry.notification)) {
    onEntryBecomingChild(entry);
  }
}
Program: 191675
Project: 191675
Buggy source:
public void onEntryAdded(final NotificationData.Entry added){
  final StatusBarNotification sbn=added.notification;
  boolean isGroupChild=isGroupChild(sbn);
  String groupKey=getGroupKey(sbn);
  NotificationGroup group=mGroupMap.get(groupKey);
  if (group == null) {
    group=new NotificationGroup();
    mGroupMap.put(groupKey,group);
  }
  if (isGroupChild) {
    group.children.add(added);
    updateSuppression(group);
  }
 else {
    group.summary=added;
    group.expanded=added.row.areChildrenExpanded();
    updateSuppression(group);
    if (!group.children.isEmpty()) {
      mListener.onGroupCreatedFromChildren(group);
    }
  }
}

Fixed version (ground truth):
public void onEntryAdded(final NotificationData.Entry added){
  final StatusBarNotification sbn=added.notification;
  boolean isGroupChild=isGroupChild(sbn);
  String groupKey=getGroupKey(sbn);
  NotificationGroup group=mGroupMap.get(groupKey);
  if (group == null) {
    group=new NotificationGroup();
    mGroupMap.put(groupKey,group);
  }
  if (isGroupChild) {
    group.children.add(added);
    updateSuppression(group);
  }
 else {
    group.summary=added;
    group.expanded=added.row.areChildrenExpanded();
    updateSuppression(group);
    if (!group.children.isEmpty()) {
      HashSet<NotificationData.Entry> childrenCopy=(HashSet<NotificationData.Entry>)group.children.clone();
      for (      NotificationData.Entry child : childrenCopy) {
        onEntryBecomingChild(child);
      }
      mListener.onGroupCreatedFromChildren(group);
    }
  }
}
Program: 191676
Project: 191676
Buggy source:
public void onEntryUpdated(NotificationData.Entry entry,StatusBarNotification oldNotification){
  if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
    onEntryRemovedInternal(entry,oldNotification);
  }
  onEntryAdded(entry);
  if (isIsolated(entry.notification)) {
    mIsolatedEntries.put(entry.key,entry.notification);
    String oldKey=oldNotification.getGroupKey();
    String newKey=entry.notification.getGroupKey();
    if (!oldKey.equals(newKey)) {
      updateSuppression(mGroupMap.get(oldKey));
      updateSuppression(mGroupMap.get(newKey));
    }
  }
}

Fixed version (ground truth):
public void onEntryUpdated(NotificationData.Entry entry,StatusBarNotification oldNotification){
  if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
    onEntryRemovedInternal(entry,oldNotification);
  }
  onEntryAdded(entry);
  if (isIsolated(entry.notification)) {
    mIsolatedEntries.put(entry.key,entry.notification);
    String oldKey=oldNotification.getGroupKey();
    String newKey=entry.notification.getGroupKey();
    if (!oldKey.equals(newKey)) {
      updateSuppression(mGroupMap.get(oldKey));
      updateSuppression(mGroupMap.get(newKey));
    }
  }
 else   if (!isGroupChild(oldNotification) && isGroupChild(entry.notification)) {
    onEntryBecomingChild(entry);
  }
}
Program: 191677
Project: 191677
Buggy source:
public void onEntryAdded(final NotificationData.Entry added){
  final StatusBarNotification sbn=added.notification;
  boolean isGroupChild=isGroupChild(sbn);
  String groupKey=getGroupKey(sbn);
  NotificationGroup group=mGroupMap.get(groupKey);
  if (group == null) {
    group=new NotificationGroup();
    mGroupMap.put(groupKey,group);
  }
  if (isGroupChild) {
    group.children.add(added);
    updateSuppression(group);
  }
 else {
    group.summary=added;
    group.expanded=added.row.areChildrenExpanded();
    updateSuppression(group);
    if (!group.children.isEmpty()) {
      mListener.onGroupCreatedFromChildren(group);
    }
  }
}

Fixed version (ground truth):
public void onEntryAdded(final NotificationData.Entry added){
  final StatusBarNotification sbn=added.notification;
  boolean isGroupChild=isGroupChild(sbn);
  String groupKey=getGroupKey(sbn);
  NotificationGroup group=mGroupMap.get(groupKey);
  if (group == null) {
    group=new NotificationGroup();
    mGroupMap.put(groupKey,group);
  }
  if (isGroupChild) {
    group.children.add(added);
    updateSuppression(group);
  }
 else {
    group.summary=added;
    group.expanded=added.row.areChildrenExpanded();
    updateSuppression(group);
    if (!group.children.isEmpty()) {
      HashSet<NotificationData.Entry> childrenCopy=(HashSet<NotificationData.Entry>)group.children.clone();
      for (      NotificationData.Entry child : childrenCopy) {
        onEntryBecomingChild(child);
      }
      mListener.onGroupCreatedFromChildren(group);
    }
  }
}
Program: 191678
Project: 191678
Buggy source:
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
}

Fixed version (ground truth):
public void onEntryRemoved(NotificationData.Entry removed){
  onEntryRemovedInternal(removed,removed.notification);
  mIsolatedEntries.remove(removed.key);
}
Program: 191682
Project: 191682
Buggy source:
public boolean dumpHistory(PrintWriter pw,String prefix,int filterUid){
  if (mEventCmds[0] == EVENT_NULL) {
    return false;
  }
  pw.println("String_Node_Str");
  long now=SystemClock.elapsedRealtime();
  for (int i=EVENT_BUFFER_SIZE - 1; i >= 0; i--) {
    int uid=mEventUids[i];
    if (filterUid != -1 && filterUid != UserHandle.getAppId(filterUid)) {
      continue;
    }
    int cmd=mEventCmds[i];
    if (cmd == EVENT_NULL) {
      continue;
    }
    String label;
switch (mEventCmds[i]) {
case EVENT_START_JOB:
      label="String_Node_Str";
    break;
case EVENT_STOP_JOB:
  label="String_Node_Str";
break;
default :
label="String_Node_Str";
break;
}
pw.print(prefix);
TimeUtils.formatDuration(mEventTimes[i] - now,pw,TimeUtils.HUNDRED_DAY_FIELD_LEN);
pw.print("String_Node_Str");
pw.print(label);
pw.print("String_Node_Str");
UserHandle.formatUid(pw,uid);
pw.print("String_Node_Str");
pw.println(mEventTags[i]);
}
return true;
}

Fixed version (ground truth):
public boolean dumpHistory(PrintWriter pw,String prefix,int filterUid){
  final int size=mEventIndices.size();
  if (size <= 0) {
    return false;
  }
  pw.println("String_Node_Str");
  final long now=SystemClock.elapsedRealtime();
  for (int i=0; i < size; i++) {
    final int index=mEventIndices.indexOf(i);
    final int uid=mEventUids[index];
    if (filterUid != -1 && filterUid != UserHandle.getAppId(filterUid)) {
      continue;
    }
    final int cmd=mEventCmds[index];
    if (cmd == EVENT_NULL) {
      continue;
    }
    final String label;
switch (mEventCmds[index]) {
case EVENT_START_JOB:
      label="String_Node_Str";
    break;
case EVENT_STOP_JOB:
  label="String_Node_Str";
break;
default :
label="String_Node_Str";
break;
}
pw.print(prefix);
TimeUtils.formatDuration(mEventTimes[index] - now,pw,TimeUtils.HUNDRED_DAY_FIELD_LEN);
pw.print("String_Node_Str");
pw.print(label);
pw.print("String_Node_Str");
UserHandle.formatUid(pw,uid);
pw.print("String_Node_Str");
pw.println(mEventTags[index]);
}
return true;
}
Program: 191683
Project: 191683
Buggy source:
public long getActiveTopTime(long now){
  long time=pastActiveTopTime;
  if (activeTopCount > 0) {
    time+=now - activeTopStartTime;
  }
  return time;
}

Fixed version (ground truth):
public long getActiveTopTime(long now){
  long time=pastActiveTopTime;
  if (activeTopNesting > 0) {
    time+=now - activeTopStartTime;
  }
  return time;
}
Program: 191684
Project: 191684
Buggy source:
void decActive(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeCount == 1) {
    pe.pastActiveTime+=now - pe.activeStartTime;
  }
  pe.activeCount--;
}

Fixed version (ground truth):
void decActive(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeNesting == 1) {
    pe.pastActiveTime+=now - pe.activeStartTime;
  }
  pe.activeNesting--;
}
Program: 191685
Project: 191685
Buggy source:
void printDuration(PrintWriter pw,long period,long duration,String suffix){
  float fraction=duration / (float)period;
  int percent=(int)((fraction * 100) + .5f);
  if (percent > 0) {
    pw.print("String_Node_Str");
    pw.print(percent);
    pw.print("String_Node_Str");
    pw.print(suffix);
  }
}

Fixed version (ground truth):
void printDuration(PrintWriter pw,long period,long duration,int count,String suffix){
  float fraction=duration / (float)period;
  int percent=(int)((fraction * 100) + .5f);
  if (percent > 0) {
    pw.print("String_Node_Str");
    pw.print(percent);
    pw.print("String_Node_Str");
    pw.print(count);
    pw.print("String_Node_Str");
    pw.print(suffix);
  }
 else   if (count > 0) {
    pw.print("String_Node_Str");
    pw.print(count);
    pw.print("String_Node_Str");
    pw.print(suffix);
  }
}
Program: 191686
Project: 191686
Buggy source:
public void addEvent(int cmd,int uid,String tag){
  System.arraycopy(mEventCmds,0,mEventCmds,1,EVENT_BUFFER_SIZE - 1);
  System.arraycopy(mEventTimes,0,mEventTimes,1,EVENT_BUFFER_SIZE - 1);
  System.arraycopy(mEventUids,0,mEventUids,1,EVENT_BUFFER_SIZE - 1);
  System.arraycopy(mEventTags,0,mEventTags,1,EVENT_BUFFER_SIZE - 1);
  mEventCmds[0]=cmd;
  mEventTimes[0]=SystemClock.elapsedRealtime();
  mEventUids[0]=uid;
  mEventTags[0]=tag;
}

Fixed version (ground truth):
public void addEvent(int cmd,int uid,String tag){
  int index=mEventIndices.add();
  mEventCmds[index]=cmd;
  mEventTimes[index]=SystemClock.elapsedRealtime();
  mEventUids[index]=uid;
  mEventTags[index]=tag;
}
Program: 191687
Project: 191687
Buggy source:
void finish(DataSet next,long now){
  for (int i=mEntries.size() - 1; i >= 0; i--) {
    ArrayMap<String,PackageEntry> uidMap=mEntries.valueAt(i);
    for (int j=uidMap.size() - 1; j >= 0; j--) {
      PackageEntry pe=uidMap.valueAt(j);
      if (pe.activeCount > 0 || pe.activeTopCount > 0 || pe.pendingCount > 0) {
        PackageEntry nextPe=next.getOrCreateEntry(mEntries.keyAt(i),uidMap.keyAt(j));
        nextPe.activeStartTime=now;
        nextPe.activeCount=pe.activeCount;
        nextPe.activeTopStartTime=now;
        nextPe.activeTopCount=pe.activeTopCount;
        nextPe.pendingStartTime=now;
        nextPe.pendingCount=pe.pendingCount;
        if (pe.activeCount > 0) {
          pe.pastActiveTime+=now - pe.activeStartTime;
          pe.activeCount=0;
        }
        if (pe.activeTopCount > 0) {
          pe.pastActiveTopTime+=now - pe.activeTopStartTime;
          pe.activeTopCount=0;
        }
        if (pe.pendingCount > 0) {
          pe.pastPendingTime+=now - pe.pendingStartTime;
          pe.pendingCount=0;
        }
      }
    }
  }
}

Fixed version (ground truth):
void finish(DataSet next,long now){
  for (int i=mEntries.size() - 1; i >= 0; i--) {
    ArrayMap<String,PackageEntry> uidMap=mEntries.valueAt(i);
    for (int j=uidMap.size() - 1; j >= 0; j--) {
      PackageEntry pe=uidMap.valueAt(j);
      if (pe.activeNesting > 0 || pe.activeTopNesting > 0 || pe.pendingNesting > 0) {
        PackageEntry nextPe=next.getOrCreateEntry(mEntries.keyAt(i),uidMap.keyAt(j));
        nextPe.activeStartTime=now;
        nextPe.activeNesting=pe.activeNesting;
        nextPe.activeTopStartTime=now;
        nextPe.activeTopNesting=pe.activeTopNesting;
        nextPe.pendingStartTime=now;
        nextPe.pendingNesting=pe.pendingNesting;
        if (pe.activeNesting > 0) {
          pe.pastActiveTime+=now - pe.activeStartTime;
          pe.activeNesting=0;
        }
        if (pe.activeTopNesting > 0) {
          pe.pastActiveTopTime+=now - pe.activeTopStartTime;
          pe.activeTopNesting=0;
        }
        if (pe.pendingNesting > 0) {
          pe.pastPendingTime+=now - pe.pendingStartTime;
          pe.pendingNesting=0;
        }
      }
    }
  }
}
Program: 191688
Project: 191688
Buggy source:
void incActiveTop(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeTopCount == 0) {
    pe.activeTopStartTime=now;
  }
  pe.activeTopCount++;
}

Fixed version (ground truth):
void incActiveTop(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeTopNesting == 0) {
    pe.activeTopStartTime=now;
    pe.activeTopCount++;
  }
  pe.activeTopNesting++;
}
Program: 191689
Project: 191689
Buggy source:
void decActiveTop(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeTopCount == 1) {
    pe.pastActiveTopTime+=now - pe.activeTopStartTime;
  }
  pe.activeTopCount--;
}

Fixed version (ground truth):
void decActiveTop(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeTopNesting == 1) {
    pe.pastActiveTopTime+=now - pe.activeTopStartTime;
  }
  pe.activeTopNesting--;
}
Program: 191690
Project: 191690
Buggy source:
void incActive(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeCount == 0) {
    pe.activeStartTime=now;
  }
  pe.activeCount++;
}

Fixed version (ground truth):
void incActive(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.activeNesting == 0) {
    pe.activeStartTime=now;
    pe.activeCount++;
  }
  pe.activeNesting++;
}
Program: 191691
Project: 191691
Buggy source:
void decPending(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.pendingCount == 1) {
    pe.pastPendingTime+=now - pe.pendingStartTime;
  }
  pe.pendingCount--;
}

Fixed version (ground truth):
void decPending(int uid,String pkg,long now){
  PackageEntry pe=getOrCreateEntry(uid,pkg);
  if (pe.pendingNesting == 1) {
    pe.pastPendingTime+=now - pe.pendingStartTime;
  }
  pe.pendingNesting--;
}