summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuffin Alex Varghese <jalex@codeaurora.org>2014-11-13 14:38:09 +0530
committerJuffin Alex Varghese <jalex@codeaurora.org>2014-11-17 15:23:16 +0530
commit782646d2cddc03f58738459282e3c377af7e0396 (patch)
tree419ed26fae2c30cd9e9066bd84432ac1f3819522
parent087a6cf7a9bf66d7789c9901cc111451b466d57b (diff)
downloadandroid_packages_apps_Bluetooth-782646d2cddc03f58738459282e3c377af7e0396.tar.gz
android_packages_apps_Bluetooth-782646d2cddc03f58738459282e3c377af7e0396.tar.bz2
android_packages_apps_Bluetooth-782646d2cddc03f58738459282e3c377af7e0396.zip
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
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java6
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java9
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppProvider.java10
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java2
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java2
-rw-r--r--src/com/android/bluetooth/opp/BluetoothShare.java7
6 files changed, 25 insertions, 11 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
index 6ec315ed9..159bb097e 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
@@ -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 {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
index a12782818..c7876409e 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexServerSession.java
@@ -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);
diff --git a/src/com/android/bluetooth/opp/BluetoothOppProvider.java b/src/com/android/bluetooth/opp/BluetoothOppProvider.java
index 132b950df..a3f3ef30f 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppProvider.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppProvider.java
@@ -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);
}
diff --git a/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
index 4bd9c21fd..327261add 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppReceiveFileInfo.java
@@ -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 {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
index f060a04e6..3901e7a31 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
@@ -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 {
diff --git a/src/com/android/bluetooth/opp/BluetoothShare.java b/src/com/android/bluetooth/opp/BluetoothShare.java
index ffec3c084..3242e7e34 100644
--- a/src/com/android/bluetooth/opp/BluetoothShare.java
+++ b/src/com/android/bluetooth/opp/BluetoothShare.java
@@ -426,4 +426,11 @@ public final class BluetoothShare implements BaseColumns {
*/
public static final int UI_UPDATE_INTERVAL = 1000;
+ /**
+ * Returns the throughput of the file transfer
+ */
+ public static float throughputInKbps(long fileSize, long timeDuration) {
+ float throughput = (float)(fileSize * 8 * 1000) / (timeDuration * 1024);
+ return throughput;
+ }
}