nus-yam/ex-repair huggingface dataset:
Program: 191246
Project: 191246
Buggy source:
JobInstance(JobStatus jobStatus){
  mJobStatus=jobStatus;
  mExecuteRunner=new TriggerRunnable(this);
  mTimeoutRunner=new TriggerRunnable(this);
  final JobInfo.TriggerContentUri[] uris=jobStatus.getJob().getTriggerContentUris();
  if (uris != null) {
    for (    JobInfo.TriggerContentUri uri : uris) {
      ObserverInstance obs=mObservers.get(uri.getUri());
      if (obs == null) {
        obs=new ObserverInstance(mHandler,uri.getUri());
        mObservers.put(uri.getUri(),obs);
        mContext.getContentResolver().registerContentObserver(uri.getUri(),(uri.getFlags() & JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS) != 0,obs);
      }
      obs.mJobs.add(this);
      mMyObservers.add(obs);
    }
  }
}

Fixed version (ground truth):
JobInstance(JobStatus jobStatus){
  mJobStatus=jobStatus;
  mExecuteRunner=new TriggerRunnable(this);
  mTimeoutRunner=new TriggerRunnable(this);
  final JobInfo.TriggerContentUri[] uris=jobStatus.getJob().getTriggerContentUris();
  if (uris != null) {
    for (    JobInfo.TriggerContentUri uri : uris) {
      ObserverInstance obs=mObservers.get(uri);
      if (obs == null) {
        obs=new ObserverInstance(mHandler,uri.getUri());
        mObservers.put(uri,obs);
        mContext.getContentResolver().registerContentObserver(uri.getUri(),(uri.getFlags() & JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS) != 0,obs);
      }
      obs.mJobs.add(this);
      mMyObservers.add(obs);
    }
  }
}
Program: 191248
Project: 191248
Buggy source:
void detachLocked(){
  final int N=mMyObservers.size();
  for (int i=0; i < N; i++) {
    final ObserverInstance obs=mMyObservers.get(i);
    obs.mJobs.remove(this);
    if (obs.mJobs.size() == 0) {
      mContext.getContentResolver().unregisterContentObserver(obs);
      mObservers.remove(obs.mUri);
    }
  }
}

Fixed version (ground truth):
void detachLocked(){
  final int N=mMyObservers.size();
  for (int i=0; i < N; i++) {
    final ObserverInstance obs=mMyObservers.get(i);
    obs.mJobs.remove(this);
    if (obs.mJobs.size() == 0) {
      mContext.getContentResolver().unregisterContentObserver(obs);
      mObservers.remove(obs);
    }
  }
}
Program: 191249
Project: 191249
Buggy source:
JobInstance(JobStatus jobStatus){
  mJobStatus=jobStatus;
  mExecuteRunner=new TriggerRunnable(this);
  mTimeoutRunner=new TriggerRunnable(this);
  final JobInfo.TriggerContentUri[] uris=jobStatus.getJob().getTriggerContentUris();
  if (uris != null) {
    for (    JobInfo.TriggerContentUri uri : uris) {
      ObserverInstance obs=mObservers.get(uri.getUri());
      if (obs == null) {
        obs=new ObserverInstance(mHandler,uri.getUri());
        mObservers.put(uri.getUri(),obs);
        mContext.getContentResolver().registerContentObserver(uri.getUri(),(uri.getFlags() & JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS) != 0,obs);
      }
      obs.mJobs.add(this);
      mMyObservers.add(obs);
    }
  }
}

Fixed version (ground truth):
JobInstance(JobStatus jobStatus){
  mJobStatus=jobStatus;
  mExecuteRunner=new TriggerRunnable(this);
  mTimeoutRunner=new TriggerRunnable(this);
  final JobInfo.TriggerContentUri[] uris=jobStatus.getJob().getTriggerContentUris();
  if (uris != null) {
    for (    JobInfo.TriggerContentUri uri : uris) {
      ObserverInstance obs=mObservers.get(uri);
      if (obs == null) {
        obs=new ObserverInstance(mHandler,uri.getUri());
        mObservers.put(uri,obs);
        mContext.getContentResolver().registerContentObserver(uri.getUri(),(uri.getFlags() & JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS) != 0,obs);
      }
      obs.mJobs.add(this);
      mMyObservers.add(obs);
    }
  }
}
Program: 191251
Project: 191251
Buggy source:
void detachLocked(){
  final int N=mMyObservers.size();
  for (int i=0; i < N; i++) {
    final ObserverInstance obs=mMyObservers.get(i);
    obs.mJobs.remove(this);
    if (obs.mJobs.size() == 0) {
      mContext.getContentResolver().unregisterContentObserver(obs);
      mObservers.remove(obs.mUri);
    }
  }
}

Fixed version (ground truth):
void detachLocked(){
  final int N=mMyObservers.size();
  for (int i=0; i < N; i++) {
    final ObserverInstance obs=mMyObservers.get(i);
    obs.mJobs.remove(this);
    if (obs.mJobs.size() == 0) {
      mContext.getContentResolver().unregisterContentObserver(obs);
      mObservers.remove(obs);
    }
  }
}
Program: 191253
Project: 191253
Buggy source:
private void cancelGroupChildrenLocked(NotificationRecord r,int callingUid,int callingPid,String listenerName,int reason){
  Notification n=r.getNotification();
  if (!n.isGroupSummary()) {
    return;
  }
  String pkg=r.sbn.getPackageName();
  int userId=r.getUserId();
  if (pkg == null) {
    if (DBG)     Log.e(TAG,"String_Node_Str" + r.getKey());
    return;
  }
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord childR=mNotificationList.get(i);
    StatusBarNotification childSbn=childR.sbn;
    if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) && childR.getGroupKey().equals(r.getGroupKey())) {
      EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,childSbn.getId(),childSbn.getTag(),userId,0,0,reason,listenerName);
      mNotificationList.remove(i);
      cancelNotificationLocked(childR,false,reason);
    }
  }
}

