summaryrefslogtreecommitdiffstats
path: root/core/jni/android_server_BluetoothEventLoop.cpp
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2009-10-07 07:44:03 +0200
committerNick Pelly <npelly@google.com>2009-10-07 23:25:24 +0200
commit16fb88a673c41b93c5d57ccb28c2697e7d87701a (patch)
treef6c32d70ca192de4fd6608c931b501263de2766b /core/jni/android_server_BluetoothEventLoop.cpp
parent64dd5be583bab8218e54068bbf70edc5fc6087c8 (diff)
downloadframeworks_base-16fb88a673c41b93c5d57ccb28c2697e7d87701a.zip
frameworks_base-16fb88a673c41b93c5d57ccb28c2697e7d87701a.tar.gz
frameworks_base-16fb88a673c41b93c5d57ccb28c2697e7d87701a.tar.bz2
Encourage developers to connect RFCOMM by UUID instead of Channel.
Hide createRfcommSocket(int channel) Add createRfcommSocketWithServiceRecord(UUID uuid) Rename listenUsingRfcomm(String,UUID) -> listenUsingRfcommWithServiceRecord(..) Now we have a complete API for developers to make peer-peer RFCOMM connections with hard-coding the limited (30) RFCOMM channels, instead using SDP lookup of an UUID. This commit addresses two serious bugs: - Do not throw IOException on accepting an incoming RFCOMM connection with BluetoothSocket. This was a regression from commit 24bb9b8af4ff6915 - Workaround failure of bluez to update SDP cache when channel changes by trying to use the same RFCOMM channel on the server every time, instead of picking server channels randomly. This is a pretty ugly workaround, and we are still trying to fix the caching issue - but with this workaround we are at least shippable and apps will work at least until they start colliding on the 30 RFCOMM channels. DrNo: eastham Bug: 2158900 Joke: What did the digital watch say to his mom? "Look mom no hands." Change-Id: Ia4879943b83afac06b6f1a3f2391cf1628afce7d
Diffstat (limited to 'core/jni/android_server_BluetoothEventLoop.cpp')
-rw-r--r--core/jni/android_server_BluetoothEventLoop.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp
index e37e832..62a50e5 100644
--- a/core/jni/android_server_BluetoothEventLoop.cpp
+++ b/core/jni/android_server_BluetoothEventLoop.cpp
@@ -36,6 +36,10 @@
namespace android {
+#define CREATE_DEVICE_ALREADY_EXISTS 1
+#define CREATE_DEVICE_SUCCESS 0
+#define CREATE_DEVICE_FAILED -1
+
#ifdef HAVE_BLUETOOTH
static jfieldID field_mNativeData;
@@ -95,7 +99,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
method_onCreatePairedDeviceResult = env->GetMethodID(clazz, "onCreatePairedDeviceResult",
"(Ljava/lang/String;I)V");
method_onCreateDeviceResult = env->GetMethodID(clazz, "onCreateDeviceResult",
- "(Ljava/lang/String;Z)V");
+ "(Ljava/lang/String;I)V");
method_onDiscoverServicesResult = env->GetMethodID(clazz, "onDiscoverServicesResult",
"(Ljava/lang/String;Z)V");
@@ -1115,10 +1119,13 @@ void onCreateDeviceResult(DBusMessage *msg, void *user, void *n) {
LOGV("... Address = %s", address);
- bool result = JNI_TRUE;
+ jint result = CREATE_DEVICE_SUCCESS;
if (dbus_set_error_from_message(&err, msg)) {
+ if (dbus_error_has_name(&err, "org.bluez.Error.AlreadyExists")) {
+ result = CREATE_DEVICE_ALREADY_EXISTS;
+ }
LOG_AND_FREE_DBUS_ERROR(&err);
- result = JNI_FALSE;
+ result = CREATE_DEVICE_FAILED;
}
env->CallVoidMethod(nat->me,
method_onCreateDeviceResult,