summaryrefslogtreecommitdiffstats
path: root/obex/javax
diff options
context:
space:
mode:
authorAnders Petersson <anders3.petersson@sonyericsson.com>2010-10-27 08:38:30 +0200
committerJohan Redestig <johan.redestig@sonyericsson.com>2010-10-27 08:38:30 +0200
commitfaf49b14a2768d3df8bfcf7f50516c5660021f51 (patch)
tree1ee6388cb6a259878f993cf3a0df10d71cf44fa1 /obex/javax
parentb4ae2f1ba419212224d53db81c46ad242bebd17b (diff)
downloadframeworks_base-faf49b14a2768d3df8bfcf7f50516c5660021f51.zip
frameworks_base-faf49b14a2768d3df8bfcf7f50516c5660021f51.tar.gz
frameworks_base-faf49b14a2768d3df8bfcf7f50516c5660021f51.tar.bz2
Bluetooth OBEX timeout problem.
Long time to show notification of file transfer failed after canceling transfer via remote part. Device A is in contact with our device, B. When device A Cancel a transfer operation, it sends OBEX_OPCODE_DISCONNECT HeaderID and the length of package to B. B use the length of package to read remainder bytes from A. If the bytes B read do not meet the received length it will block and wait for remainder bytes from A. But when B compute the remainder bytes it forgets to subtract the three bytes it has already read through HeaderID and the length of the package. So the operation was blocked until the operation timeout. Change-Id: I0f8bf62d3119e081b5c01af9fc05fe586fd4fabc
Diffstat (limited to 'obex/javax')
-rw-r--r--obex/javax/obex/ServerOperation.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java
index 07a3a53..d1476d2 100644
--- a/obex/javax/obex/ServerOperation.java
+++ b/obex/javax/obex/ServerOperation.java
@@ -397,11 +397,13 @@ public final class ServerOperation implements Operation, BaseStream {
&& (headerID != ObexHelper.OBEX_OPCODE_GET_FINAL)) {
if (length > 3) {
- byte[] temp = new byte[length];
+ byte[] temp = new byte[length - 3];
+ // First three bytes already read, compensating for this
bytesReceived = mInput.read(temp);
- while (bytesReceived != length) {
- bytesReceived += mInput.read(temp, bytesReceived, length - bytesReceived);
+ while (bytesReceived != temp.length) {
+ bytesReceived += mInput.read(temp, bytesReceived,
+ temp.length - bytesReceived);
}
}