private void processCurrentShare() {
   /* This transfer need user confirm */
   if (V) Log.v(TAG, "processCurrentShare" + mCurrentShare.mId);
   mSession.addShare(mCurrentShare);
   if (mCurrentShare.mConfirm == BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED) {
     confirmStatusChanged();
   }
 }
 /** Set transfer confirmed status. It should only be called for inbound transfer */
 public void confirmStatusChanged() {
   /* unblock server session */
   final Thread notifyThread =
       new Thread("Server Unblock thread") {
         public void run() {
           synchronized (mSession) {
             mSession.unblock();
             mSession.notify();
           }
         }
       };
   if (V) Log.v(TAG, "confirmStatusChanged to unblock mSession" + mSession.toString());
   notifyThread.start();
 }
  private void startObexSession() {

    mBatch.mStatus = Constants.BATCH_STATUS_RUNNING;

    mCurrentShare = mBatch.getPendingShare();
    if (mCurrentShare == null) {
      /*
       * TODO catch this error
       */
      Log.e(TAG, "Unexpected error happened !");
      return;
    }
    if (V) Log.v(TAG, "Start session for info " + mCurrentShare.mId + " for batch " + mBatch.mId);

    if (mBatch.mDirection == BluetoothShare.DIRECTION_OUTBOUND) {
      if (V) Log.v(TAG, "Create Client session with transport " + mTransport.toString());
      mSession = new BluetoothOppObexClientSession(mContext, mTransport);
    } else if (mBatch.mDirection == BluetoothShare.DIRECTION_INBOUND) {
      /*
       * For inbounds transfer, a server session should already exists
       * before BluetoothOppTransfer is initialized. We should pass in a
       * mSession instance.
       */
      if (mSession == null) {
        /** set current share as error */
        Log.e(TAG, "Unexpected error happened !");
        markBatchFailed();
        mBatch.mStatus = Constants.BATCH_STATUS_FAILED;
        return;
      }
      if (V) Log.v(TAG, "Transfer has Server session" + mSession.toString());
    }

    mSession.start(mSessionHandler, mBatch.getNumShares());
    processCurrentShare();
  }
 /** Stop the transfer */
 public void stop() {
   if (V) Log.v(TAG, "stop");
   if (mConnectThread != null) {
     try {
       mConnectThread.interrupt();
       if (V) Log.v(TAG, "waiting for connect thread to terminate");
       mConnectThread.join();
     } catch (InterruptedException e) {
       if (V) Log.v(TAG, "Interrupted waiting for connect thread to join");
     }
     mConnectThread = null;
   }
   if (mSession != null) {
     if (V) Log.v(TAG, "Stop mSession");
     mSession.stop();
   }
   if (mHandlerThread != null) {
     mHandlerThread.getLooper().quit();
     mHandlerThread.interrupt();
     mHandlerThread = null;
   }
 }