summaryrefslogtreecommitdiffstats
path: root/obex
diff options
context:
space:
mode:
authorHemant Gupta <hemantg@codeaurora.org>2013-08-16 14:57:55 +0530
committerMike Lockwood <lockwood@google.com>2014-07-01 18:01:27 +0000
commit8949bfb90c415629dbd0e30d25003fb3e0375fb5 (patch)
treea11a128c60d3301f41419e1ef9598d3a1bc28cc5 /obex
parente19a4fe32fd87a6c819f15155bb43d9fbe67607a (diff)
downloadframeworks_base-8949bfb90c415629dbd0e30d25003fb3e0375fb5.zip
frameworks_base-8949bfb90c415629dbd0e30d25003fb3e0375fb5.tar.gz
frameworks_base-8949bfb90c415629dbd0e30d25003fb3e0375fb5.tar.bz2
Bluetooth: Support MAP Client role on Bluedroid.
Implementation changes to support MAP client and PBAP client role on Bluedroid stack. Change-Id: I1733a67bf5256bd7b181bd5e68e40b476994ebfd
Diffstat (limited to 'obex')
-rw-r--r--obex/javax/obex/ClientOperation.java50
-rw-r--r--obex/javax/obex/HeaderSet.java23
-rw-r--r--obex/javax/obex/ObexHelper.java6
3 files changed, 70 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) {
diff --git a/obex/javax/obex/HeaderSet.java b/obex/javax/obex/HeaderSet.java
index 2b3066f..51b560a 100644
--- a/obex/javax/obex/HeaderSet.java
+++ b/obex/javax/obex/HeaderSet.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2014 The Android Open Source Project
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -181,6 +182,8 @@ public final class HeaderSet {
private String mName; // null terminated Unicode text string
+ private boolean mEmptyName;
+
private String mType; // null terminated ASCII text string
private Long mLength; // 4 byte unsigend integer
@@ -235,6 +238,25 @@ public final class HeaderSet {
}
/**
+ * Sets flag for special "value" of NAME header which should be empty. This
+ * is not the same as NAME header with empty string in which case it will
+ * have length of 5 bytes. It should be 3 bytes with only header id and
+ * length field.
+ */
+ public void setEmptyNameHeader() {
+ mName = null;
+ mEmptyName = true;
+ }
+
+ /**
+ * Gets flag for special "value" of NAME header which should be empty. See
+ * above.
+ */
+ public boolean getEmptyNameHeader() {
+ return mEmptyName;
+ }
+
+ /**
* Sets the value of the header identifier to the value provided. The type
* of object must correspond to the Java type defined in the description of
* this interface. If <code>null</code> is passed as the
@@ -269,6 +291,7 @@ public final class HeaderSet {
if ((headerValue != null) && (!(headerValue instanceof String))) {
throw new IllegalArgumentException("Name must be a String");
}
+ mEmptyName = false;
mName = (String)headerValue;
break;
case TYPE:
diff --git a/obex/javax/obex/ObexHelper.java b/obex/javax/obex/ObexHelper.java
index 8c12a20..0a06709 100644
--- a/obex/javax/obex/ObexHelper.java
+++ b/obex/javax/obex/ObexHelper.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2014 The Android Open Source Project
* Copyright (c) 2008-2009, Motorola, Inc.
*
* All rights reserved.
@@ -387,6 +388,11 @@ public final class ObexHelper {
if (nullOut) {
headImpl.setHeader(HeaderSet.NAME, null);
}
+ } else if (headImpl.getEmptyNameHeader()) {
+ out.write((byte) HeaderSet.NAME);
+ lengthArray[0] = (byte) 0x00;
+ lengthArray[1] = (byte) 0x03;
+ out.write(lengthArray);
}
// Type Header