Merge "Make setting the adapter properties asynchronous."
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index f47c553..ec6ca7d 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -309,6 +309,8 @@
             // Note: bluez only sends this property change when it restarts.
             if (propValues[1].equals("true"))
                 onRestartRequired();
+        } else if (name.equals("DiscoverableTimeout")) {
+            mBluetoothService.setProperty(name, propValues[1]);
         }
     }
 
diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp
index 337dccc..848b8f5 100644
--- a/core/jni/android_server_BluetoothService.cpp
+++ b/core/jni/android_server_BluetoothService.cpp
@@ -744,11 +744,10 @@
     LOGV(__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);
-        dbus_error_init(&err);
 
         msg = dbus_message_new_method_call(BLUEZ_DBUS_BASE_IFC,
                                            get_adapter_path(env, object),
@@ -764,19 +763,13 @@
         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 propertyChange
+        reply = dbus_connection_send_with_reply(nat->conn, msg, NULL, -1);
         dbus_message_unref(msg);
 
         env->ReleaseStringUTFChars(key, c_key);
+        return reply ? JNI_TRUE : JNI_FALSE;
 
-        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;
     }
 #endif
     return JNI_FALSE;