Merge change I65208317 into eclair
* changes: Update OBEX to fix missing several contact entries issue.
This commit is contained in:
@@ -269,7 +269,7 @@ public final class ClientOperation implements Operation, BaseStream {
|
|||||||
|
|
||||||
if (mPrivateOutput == null) {
|
if (mPrivateOutput == null) {
|
||||||
// there are 3 bytes operation headers and 3 bytes body headers //
|
// there are 3 bytes operation headers and 3 bytes body headers //
|
||||||
mPrivateOutput = new PrivateOutputStream(this, mMaxPacketSize - 6);
|
mPrivateOutput = new PrivateOutputStream(this, getMaxPacketSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
mPrivateOutputOpen = true;
|
mPrivateOutputOpen = true;
|
||||||
@@ -278,7 +278,13 @@ public final class ClientOperation implements Operation, BaseStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxPacketSize() {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ public interface Operation {
|
|||||||
|
|
||||||
long getLength();
|
long getLength();
|
||||||
|
|
||||||
|
int getHeaderLength();
|
||||||
|
|
||||||
String getType();
|
String getType();
|
||||||
|
|
||||||
InputStream openInputStream() throws IOException;
|
InputStream openInputStream() throws IOException;
|
||||||
|
|||||||
@@ -124,21 +124,30 @@ public final class ServerOperation implements Operation, BaseStream {
|
|||||||
* It is a PUT request.
|
* It is a PUT request.
|
||||||
*/
|
*/
|
||||||
mGetOperation = false;
|
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.
|
* It is a GET request.
|
||||||
*/
|
*/
|
||||||
mGetOperation = true;
|
mGetOperation = true;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
// For Get request, final bit set is decided by server side logic
|
||||||
* Determine if the final bit is set
|
|
||||||
*/
|
|
||||||
if ((request & 0x80) == 0) {
|
|
||||||
finalBitSet = false;
|
finalBitSet = false;
|
||||||
|
|
||||||
|
if (request == 0x83) {
|
||||||
|
mRequestFinished = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
finalBitSet = true;
|
throw new IOException("ServerOperation can not handle such request");
|
||||||
mRequestFinished = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = in.read();
|
int length = in.read();
|
||||||
@@ -216,12 +225,9 @@ public final class ServerOperation implements Operation, BaseStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wait for get request finished !!!!
|
// wait for get request finished !!!!
|
||||||
while (mGetOperation && !finalBitSet) {
|
while (mGetOperation && !mRequestFinished) {
|
||||||
sendReply(ResponseCodes.OBEX_HTTP_CONTINUE);
|
sendReply(ResponseCodes.OBEX_HTTP_CONTINUE);
|
||||||
}
|
}
|
||||||
if (finalBitSet && mGetOperation) {
|
|
||||||
mRequestFinished = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidBody() {
|
public boolean isValidBody() {
|
||||||
@@ -333,6 +339,12 @@ public final class ServerOperation implements Operation, BaseStream {
|
|||||||
out.write(headerArray);
|
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 ((finalBitSet) || (headerArray.length < (mMaxPacketLength - 20))) {
|
||||||
if (bodyLength > 0) {
|
if (bodyLength > 0) {
|
||||||
/*
|
/*
|
||||||
@@ -410,9 +422,10 @@ public final class ServerOperation implements Operation, BaseStream {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ((headerID == ObexHelper.OBEX_OPCODE_PUT_FINAL)
|
if ((headerID == ObexHelper.OBEX_OPCODE_PUT_FINAL)) {
|
||||||
|| (headerID == ObexHelper.OBEX_OPCODE_GET_FINAL)) {
|
|
||||||
finalBitSet = true;
|
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() {
|
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) {
|
if (mPrivateOutput == null) {
|
||||||
mPrivateOutput = new PrivateOutputStream(this, mMaxPacketLength - 6);
|
mPrivateOutput = new PrivateOutputStream(this, getMaxPacketSize());
|
||||||
}
|
}
|
||||||
mPrivateOutputOpen = true;
|
mPrivateOutputOpen = true;
|
||||||
return mPrivateOutput;
|
return mPrivateOutput;
|
||||||
|
|||||||
Reference in New Issue
Block a user