From eed32008a8d818d2781314adc7eccd7376ccf8b0 Mon Sep 17 00:00:00 2001 From: AnubhavGupta Date: Mon, 21 Mar 2016 17:44:17 +0530 Subject: [PATCH] Bluetooth: Send GET request as single packet - If obex based profile explicitly sets GET with final flag, then GET should always be sent as single packet request with final flag set. Change-Id: I82ff8295a239c4dbbfb4b3abfd358021820283cc --- obex/javax/obex/ClientOperation.java | 49 +++++++++++++++++++--------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/obex/javax/obex/ClientOperation.java b/obex/javax/obex/ClientOperation.java index 883c8c6ed75d2..eb7e28040d22e 100644 --- a/obex/javax/obex/ClientOperation.java +++ b/obex/javax/obex/ClientOperation.java @@ -632,21 +632,32 @@ private synchronized void startProcessing() throws IOException { if (mGetOperation) { if (!mOperationDone) { - mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE; - while ((more) && (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE)) { - more = sendRequest(ObexHelper.OBEX_OPCODE_GET); - } - // For GET we need to loop until all headers have been sent, - // And then we wait for the first continue package with the - // reply. - if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) { - mParent.sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL, - null, mReplyHeader, mPrivateInput, mSrmActive); - } - if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) { - mOperationDone = true; + if (!mGetFinalFlag) { + mReplyHeader.responseCode = ResponseCodes.OBEX_HTTP_CONTINUE; + while ((more) && (mReplyHeader.responseCode == + ResponseCodes.OBEX_HTTP_CONTINUE)) { + more = sendRequest(ObexHelper.OBEX_OPCODE_GET); + } + // For GET we need to loop until all headers have been sent, + // And then we wait for the first continue package with the + // reply. + if (mReplyHeader.responseCode == ResponseCodes.OBEX_HTTP_CONTINUE) { + mParent.sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL, + null, mReplyHeader, mPrivateInput, mSrmActive); + } + if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) { + mOperationDone = true; + } else { + checkForSrm(); + } } else { - checkForSrm(); + more = sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL); + + if (more) { + throw new IOException("FINAL_GET forced, data didn't fit into one packet"); + } + + mOperationDone = true; } } } else { @@ -705,7 +716,15 @@ public synchronized boolean continueOperation(boolean sendEmpty, boolean inStrea if (mPrivateInput == null) { mPrivateInput = new PrivateInputStream(this); } - sendRequest(ObexHelper.OBEX_OPCODE_GET); + + if (!mGetFinalFlag) { + sendRequest(ObexHelper.OBEX_OPCODE_GET); + } else { + sendRequest(ObexHelper.OBEX_OPCODE_GET_FINAL); + } + if (mReplyHeader.responseCode != ResponseCodes.OBEX_HTTP_CONTINUE) { + mOperationDone = true; + } return true; } else if (mOperationDone) {