Program: 165219
Project: 165219
Buggy source:
NotificationHelper(Context context){
  this.context=context;
  appUpdateStatusManager=AppUpdateStatusManager.getInstance(context);
  notificationManager=NotificationManagerCompat.from(context);
  displayImageOptions=new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).imageScaleType(ImageScaleType.NONE).bitmapConfig(Bitmap.Config.RGB_565).build();
  IntentFilter filter=new IntentFilter();
  filter.addAction(BROADCAST_NOTIFICATIONS_ALL_UPDATES_CLEARED);
  filter.addAction(BROADCAST_NOTIFICATIONS_ALL_INSTALLED_CLEARED);
  filter.addAction(BROADCAST_NOTIFICATIONS_UPDATE_CLEARED);
  filter.addAction(BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED);
  BroadcastReceiver receiverNotificationsCleared=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
switch (intent.getAction()) {
case BROADCAST_NOTIFICATIONS_ALL_UPDATES_CLEARED:
        appUpdateStatusManager.clearAllUpdates();
      break;
case BROADCAST_NOTIFICATIONS_ALL_INSTALLED_CLEARED:
    appUpdateStatusManager.clearAllInstalled();
  break;
case BROADCAST_NOTIFICATIONS_UPDATE_CLEARED:
AppUpdateStatusManager.AppUpdateStatus appUpdateStatus=appUpdateStatusManager.get(intent.getStringExtra(EXTRA_NOTIFICATION_KEY));
if (appUpdateStatus != null && appUpdateStatus.status == AppUpdateStatusManager.Status.InstallError) {
appUpdateStatusManager.removeApk(intent.getStringExtra(EXTRA_NOTIFICATION_KEY));
}
break;
case BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED:
appUpdateStatusManager.removeApk(intent.getStringExtra(EXTRA_NOTIFICATION_KEY));
break;
}
}
}
;
context.registerReceiver(receiverNotificationsCleared,filter);
filter=new IntentFilter();
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED);
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED);
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
BroadcastReceiver receiverAppStatusChanges=new BroadcastReceiver(){
@Override public void onReceive(Context context,Intent intent){
switch (intent.getAction()) {
case AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED:
notificationManager.cancelAll();
updateStatusLists();
createSummaryNotifications();
for (AppUpdateStatusManager.AppUpdateStatus entry : appUpdateStatusManager.getAll()) {
createNotification(entry);
}
break;
case AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED:
{
updateStatusLists();
createSummaryNotifications();
String url=intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
AppUpdateStatusManager.AppUpdateStatus entry=appUpdateStatusManager.get(url);
if (entry != null) {
createNotification(entry);
}
break;
}
case AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED:
{
String url=intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
AppUpdateStatusManager.AppUpdateStatus entry=appUpdateStatusManager.get(url);
updateStatusLists();
if (entry != null) {
createNotification(entry);
}
if (intent.getBooleanExtra(AppUpdateStatusManager.EXTRA_IS_STATUS_UPDATE,false)) {
createSummaryNotifications();
}
break;
}
case AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED:
{
String url=intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
notificationManager.cancel(url,NOTIFY_ID_INSTALLED);
notificationManager.cancel(url,NOTIFY_ID_UPDATES);
updateStatusLists();
createSummaryNotifications();
break;
}
}
}
}
;
LocalBroadcastManager.getInstance(context).registerReceiver(receiverAppStatusChanges,filter);
}

Fixed version (ground truth):
NotificationHelper(Context context){
  this.context=context;
  appUpdateStatusManager=AppUpdateStatusManager.getInstance(context);
  notificationManager=NotificationManagerCompat.from(context);
  displayImageOptions=new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).imageScaleType(ImageScaleType.NONE).bitmapConfig(Bitmap.Config.RGB_565).build();
  IntentFilter filter=new IntentFilter();
  filter.addAction(BROADCAST_NOTIFICATIONS_ALL_UPDATES_CLEARED);
  filter.addAction(BROADCAST_NOTIFICATIONS_ALL_INSTALLED_CLEARED);
  filter.addAction(BROADCAST_NOTIFICATIONS_UPDATE_CLEARED);
  filter.addAction(BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED);
  BroadcastReceiver receiverNotificationsCleared=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
switch (intent.getAction()) {
case BROADCAST_NOTIFICATIONS_ALL_UPDATES_CLEARED:
        appUpdateStatusManager.clearAllUpdates();
      break;
case BROADCAST_NOTIFICATIONS_ALL_INSTALLED_CLEARED:
    appUpdateStatusManager.clearAllInstalled();
  break;
case BROADCAST_NOTIFICATIONS_UPDATE_CLEARED:
AppUpdateStatusManager.AppUpdateStatus appUpdateStatus=appUpdateStatusManager.get(intent.getStringExtra(EXTRA_NOTIFICATION_KEY));
if (appUpdateStatus != null && appUpdateStatus.status == AppUpdateStatusManager.Status.InstallError) {
appUpdateStatusManager.removeApk(intent.getStringExtra(EXTRA_NOTIFICATION_KEY));
}
break;
case BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED:
appUpdateStatusManager.removeApk(intent.getStringExtra(EXTRA_NOTIFICATION_KEY));
break;
}
}
}
;
context.registerReceiver(receiverNotificationsCleared,filter);
filter=new IntentFilter();
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED);
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED);
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED);
filter.addAction(AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
BroadcastReceiver receiverAppStatusChanges=new BroadcastReceiver(){
@Override public void onReceive(Context context,Intent intent){
AppUpdateStatusManager.AppUpdateStatus entry;
String url;
switch (intent.getAction()) {
case AppUpdateStatusManager.BROADCAST_APPSTATUS_LIST_CHANGED:
notificationManager.cancelAll();
updateStatusLists();
createSummaryNotifications();
for (AppUpdateStatusManager.AppUpdateStatus appUpdateStatus : appUpdateStatusManager.getAll()) {
createNotification(appUpdateStatus);
}
break;
case AppUpdateStatusManager.BROADCAST_APPSTATUS_ADDED:
updateStatusLists();
createSummaryNotifications();
url=intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
entry=appUpdateStatusManager.get(url);
if (entry != null) {
createNotification(entry);
}
break;
case AppUpdateStatusManager.BROADCAST_APPSTATUS_CHANGED:
url=intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
entry=appUpdateStatusManager.get(url);
updateStatusLists();
if (entry != null) {
createNotification(entry);
}
if (intent.getBooleanExtra(AppUpdateStatusManager.EXTRA_IS_STATUS_UPDATE,false)) {
createSummaryNotifications();
}
break;
case AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED:
url=intent.getStringExtra(AppUpdateStatusManager.EXTRA_APK_URL);
notificationManager.cancel(url,NOTIFY_ID_INSTALLED);
notificationManager.cancel(url,NOTIFY_ID_UPDATES);
updateStatusLists();
createSummaryNotifications();
break;
}
}
}
;
LocalBroadcastManager.getInstance(context).registerReceiver(receiverAppStatusChanges,filter);
}