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

Commit 3aecf543 authored by Pradeep Panigrahi's avatar Pradeep Panigrahi Committed by Andre Eisenbach
Browse files

Use long as file size instead of int while using OPP.

Use Case:
1. Pair and connect to Dongle
2. Send a 2GB file from Dongle to DUT.

Failure:
File transfer failed in between.

Fix:
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.

Bug: 21896912
Change-Id: I49f9bf8a4a0e3668e32058d582a2700b0e6057e8
parent ae8997b8
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -111,9 +111,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.

@@ -241,8 +241,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);
@@ -319,7 +319,15 @@ class BluetoothOppNotification {
            b.setContentTitle(item.description);
            b.setContentInfo(
                BluetoothOppUtility.formatProgressText(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);
+3 −1
Original line number Diff line number Diff line
@@ -268,7 +268,9 @@ public class BluetoothOppObexServerSession extends ServerRequestHandler implemen
        ContentValues values = new ContentValues();

        values.put(BluetoothShare.FILENAME_HINT, name);
        values.put(BluetoothShare.TOTAL_BYTES, length.intValue());

        values.put(BluetoothShare.TOTAL_BYTES, length);

        values.put(BluetoothShare.MIMETYPE, mimeType);

        values.put(BluetoothShare.DESTINATION, destination);
+8 −2
Original line number Diff line number Diff line
@@ -215,6 +215,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();
@@ -232,8 +239,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
@@ -100,7 +100,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
@@ -122,7 +122,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