summaryrefslogtreecommitdiffstats
path: root/obex/javax/obex/ClientOperation.java
diff options
context:
space:
mode:
Diffstat (limited to 'obex/javax/obex/ClientOperation.java')
-rw-r--r--obex/javax/obex/ClientOperation.java50
1 files changed, 41 insertions, 9 deletions
diff --git a/obex/javax/obex/ClientOperation.java b/obex/javax/obex/ClientOperation.java
index 0c65283..75278b5 100644
--- a/obex/javax/obex/ClientOperation.java
+++ b/obex/javax/obex/ClientOperation.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2014 The Android Open Source Project
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -66,6 +67,8 @@ public final class ClientOperation implements Operation, BaseStream {
private boolean mGetOperation;
+ private boolean mGetFinalFlag;
+
private HeaderSet mRequestHeader;
private HeaderSet mReplyHeader;
@@ -90,6 +93,7 @@ public final class ClientOperation implements Operation, BaseStream {
mOperationDone = false;
mMaxPacketSize = maxSize;
mGetOperation = type;
+ mGetFinalFlag = false;
mPrivateInputOpen = false;
mPrivateOutputOpen = false;
@@ -131,6 +135,15 @@ public final class ClientOperation implements Operation, BaseStream {
}
/**
+ * Allows to set flag which will force GET to be always sent as single packet request with
+ * final flag set. This is to improve compatibility with some profiles, i.e. PBAP which
+ * require requests to be sent this way.
+ */
+ public void setGetFinalFlag(boolean flag) {
+ mGetFinalFlag = flag;
+ }
+
+ /**
* Sends an ABORT message to the server. By calling this method, the
* corresponding input and output streams will be closed along with this
* object.
@@ -551,15 +564,25 @@ public final class ClientOperation implements Operation, BaseStream {
if (mGetOperation) {
if (!mOperationDone) {
- mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE;
- while ((more) && (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE)) {
- more = sendRequest(0x03);
- }
+ if (!mGetFinalFlag) {
+ mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE;
+ while ((more) && (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE)) {
+ more = sendRequest(0x03);
+ }
+
+ if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) {
+ mParent.sendRequest(0x83, null, mReplyHeader, mPrivateInput);
+ }
+ if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) {
+ mOperationDone = true;
+ }
+ } else {
+ more = sendRequest(0x83);
+
+ if (more) {
+ throw new IOException("FINAL_GET forced but data did not fit into single packet!");
+ }
- if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) {
- mParent.sendRequest(0x83, null, mReplyHeader, mPrivateInput);
- }
- if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) {
mOperationDone = true;
}
}
@@ -613,7 +636,16 @@ public final class ClientOperation implements Operation, BaseStream {
if (mPrivateInput == null) {
mPrivateInput = new PrivateInputStream(this);
}
- sendRequest(0x03);
+
+ if (!mGetFinalFlag) {
+ sendRequest(0x03);
+ } else {
+ sendRequest(0x83);
+
+ if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) {
+ mOperationDone = true;
+ }
+ }
return true;
} else if (mOperationDone) {