Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cfc7f1aa authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 25382 into eclair

* changes:
  Fix async calls with Connect And Disconnect Sink.
parents 2f20df19 4f3ebc43
Loading
Loading
Loading
Loading
+10 −30
Original line number Original line Diff line number Diff line
@@ -133,23 +133,13 @@ static jboolean connectSinkNative(JNIEnv *env, jobject object, jstring path) {
    LOGV(__FUNCTION__);
    LOGV(__FUNCTION__);
    if (nat) {
    if (nat) {
        const char *c_path = env->GetStringUTFChars(path, NULL);
        const char *c_path = env->GetStringUTFChars(path, NULL);
        DBusError err;
        dbus_error_init(&err);


        DBusMessage *reply =
        bool ret = dbus_func_args_async(env, nat->conn, -1, NULL, NULL, nat,
                dbus_func_args_timeout(env, nat->conn, -1, c_path,
                                    c_path, "org.bluez.AudioSink", "Connect",
                               "org.bluez.AudioSink", "Connect",
                                    DBUS_TYPE_INVALID);
                                    DBUS_TYPE_INVALID);
        env->ReleaseStringUTFChars(path, c_path);


        if (!reply && dbus_error_is_set(&err)) {
        env->ReleaseStringUTFChars(path, c_path);
            LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, reply);
        return ret ? JNI_TRUE : JNI_FALSE;
            return JNI_FALSE;
        } else if (!reply) {
            LOGE("DBus reply is NULL in function %s", __FUNCTION__);
            return JNI_FALSE;
        }
        return JNI_TRUE;
    }
    }
#endif
#endif
    return JNI_FALSE;
    return JNI_FALSE;
@@ -161,23 +151,13 @@ static jboolean disconnectSinkNative(JNIEnv *env, jobject object,
    LOGV(__FUNCTION__);
    LOGV(__FUNCTION__);
    if (nat) {
    if (nat) {
        const char *c_path = env->GetStringUTFChars(path, NULL);
        const char *c_path = env->GetStringUTFChars(path, NULL);
        DBusError err;
        dbus_error_init(&err);


        DBusMessage *reply =
        bool ret = dbus_func_args_async(env, nat->conn, -1, NULL, NULL, nat,
              dbus_func_args_timeout(env, nat->conn, -1, c_path,
                                    c_path, "org.bluez.AudioSink", "Disconnect",
                                     "org.bluez.AudioSink", "Disconnect",
                                    DBUS_TYPE_INVALID);
                                    DBUS_TYPE_INVALID);
        env->ReleaseStringUTFChars(path, c_path);


        if (!reply && dbus_error_is_set(&err)) {
        env->ReleaseStringUTFChars(path, c_path);
            LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, reply);
        return ret ? JNI_TRUE : JNI_FALSE;
            return JNI_FALSE;
        } else if (!reply) {
            LOGE("DBus reply is NULL in function %s", __FUNCTION__);
            return JNI_FALSE;
        }
        return JNI_TRUE;
    }
    }
#endif
#endif
    return JNI_FALSE;
    return JNI_FALSE;