Program: 153182
Project: 153182
Buggy source:
public void downloadAndInstall(String url,String mimetype,AppInfo appInfo){
  if (null == url || null == mimetype || null == appInfo) {
    throw new NullPointerException();
  }
  if (null == appInfo.mAppCode || null == appInfo.mAppVersion || null == appInfo.mAppName) {
    throw new IllegalArgumentException();
  }
  boolean bExists=false;
  String statusStr=null;
  PackageState state=PackageState.unknown;
  String downloadUri=null;
  String[] columns={PackageDbHelper.COLUMN_CODE,PackageDbHelper.COLUMN_STATE,PackageDbHelper.COLUMN_DOWNLOAD_URI};
  String where=PackageDbHelper.COLUMN_CODE + "String_Node_Str";
  String[] whereValue={appInfo.mAppCode};
  Cursor c=mPkgDBHelper.select(columns,where,whereValue,null);
  if (null != c) {
    Assert.assertTrue(c.getCount() >= 0 && c.getCount() <= 1);
    bExists=(c.getCount() == 1 && c.moveToFirst());
    if (bExists) {
      int index=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_STATE);
      statusStr=c.getString(index);
      state=PackageState.valueOf(statusStr);
      index=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_DOWNLOAD_URI);
      downloadUri=c.getString(index);
    }
    c.close();
  }
  if (bExists && isDownloadingOrInstalling(state)) {
    Log.i(TAG,"String_Node_Str" + appInfo.mAppCode);
    PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,state.name());
  }
 else {
    try {
      URI uri=getURI(url);
      Log.i(TAG,"String_Node_Str" + uri.toString());
      ContentValues values=new ContentValues();
      values.put(Downloads.COLUMN_URI,uri.toString());
      values.put(Downloads.COLUMN_NOTIFICATION_PACKAGE,this.getPackageName());
      values.put(Downloads.COLUMN_NOTIFICATION_CLASS,DownloadReceiver.class.getCanonicalName());
      values.put(Downloads.COLUMN_VISIBILITY,Downloads.VISIBILITY_HIDDEN);
      values.put(Downloads.COLUMN_MIME_TYPE,mimetype);
      values.put(Downloads.COLUMN_DESCRIPTION,appInfo.mAppCode);
      values.put(Downloads.COLUMN_NOTIFICATION_EXTRAS,appInfo.mAppCode);
      values.put(Downloads.COLUMN_DESTINATION,Downloads.DESTINATION_CACHE_PARTITION_PURGEABLE);
      values.put(Downloads.COLUMN_TOTAL_BYTES,-1);
      Uri uriInserted=getContentResolver().insert(Downloads.CONTENT_URI,values);
      if (null != uriInserted) {
        Log.i(TAG,"String_Node_Str" + uriInserted.toString());
        Log.i(TAG,"String_Node_Str" + appInfo.mAppShortDesc);
        ContentValues valuesLocal=new ContentValues(10);
        valuesLocal.put(PackageDbHelper.COLUMN_VERSION,appInfo.mAppVersion);
        valuesLocal.put(PackageDbHelper.COLUMN_APP_NAME,appInfo.mAppName);
        valuesLocal.put(PackageDbHelper.COLUMN_AUTHOR,appInfo.mAppAuthor);
        valuesLocal.put(PackageDbHelper.COLUMN_DESC,appInfo.mAppShortDesc);
        valuesLocal.put(PackageDbHelper.COLUMN_SRC_PATH,"String_Node_Str");
        valuesLocal.put(PackageDbHelper.COLUMN_PKG_NAME,"String_Node_Str");
        valuesLocal.put(PackageDbHelper.COLUMN_STATE,Constants.PackageState.downloading.name());
        valuesLocal.put(PackageDbHelper.COLUMN_DOWNLOAD_URI,uriInserted.toString());
        valuesLocal.put(PackageDbHelper.COLUMN_IMAGE_URL,appInfo.mAppImageUrl);
        if (bExists) {
          try {
            getContentResolver().delete(Uri.parse(downloadUri),null,null);
          }
 catch (          Throwable tr) {
          }
          mPkgDBHelper.update(appInfo.mAppCode,valuesLocal);
        }
 else {
          valuesLocal.put(PackageDbHelper.COLUMN_CODE,appInfo.mAppCode);
          mPkgDBHelper.insert(valuesLocal);
        }
        PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,Constants.PackageState.downloading.name());
      }
 else {
        PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,Constants.PackageState.download_failed.name());
      }
    }
 catch (    Throwable tr) {
      Log.w(TAG,"String_Node_Str" + tr.getLocalizedMessage());
    }
  }
}

