Program: 184978
Project: 184978
Buggy source:
/** 
 * Notify the host application a download should be done, even if there is a streaming viewer available for thise type.
 * @param url The full url to the content that should be downloaded
 * @param contentDisposition Content-disposition http header, ifpresent.
 * @param mimetype The mimetype of the content reported by the server
 * @param contentLength The file size reported by the server
 */
void onDownloadStartNoStream(String url,String userAgent,String contentDisposition,String mimetype,long contentLength){
  String filename=URLUtil.guessFileName(url,contentDisposition,mimetype);
  String status=Environment.getExternalStorageState();
  if (!status.equals(Environment.MEDIA_MOUNTED)) {
    int title;
    String msg;
    if (status.equals(Environment.MEDIA_SHARED)) {
      msg=getString(R.string.download_sdcard_busy_dlg_msg);
      title=R.string.download_sdcard_busy_dlg_title;
    }
 else {
      msg=getString(R.string.download_no_sdcard_dlg_msg,filename);
      title=R.string.download_no_sdcard_dlg_title;
    }
    new AlertDialog.Builder(this).setTitle(title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(msg).setPositiveButton(R.string.ok,null).show();
    return;
  }
  URI uri=null;
  try {
    String newUrl=new String(URLUtil.decode(url.getBytes()));
    WebAddress w=new WebAddress(newUrl);
    String frag=null;
    String query=null;
    String path=w.mPath;
    if (path.length() > 0) {
      int idx=path.lastIndexOf('#');
      if (idx != -1) {
        frag=path.substring(idx + 1);
        path=path.substring(0,idx);
      }
      idx=path.lastIndexOf('?');
      if (idx != -1) {
        query=path.substring(idx + 1);
        path=path.substring(0,idx);
      }
    }
    uri=new URI(w.mScheme,w.mAuthInfo,w.mHost,w.mPort,path,query,frag);
  }
 catch (  Exception e) {
    Log.e(LOGTAG,"String_Node_Str" + url,e);
    return;
  }
  String cookies=CookieManager.getInstance().getCookie(url);
  ContentValues values=new ContentValues();
  values.put(Downloads.Impl.COLUMN_URI,uri.toString());
  values.put(Downloads.Impl.COLUMN_COOKIE_DATA,cookies);
  values.put(Downloads.Impl.COLUMN_USER_AGENT,userAgent);
  values.put(Downloads.Impl.COLUMN_NOTIFICATION_PACKAGE,getPackageName());
  values.put(Downloads.Impl.COLUMN_NOTIFICATION_CLASS,BrowserDownloadPage.class.getCanonicalName());
  values.put(Downloads.Impl.COLUMN_VISIBILITY,Downloads.Impl.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  values.put(Downloads.Impl.COLUMN_MIME_TYPE,mimetype);
  values.put(Downloads.Impl.COLUMN_FILE_NAME_HINT,filename);
  values.put(Downloads.Impl.COLUMN_DESCRIPTION,uri.getHost());
  if (contentLength > 0) {
    values.put(Downloads.Impl.COLUMN_TOTAL_BYTES,contentLength);
  }
  if (mimetype == null) {
    new FetchUrlMimeType(this).execute(values);
  }
 else {
    final Uri contentUri=getContentResolver().insert(Downloads.Impl.CONTENT_URI,values);
  }
  Toast.makeText(this,R.string.download_pending,Toast.LENGTH_SHORT).show();
}

Fixed version (ground truth):
/** 
 * Notify the host application a download should be done, even if there is a streaming viewer available for thise type.
 * @param url The full url to the content that should be downloaded
 * @param contentDisposition Content-disposition http header, ifpresent.
 * @param mimetype The mimetype of the content reported by the server
 * @param contentLength The file size reported by the server
 */
void onDownloadStartNoStream(String url,String userAgent,String contentDisposition,String mimetype,long contentLength){
  String filename=URLUtil.guessFileName(url,contentDisposition,mimetype);
  String status=Environment.getExternalStorageState();
  if (!status.equals(Environment.MEDIA_MOUNTED)) {
    int title;
    String msg;
    if (status.equals(Environment.MEDIA_SHARED)) {
      msg=getString(R.string.download_sdcard_busy_dlg_msg);
      title=R.string.download_sdcard_busy_dlg_title;
    }
 else {
      msg=getString(R.string.download_no_sdcard_dlg_msg,filename);
      title=R.string.download_no_sdcard_dlg_title;
    }
    new AlertDialog.Builder(this).setTitle(title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(msg).setPositiveButton(R.string.ok,null).show();
    return;
  }
  WebAddress webAddress;
  try {
    webAddress=new WebAddress(url);
    webAddress.mPath=encodePath(webAddress.mPath);
  }
 catch (  Exception e) {
    Log.e(LOGTAG,"String_Node_Str" + url);
    return;
  }
  String cookies=CookieManager.getInstance().getCookie(url);
  ContentValues values=new ContentValues();
  values.put(Downloads.Impl.COLUMN_URI,webAddress.toString());
  values.put(Downloads.Impl.COLUMN_COOKIE_DATA,cookies);
  values.put(Downloads.Impl.COLUMN_USER_AGENT,userAgent);
  values.put(Downloads.Impl.COLUMN_NOTIFICATION_PACKAGE,getPackageName());
  values.put(Downloads.Impl.COLUMN_NOTIFICATION_CLASS,BrowserDownloadPage.class.getCanonicalName());
  values.put(Downloads.Impl.COLUMN_VISIBILITY,Downloads.Impl.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
  values.put(Downloads.Impl.COLUMN_MIME_TYPE,mimetype);
  values.put(Downloads.Impl.COLUMN_FILE_NAME_HINT,filename);
  values.put(Downloads.Impl.COLUMN_DESCRIPTION,webAddress.mHost);
  if (contentLength > 0) {
    values.put(Downloads.Impl.COLUMN_TOTAL_BYTES,contentLength);
  }
  if (mimetype == null) {
    new FetchUrlMimeType(this).execute(values);
  }
 else {
    final Uri contentUri=getContentResolver().insert(Downloads.Impl.CONTENT_URI,values);
  }
  Toast.makeText(this,R.string.download_pending,Toast.LENGTH_SHORT).show();
}