summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshwini Munigala <AshwiniM@codeaurora.org>2013-06-12 15:38:48 +0530
committerSteve Kondik <shade@chemlab.org>2013-09-07 11:45:09 -0700
commitef234efec2e5933b189b7158cea3bbb29fc75ab9 (patch)
treeb3e78d4bdff32d092bc76e868ec26f6883946aba
parent08adbb822be78164a19431d37f7c963faf7e29cf (diff)
downloadandroid_frameworks_base-bt-next.tar.gz
android_frameworks_base-bt-next.tar.bz2
android_frameworks_base-bt-next.zip
MAP: Support MAP Server role on Bluedroid with javax.OBEX lib.bt-next
Handle No END OF BODY for MAP 1.0 Server Get request. Only the last packet need send the 0x49(End of Body). For intermediate packets, we need to send 0x48 (Body). Move definitions for MAP or FTP Service Specific UUID and Request type for CONNECTION_ACCESS_REQUEST intent to BluetoothExt APK. Change-Id: I04cfeb8d53b8f8c19160a2de1eb448a7ec1f2c41 CRs-fixed: 504042
-rw-r--r--obex/javax/obex/ClientOperation.java4
-rw-r--r--obex/javax/obex/ClientSession.java16
-rw-r--r--obex/javax/obex/Operation.java3
-rw-r--r--obex/javax/obex/ServerOperation.java43
4 files changed, 46 insertions, 20 deletions
diff --git a/obex/javax/obex/ClientOperation.java b/obex/javax/obex/ClientOperation.java
index 05b498c1357..4afb3555181 100644
--- a/obex/javax/obex/ClientOperation.java
+++ b/obex/javax/obex/ClientOperation.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -723,4 +724,7 @@ public final class ClientOperation implements Operation, BaseStream {
}
}
}
+ public void noEndofBody() {
+
+ }
}
diff --git a/obex/javax/obex/ClientSession.java b/obex/javax/obex/ClientSession.java
index 27d8976d070..e7f4e0b17fa 100644
--- a/obex/javax/obex/ClientSession.java
+++ b/obex/javax/obex/ClientSession.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -62,6 +63,7 @@ public final class ClientSession extends ObexSession {
private final OutputStream mOutput;
+ private long mTotalSize = 0;
public ClientSession(final ObexTransport trans) throws IOException {
mInput = trans.openInputStream();
mOutput = trans.openOutputStream();
@@ -476,10 +478,16 @@ public final class ClientSession extends ObexSession {
}
}
- byte[] body = ObexHelper.updateHeaderSet(header, data);
- if ((privateInput != null) && (body != null)) {
- privateInput.writeBytes(body, 1);
- }
+ byte[] body = ObexHelper.updateHeaderSet(header, data);
+ if ((privateInput != null) && (body != null)) {
+ privateInput.writeBytes(body, 1);
+ mTotalSize += (long)(body.length - 1);
+ if((body[0] == HeaderSet.END_OF_BODY) &&
+ (header.getHeader(HeaderSet.LENGTH) == null)){
+ header.setHeader(HeaderSet.LENGTH, mTotalSize);
+ mTotalSize = 0;
+ }
+ }
if (header.mConnectionID != null) {
mConnectionId = new byte[4];
diff --git a/obex/javax/obex/Operation.java b/obex/javax/obex/Operation.java
index 25656ed5d6a..6db6b68e666 100644
--- a/obex/javax/obex/Operation.java
+++ b/obex/javax/obex/Operation.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -177,5 +178,7 @@ public interface Operation {
void close() throws IOException;
+ void noEndofBody();
+
int getMaxPacketSize();
}
diff --git a/obex/javax/obex/ServerOperation.java b/obex/javax/obex/ServerOperation.java
index d1476d271cf..b2dd33f45bd 100644
--- a/obex/javax/obex/ServerOperation.java
+++ b/obex/javax/obex/ServerOperation.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -88,6 +89,7 @@ public final class ServerOperation implements Operation, BaseStream {
private boolean mHasBody;
+ private boolean mEndofBody = true;
/**
* Creates new ServerOperation
* @param p the parent that created this object
@@ -364,28 +366,33 @@ public final class ServerOperation implements Operation, BaseStream {
* (End of Body) otherwise, we need to send 0x48 (Body)
*/
if ((finalBitSet) || (mPrivateOutput.isClosed())) {
- out.write(0x49);
+ if (mEndofBody) {
+ out.write(0x49);
+ bodyLength += 3;
+ out.write((byte)(bodyLength >> 8));
+ out.write((byte)bodyLength);
+ out.write(body);
+ }
} else {
out.write(0x48);
+ bodyLength += 3;
+ out.write((byte)(bodyLength >> 8));
+ out.write((byte)bodyLength);
+ out.write(body);
}
-
- bodyLength += 3;
- out.write((byte)(bodyLength >> 8));
- out.write((byte)bodyLength);
- out.write(body);
}
}
- if ((finalBitSet) && (type == ResponseCodes.OBEX_HTTP_OK) && (orginalBodyLength <= 0)) {
- out.write(0x49);
- orginalBodyLength = 3;
- out.write((byte)(orginalBodyLength >> 8));
- out.write((byte)orginalBodyLength);
-
- }
-
- mResponseSize = 3;
- mParent.sendResponse(type, out.toByteArray());
+ if ((finalBitSet) && (type == ResponseCodes.OBEX_HTTP_OK) && (orginalBodyLength <= 0)) {
+ if (mEndofBody) {
+ out.write(0x49);
+ orginalBodyLength = 3;
+ out.write((byte)(orginalBodyLength >> 8));
+ out.write((byte)orginalBodyLength);
+ }
+ }
+ mResponseSize = 3;
+ mParent.sendResponse(type, out.toByteArray());
if (type == ResponseCodes.OBEX_HTTP_CONTINUE) {
int headerID = mInput.read();
@@ -711,4 +718,8 @@ public final class ServerOperation implements Operation, BaseStream {
public void streamClosed(boolean inStream) throws IOException {
}
+
+ public void noEndofBody() {
+ mEndofBody = false;
+ }
}