summaryrefslogtreecommitdiffstats
path: root/core/jni/android_bluetooth_BluetoothSocket.cpp
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2009-08-31 13:33:06 -0700
committerNick Pelly <npelly@google.com>2009-08-31 13:33:06 -0700
commit41a0a4a850184c8c936818dc0f2ac4d3ecd9a1c6 (patch)
treea1a68ff6a57bdb348048cf67197e20db38d885cb /core/jni/android_bluetooth_BluetoothSocket.cpp
parent66360af891ac1b77fa5a48d668bd848c84b6f041 (diff)
downloadframeworks_base-41a0a4a850184c8c936818dc0f2ac4d3ecd9a1c6.zip
frameworks_base-41a0a4a850184c8c936818dc0f2ac4d3ecd9a1c6.tar.gz
frameworks_base-41a0a4a850184c8c936818dc0f2ac4d3ecd9a1c6.tar.bz2
Set RFCOMM SO_SNDBUF size to 70 KB for large RFCOMM writes.
With a 64 KB OBEX MTU, net/rfcomm/sock.c:rfcomm_sock_sendmsg() quietly drops data. The default SO_SNDBUF is 24 KB. Empircally, 36 KB still drops, and 38 KB no longer drops (this is because SO_SNDBUF is doubled in net/core/sock.c and then there is OBEX/RFCOMM overhead). Set to 70 KB so we have plenty of room to spare. See http://b/2090000 to investigate this in more detail later.
Diffstat (limited to 'core/jni/android_bluetooth_BluetoothSocket.cpp')
-rw-r--r--core/jni/android_bluetooth_BluetoothSocket.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/jni/android_bluetooth_BluetoothSocket.cpp b/core/jni/android_bluetooth_BluetoothSocket.cpp
index 9c4f7c7..0aeaadc 100644
--- a/core/jni/android_bluetooth_BluetoothSocket.cpp
+++ b/core/jni/android_bluetooth_BluetoothSocket.cpp
@@ -54,6 +54,8 @@ static const int TYPE_RFCOMM = 1;
static const int TYPE_SCO = 2;
static const int TYPE_L2CAP = 3; // TODO: Test l2cap code paths
+static const int RFCOMM_SO_SNDBUF = 70 * 1024; // 70 KB send buffer
+
static struct asocket *get_socketData(JNIEnv *env, jobject obj) {
struct asocket *s =
(struct asocket *) env->GetIntField(obj, field_mSocketData);
@@ -87,6 +89,7 @@ static void initSocketNative(JNIEnv *env, jobject obj) {
int fd;
int lm = 0;
+ int sndbuf;
jboolean auth;
jboolean encrypt;
jint type;
@@ -131,7 +134,16 @@ static void initSocketNative(JNIEnv *env, jobject obj) {
if (lm) {
if (setsockopt(fd, SOL_RFCOMM, RFCOMM_LM, &lm, sizeof(lm))) {
- LOGV("setsockopt() failed, throwing");
+ LOGV("setsockopt(RFCOMM_LM) failed, throwing");
+ jniThrowIOException(env, errno);
+ return;
+ }
+ }
+
+ if (type == TYPE_RFCOMM) {
+ sndbuf = RFCOMM_SO_SNDBUF;
+ if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf))) {
+ LOGV("setsockopt(SO_SNDBUF) failed, throwing");
jniThrowIOException(env, errno);
return;
}
@@ -274,16 +286,21 @@ static void bindListenNative(JNIEnv *env, jobject obj) {
}
if (bind(s->fd, addr, addr_sz)) {
+ LOGV("...bind(%d) gave errno %d", s->fd, errno);
jniThrowIOException(env, errno);
return;
}
if (listen(s->fd, 1)) {
+ LOGV("...listen(%d) gave errno %d", s->fd, errno);
jniThrowIOException(env, errno);
return;
}
+ LOGV("...bindListenNative(%d) success", s->fd);
+
return;
+
#endif
jniThrowIOException(env, ENOSYS);
}