summaryrefslogtreecommitdiffstats
path: root/core/jni/android_server_BluetoothService.cpp
diff options
context:
space:
mode:
authorMatthew Xie <mattx@google.com>2011-07-29 14:51:28 -0700
committerMatthew Xie <mattx@google.com>2011-07-29 15:08:41 -0700
commit3fd36737b3bdf0100045cf46fe98534431c3fd5c (patch)
tree64af4bc0dd4dddb643203fb838378c751110ffb2 /core/jni/android_server_BluetoothService.cpp
parent269e81a563cfe080d7f241d0d46411d3c946c111 (diff)
downloadframeworks_base-3fd36737b3bdf0100045cf46fe98534431c3fd5c.zip
frameworks_base-3fd36737b3bdf0100045cf46fe98534431c3fd5c.tar.gz
frameworks_base-3fd36737b3bdf0100045cf46fe98534431c3fd5c.tar.bz2
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
Diffstat (limited to 'core/jni/android_server_BluetoothService.cpp')
-rw-r--r--core/jni/android_server_BluetoothService.cpp20
1 files changed, 7 insertions, 13 deletions
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;