From 3fd36737b3bdf0100045cf46fe98534431c3fd5c Mon Sep 17 00:00:00 2001 From: Matthew Xie Date: Fri, 29 Jul 2011 14:51:28 -0700 Subject: Change setDevicePropertyNative to no block. Change setDevicePropertyNative to use async dbus call to bluez instead of blocking call. The old call was dbus_connection_send_with_reply_and_block. It is replaced by dbus_connection_send_with_reply. Change-Id: I1a772b33b54c8aad71a6f4d86dcd289354d8155b --- core/jni/android_server_BluetoothService.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'core/jni/android_server_BluetoothService.cpp') diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp index 41056fd..819449a 100644 --- a/core/jni/android_server_BluetoothService.cpp +++ b/core/jni/android_server_BluetoothService.cpp @@ -846,14 +846,13 @@ static jboolean setDevicePropertyNative(JNIEnv *env, jobject object, jstring pat LOGV("%s", __FUNCTION__); native_data_t *nat = get_native_data(env, object); if (nat) { - DBusMessage *reply, *msg; + DBusMessage *msg; DBusMessageIter iter; - DBusError err; + dbus_bool_t reply = JNI_FALSE; const char *c_key = env->GetStringUTFChars(key, NULL); const char *c_path = env->GetStringUTFChars(path, NULL); - dbus_error_init(&err); msg = dbus_message_new_method_call(BLUEZ_DBUS_BASE_IFC, c_path, DBUS_DEVICE_IFACE, "SetProperty"); if (!msg) { @@ -867,19 +866,14 @@ static jboolean setDevicePropertyNative(JNIEnv *env, jobject object, jstring pat dbus_message_iter_init_append(msg, &iter); append_variant(&iter, type, value); - reply = dbus_connection_send_with_reply_and_block(nat->conn, msg, -1, &err); + // Asynchronous call - the callbacks come via Device propertyChange + reply = dbus_connection_send_with_reply(nat->conn, msg, NULL, -1); dbus_message_unref(msg); - env->ReleaseStringUTFChars(key, c_key); env->ReleaseStringUTFChars(path, c_path); - if (!reply) { - if (dbus_error_is_set(&err)) { - LOG_AND_FREE_DBUS_ERROR(&err); - } else - LOGE("DBus reply is NULL in function %s", __FUNCTION__); - return JNI_FALSE; - } - return JNI_TRUE; + env->ReleaseStringUTFChars(key, c_key); + + return reply ? JNI_TRUE : JNI_FALSE; } #endif return JNI_FALSE; -- cgit v1.1