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

Commit 782646d2 authored by Juffin Alex Varghese's avatar Juffin Alex Varghese
Browse files

Bluetooth-OPP: Use long data type to contain receiving file size

If receiving file size is in GBs int type will not be able to contain
actual size and will lead to failure. So change to long instead of
int.

CRs-Fixed: 756089
Change-Id: Idc069eb59311d4e56013454ae10b0ecd37314ddd
parent 087a6cf7
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -667,8 +667,10 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
                    } else if (!mInterrupted && position == fileInfo.mLength) {
                        long endTime = System.currentTimeMillis();
                        Log.i(TAG, "SendFile finished sending file " + fileInfo.mFileName
                                + " length " + fileInfo.mLength
                                + "Bytes in " + (endTime - beginTime) + "ms"  );
                                + " length " + fileInfo.mLength + " Bytes. Approx. throughput is "
                                + BluetoothShare.throughputInKbps(fileInfo.mLength,
                                        (endTime - beginTime))
                                + " Kbps");
                        status = BluetoothShare.STATUS_SUCCESS;
                        outputStream.close();
                    } else {
+4 −5
Original line number Diff line number Diff line
@@ -384,9 +384,7 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen

        values.put(BluetoothShare.FILENAME_HINT, name);

        if (length != null) {
            values.put(BluetoothShare.TOTAL_BYTES, length.intValue());
        }
        values.put(BluetoothShare.TOTAL_BYTES, length);

        values.put(BluetoothShare.MIMETYPE, mimeType);

@@ -664,8 +662,9 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
            if (position == fileInfo.mLength) {
                long endTime = System.currentTimeMillis();
                Log.i(TAG, "Receiving file completed for " + fileInfo.mFileName
                        + " length " + fileInfo.mLength
                        + " Bytes in " + (endTime - beginTime) + "ms"  );
                        + " length " + fileInfo.mLength + " Bytes. Approx. throughput is "
                        + BluetoothShare.throughputInKbps(fileInfo.mLength, (endTime - beginTime))
                        + " Kbps");
                status = BluetoothShare.STATUS_SUCCESS;
            } else {
                Log.i(TAG, "Reading file failed at " + position + " of " + fileInfo.mLength);
+8 −2
Original line number Diff line number Diff line
@@ -228,6 +228,13 @@ public final class BluetoothOppProvider extends ContentProvider {
        }
    }

    private static final void copyLong(String key, ContentValues from, ContentValues to) {
        Long i = from.getAsLong(key);
        if (i != null) {
            to.put(key, i);
        }
    }

    @Override
    public Uri insert(Uri uri, ContentValues values) {
        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -245,8 +252,7 @@ public final class BluetoothOppProvider extends ContentProvider {
        copyString(BluetoothShare.DESTINATION, values, filteredValues);

        copyInteger(BluetoothShare.VISIBILITY, values, filteredValues);
        copyInteger(BluetoothShare.TOTAL_BYTES, values, filteredValues);

        copyLong(BluetoothShare.TOTAL_BYTES, values, filteredValues);
        if (values.getAsInteger(BluetoothShare.VISIBILITY) == null) {
            filteredValues.put(BluetoothShare.VISIBILITY, BluetoothShare.VISIBILITY_VISIBLE);
        }
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ public class BluetoothOppReceiveFileInfo {
            try {
                if (metadataCursor.moveToFirst()) {
                    hint = metadataCursor.getString(0);
                    length = metadataCursor.getInt(1);
                    length = metadataCursor.getLong(1);
                    mimeType = metadataCursor.getString(2);
                }
            } finally {
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ public class BluetoothOppSendFileInfo {
                try {
                    if (metadataCursor.moveToFirst()) {
                        fileName = metadataCursor.getString(0);
                        length = metadataCursor.getInt(1);
                        length = metadataCursor.getLong(1);
                        if (D) Log.d(TAG, "fileName = " + fileName + " length = " + length);
                    }
                } finally {
Loading