Program: 191616
Project: 191616
Buggy source:
/** 
 * Updates expanded, dimmed and locked states of notification rows.
 */
protected void updateRowStates(){
  mKeyguardIconOverflowContainer.getIconsView().removeAllViews();
  ArrayList<Entry> activeNotifications=mNotificationData.getActiveNotifications();
  final int N=activeNotifications.size();
  int visibleNotifications=0;
  boolean onKeyguard=mState == StatusBarState.KEYGUARD;
  int maxNotifications=0;
  if (onKeyguard) {
    maxNotifications=getMaxKeyguardNotifications(true);
  }
  for (int i=0; i < N; i++) {
    NotificationData.Entry entry=activeNotifications.get(i);
    boolean childNotification=mGroupManager.isChildInGroupWithSummary(entry.notification);
    if (onKeyguard) {
      entry.row.setOnKeyguard(true);
    }
 else {
      entry.row.setOnKeyguard(false);
      entry.row.setSystemExpanded(visibleNotifications == 0 && !childNotification);
    }
    boolean suppressedSummary=mGroupManager.isSummaryOfSuppressedGroup(entry.notification) && !entry.row.isRemoved();
    boolean childWithVisibleSummary=childNotification && mGroupManager.getGroupSummary(entry.notification).getVisibility() == View.VISIBLE;
    boolean showOnKeyguard=shouldShowOnKeyguard(entry.notification);
    if (suppressedSummary || (isLockscreenPublicMode() && !mShowLockscreenNotifications) || (onKeyguard && !childWithVisibleSummary && (visibleNotifications >= maxNotifications || !showOnKeyguard))) {
      entry.row.setVisibility(View.GONE);
      if (onKeyguard && showOnKeyguard && !childNotification&& !suppressedSummary) {
        mKeyguardIconOverflowContainer.getIconsView().addNotification(entry);
      }
    }
 else {
      boolean wasGone=entry.row.getVisibility() == View.GONE;
      entry.row.setVisibility(View.VISIBLE);
      if (!childNotification) {
        if (wasGone) {
          mStackScroller.generateAddAnimation(entry.row,!showOnKeyguard);
        }
        visibleNotifications++;
      }
    }
  }
  mStackScroller.updateOverflowContainerVisibility(onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0);
  mStackScroller.changeViewPosition(mDismissView,mStackScroller.getChildCount() - 1);
  mStackScroller.changeViewPosition(mEmptyShadeView,mStackScroller.getChildCount() - 2);
  mStackScroller.changeViewPosition(mKeyguardIconOverflowContainer,mStackScroller.getChildCount() - 3);
}

Fixed version (ground truth):
/** 
 * Updates expanded, dimmed and locked states of notification rows.
 */
protected void updateRowStates(){
  mKeyguardIconOverflowContainer.getIconsView().removeAllViews();
  ArrayList<Entry> activeNotifications=mNotificationData.getActiveNotifications();
  final int N=activeNotifications.size();
  int visibleNotifications=0;
  boolean onKeyguard=mState == StatusBarState.KEYGUARD;
  int maxNotifications=0;
  if (onKeyguard) {
    maxNotifications=getMaxKeyguardNotifications(true);
  }
  for (int i=0; i < N; i++) {
    NotificationData.Entry entry=activeNotifications.get(i);
    boolean childNotification=mGroupManager.isChildInGroupWithSummary(entry.notification);
    if (onKeyguard) {
      entry.row.setOnKeyguard(true);
    }
 else {
      entry.row.setOnKeyguard(false);
      entry.row.setSystemExpanded(visibleNotifications == 0 && !childNotification);
    }
    boolean suppressedSummary=mGroupManager.isSummaryOfSuppressedGroup(entry.notification) && !entry.row.isRemoved();
    boolean childWithVisibleSummary=childNotification && mGroupManager.getGroupSummary(entry.notification).getVisibility() == View.VISIBLE;
    boolean showOnKeyguard=shouldShowOnKeyguard(entry.notification);
    if (suppressedSummary || (isLockscreenPublicMode() && !mShowLockscreenNotifications) || (onKeyguard && !childWithVisibleSummary && (visibleNotifications >= maxNotifications || !showOnKeyguard))) {
      entry.row.setVisibility(View.GONE);
      if (onKeyguard && showOnKeyguard && !childNotification&& !suppressedSummary) {
        mKeyguardIconOverflowContainer.getIconsView().addNotification(entry);
      }
    }
 else {
      boolean wasGone=entry.row.getVisibility() == View.GONE;
      entry.row.setVisibility(View.VISIBLE);
      if (!childNotification && !entry.row.isRemoved()) {
        if (wasGone) {
          mStackScroller.generateAddAnimation(entry.row,!showOnKeyguard);
        }
        visibleNotifications++;
      }
    }
  }
  mStackScroller.updateOverflowContainerVisibility(onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0);
  mStackScroller.changeViewPosition(mDismissView,mStackScroller.getChildCount() - 1);
  mStackScroller.changeViewPosition(mEmptyShadeView,mStackScroller.getChildCount() - 2);
  mStackScroller.changeViewPosition(mKeyguardIconOverflowContainer,mStackScroller.getChildCount() - 3);
}