summaryrefslogtreecommitdiffstats
path: root/obex
diff options
context:
space:
mode:
authorLixin Yue <L.X.YUE@motorola.com>2009-11-11 00:51:22 +0800
committerJaikumar Ganesh <jaikumar@google.com>2009-11-10 15:34:18 -0800
commit65208317ba9d16486b47ebcaa868c596d424c87f (patch)
tree51825f34b55b0427c767a942af327cae7557dd4d /obex
parente6ab011b8b8aa6c461e64cabb9b25d890d68edb1 (diff)
downloadframeworks_base-65208317ba9d16486b47ebcaa868c596d424c87f.zip
frameworks_base-65208317ba9d16486b47ebcaa868c596d424c87f.tar.gz
frameworks_base-65208317ba9d16486b47ebcaa868c596d424c87f.tar.bz2
Update OBEX to fix missing several contact entries issue.
The third parameter count of PrivateOutputStream.write() should be the size of vcards data plus header length, excluding the 3 bytes for the response message and 3 bytes for the header ID and length. Adjust the return value of getMaxPacketSize() by minus headser size, so that applications should not get packet slipped during multiple sharing operation. Do not set the header to null in getHeaderLength() to get PBAP PTS passed; Per OBEX spec, for Get request: Only the last packet need send the 0x49(End of Body); for intermediate packets, we need to send 0x48 (Body). If all packets use 0x49, some carkit like Nokia PD-17 will fail to download all contacts, except data in the last packet. Bug: 2246927 Dr No: Eastham
Diffstat (limited to 'obex')
-rw-r--r--obex/javax/obex/ClientOperation.java10
-rw-r--r--obex/javax/obex/Operation.java2
-rw-r--r--obex/javax/obex/ServerOperation.java58
3 files changed, 52 insertions, 18 deletions
diff --git a/obex/javax/obex/ClientOperation.java b/obex/javax/obex/ClientOperation.java
index 65663b1..05b498c 100644
--- a/obex/javax/obex/ClientOperation.java
+++ b/obex/javax/obex/ClientOperation.java
@@ -269,7 +269,7 @@ public final class ClientOperation implements Operation, BaseStream {
if (mPrivateOutput == null) {
// there are 3 bytes operation headers and 3 bytes body headers //
- mPrivateOutput = new PrivateOutputStream(this, mMaxPacketSize - 6);
+ mPrivateOutput = new PrivateOutputStream(this, getMaxPacketSize());
}
mPrivateOutputOpen = true;
@@ -278,7 +278,13 @@ public final class ClientOperation implements Operation, BaseStream {
}
public int getMaxPacketSize() {
- return mMaxPacketSize - 6;
+ return mMaxPacketSize - 6 - getHeaderLength();
+ }
+
+ public int getHeaderLength() {
+ // OPP may need it
+ byte[] headerArray = ObexHelper.createHeader(mRequestHeader, false);
+ return headerArray.length;
}
/**
diff --git a/obex/javax/obex/Operation.java b/obex/javax/obex/Operation.java
index 20653f2..25656ed 100644
--- a/obex/javax/obex/Operation.java
+++ b/obex/javax/obex/Operation.java
@@ -163,6 +163,8 @@ public interface Operation {
long getLength();
+ int getHeaderLength();
+
String getType();
InputStream openInputStream() throws IOException;
diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java
index 504fe35..07a3a53 100644
--- a/obex/javax/obex/ServerOperation.java
+++ b/obex/javax/obex/ServerOperation.java
@@ -124,21 +124,30 @@ public final class ServerOperation implements Operation, BaseStream {
* It is a PUT request.
*/
mGetOperation = false;
- } else {
+
+ /*
+ * Determine if the final bit is set
+ */
+ if ((request & 0x80) == 0) {
+ finalBitSet = false;
+ } else {
+ finalBitSet = true;
+ mRequestFinished = true;
+ }
+ } else if ((request == 0x03) || (request == 0x83)) {
/*
* It is a GET request.
*/
mGetOperation = true;
- }
- /*
- * Determine if the final bit is set
- */
- if ((request & 0x80) == 0) {
+ // For Get request, final bit set is decided by server side logic
finalBitSet = false;
+
+ if (request == 0x83) {
+ mRequestFinished = true;
+ }
} else {
- finalBitSet = true;
- mRequestFinished = true;
+ throw new IOException("ServerOperation can not handle such request");
}
int length = in.read();
@@ -216,12 +225,9 @@ public final class ServerOperation implements Operation, BaseStream {
}
// wait for get request finished !!!!
- while (mGetOperation && !finalBitSet) {
+ while (mGetOperation && !mRequestFinished) {
sendReply(ResponseCodes.OBEX_HTTP_CONTINUE);
}
- if (finalBitSet && mGetOperation) {
- mRequestFinished = true;
- }
}
public boolean isValidBody() {
@@ -333,6 +339,12 @@ public final class ServerOperation implements Operation, BaseStream {
out.write(headerArray);
}
+ // For Get operation: if response code is OBEX_HTTP_OK, then this is the
+ // last packet; so set finalBitSet to true.
+ if (mGetOperation && type == ResponseCodes.OBEX_HTTP_OK) {
+ finalBitSet = true;
+ }
+
if ((finalBitSet) || (headerArray.length < (mMaxPacketLength - 20))) {
if (bodyLength > 0) {
/*
@@ -410,9 +422,10 @@ public final class ServerOperation implements Operation, BaseStream {
}
} else {
- if ((headerID == ObexHelper.OBEX_OPCODE_PUT_FINAL)
- || (headerID == ObexHelper.OBEX_OPCODE_GET_FINAL)) {
+ if ((headerID == ObexHelper.OBEX_OPCODE_PUT_FINAL)) {
finalBitSet = true;
+ } else if (headerID == ObexHelper.OBEX_OPCODE_GET_FINAL) {
+ mRequestFinished = true;
}
/*
@@ -584,7 +597,20 @@ public final class ServerOperation implements Operation, BaseStream {
}
public int getMaxPacketSize() {
- return mMaxPacketLength - 6;
+ return mMaxPacketLength - 6 - getHeaderLength();
+ }
+
+ public int getHeaderLength() {
+ long id = mListener.getConnectionId();
+ if (id == -1) {
+ replyHeader.mConnectionID = null;
+ } else {
+ replyHeader.mConnectionID = ObexHelper.convertToByteArray(id);
+ }
+
+ byte[] headerArray = ObexHelper.createHeader(replyHeader, false);
+
+ return headerArray.length;
}
/**
@@ -623,7 +649,7 @@ public final class ServerOperation implements Operation, BaseStream {
}
if (mPrivateOutput == null) {
- mPrivateOutput = new PrivateOutputStream(this, mMaxPacketLength - 6);
+ mPrivateOutput = new PrivateOutputStream(this, getMaxPacketSize());
}
mPrivateOutputOpen = true;
return mPrivateOutput;