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

Commit 701b6cc9 authored by Hemant Gupta's avatar Hemant Gupta
Browse files

Bluetooth: OPP: Use long as file size instead of int

This patch fixes issue of problems in sending/receiving files
which cannot be accomodated in int type of Java. Instead of using
int, long data type is used, which can hold 64 bits data size in JAVA
which is suitable for storing file sizes in GB. Changes are done
in how updates are sent to progress bar which supports only int
by using the percentage of data transferred to update the progress.

Change-Id: Ie545fd483c46dd7f41da56857e67decbe7f5a167
CRs-Fixed: 583275
parent 51f081eb
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -112,9 +112,9 @@ class BluetoothOppNotification {

        int direction; // to indicate sending or receiving

        int totalCurrent = 0; // current transfer bytes
        long totalCurrent = 0; // current transfer bytes

        int totalTotal = 0; // total bytes for current transfer
        long totalTotal = 0; // total bytes for current transfer

        long timeStamp = 0; // Database time stamp. Used for sorting ongoing transfers.

@@ -261,8 +261,8 @@ class BluetoothOppNotification {
            long timeStamp = cursor.getLong(timestampIndex);
            int dir = cursor.getInt(directionIndex);
            int id = cursor.getInt(idIndex);
            int total = cursor.getInt(totalBytesIndex);
            int current = cursor.getInt(currentBytesIndex);
            long total = cursor.getLong(totalBytesIndex);
            long current = cursor.getLong(currentBytesIndex);
            int confirmation = cursor.getInt(confirmIndex);

            String destination = cursor.getString(destinationIndex);
@@ -337,7 +337,15 @@ class BluetoothOppNotification {
            b.setContentTitle(item.description);
            b.setContentInfo(
                BluetoothOppUtility.formatProgressText(mContext, item.totalTotal, item.totalCurrent));
            b.setProgress(item.totalTotal, item.totalCurrent, item.totalTotal == -1);
            if (item.totalTotal != 0) {
                if (V) Log.v(TAG, "mCurrentBytes: " + item.totalCurrent +
                    " mTotalBytes: " + item.totalTotal + " (" +
                    (int)((item.totalCurrent * 100) / item.totalTotal) + " %)");
                b.setProgress(100, (int)((item.totalCurrent * 100) / item.totalTotal),
                    item.totalTotal == -1);
            } else {
                b.setProgress(100, 100, item.totalTotal == -1);
            }
            b.setWhen(item.timeStamp);
            if (item.direction == BluetoothShare.DIRECTION_OUTBOUND) {
                b.setSmallIcon(android.R.drawable.stat_sys_upload);
+1 −1
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
            ContentValues updateValues;
            ContentResolverUpdateThread uiUpdateThread = null;
            HeaderSet reply;
            int position = 0;
            long position = 0;
            reply = new HeaderSet();
            HeaderSet request;
            request = new HeaderSet();
+10 −7
Original line number Diff line number Diff line
@@ -426,16 +426,19 @@ public class BluetoothOppTransferActivity extends AlertActivity implements
            return;
        }

        if (mTransInfo.mTotalBytes == 0) {
            // if Max and progress both equal 0, the progress display 100%.
            // Below is to fix it.
        // Set Transfer Max as 100. Percentage calculation would be done in setProgress API
        mProgressTransfer.setMax(100);

        if (mTransInfo.mTotalBytes != 0) {
            if (V) Log.v(TAG, "mCurrentBytes: " + mTransInfo.mCurrentBytes +
                " mTotalBytes: " + mTransInfo.mTotalBytes + " (" +
                (int)((mTransInfo.mCurrentBytes * 100) / mTransInfo.mTotalBytes) + "%)");
            mProgressTransfer.setProgress((int)((mTransInfo.mCurrentBytes * 100) /
                mTransInfo.mTotalBytes));
        } else {
            mProgressTransfer.setMax(mTransInfo.mTotalBytes);
            mProgressTransfer.setProgress(100);
        }

        mProgressTransfer.setProgress(mTransInfo.mCurrentBytes);

        mPercentView.setText(BluetoothOppUtility.formatProgressText(this, mTransInfo.mTotalBytes,
                mTransInfo.mCurrentBytes));

+2 −2
Original line number Diff line number Diff line
@@ -41,9 +41,9 @@ public class BluetoothOppTransferInfo {

    int mDirection;

    int mTotalBytes;
    long mTotalBytes;

    int mCurrentBytes;
    long mCurrentBytes;

    int mStatus;

+2 −2
Original line number Diff line number Diff line
@@ -83,9 +83,9 @@ public class BluetoothOppUtility {
                info.mStatus = cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.STATUS));
                info.mDirection = cursor.getInt(cursor
                        .getColumnIndexOrThrow(BluetoothShare.DIRECTION));
                info.mTotalBytes = cursor.getInt(cursor
                info.mTotalBytes = cursor.getLong(cursor
                        .getColumnIndexOrThrow(BluetoothShare.TOTAL_BYTES));
                info.mCurrentBytes = cursor.getInt(cursor
                info.mCurrentBytes = cursor.getLong(cursor
                        .getColumnIndexOrThrow(BluetoothShare.CURRENT_BYTES));
                info.mTimeStamp = cursor.getLong(cursor
                        .getColumnIndexOrThrow(BluetoothShare.TIMESTAMP));