Fixed version (ground truth):
private void cancelGroupChildrenLocked(NotificationRecord r,int callingUid,int callingPid,String listenerName,int reason,boolean sendDelete){
  Notification n=r.getNotification();
  if (!n.isGroupSummary()) {
    return;
  }
  String pkg=r.sbn.getPackageName();
  int userId=r.getUserId();
  if (pkg == null) {
    if (DBG)     Log.e(TAG,"String_Node_Str" + r.getKey());
    return;
  }
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord childR=mNotificationList.get(i);
    StatusBarNotification childSbn=childR.sbn;
    if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) && childR.getGroupKey().equals(r.getGroupKey())) {
      EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,childSbn.getId(),childSbn.getTag(),userId,0,0,reason,listenerName);
      mNotificationList.remove(i);
      cancelNotificationLocked(childR,sendDelete,reason);
    }
  }
}
Program: 191254
Project: 191254
Buggy source:
/** 
 * Cancels a notification ONLY if it has all of the   {@code mustHaveFlags}and none of the   {@code mustNotHaveFlags}.
 */
void cancelNotification(final int callingUid,final int callingPid,final String pkg,final String tag,final int id,final int mustHaveFlags,final int mustNotHaveFlags,final boolean sendDelete,final int userId,final int reason,final ManagedServiceInfo listener){
  mHandler.post(new Runnable(){
    @Override public void run(){
      String listenerName=listener == null ? null : listener.component.toShortString();
      if (DBG)       EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,id,tag,userId,mustHaveFlags,mustNotHaveFlags,reason,listenerName);
synchronized (mNotificationList) {
        int index=indexOfNotificationLocked(pkg,tag,id,userId);
        if (index >= 0) {
          NotificationRecord r=mNotificationList.get(index);
          if (reason == REASON_DELEGATE_CLICK) {
            mUsageStats.registerClickedByUser(r);
          }
          if ((r.getNotification().flags & mustHaveFlags) != mustHaveFlags) {
            return;
          }
          if ((r.getNotification().flags & mustNotHaveFlags) != 0) {
            return;
          }
          mNotificationList.remove(index);
          cancelNotificationLocked(r,sendDelete,reason);
          cancelGroupChildrenLocked(r,callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED);
          updateLightsLocked();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Cancels a notification ONLY if it has all of the   {@code mustHaveFlags}and none of the   {@code mustNotHaveFlags}.
 */
void cancelNotification(final int callingUid,final int callingPid,final String pkg,final String tag,final int id,final int mustHaveFlags,final int mustNotHaveFlags,final boolean sendDelete,final int userId,final int reason,final ManagedServiceInfo listener){
  mHandler.post(new Runnable(){
    @Override public void run(){
      String listenerName=listener == null ? null : listener.component.toShortString();
      if (DBG)       EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,id,tag,userId,mustHaveFlags,mustNotHaveFlags,reason,listenerName);
synchronized (mNotificationList) {
        int index=indexOfNotificationLocked(pkg,tag,id,userId);
        if (index >= 0) {
          NotificationRecord r=mNotificationList.get(index);
          if (reason == REASON_DELEGATE_CLICK) {
            mUsageStats.registerClickedByUser(r);
          }
          if ((r.getNotification().flags & mustHaveFlags) != mustHaveFlags) {
            return;
          }
          if ((r.getNotification().flags & mustNotHaveFlags) != 0) {
            return;
          }
          mNotificationList.remove(index);
          cancelNotificationLocked(r,sendDelete,reason);
          cancelGroupChildrenLocked(r,callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED,sendDelete);
          updateLightsLocked();
        }
      }
    }
  }
);
}
Program: 191255
Project: 191255
Buggy source:
/** 
 * Ensures that grouped notification receive their special treatment. <p>Cancels group children if the new notification causes a group to lose its summary.</p> <p>Updates mSummaryByGroupKey.</p>
 */
private void handleGroupedNotificationLocked(NotificationRecord r,NotificationRecord old,int callingUid,int callingPid){
  StatusBarNotification sbn=r.sbn;
  Notification n=sbn.getNotification();
  if (n.isGroupSummary() && !sbn.isAppGroup()) {
    n.flags&=~Notification.FLAG_GROUP_SUMMARY;
  }
  String group=sbn.getGroupKey();
  boolean isSummary=n.isGroupSummary();
  Notification oldN=old != null ? old.sbn.getNotification() : null;
  String oldGroup=old != null ? old.sbn.getGroupKey() : null;
  boolean oldIsSummary=old != null && oldN.isGroupSummary();
  if (oldIsSummary) {
    NotificationRecord removedSummary=mSummaryByGroupKey.remove(oldGroup);
    if (removedSummary != old) {
      String removedKey=removedSummary != null ? removedSummary.getKey() : "String_Node_Str";
      Slog.w(TAG,"String_Node_Str" + old.getKey() + "String_Node_Str"+ removedKey);
    }
  }
  if (isSummary) {
    mSummaryByGroupKey.put(group,r);
  }
  if (oldIsSummary && (!isSummary || !oldGroup.equals(group))) {
    cancelGroupChildrenLocked(old,callingUid,callingPid,null,REASON_GROUP_SUMMARY_CANCELED);
  }
}

Fixed version (ground truth):
/** 
 * Ensures that grouped notification receive their special treatment. <p>Cancels group children if the new notification causes a group to lose its summary.</p> <p>Updates mSummaryByGroupKey.</p>
 */
private void handleGroupedNotificationLocked(NotificationRecord r,NotificationRecord old,int callingUid,int callingPid){
  StatusBarNotification sbn=r.sbn;
  Notification n=sbn.getNotification();
  if (n.isGroupSummary() && !sbn.isAppGroup()) {
    n.flags&=~Notification.FLAG_GROUP_SUMMARY;
  }
  String group=sbn.getGroupKey();
  boolean isSummary=n.isGroupSummary();
  Notification oldN=old != null ? old.sbn.getNotification() : null;
  String oldGroup=old != null ? old.sbn.getGroupKey() : null;
  boolean oldIsSummary=old != null && oldN.isGroupSummary();
  if (oldIsSummary) {
    NotificationRecord removedSummary=mSummaryByGroupKey.remove(oldGroup);
    if (removedSummary != old) {
      String removedKey=removedSummary != null ? removedSummary.getKey() : "String_Node_Str";
      Slog.w(TAG,"String_Node_Str" + old.getKey() + "String_Node_Str"+ removedKey);
    }
  }
  if (isSummary) {
    mSummaryByGroupKey.put(group,r);
  }
  if (oldIsSummary && (!isSummary || !oldGroup.equals(group))) {
    cancelGroupChildrenLocked(old,callingUid,callingPid,null,REASON_GROUP_SUMMARY_CANCELED,false);
  }
}
Program: 191256
Project: 191256
Buggy source:
void cancelAllLocked(int callingUid,int callingPid,int userId,int reason,ManagedServiceInfo listener,boolean includeCurrentProfiles){
  String listenerName=listener == null ? null : listener.component.toShortString();
  EventLogTags.writeNotificationCancelAll(callingUid,callingPid,null,userId,0,0,reason,listenerName);
  ArrayList<NotificationRecord> canceledNotifications=null;
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord r=mNotificationList.get(i);
    if (includeCurrentProfiles) {
      if (!notificationMatchesCurrentProfiles(r,userId)) {
        continue;
      }
    }
 else {
      if (!notificationMatchesUserId(r,userId)) {
        continue;
      }
    }
    if ((r.getFlags() & (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)) == 0) {
      mNotificationList.remove(i);
      cancelNotificationLocked(r,true,reason);
      if (canceledNotifications == null) {
        canceledNotifications=new ArrayList<>();
      }
      canceledNotifications.add(r);
    }
  }
  int M=canceledNotifications != null ? canceledNotifications.size() : 0;
  for (int i=0; i < M; i++) {
    cancelGroupChildrenLocked(canceledNotifications.get(i),callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED);
  }
  updateLightsLocked();
}

Fixed version (ground truth):
void cancelAllLocked(int callingUid,int callingPid,int userId,int reason,ManagedServiceInfo listener,boolean includeCurrentProfiles){
  String listenerName=listener == null ? null : listener.component.toShortString();
  EventLogTags.writeNotificationCancelAll(callingUid,callingPid,null,userId,0,0,reason,listenerName);
  ArrayList<NotificationRecord> canceledNotifications=null;
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord r=mNotificationList.get(i);
    if (includeCurrentProfiles) {
      if (!notificationMatchesCurrentProfiles(r,userId)) {
        continue;
      }
    }
 else {
      if (!notificationMatchesUserId(r,userId)) {
        continue;
      }
    }
    if ((r.getFlags() & (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)) == 0) {
      mNotificationList.remove(i);
      cancelNotificationLocked(r,true,reason);
      if (canceledNotifications == null) {
        canceledNotifications=new ArrayList<>();
      }
      canceledNotifications.add(r);
    }
  }
  int M=canceledNotifications != null ? canceledNotifications.size() : 0;
  for (int i=0; i < M; i++) {
    cancelGroupChildrenLocked(canceledNotifications.get(i),callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED,false);
  }
  updateLightsLocked();
}
Program: 191258
Project: 191258
Buggy source:
private void cancelGroupChildrenLocked(NotificationRecord r,int callingUid,int callingPid,String listenerName,int reason){
  Notification n=r.getNotification();
  if (!n.isGroupSummary()) {
    return;
  }
  String pkg=r.sbn.getPackageName();
  int userId=r.getUserId();
  if (pkg == null) {
    if (DBG)     Log.e(TAG,"String_Node_Str" + r.getKey());
    return;
  }
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord childR=mNotificationList.get(i);
    StatusBarNotification childSbn=childR.sbn;
    if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) && childR.getGroupKey().equals(r.getGroupKey())) {
      EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,childSbn.getId(),childSbn.getTag(),userId,0,0,reason,listenerName);
      mNotificationList.remove(i);
      cancelNotificationLocked(childR,false,reason);
    }
  }
}

