diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2009-07-16 18:26:28 -0700 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2009-07-17 14:00:32 -0700 |
commit | 228b2f3a813e93413a0f9e2f29dfbfc54590a356 (patch) | |
tree | 9912bf96f82aef0fba304b25e3a25ec85cd324e1 /core/jni/android_server_BluetoothEventLoop.cpp | |
parent | 0fde7de9d660e4acdb8404f954f75d8c331b5d45 (diff) | |
download | frameworks_base-228b2f3a813e93413a0f9e2f29dfbfc54590a356.zip frameworks_base-228b2f3a813e93413a0f9e2f29dfbfc54590a356.tar.gz frameworks_base-228b2f3a813e93413a0f9e2f29dfbfc54590a356.tar.bz2 |
Initial support of 2.1 pairing.
Note: Some cases have not been tested yet, as we would need to
get proper UI support.
Diffstat (limited to 'core/jni/android_server_BluetoothEventLoop.cpp')
-rw-r--r-- | core/jni/android_server_BluetoothEventLoop.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp index 0857cb3..4a13e80 100644 --- a/core/jni/android_server_BluetoothEventLoop.cpp +++ b/core/jni/android_server_BluetoothEventLoop.cpp @@ -50,6 +50,8 @@ static jmethodID method_onCreatePairedDeviceResult; static jmethodID method_onGetDeviceServiceChannelResult; static jmethodID method_onRequestPinCode; +static jmethodID method_onRequestPasskey; +static jmethodID method_onRequestConfirmation; static jmethodID method_onAgentAuthorize; static jmethodID method_onAgentCancel; @@ -89,6 +91,10 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_onAgentCancel = env->GetMethodID(clazz, "onAgentCancel", "()V"); method_onRequestPinCode = env->GetMethodID(clazz, "onRequestPinCode", "(Ljava/lang/String;I)V"); + method_onRequestPasskey = env->GetMethodID(clazz, "onRequestPasskey", + "(Ljava/lang/String;I)V"); + method_onRequestConfirmation = env->GetMethodID(clazz, "onRequestConfirmation", + "(Ljava/lang/String;II)V"); field_mNativeData = env->GetFieldID(clazz, "mNativeData", "I"); #endif @@ -872,6 +878,38 @@ DBusHandlerResult agent_event_filter(DBusConnection *conn, int(msg)); return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_method_call(msg, + "org.bluez.Agent", "RequestPasskey")) { + char *object_path; + if (!dbus_message_get_args(msg, NULL, + DBUS_TYPE_OBJECT_PATH, &object_path, + DBUS_TYPE_INVALID)) { + LOGE("%s: Invalid arguments for RequestPasskey() method", __FUNCTION__); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + dbus_message_ref(msg); // increment refcount because we pass to java + env->CallVoidMethod(nat->me, method_onRequestPasskey, + env->NewStringUTF(object_path), + int(msg)); + } else if (dbus_message_is_method_call(msg, + "org.bluez.Agent", "RequestConfirmation")) { + char *object_path; + uint32_t passkey; + if (!dbus_message_get_args(msg, NULL, + DBUS_TYPE_OBJECT_PATH, &object_path, + DBUS_TYPE_UINT32, &passkey, + DBUS_TYPE_INVALID)) { + LOGE("%s: Invalid arguments for RequestConfirmation() method", __FUNCTION__); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + dbus_message_ref(msg); // increment refcount because we pass to java + env->CallVoidMethod(nat->me, method_onRequestConfirmation, + env->NewStringUTF(object_path), + passkey, + int(msg)); + return DBUS_HANDLER_RESULT_HANDLED; + } else if (dbus_message_is_method_call(msg, "org.bluez.Agent", "Release")) { // reply DBusMessage *reply = dbus_message_new_method_return(msg); |