diff options
author | Pradeep Panigrahi <pradeepp@codeaurora.org> | 2015-07-27 14:26:53 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2016-08-24 08:17:20 -0600 |
commit | 2b57c272a9e109108374cc7755aa170f79be781e (patch) | |
tree | c29f5b00b1f9f50dd6ef1c08bb6e80304a6327d0 /src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java | |
parent | 3820e44258af3ed4f7ed8ce8c524ea9dbfc49a70 (diff) | |
download | android_packages_apps_Bluetooth-2b57c272a9e109108374cc7755aa170f79be781e.tar.gz android_packages_apps_Bluetooth-2b57c272a9e109108374cc7755aa170f79be781e.tar.bz2 android_packages_apps_Bluetooth-2b57c272a9e109108374cc7755aa170f79be781e.zip |
Bluetooth: Add OPP 1.2 feature.
Add change to support OPP 1.2 which uses obex over l2cap.
Change-Id: I8cc4697658cae6decdba382c77f62c49c29fbf02
Diffstat (limited to 'src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java')
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java index 5d7f36291..45e964c17 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java @@ -396,6 +396,7 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { int readLength = 0; long percent = 0; long prevPercent = 0; + long readbytesleft = 0; boolean okToProceed = false; long timestamp = 0; int outputBufferSize = putOperation.getMaxPacketSize(); @@ -403,6 +404,10 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { BufferedInputStream a = new BufferedInputStream(fileInfo.mInputStream, 0x4000); if (!mInterrupted && (position != fileInfo.mLength)) { + readbytesleft = fileInfo.mLength - position; + if(readbytesleft < outputBufferSize) { + outputBufferSize = (int) readbytesleft; + } readLength = readFully(a, buffer, outputBufferSize); mCallback.sendMessageDelayed(mCallback @@ -437,12 +442,19 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { } } + long beginTime = System.currentTimeMillis(); while (!mInterrupted && okToProceed && (position < fileInfo.mLength)) { if (V) timestamp = System.currentTimeMillis(); + readbytesleft = fileInfo.mLength - position; + if(readbytesleft < outputBufferSize) { + outputBufferSize = (int) readbytesleft; + } readLength = a.read(buffer, 0, outputBufferSize); outputStream.write(buffer, 0, readLength); + if (V) Log.v(TAG, "waiting for response code"); + /* check remote abort */ responseCode = putOperation.getResponseCode(); if (V) Log.v(TAG, "Response code is " + responseCode); @@ -478,8 +490,13 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession { Log.i(TAG, "Remote reject file type " + fileInfo.mMimetype); status = BluetoothShare.STATUS_NOT_ACCEPTABLE; } else if (!mInterrupted && position == fileInfo.mLength) { + long endTime = System.currentTimeMillis(); Log.i(TAG, "SendFile finished send out file " + fileInfo.mFileName - + " length " + fileInfo.mLength); + + " length " + fileInfo.mLength + " Bytes. Approx. throughput is " + +BluetoothShare.throughputInKbps(fileInfo.mLength, + (endTime - beginTime)) + + " Kbps"); + status = BluetoothShare.STATUS_SUCCESS; } else { error = true; status = BluetoothShare.STATUS_CANCELED; |