Program: 191813
Project: 191813
Buggy source:
@Override public void removeNotification(String key,RankingMap ranking){
  boolean deferRemoval=false;
  if (mHeadsUpManager.isHeadsUp(key)) {
    deferRemoval=!mHeadsUpManager.removeNotification(key);
  }
  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;
  }
  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) {
        goToKeyguard();
      }
    }
  }
  setAreThereNotifications();
}

Fixed version (ground truth):
@Override public void removeNotification(String key,RankingMap ranking){
  boolean deferRemoval=false;
  if (mHeadsUpManager.isHeadsUp(key)) {
    deferRemoval=!mHeadsUpManager.removeNotification(key);
  }
  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;
  }
  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) {
        goToKeyguard();
      }
    }
  }
  setAreThereNotifications();
}