Fixed version (ground truth):
private void cancelGroupChildrenLocked(NotificationRecord r,int callingUid,int callingPid,String listenerName,int reason,boolean sendDelete){
  Notification n=r.getNotification();
  if (!n.isGroupSummary()) {
    return;
  }
  String pkg=r.sbn.getPackageName();
  int userId=r.getUserId();
  if (pkg == null) {
    if (DBG)     Log.e(TAG,"String_Node_Str" + r.getKey());
    return;
  }
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord childR=mNotificationList.get(i);
    StatusBarNotification childSbn=childR.sbn;
    if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) && childR.getGroupKey().equals(r.getGroupKey())) {
      EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,childSbn.getId(),childSbn.getTag(),userId,0,0,reason,listenerName);
      mNotificationList.remove(i);
      cancelNotificationLocked(childR,sendDelete,reason);
    }
  }
}
Program: 191259
Project: 191259
Buggy source:
/** 
 * Cancels a notification ONLY if it has all of the   {@code mustHaveFlags}and none of the   {@code mustNotHaveFlags}.
 */
void cancelNotification(final int callingUid,final int callingPid,final String pkg,final String tag,final int id,final int mustHaveFlags,final int mustNotHaveFlags,final boolean sendDelete,final int userId,final int reason,final ManagedServiceInfo listener){
  mHandler.post(new Runnable(){
    @Override public void run(){
      String listenerName=listener == null ? null : listener.component.toShortString();
      if (DBG)       EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,id,tag,userId,mustHaveFlags,mustNotHaveFlags,reason,listenerName);
synchronized (mNotificationList) {
        int index=indexOfNotificationLocked(pkg,tag,id,userId);
        if (index >= 0) {
          NotificationRecord r=mNotificationList.get(index);
          if (reason == REASON_DELEGATE_CLICK) {
            mUsageStats.registerClickedByUser(r);
          }
          if ((r.getNotification().flags & mustHaveFlags) != mustHaveFlags) {
            return;
          }
          if ((r.getNotification().flags & mustNotHaveFlags) != 0) {
            return;
          }
          mNotificationList.remove(index);
          cancelNotificationLocked(r,sendDelete,reason);
          cancelGroupChildrenLocked(r,callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED);
          updateLightsLocked();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Cancels a notification ONLY if it has all of the   {@code mustHaveFlags}and none of the   {@code mustNotHaveFlags}.
 */
void cancelNotification(final int callingUid,final int callingPid,final String pkg,final String tag,final int id,final int mustHaveFlags,final int mustNotHaveFlags,final boolean sendDelete,final int userId,final int reason,final ManagedServiceInfo listener){
  mHandler.post(new Runnable(){
    @Override public void run(){
      String listenerName=listener == null ? null : listener.component.toShortString();
      if (DBG)       EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,id,tag,userId,mustHaveFlags,mustNotHaveFlags,reason,listenerName);
synchronized (mNotificationList) {
        int index=indexOfNotificationLocked(pkg,tag,id,userId);
        if (index >= 0) {
          NotificationRecord r=mNotificationList.get(index);
          if (reason == REASON_DELEGATE_CLICK) {
            mUsageStats.registerClickedByUser(r);
          }
          if ((r.getNotification().flags & mustHaveFlags) != mustHaveFlags) {
            return;
          }
          if ((r.getNotification().flags & mustNotHaveFlags) != 0) {
            return;
          }
          mNotificationList.remove(index);
          cancelNotificationLocked(r,sendDelete,reason);
          cancelGroupChildrenLocked(r,callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED,sendDelete);
          updateLightsLocked();
        }
      }
    }
  }
);
}
Program: 191260
Project: 191260
Buggy source:
/** 
 * Ensures that grouped notification receive their special treatment. <p>Cancels group children if the new notification causes a group to lose its summary.</p> <p>Updates mSummaryByGroupKey.</p>
 */
private void handleGroupedNotificationLocked(NotificationRecord r,NotificationRecord old,int callingUid,int callingPid){
  StatusBarNotification sbn=r.sbn;
  Notification n=sbn.getNotification();
  if (n.isGroupSummary() && !sbn.isAppGroup()) {
    n.flags&=~Notification.FLAG_GROUP_SUMMARY;
  }
  String group=sbn.getGroupKey();
  boolean isSummary=n.isGroupSummary();
  Notification oldN=old != null ? old.sbn.getNotification() : null;
  String oldGroup=old != null ? old.sbn.getGroupKey() : null;
  boolean oldIsSummary=old != null && oldN.isGroupSummary();
  if (oldIsSummary) {
    NotificationRecord removedSummary=mSummaryByGroupKey.remove(oldGroup);
    if (removedSummary != old) {
      String removedKey=removedSummary != null ? removedSummary.getKey() : "String_Node_Str";
      Slog.w(TAG,"String_Node_Str" + old.getKey() + "String_Node_Str"+ removedKey);
    }
  }
  if (isSummary) {
    mSummaryByGroupKey.put(group,r);
  }
  if (oldIsSummary && (!isSummary || !oldGroup.equals(group))) {
    cancelGroupChildrenLocked(old,callingUid,callingPid,null,REASON_GROUP_SUMMARY_CANCELED);
  }
}

Fixed version (ground truth):
/** 
 * Ensures that grouped notification receive their special treatment. <p>Cancels group children if the new notification causes a group to lose its summary.</p> <p>Updates mSummaryByGroupKey.</p>
 */
private void handleGroupedNotificationLocked(NotificationRecord r,NotificationRecord old,int callingUid,int callingPid){
  StatusBarNotification sbn=r.sbn;
  Notification n=sbn.getNotification();
  if (n.isGroupSummary() && !sbn.isAppGroup()) {
    n.flags&=~Notification.FLAG_GROUP_SUMMARY;
  }
  String group=sbn.getGroupKey();
  boolean isSummary=n.isGroupSummary();
  Notification oldN=old != null ? old.sbn.getNotification() : null;
  String oldGroup=old != null ? old.sbn.getGroupKey() : null;
  boolean oldIsSummary=old != null && oldN.isGroupSummary();
  if (oldIsSummary) {
    NotificationRecord removedSummary=mSummaryByGroupKey.remove(oldGroup);
    if (removedSummary != old) {
      String removedKey=removedSummary != null ? removedSummary.getKey() : "String_Node_Str";
      Slog.w(TAG,"String_Node_Str" + old.getKey() + "String_Node_Str"+ removedKey);
    }
  }
  if (isSummary) {
    mSummaryByGroupKey.put(group,r);
  }
  if (oldIsSummary && (!isSummary || !oldGroup.equals(group))) {
    cancelGroupChildrenLocked(old,callingUid,callingPid,null,REASON_GROUP_SUMMARY_CANCELED,false);
  }
}
Program: 191261
Project: 191261
Buggy source:
void cancelAllLocked(int callingUid,int callingPid,int userId,int reason,ManagedServiceInfo listener,boolean includeCurrentProfiles){
  String listenerName=listener == null ? null : listener.component.toShortString();
  EventLogTags.writeNotificationCancelAll(callingUid,callingPid,null,userId,0,0,reason,listenerName);
  ArrayList<NotificationRecord> canceledNotifications=null;
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord r=mNotificationList.get(i);
    if (includeCurrentProfiles) {
      if (!notificationMatchesCurrentProfiles(r,userId)) {
        continue;
      }
    }
 else {
      if (!notificationMatchesUserId(r,userId)) {
        continue;
      }
    }
    if ((r.getFlags() & (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)) == 0) {
      mNotificationList.remove(i);
      cancelNotificationLocked(r,true,reason);
      if (canceledNotifications == null) {
        canceledNotifications=new ArrayList<>();
      }
      canceledNotifications.add(r);
    }
  }
  int M=canceledNotifications != null ? canceledNotifications.size() : 0;
  for (int i=0; i < M; i++) {
    cancelGroupChildrenLocked(canceledNotifications.get(i),callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED);
  }
  updateLightsLocked();
}

Fixed version (ground truth):
void cancelAllLocked(int callingUid,int callingPid,int userId,int reason,ManagedServiceInfo listener,boolean includeCurrentProfiles){
  String listenerName=listener == null ? null : listener.component.toShortString();
  EventLogTags.writeNotificationCancelAll(callingUid,callingPid,null,userId,0,0,reason,listenerName);
  ArrayList<NotificationRecord> canceledNotifications=null;
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord r=mNotificationList.get(i);
    if (includeCurrentProfiles) {
      if (!notificationMatchesCurrentProfiles(r,userId)) {
        continue;
      }
    }
 else {
      if (!notificationMatchesUserId(r,userId)) {
        continue;
      }
    }
    if ((r.getFlags() & (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)) == 0) {
      mNotificationList.remove(i);
      cancelNotificationLocked(r,true,reason);
      if (canceledNotifications == null) {
        canceledNotifications=new ArrayList<>();
      }
      canceledNotifications.add(r);
    }
  }
  int M=canceledNotifications != null ? canceledNotifications.size() : 0;
  for (int i=0; i < M; i++) {
    cancelGroupChildrenLocked(canceledNotifications.get(i),callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED,false);
  }
  updateLightsLocked();
}
Program: 191263
Project: 191263
Buggy source:
private void cancelGroupChildrenLocked(NotificationRecord r,int callingUid,int callingPid,String listenerName,int reason){
  Notification n=r.getNotification();
  if (!n.isGroupSummary()) {
    return;
  }
  String pkg=r.sbn.getPackageName();
  int userId=r.getUserId();
  if (pkg == null) {
    if (DBG)     Log.e(TAG,"String_Node_Str" + r.getKey());
    return;
  }
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord childR=mNotificationList.get(i);
    StatusBarNotification childSbn=childR.sbn;
    if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) && childR.getGroupKey().equals(r.getGroupKey())) {
      EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,childSbn.getId(),childSbn.getTag(),userId,0,0,reason,listenerName);
      mNotificationList.remove(i);
      cancelNotificationLocked(childR,false,reason);
    }
  }
}

