Program: 191087
Project: 191087
Buggy source:
@Override public void removeNotification(String key,RankingMap ranking){
  boolean deferRemoval=false;
  if (mHeadsUpManager.isHeadsUp(key)) {
    boolean ignoreEarliestRemovalTime=mRemoteInputController.isSpinning(key) && !FORCE_REMOTE_INPUT_HISTORY;
    deferRemoval=!mHeadsUpManager.removeNotification(key,ignoreEarliestRemovalTime);
  }
  if (key.equals(mMediaNotificationKey)) {
    clearCurrentMediaNotification();
    updateMediaMetaData(true,true);
  }
  if (FORCE_REMOTE_INPUT_HISTORY && mRemoteInputController.isSpinning(key)) {
    Entry entry=mNotificationData.get(key);
    StatusBarNotification sbn=entry.notification;
    Notification.Builder b=Notification.Builder.recoverBuilder(mContext,sbn.getNotification().clone());
    CharSequence[] oldHistory=sbn.getNotification().extras.getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY);
    CharSequence[] newHistory;
    if (oldHistory == null) {
      newHistory=new CharSequence[1];
    }
 else {
      newHistory=new CharSequence[oldHistory.length + 1];
      for (int i=0; i < oldHistory.length; i++) {
        newHistory[i + 1]=oldHistory[i];
      }
    }
    newHistory[0]=String.valueOf(entry.remoteInputText);
    b.setRemoteInputHistory(newHistory);
    Notification newNotification=b.build();
    newNotification.contentView=sbn.getNotification().contentView;
    newNotification.bigContentView=sbn.getNotification().bigContentView;
    newNotification.headsUpContentView=sbn.getNotification().headsUpContentView;
    StatusBarNotification newSbn=new StatusBarNotification(sbn.getPackageName(),sbn.getOpPkg(),sbn.getId(),sbn.getTag(),sbn.getUid(),sbn.getInitialPid(),0,newNotification,sbn.getUser(),sbn.getPostTime());
    updateNotification(newSbn,null);
    mKeysKeptForRemoteInput.add(entry.key);
    return;
  }
  if (deferRemoval) {
    mLatestRankingMap=ranking;
    mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key));
    return;
  }
  Entry entry=mNotificationData.get(key);
  if (entry != null && mRemoteInputController.isRemoteInputActive(entry)) {
    mLatestRankingMap=ranking;
    mRemoteInputEntriesToRemoveOnCollapse.add(entry);
    return;
  }
  if (entry != null && entry.row != null) {
    entry.row.setRemoved();
  }
  handleGroupSummaryRemoved(key,ranking);
  StatusBarNotification old=removeNotificationViews(key,ranking);
  if (SPEW)   Log.d(TAG,"String_Node_Str" + key + "String_Node_Str"+ old);
  if (old != null) {
    if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() && !mNotificationPanel.isTracking()&& !mNotificationPanel.isQsExpanded()) {
      if (mState == StatusBarState.SHADE) {
        animateCollapsePanels();
      }
 else       if (mState == StatusBarState.SHADE_LOCKED && !isCollapsing()) {
        goToKeyguard();
      }
    }
  }
  setAreThereNotifications();
}

Fixed version (ground truth):
@Override public void removeNotification(String key,RankingMap ranking){
  boolean deferRemoval=false;
  if (mHeadsUpManager.isHeadsUp(key)) {
    boolean ignoreEarliestRemovalTime=mRemoteInputController.isSpinning(key) && !FORCE_REMOTE_INPUT_HISTORY;
    deferRemoval=!mHeadsUpManager.removeNotification(key,ignoreEarliestRemovalTime);
  }
  if (key.equals(mMediaNotificationKey)) {
    clearCurrentMediaNotification();
    updateMediaMetaData(true,true);
  }
  if (FORCE_REMOTE_INPUT_HISTORY && mRemoteInputController.isSpinning(key)) {
    Entry entry=mNotificationData.get(key);
    StatusBarNotification sbn=entry.notification;
    Notification.Builder b=Notification.Builder.recoverBuilder(mContext,sbn.getNotification().clone());
    CharSequence[] oldHistory=sbn.getNotification().extras.getCharSequenceArray(Notification.EXTRA_REMOTE_INPUT_HISTORY);
    CharSequence[] newHistory;
    if (oldHistory == null) {
      newHistory=new CharSequence[1];
    }
 else {
      newHistory=new CharSequence[oldHistory.length + 1];
      for (int i=0; i < oldHistory.length; i++) {
        newHistory[i + 1]=oldHistory[i];
      }
    }
    newHistory[0]=String.valueOf(entry.remoteInputText);
    b.setRemoteInputHistory(newHistory);
    Notification newNotification=b.build();
    newNotification.contentView=sbn.getNotification().contentView;
    newNotification.bigContentView=sbn.getNotification().bigContentView;
    newNotification.headsUpContentView=sbn.getNotification().headsUpContentView;
    StatusBarNotification newSbn=new StatusBarNotification(sbn.getPackageName(),sbn.getOpPkg(),sbn.getId(),sbn.getTag(),sbn.getUid(),sbn.getInitialPid(),0,newNotification,sbn.getUser(),sbn.getPostTime());
    updateNotification(newSbn,null);
    mKeysKeptForRemoteInput.add(entry.key);
    return;
  }
  if (deferRemoval) {
    mLatestRankingMap=ranking;
    mHeadsUpEntriesToRemoveOnSwitch.add(mHeadsUpManager.getEntry(key));
    return;
  }
  Entry entry=mNotificationData.get(key);
  if (entry != null && mRemoteInputController.isRemoteInputActive(entry) && (entry.row != null && !entry.row.isDismissed())) {
    mLatestRankingMap=ranking;
    mRemoteInputEntriesToRemoveOnCollapse.add(entry);
    return;
  }
  if (entry != null && entry.row != null) {
    entry.row.setRemoved();
  }
  handleGroupSummaryRemoved(key,ranking);
  StatusBarNotification old=removeNotificationViews(key,ranking);
  if (SPEW)   Log.d(TAG,"String_Node_Str" + key + "String_Node_Str"+ old);
  if (old != null) {
    if (CLOSE_PANEL_WHEN_EMPTIED && !hasActiveNotifications() && !mNotificationPanel.isTracking()&& !mNotificationPanel.isQsExpanded()) {
      if (mState == StatusBarState.SHADE) {
        animateCollapsePanels();
      }
 else       if (mState == StatusBarState.SHADE_LOCKED && !isCollapsing()) {
        goToKeyguard();
      }
    }
  }
  setAreThereNotifications();
}