From 4b7462055ae34b4da7101e675420dab6a2c641bf Mon Sep 17 00:00:00 2001 From: Shuki Hashimoto Date: Thu, 29 Sep 2016 14:54:20 +0900 Subject: [PATCH] OPP: Fix "0%" progress even after file transfer finished 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java index 1688c706..f57147d3 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java +++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java @@ -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; -- 2.11.0