Program: 153186
Project: 153186
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();
  }
  String[] columns={PackageDbHelper.COLUMN_CODE,PackageDbHelper.COLUMN_STATE};
  String where=PackageDbHelper.COLUMN_CODE + "String_Node_Str";
  String[] whereValue={appInfo.mAppCode};
  Cursor c=mPkgDBHelper.select(columns,where,whereValue,null);
  Assert.assertTrue(c.getCount() >= 0 && c.getCount() <= 1);
  boolean bExists=(c.getCount() == 1);
  String statusStr=null;
  PackageState state=PackageState.unknown;
  if (bExists) {
    int index=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_STATE);
    statusStr=c.getString(index);
    try {
      state=PackageState.valueOf(statusStr);
    }
 catch (    Throwable tr) {
    }
  }
  c.close();
  if (bExists && isDownloadingOrInstalling(state)) {
    Log.i(TAG,"String_Node_Str" + appInfo.mAppCode);
    PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,state.name());
  }
 else {
    URI uri=getURI(url);
    ContentValues valuesLocal=new ContentValues();
    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.mAppDesc);
    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_IMAGE_URL,appInfo.mAppImageUrl);
    if (bExists) {
      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());
    int delCount=getContentResolver().delete(Downloads.CONTENT_URI,where,whereValue);
    Log.i(TAG,"String_Node_Str" + code + "String_Node_Str"+ Integer.toString(delCount));
    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,BEHOO_APP_MARKET);
    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);
    Log.i(TAG,"String_Node_Str" + uriInserted.toString());
  }
}

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();
  }
  String[] columns={PackageDbHelper.COLUMN_CODE,PackageDbHelper.COLUMN_STATE};
  String where=PackageDbHelper.COLUMN_CODE + "String_Node_Str";
  String[] whereValue={appInfo.mAppCode};
  Cursor c=mPkgDBHelper.select(columns,where,whereValue,null);
  Assert.assertTrue(c.getCount() >= 0 && c.getCount() <= 1);
  boolean bExists=(c.getCount() == 1);
  String statusStr=null;
  PackageState state=PackageState.unknown;
  if (bExists) {
    int index=c.getColumnIndexOrThrow(PackageDbHelper.COLUMN_STATE);
    statusStr=c.getString(index);
    try {
      state=PackageState.valueOf(statusStr);
    }
 catch (    Throwable tr) {
    }
  }
  c.close();
  if (bExists && isDownloadingOrInstalling(state)) {
    Log.i(TAG,"String_Node_Str" + appInfo.mAppCode);
    PackageStateSender.sendPackageStateBroadcast(this,appInfo.mAppCode,state.name());
  }
 else {
    URI uri=getURI(url);
    ContentValues valuesLocal=new ContentValues();
    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.mAppDesc);
    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_IMAGE_URL,appInfo.mAppImageUrl);
    if (bExists) {
      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());
    int delCount=getContentResolver().delete(Downloads.CONTENT_URI,where,whereValue);
    Log.i(TAG,"String_Node_Str" + appInfo.mAppCode + "String_Node_Str"+ Integer.toString(delCount));
    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,BEHOO_APP_MARKET);
    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);
    Log.i(TAG,"String_Node_Str" + uriInserted.toString());
  }
}