private void markBatchFailed(int failReason) {
    synchronized (this) {
      try {
        wait(1000);
      } catch (InterruptedException e) {
        if (V) Log.v(TAG, "Interrupted waiting for markBatchFailed");
      }
    }

    if (D) Log.d(TAG, "Mark all ShareInfo in the batch as failed");
    if (mCurrentShare != null) {
      if (V) Log.v(TAG, "Current share has status " + mCurrentShare.mStatus);
      if (BluetoothShare.isStatusError(mCurrentShare.mStatus)) {
        failReason = mCurrentShare.mStatus;
      }
      if (mCurrentShare.mDirection == BluetoothShare.DIRECTION_INBOUND
          && mCurrentShare.mFilename != null) {
        new File(mCurrentShare.mFilename).delete();
      }
    }

    BluetoothOppShareInfo info = null;
    if (mBatch == null) {
      return;
    }
    info = mBatch.getPendingShare();
    while (info != null) {
      if (info.mStatus < 200) {
        info.mStatus = failReason;
        Uri contentUri = Uri.parse(BluetoothShare.CONTENT_URI + "/" + info.mId);
        ContentValues updateValues = new ContentValues();
        updateValues.put(BluetoothShare.STATUS, info.mStatus);
        /* Update un-processed outbound transfer to show some info */
        if (info.mDirection == BluetoothShare.DIRECTION_OUTBOUND) {
          BluetoothOppSendFileInfo fileInfo = BluetoothOppUtility.getSendFileInfo(info.mUri);
          BluetoothOppUtility.closeSendFileInfo(info.mUri);
          if (fileInfo.mFileName != null) {
            updateValues.put(BluetoothShare.FILENAME_HINT, fileInfo.mFileName);
            updateValues.put(BluetoothShare.TOTAL_BYTES, fileInfo.mLength);
            updateValues.put(BluetoothShare.MIMETYPE, fileInfo.mMimetype);
          }
        } else {
          if (info.mStatus < 200 && info.mFilename != null) {
            new File(info.mFilename).delete();
          }
        }
        mContext.getContentResolver().update(contentUri, updateValues, null, null);
        Constants.sendIntentIfCompleted(mContext, contentUri, info.mStatus);
      }
      info = mBatch.getPendingShare();
    }
  }