Program: 162421
Project: 162421
Buggy source:
/** 
 * Publish the results of the progress to notification and   {@link DatapointParcelable}and eventually to   {@link ProcessViewerFragment}
 * @param fileName       file name of current file being copied
 * @param sourceFiles    total number of files selected by user for copy
 * @param sourceProgress files been copied out of them
 * @param totalSize      total size of selected items to copy
 * @param writtenSize    bytes successfully copied
 * @param speed          number of bytes being copied per sec
 * @param isComplete     whether operation completed or ongoing (not supported at the moment)
 * @param move           if the files are to be movedIn case of encryption, this is true for decrypting operation
 */
public final void publishResults(String fileName,int sourceFiles,int sourceProgress,long totalSize,long writtenSize,long speed,boolean isComplete,boolean move){
  if (!getProgressHandler().getCancelled()) {
    context=getApplicationContext();
    setPercentProgress(((float)writtenSize / totalSize) * 100);
    if (!isNotificationTitleSet) {
      int titleResource;
switch (getNotificationId()) {
case NotificationConstants.COPY_ID:
        titleResource=move ? R.string.moving : R.string.copying;
      break;
case NotificationConstants.ENCRYPT_ID:
    titleResource=move ? R.string.crypt_decrypting : R.string.crypt_encrypting;
  break;
case NotificationConstants.EXTRACT_ID:
titleResource=R.string.extracting;
break;
case NotificationConstants.ZIP_ID:
titleResource=R.string.compressing;
break;
case NotificationConstants.DECRYPT_ID:
titleResource=R.string.crypt_decrypting;
break;
default :
titleResource=R.string.processing;
break;
}
getNotificationBuilder().setSubText(context.getResources().getString(titleResource));
isNotificationTitleSet=true;
}
if (ServiceWatcherUtil.state != ServiceWatcherUtil.ServiceWatcherInteractionInterface.STATE_HALTED) {
String written=Formatter.formatFileSize(context,writtenSize) + "String_Node_Str" + Formatter.formatFileSize(context,totalSize);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_filename_big,fileName);
getNotificationCustomViewSmall().setTextViewText(R.id.notification_service_textView_filename_small,fileName);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_written_big,written);
getNotificationCustomViewSmall().setTextViewText(R.id.notification_service_textView_written_small,written);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_transferRate_big,Formatter.formatFileSize(context,speed) + "String_Node_Str");
String remainingTime=Utils.formatTimer(Math.round((totalSize - writtenSize) / speed));
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_timeRemaining_big,remainingTime);
getNotificationBuilder().setProgress(100,Math.round(getPercentProgress()),false);
getNotificationBuilder().setOngoing(true);
getNotificationManager().notify(getNotificationId(),getNotificationBuilder().build());
}
if (writtenSize == totalSize || totalSize == 0) {
if (move && getNotificationId() == NotificationConstants.COPY_ID) {
getNotificationBuilder().setProgress(0,0,true);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_filename_big,context.getResources().getString(R.string.processing));
getNotificationCustomViewSmall().setTextViewText(R.id.notification_service_textView_filename_small,context.getResources().getString(R.string.processing));
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_timeRemaining_big,getString(R.string.unknown));
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_transferRate_big,getString(R.string.unknown));
getNotificationBuilder().setOngoing(false);
getNotificationBuilder().setAutoCancel(true);
getNotificationManager().notify(getNotificationId(),getNotificationBuilder().build());
}
 else {
publishCompletedResult(getNotificationId());
}
}
DatapointParcelable intent=new DatapointParcelable(fileName,sourceFiles,sourceProgress,totalSize,writtenSize,speed,move,isComplete);
addDatapoint(intent);
}
 else publishCompletedResult(getNotificationId());
}

Fixed version (ground truth):
/** 
 * Publish the results of the progress to notification and   {@link DatapointParcelable}and eventually to   {@link ProcessViewerFragment}
 * @param fileName       file name of current file being copied
 * @param sourceFiles    total number of files selected by user for copy
 * @param sourceProgress files been copied out of them
 * @param totalSize      total size of selected items to copy
 * @param writtenSize    bytes successfully copied
 * @param speed          number of bytes being copied per sec
 * @param isComplete     whether operation completed or ongoing (not supported at the moment)
 * @param move           if the files are to be movedIn case of encryption, this is true for decrypting operation
 */
public final void publishResults(String fileName,int sourceFiles,int sourceProgress,long totalSize,long writtenSize,long speed,boolean isComplete,boolean move){
  if (!getProgressHandler().getCancelled()) {
    context=getApplicationContext();
    setPercentProgress(((float)writtenSize / totalSize) * 100);
    if (!isNotificationTitleSet) {
      int titleResource;
switch (getNotificationId()) {
case NotificationConstants.COPY_ID:
        titleResource=move ? R.string.moving : R.string.copying;
      break;
case NotificationConstants.ENCRYPT_ID:
    titleResource=move ? R.string.crypt_decrypting : R.string.crypt_encrypting;
  break;
case NotificationConstants.EXTRACT_ID:
titleResource=R.string.extracting;
break;
case NotificationConstants.ZIP_ID:
titleResource=R.string.compressing;
break;
case NotificationConstants.DECRYPT_ID:
titleResource=R.string.crypt_decrypting;
break;
default :
titleResource=R.string.processing;
break;
}
getNotificationBuilder().setSubText(context.getResources().getString(titleResource));
isNotificationTitleSet=true;
}
if (ServiceWatcherUtil.state != ServiceWatcherUtil.ServiceWatcherInteractionInterface.STATE_HALTED) {
String written=Formatter.formatFileSize(context,writtenSize) + "String_Node_Str" + Formatter.formatFileSize(context,totalSize);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_filename_big,fileName);
getNotificationCustomViewSmall().setTextViewText(R.id.notification_service_textView_filename_small,fileName);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_written_big,written);
getNotificationCustomViewSmall().setTextViewText(R.id.notification_service_textView_written_small,written);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_transferRate_big,Formatter.formatFileSize(context,speed) + "String_Node_Str");
String remainingTime;
if (speed != 0) {
remainingTime=Utils.formatTimer(Math.round((totalSize - writtenSize) / speed));
}
 else {
remainingTime=getResources().getString(R.string.unknown);
}
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_timeRemaining_big,remainingTime);
getNotificationBuilder().setProgress(100,Math.round(getPercentProgress()),false);
getNotificationBuilder().setOngoing(true);
getNotificationManager().notify(getNotificationId(),getNotificationBuilder().build());
}
if (writtenSize == totalSize || totalSize == 0) {
if (move && getNotificationId() == NotificationConstants.COPY_ID) {
getNotificationBuilder().setProgress(0,0,true);
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_filename_big,context.getResources().getString(R.string.processing));
getNotificationCustomViewSmall().setTextViewText(R.id.notification_service_textView_filename_small,context.getResources().getString(R.string.processing));
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_timeRemaining_big,getString(R.string.unknown));
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_transferRate_big,getString(R.string.unknown));
getNotificationBuilder().setOngoing(false);
getNotificationBuilder().setAutoCancel(true);
getNotificationManager().notify(getNotificationId(),getNotificationBuilder().build());
}
 else {
publishCompletedResult(getNotificationId());
}
}
DatapointParcelable intent=new DatapointParcelable(fileName,sourceFiles,sourceProgress,totalSize,writtenSize,speed,move,isComplete);
addDatapoint(intent);
}
 else publishCompletedResult(getNotificationId());
}