Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45f7fd51 authored by Juffin Alex Varghese's avatar Juffin Alex Varghese
Browse files

Bluetooth-OPP: Remove OBEX session cleanup from OPP Service

OBEX session cleanup should be initiated from corresponding session
instead of OPP Service. Otherwise, during batch transfer if next file
in the batch starts before updating the previous transfer that will
lead to mismatch in status. This will cause UI progress bar stall
and transfer failure.

CRs-Fixed: 756084
Change-Id: Ibfa787396fe5f4f5b678ebcb4bdd36cb6641a161
parent 6d463247
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -609,8 +609,20 @@ public class BluetoothOppService extends Service {
                    return;
                }

                if (V) Log.v(TAG, "Batch size= " + mBatchs.size());
            } while ((mBatchs.size() > 0) && mPowerManager.isScreenOn());
                if (V) {
                    if (mServerSession != null) {
                        Log.v(TAG, "Server Session is active");
                    } else {
                        Log.v(TAG, "No active Server Session");
                    }

                    if (mTransfer != null) {
                        Log.v(TAG, "Client Session is active");
                    } else {
                        Log.v(TAG, "No active Client Session");
                    }
                }
            } while (mPowerManager.isScreenOn() && ((mServerSession != null) || (mTransfer != null)));

            synchronized (BluetoothOppService.this) {
                mUpdateThread = null;
@@ -822,19 +834,6 @@ public class BluetoothOppService extends Service {

        if (V) Log.v(TAG," UpdateShare: oldStatus = " + oldStatus + " newStatus = " + newStatus);
        info.mStatus = newStatus;
        if ((!BluetoothShare.isStatusCompleted(oldStatus))
                && (BluetoothShare.isStatusCompleted(newStatus))) {
            if (V) Log.v(TAG," UpdateShare: Share Completed: oldStatus = " + oldStatus + " newStatus = " + newStatus);
            try {
                if((info.mDirection == BluetoothShare.DIRECTION_OUTBOUND) && (mTransfer != null)) {
                    mTransfer.markShareComplete(newStatus);
                } else if (mServerTransfer != null) {
                    mServerTransfer.markShareComplete(newStatus);
                }
            } catch (Exception e) {
                Log.e(TAG, "Exception: updateShare: oldStatus: " + oldStatus + " newStatus: " + newStatus);
            }
        }
        info.mTotalBytes = cursor.getLong(cursor.getColumnIndexOrThrow(BluetoothShare.TOTAL_BYTES));
        info.mCurrentBytes = cursor.getLong(cursor
                .getColumnIndexOrThrow(BluetoothShare.CURRENT_BYTES));
+1 −25
Original line number Diff line number Diff line
@@ -564,31 +564,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
            setConfirmed();
        }
    }
   public void markShareComplete(int newstatus) {
        Log.d(TAG,"markShareComplete: newStatus = " + newstatus);
        if (newstatus == BluetoothShare.STATUS_SUCCESS) {
            Message msg = Message.obtain(mSessionHandler);
            msg.what = BluetoothOppObexSession.MSG_SHARE_COMPLETE;
            msg.obj = mCurrentShare;
            msg.sendToTarget();
        } else if ((newstatus == BluetoothShare.STATUS_FORBIDDEN) &&
                  Constants.ZERO_LENGTH_FILE) {
            /* Mark the status as success when a zero length file is rejected
             * by the remote device. It allows us to continue the transfer if
             * we have a batch and the file(s) are yet to be sent in the row.
             */
            Message msg = Message.obtain(mSessionHandler);
            msg.what = BluetoothOppObexSession.MSG_SHARE_COMPLETE;
            msg.obj = mCurrentShare;
            msg.sendToTarget();
            Constants.ZERO_LENGTH_FILE = false;
        } else {
            Message msg = Message.obtain(mSessionHandler);
            msg.what = BluetoothOppObexSession.MSG_SESSION_ERROR;
            msg.obj = mCurrentShare;
            msg.sendToTarget();
        }
   }

    /**
     * Set transfer confirmed status. It should only be called for inbound
     * transfer