diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2009-09-16 15:15:21 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-09-16 17:27:10 -0700 |
commit | 4f3ebc43af1f254d99e1cf64620ff94d28023bd2 (patch) | |
tree | 7899f13955f316eba13c4f6868d53a2ca2af756d /core/jni | |
parent | 9092ab4d458ad60b459d5fad52368bde5d25f665 (diff) | |
download | frameworks_base-4f3ebc43af1f254d99e1cf64620ff94d28023bd2.zip frameworks_base-4f3ebc43af1f254d99e1cf64620ff94d28023bd2.tar.gz frameworks_base-4f3ebc43af1f254d99e1cf64620ff94d28023bd2.tar.bz2 |
Fix async calls with Connect And Disconnect Sink.
Change-Id: I814c7fdf40ec0d6aefeb410b1a1b1572ab4a8d88
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android_server_BluetoothA2dpService.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/core/jni/android_server_BluetoothA2dpService.cpp b/core/jni/android_server_BluetoothA2dpService.cpp index a185d8d..ba13519 100644 --- a/core/jni/android_server_BluetoothA2dpService.cpp +++ b/core/jni/android_server_BluetoothA2dpService.cpp @@ -133,23 +133,13 @@ static jboolean connectSinkNative(JNIEnv *env, jobject object, jstring path) { LOGV(__FUNCTION__); if (nat) { const char *c_path = env->GetStringUTFChars(path, NULL); - DBusError err; - dbus_error_init(&err); - DBusMessage *reply = - dbus_func_args_timeout(env, nat->conn, -1, c_path, - "org.bluez.AudioSink", "Connect", - DBUS_TYPE_INVALID); - env->ReleaseStringUTFChars(path, c_path); + bool ret = dbus_func_args_async(env, nat->conn, -1, NULL, NULL, nat, + c_path, "org.bluez.AudioSink", "Connect", + DBUS_TYPE_INVALID); - if (!reply && dbus_error_is_set(&err)) { - LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, reply); - return JNI_FALSE; - } else if (!reply) { - LOGE("DBus reply is NULL in function %s", __FUNCTION__); - return JNI_FALSE; - } - return JNI_TRUE; + env->ReleaseStringUTFChars(path, c_path); + return ret ? JNI_TRUE : JNI_FALSE; } #endif return JNI_FALSE; @@ -161,23 +151,13 @@ static jboolean disconnectSinkNative(JNIEnv *env, jobject object, LOGV(__FUNCTION__); if (nat) { const char *c_path = env->GetStringUTFChars(path, NULL); - DBusError err; - dbus_error_init(&err); - DBusMessage *reply = - dbus_func_args_timeout(env, nat->conn, -1, c_path, - "org.bluez.AudioSink", "Disconnect", - DBUS_TYPE_INVALID); - env->ReleaseStringUTFChars(path, c_path); + bool ret = dbus_func_args_async(env, nat->conn, -1, NULL, NULL, nat, + c_path, "org.bluez.AudioSink", "Disconnect", + DBUS_TYPE_INVALID); - if (!reply && dbus_error_is_set(&err)) { - LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, reply); - return JNI_FALSE; - } else if (!reply) { - LOGE("DBus reply is NULL in function %s", __FUNCTION__); - return JNI_FALSE; - } - return JNI_TRUE; + env->ReleaseStringUTFChars(path, c_path); + return ret ? JNI_TRUE : JNI_FALSE; } #endif return JNI_FALSE; |