Fixed version (ground truth):
private void cancelGroupChildrenLocked(NotificationRecord r,int callingUid,int callingPid,String listenerName,int reason,boolean sendDelete){
  Notification n=r.getNotification();
  if (!n.isGroupSummary()) {
    return;
  }
  String pkg=r.sbn.getPackageName();
  int userId=r.getUserId();
  if (pkg == null) {
    if (DBG)     Log.e(TAG,"String_Node_Str" + r.getKey());
    return;
  }
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord childR=mNotificationList.get(i);
    StatusBarNotification childSbn=childR.sbn;
    if ((childSbn.isGroup() && !childSbn.getNotification().isGroupSummary()) && childR.getGroupKey().equals(r.getGroupKey())) {
      EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,childSbn.getId(),childSbn.getTag(),userId,0,0,reason,listenerName);
      mNotificationList.remove(i);
      cancelNotificationLocked(childR,sendDelete,reason);
    }
  }
}
Program: 191264
Project: 191264
Buggy source:
/** 
 * Cancels a notification ONLY if it has all of the   {@code mustHaveFlags}and none of the   {@code mustNotHaveFlags}.
 */
void cancelNotification(final int callingUid,final int callingPid,final String pkg,final String tag,final int id,final int mustHaveFlags,final int mustNotHaveFlags,final boolean sendDelete,final int userId,final int reason,final ManagedServiceInfo listener){
  mHandler.post(new Runnable(){
    @Override public void run(){
      String listenerName=listener == null ? null : listener.component.toShortString();
      if (DBG)       EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,id,tag,userId,mustHaveFlags,mustNotHaveFlags,reason,listenerName);
synchronized (mNotificationList) {
        int index=indexOfNotificationLocked(pkg,tag,id,userId);
        if (index >= 0) {
          NotificationRecord r=mNotificationList.get(index);
          if (reason == REASON_DELEGATE_CLICK) {
            mUsageStats.registerClickedByUser(r);
          }
          if ((r.getNotification().flags & mustHaveFlags) != mustHaveFlags) {
            return;
          }
          if ((r.getNotification().flags & mustNotHaveFlags) != 0) {
            return;
          }
          mNotificationList.remove(index);
          cancelNotificationLocked(r,sendDelete,reason);
          cancelGroupChildrenLocked(r,callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED);
          updateLightsLocked();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Cancels a notification ONLY if it has all of the   {@code mustHaveFlags}and none of the   {@code mustNotHaveFlags}.
 */
void cancelNotification(final int callingUid,final int callingPid,final String pkg,final String tag,final int id,final int mustHaveFlags,final int mustNotHaveFlags,final boolean sendDelete,final int userId,final int reason,final ManagedServiceInfo listener){
  mHandler.post(new Runnable(){
    @Override public void run(){
      String listenerName=listener == null ? null : listener.component.toShortString();
      if (DBG)       EventLogTags.writeNotificationCancel(callingUid,callingPid,pkg,id,tag,userId,mustHaveFlags,mustNotHaveFlags,reason,listenerName);
synchronized (mNotificationList) {
        int index=indexOfNotificationLocked(pkg,tag,id,userId);
        if (index >= 0) {
          NotificationRecord r=mNotificationList.get(index);
          if (reason == REASON_DELEGATE_CLICK) {
            mUsageStats.registerClickedByUser(r);
          }
          if ((r.getNotification().flags & mustHaveFlags) != mustHaveFlags) {
            return;
          }
          if ((r.getNotification().flags & mustNotHaveFlags) != 0) {
            return;
          }
          mNotificationList.remove(index);
          cancelNotificationLocked(r,sendDelete,reason);
          cancelGroupChildrenLocked(r,callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED,sendDelete);
          updateLightsLocked();
        }
      }
    }
  }
);
}
Program: 191265
Project: 191265
Buggy source:
/** 
 * Ensures that grouped notification receive their special treatment. <p>Cancels group children if the new notification causes a group to lose its summary.</p> <p>Updates mSummaryByGroupKey.</p>
 */
private void handleGroupedNotificationLocked(NotificationRecord r,NotificationRecord old,int callingUid,int callingPid){
  StatusBarNotification sbn=r.sbn;
  Notification n=sbn.getNotification();
  if (n.isGroupSummary() && !sbn.isAppGroup()) {
    n.flags&=~Notification.FLAG_GROUP_SUMMARY;
  }
  String group=sbn.getGroupKey();
  boolean isSummary=n.isGroupSummary();
  Notification oldN=old != null ? old.sbn.getNotification() : null;
  String oldGroup=old != null ? old.sbn.getGroupKey() : null;
  boolean oldIsSummary=old != null && oldN.isGroupSummary();
  if (oldIsSummary) {
    NotificationRecord removedSummary=mSummaryByGroupKey.remove(oldGroup);
    if (removedSummary != old) {
      String removedKey=removedSummary != null ? removedSummary.getKey() : "String_Node_Str";
      Slog.w(TAG,"String_Node_Str" + old.getKey() + "String_Node_Str"+ removedKey);
    }
  }
  if (isSummary) {
    mSummaryByGroupKey.put(group,r);
  }
  if (oldIsSummary && (!isSummary || !oldGroup.equals(group))) {
    cancelGroupChildrenLocked(old,callingUid,callingPid,null,REASON_GROUP_SUMMARY_CANCELED);
  }
}

Fixed version (ground truth):
/** 
 * Ensures that grouped notification receive their special treatment. <p>Cancels group children if the new notification causes a group to lose its summary.</p> <p>Updates mSummaryByGroupKey.</p>
 */
private void handleGroupedNotificationLocked(NotificationRecord r,NotificationRecord old,int callingUid,int callingPid){
  StatusBarNotification sbn=r.sbn;
  Notification n=sbn.getNotification();
  if (n.isGroupSummary() && !sbn.isAppGroup()) {
    n.flags&=~Notification.FLAG_GROUP_SUMMARY;
  }
  String group=sbn.getGroupKey();
  boolean isSummary=n.isGroupSummary();
  Notification oldN=old != null ? old.sbn.getNotification() : null;
  String oldGroup=old != null ? old.sbn.getGroupKey() : null;
  boolean oldIsSummary=old != null && oldN.isGroupSummary();
  if (oldIsSummary) {
    NotificationRecord removedSummary=mSummaryByGroupKey.remove(oldGroup);
    if (removedSummary != old) {
      String removedKey=removedSummary != null ? removedSummary.getKey() : "String_Node_Str";
      Slog.w(TAG,"String_Node_Str" + old.getKey() + "String_Node_Str"+ removedKey);
    }
  }
  if (isSummary) {
    mSummaryByGroupKey.put(group,r);
  }
  if (oldIsSummary && (!isSummary || !oldGroup.equals(group))) {
    cancelGroupChildrenLocked(old,callingUid,callingPid,null,REASON_GROUP_SUMMARY_CANCELED,false);
  }
}
Program: 191266
Project: 191266
Buggy source:
void cancelAllLocked(int callingUid,int callingPid,int userId,int reason,ManagedServiceInfo listener,boolean includeCurrentProfiles){
  String listenerName=listener == null ? null : listener.component.toShortString();
  EventLogTags.writeNotificationCancelAll(callingUid,callingPid,null,userId,0,0,reason,listenerName);
  ArrayList<NotificationRecord> canceledNotifications=null;
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord r=mNotificationList.get(i);
    if (includeCurrentProfiles) {
      if (!notificationMatchesCurrentProfiles(r,userId)) {
        continue;
      }
    }
 else {
      if (!notificationMatchesUserId(r,userId)) {
        continue;
      }
    }
    if ((r.getFlags() & (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)) == 0) {
      mNotificationList.remove(i);
      cancelNotificationLocked(r,true,reason);
      if (canceledNotifications == null) {
        canceledNotifications=new ArrayList<>();
      }
      canceledNotifications.add(r);
    }
  }
  int M=canceledNotifications != null ? canceledNotifications.size() : 0;
  for (int i=0; i < M; i++) {
    cancelGroupChildrenLocked(canceledNotifications.get(i),callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED);
  }
  updateLightsLocked();
}

Fixed version (ground truth):
void cancelAllLocked(int callingUid,int callingPid,int userId,int reason,ManagedServiceInfo listener,boolean includeCurrentProfiles){
  String listenerName=listener == null ? null : listener.component.toShortString();
  EventLogTags.writeNotificationCancelAll(callingUid,callingPid,null,userId,0,0,reason,listenerName);
  ArrayList<NotificationRecord> canceledNotifications=null;
  final int N=mNotificationList.size();
  for (int i=N - 1; i >= 0; i--) {
    NotificationRecord r=mNotificationList.get(i);
    if (includeCurrentProfiles) {
      if (!notificationMatchesCurrentProfiles(r,userId)) {
        continue;
      }
    }
 else {
      if (!notificationMatchesUserId(r,userId)) {
        continue;
      }
    }
    if ((r.getFlags() & (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)) == 0) {
      mNotificationList.remove(i);
      cancelNotificationLocked(r,true,reason);
      if (canceledNotifications == null) {
        canceledNotifications=new ArrayList<>();
      }
      canceledNotifications.add(r);
    }
  }
  int M=canceledNotifications != null ? canceledNotifications.size() : 0;
  for (int i=0; i < M; i++) {
    cancelGroupChildrenLocked(canceledNotifications.get(i),callingUid,callingPid,listenerName,REASON_GROUP_SUMMARY_CANCELED,false);
  }
  updateLightsLocked();
}
Program: 191268
Project: 191268
Buggy source:
private void performReceiveLocked(ProcessRecord app,IIntentReceiver receiver,Intent intent,int resultCode,String data,Bundle extras,boolean ordered,boolean sticky,int sendingUser) throws RemoteException {
  if (app != null) {
    if (app.thread != null) {
      try {
        app.thread.scheduleRegisteredReceiver(receiver,intent,resultCode,data,extras,ordered,sticky,sendingUser,app.repProcState);
      }
 catch (      RemoteException ex) {
synchronized (mService) {
          Slog.w(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
          app.scheduleCrash("String_Node_Str");
        }
        throw ex;
      }
    }
 else {
      throw new RemoteException("String_Node_Str");
    }
  }
 else {
    receiver.performReceive(intent,resultCode,data,extras,ordered,sticky,sendingUser);
  }
}

Fixed version (ground truth):
void performReceiveLocked(ProcessRecord app,IIntentReceiver receiver,Intent intent,int resultCode,String data,Bundle extras,boolean ordered,boolean sticky,int sendingUser) throws RemoteException {
  if (app != null) {
    if (app.thread != null) {
      try {
        app.thread.scheduleRegisteredReceiver(receiver,intent,resultCode,data,extras,ordered,sticky,sendingUser,app.repProcState);
      }
 catch (      RemoteException ex) {
synchronized (mService) {
          Slog.w(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
          app.scheduleCrash("String_Node_Str");
        }
        throw ex;
      }
    }
 else {
      throw new RemoteException("String_Node_Str");
    }
  }
 else {
    receiver.performReceive(intent,resultCode,data,extras,ordered,sticky,sendingUser);
  }
}
Program: 191270
Project: 191270
Buggy source:
private void performReceiveLocked(ProcessRecord app,IIntentReceiver receiver,Intent intent,int resultCode,String data,Bundle extras,boolean ordered,boolean sticky,int sendingUser) throws RemoteException {
  if (app != null) {
    if (app.thread != null) {
      try {
        app.thread.scheduleRegisteredReceiver(receiver,intent,resultCode,data,extras,ordered,sticky,sendingUser,app.repProcState);
      }
 catch (      RemoteException ex) {
synchronized (mService) {
          Slog.w(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
          app.scheduleCrash("String_Node_Str");
        }
        throw ex;
      }
    }
 else {
      throw new RemoteException("String_Node_Str");
    }
  }
 else {
    receiver.performReceive(intent,resultCode,data,extras,ordered,sticky,sendingUser);
  }
}

Fixed version (ground truth):
void performReceiveLocked(ProcessRecord app,IIntentReceiver receiver,Intent intent,int resultCode,String data,Bundle extras,boolean ordered,boolean sticky,int sendingUser) throws RemoteException {
  if (app != null) {
    if (app.thread != null) {
      try {
        app.thread.scheduleRegisteredReceiver(receiver,intent,resultCode,data,extras,ordered,sticky,sendingUser,app.repProcState);
      }
 catch (      RemoteException ex) {
synchronized (mService) {
          Slog.w(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
          app.scheduleCrash("String_Node_Str");
        }
        throw ex;
      }
    }
 else {
      throw new RemoteException("String_Node_Str");
    }
  }
 else {
    receiver.performReceive(intent,resultCode,data,extras,ordered,sticky,sendingUser);
  }
}
Program: 191271
Project: 191271
Buggy source:
/** 
 * Defer the specified SyncOperation by rescheduling it on the JobScheduler with some delay. This is equivalent to a failure. If this is a periodic sync, a delayed one-off sync will be scheduled.
 */
private void deferSyncH(SyncOperation op,long delay){
  mSyncJobService.callJobFinished(op.jobId,false);
  if (op.isPeriodic) {
    scheduleSyncOperationH(op.createOneTimeSyncOperation(),delay);
  }
 else {
    scheduleSyncOperationH(op,delay);
  }
}

Fixed version (ground truth):
/** 
 * Defer the specified SyncOperation by rescheduling it on the JobScheduler with some delay. This is equivalent to a failure. If this is a periodic sync, a delayed one-off sync will be scheduled.
 */
private void deferSyncH(SyncOperation op,long delay){
  mSyncJobService.callJobFinished(op.jobId,false);
  if (op.isPeriodic) {
    scheduleSyncOperationH(op.createOneTimeSyncOperation(),delay);
  }
 else {
    getJobScheduler().cancel(op.jobId);
    scheduleSyncOperationH(op,delay);
  }
}
Program: 191275
Project: 191275
Buggy source:
private void performReceiveLocked(ProcessRecord app,IIntentReceiver receiver,Intent intent,int resultCode,String data,Bundle extras,boolean ordered,boolean sticky,int sendingUser) throws RemoteException {
  if (app != null) {
    if (app.thread != null) {
      try {
        app.thread.scheduleRegisteredReceiver(receiver,intent,resultCode,data,extras,ordered,sticky,sendingUser,app.repProcState);
      }
 catch (      RemoteException ex) {
synchronized (mService) {
          Slog.w(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
          app.scheduleCrash("String_Node_Str");
        }
        throw ex;
      }
    }
 else {
      throw new RemoteException("String_Node_Str");
    }
  }
 else {
    receiver.performReceive(intent,resultCode,data,extras,ordered,sticky,sendingUser);
  }
}

Fixed version (ground truth):
void performReceiveLocked(ProcessRecord app,IIntentReceiver receiver,Intent intent,int resultCode,String data,Bundle extras,boolean ordered,boolean sticky,int sendingUser) throws RemoteException {
  if (app != null) {
    if (app.thread != null) {
      try {
        app.thread.scheduleRegisteredReceiver(receiver,intent,resultCode,data,extras,ordered,sticky,sendingUser,app.repProcState);
      }
 catch (      RemoteException ex) {
synchronized (mService) {
          Slog.w(TAG,"String_Node_Str" + app.processName + "String_Node_Str"+ app.pid+ "String_Node_Str");
          app.scheduleCrash("String_Node_Str");
        }
        throw ex;
      }
    }
 else {
      throw new RemoteException("String_Node_Str");
    }
  }
 else {
    receiver.performReceive(intent,resultCode,data,extras,ordered,sticky,sendingUser);
  }
}
Program: 191276
Project: 191276
Buggy source:
public void setRemoved(){
  mRemoved=true;
  mPrivateLayout.setRemoved();
  if (mChildrenContainer != null) {
    mChildrenContainer.setRemoved();
  }
}

Fixed version (ground truth):
public void setRemoved(){
  mRemoved=true;
  mPrivateLayout.setRemoved();
}
Program: 191277
Project: 191277
Buggy source:
/** 
 * Defer the specified SyncOperation by rescheduling it on the JobScheduler with some delay. This is equivalent to a failure. If this is a periodic sync, a delayed one-off sync will be scheduled.
 */
private void deferSyncH(SyncOperation op,long delay){
  mSyncJobService.callJobFinished(op.jobId,false);
  if (op.isPeriodic) {
    scheduleSyncOperationH(op.createOneTimeSyncOperation(),delay);
  }
 else {
    scheduleSyncOperationH(op,delay);
  }
}

Fixed version (ground truth):
/** 
 * Defer the specified SyncOperation by rescheduling it on the JobScheduler with some delay. This is equivalent to a failure. If this is a periodic sync, a delayed one-off sync will be scheduled.
 */
private void deferSyncH(SyncOperation op,long delay){
  mSyncJobService.callJobFinished(op.jobId,false);
  if (op.isPeriodic) {
    scheduleSyncOperationH(op.createOneTimeSyncOperation(),delay);
  }
 else {
    getJobScheduler().cancel(op.jobId);
    scheduleSyncOperationH(op,delay);
  }
}
Program: 191280
Project: 191280
Buggy source:
public void setHideSensitive(boolean hideSensitive,boolean animated,long delay,long duration){
  boolean oldShowingPublic=mShowingPublic;
  mShowingPublic=mSensitive && hideSensitive;
  if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
    return;
  }
  if (mPublicLayout.getChildCount() == 0)   return;
  if (!animated) {
    mPublicLayout.animate().cancel();
    mPrivateLayout.animate().cancel();
    mPublicLayout.setAlpha(1f);
    mPrivateLayout.setAlpha(1f);
    mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
    updateChildrenVisibility();
  }
 else {
    animateShowingPublic(delay,duration);
  }
  NotificationContentView showingLayout=getShowingLayout();
  showingLayout.updateBackgroundColor(animated);
  mPrivateLayout.updateExpandButtons(isExpandable());
  updateClearability();
  mShowingPublicInitialized=true;
}

Fixed version (ground truth):
public void setHideSensitive(boolean hideSensitive,boolean animated,long delay,long duration){
  boolean oldShowingPublic=mShowingPublic;
  mShowingPublic=mSensitive && hideSensitive;
  if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
    return;
  }
  if (mPublicLayout.getChildCount() == 0)   return;
  if (!animated) {
    mPublicLayout.animate().cancel();
    mPrivateLayout.animate().cancel();
    if (mChildrenContainer != null) {
      mChildrenContainer.animate().cancel();
      mChildrenContainer.setAlpha(1f);
    }
    mPublicLayout.setAlpha(1f);
    mPrivateLayout.setAlpha(1f);
    mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
    updateChildrenVisibility();
  }
 else {
    animateShowingPublic(delay,duration);
  }
  NotificationContentView showingLayout=getShowingLayout();
  showingLayout.updateBackgroundColor(animated);
  mPrivateLayout.updateExpandButtons(isExpandable());
  updateClearability();
  mShowingPublicInitialized=true;
}
Program: 191281
Project: 191281
Buggy source:
@Override public int getIntrinsicHeight(){
  if (isUserLocked()) {
    return getActualHeight();
  }
  if (mGuts != null && mGuts.areGutsExposed()) {
    return mGuts.getHeight();
  }
 else   if ((isChildInGroup() && !isGroupExpanded())) {
    return mPrivateLayout.getMinHeight();
  }
 else   if (mSensitive && mHideSensitiveForIntrinsicHeight) {
    return getMinHeight();
  }
 else   if (mIsSummaryWithChildren && !mOnKeyguard) {
    return mChildrenContainer.getIntrinsicHeight();
  }
 else   if (mIsHeadsUp) {
    if (isPinned()) {
      return getPinnedHeadsUpHeight(true);
    }
 else     if (isExpanded()) {
      return Math.max(getMaxExpandHeight(),mHeadsUpHeight);
    }
 else {
      return Math.max(getCollapsedHeight(),mHeadsUpHeight);
    }
  }
 else   if (isExpanded()) {
    return getMaxExpandHeight();
  }
 else {
    return getCollapsedHeight();
  }
}

Fixed version (ground truth):
@Override public int getIntrinsicHeight(){
  if (isUserLocked()) {
    return getActualHeight();
  }
  if (mGuts != null && mGuts.areGutsExposed()) {
    return mGuts.getHeight();
  }
 else   if ((isChildInGroup() && !isGroupExpanded())) {
    return mPrivateLayout.getMinHeight();
  }
 else   if (mSensitive && mHideSensitiveForIntrinsicHeight) {
    return getMinHeight();
  }
 else   if (mIsSummaryWithChildren && !mOnKeyguard) {
    return mChildrenContainer.getIntrinsicHeight();
  }
 else   if (mIsHeadsUp || mHeadsupDisappearRunning) {
    if (isPinned() || mHeadsupDisappearRunning) {
      return getPinnedHeadsUpHeight(true);
    }
 else     if (isExpanded()) {
      return Math.max(getMaxExpandHeight(),mHeadsUpHeight);
    }
 else {
      return Math.max(getCollapsedHeight(),mHeadsUpHeight);
    }
  }
 else   if (isExpanded()) {
    return getMaxExpandHeight();
  }
 else {
    return getCollapsedHeight();
  }
}
Program: 191282
Project: 191282
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 || isGroupExpanded() || !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 || mHeadsupDisappearRunning) && 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;
    }
  }
}