OSDN Git Service

OPP: Fix "0%" progress even after file transfer finished
authorShuki Hashimoto <shuki.x.hashimoto@sonymobile.com>
Thu, 29 Sep 2016 05:54:20 +0000 (14:54 +0900)
committerAndre Eisenbach <eisenbach@google.com>
Mon, 17 Oct 2016 20:16:20 +0000 (20:16 +0000)
When the file is small enough to be sent together with header in one
packet, PrivateOutputStream#write() never calls back ClientOperation,
because OBEX Client has no more data to send.
In this case, response code in ClientOperation is not updated from
default value (-1) until the PrivateOutputStream is closed.
It causes progress bar not updated from 0%.

The patch adds PrivateOutputStream#close() call after the first write
operation when file and header are sent in one packet, and ensures
progress bar to be updated properly.

Bug: 31895670
Test: manual

Change-Id: I735a872b756ab1c8892c2f8bbf2dce51ae24fc5a

src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java

index 1688c70..f57147d 100644 (file)
@@ -416,6 +416,13 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
 
                         position += readLength;
 
+                        if (position == fileInfo.mLength) {
+                            // if file length is smaller than buffer size, only one packet
+                            // so block point is here
+                            outputStream.close();
+                            outputStream = null;
+                        }
+
                         mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
                         synchronized (this) {
                             mWaitingForRemote = false;