Fixed version (ground truth):
public void downloadAndInstall(String url,String mimetype,AppInfo appInfo){
  if (null == url || null == mimetype || null == appInfo) {
    throw new NullPointerException();
  }
  if (null == appInfo.mAppCode || null == appInfo.mAppVersion || null == appInfo.mAppName) {
    throw new IllegalArgumentException();
  }
  boolean bExists=false;
  String statusStr=null;
  PackageState state=PackageState.unknown;
  String downloadUri=null;
  String[] columns={PackageDbHelper.COLUMN_CODE,PackageDbHelper.COLUMN_STATE,PackageDbHelper.COLUMN_DOWNLOAD_URI};
  String where=PackageDbHelper.COLUMN_CODE + "String_Node_Str";
  String[] whereValue={appInfo.mAppCode};
  Cursor c=mPkgDBHelper.select(columns,where,whereValue,null);
  if (null != c) {
    Assert.assertTrue(c.getCount() >= 0 && c.getCount() <= 1);
    bExists=(c.getCount() == 1 && c.moveToFirst());
    if (bExists) {
      int index=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_STATE);
      statusStr=c.getString(index);
      state=PackageState.valueOf(statusStr);
      index=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_DOWNLOAD_URI);
      downloadUri=c.getString(index);
    }
    c.close();
  }
  if (bExists && isDownloadingOrInstalling(state)) {
    Log.i(TAG,"String_Node_Str" + appInfo.mAppCode);
    PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,state.name());
  }
 else {
    try {
      URI uri=getURI(url);
      Log.i(TAG,"String_Node_Str" + uri.toString());
      ContentValues values=new ContentValues();
      values.put(Downloads.COLUMN_URI,uri.toString());
      values.put(Downloads.COLUMN_NOTIFICATION_PACKAGE,this.getPackageName());
      values.put(Downloads.COLUMN_NOTIFICATION_CLASS,DownloadReceiver.class.getCanonicalName());
      values.put(Downloads.COLUMN_VISIBILITY,Downloads.VISIBILITY_HIDDEN);
      values.put(Downloads.COLUMN_MIME_TYPE,mimetype);
      values.put(Downloads.COLUMN_DESCRIPTION,appInfo.mAppCode);
      values.put(Downloads.COLUMN_NOTIFICATION_EXTRAS,appInfo.mAppCode);
      values.put(Downloads.COLUMN_DESTINATION,Downloads.DESTINATION_CACHE_PARTITION_PURGEABLE);
      values.put(Downloads.COLUMN_TOTAL_BYTES,-1);
      Uri uriInserted=getContentResolver().insert(Downloads.CONTENT_URI,values);
      if (null != uriInserted) {
        Log.i(TAG,"String_Node_Str" + uriInserted.toString());
        ContentValues valuesLocal=new ContentValues(10);
        valuesLocal.put(PackageDbHelper.COLUMN_VERSION,appInfo.mAppVersion);
        valuesLocal.put(PackageDbHelper.COLUMN_APP_NAME,appInfo.mAppName);
        valuesLocal.put(PackageDbHelper.COLUMN_AUTHOR,appInfo.mAppAuthor);
        valuesLocal.put(PackageDbHelper.COLUMN_DESC,appInfo.mAppShortDesc);
        valuesLocal.put(PackageDbHelper.COLUMN_SRC_PATH,"String_Node_Str");
        valuesLocal.put(PackageDbHelper.COLUMN_PKG_NAME,"String_Node_Str");
        valuesLocal.put(PackageDbHelper.COLUMN_STATE,Constants.PackageState.downloading.name());
        valuesLocal.put(PackageDbHelper.COLUMN_DOWNLOAD_URI,uriInserted.toString());
        valuesLocal.put(PackageDbHelper.COLUMN_IMAGE_URL,appInfo.mAppImageUrl);
        if (bExists) {
          try {
            getContentResolver().delete(Uri.parse(downloadUri),null,null);
          }
 catch (          Throwable tr) {
          }
          mPkgDBHelper.update(appInfo.mAppCode,valuesLocal);
        }
 else {
          valuesLocal.put(PackageDbHelper.COLUMN_CODE,appInfo.mAppCode);
          mPkgDBHelper.insert(valuesLocal);
        }
        PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,Constants.PackageState.downloading.name());
      }
 else {
        PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,Constants.PackageState.download_failed.name());
      }
    }
 catch (    Throwable tr) {
      Log.w(TAG,"String_Node_Str" + tr.getLocalizedMessage());
    }
  }
}