summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2009-12-16 16:31:25 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2009-12-16 16:31:25 -0800
commitef3308790a1a1765f551ef7ac65c62a7d36c367e (patch)
tree4e345426e25a32668b4054c555edef9c52e8d94f /core/jni
parentf432b6db33d141b60e5894d27174334fd77dfa91 (diff)
parent57043a675f8826099e619c5d325fc7670be83e0b (diff)
downloadframeworks_base-ef3308790a1a1765f551ef7ac65c62a7d36c367e.zip
frameworks_base-ef3308790a1a1765f551ef7ac65c62a7d36c367e.tar.gz
frameworks_base-ef3308790a1a1765f551ef7ac65c62a7d36c367e.tar.bz2
am 57043a67: am 43ad522d: Merge change Ic0e32f12 into eclair-mr2
Merge commit '57043a675f8826099e619c5d325fc7670be83e0b' * commit '57043a675f8826099e619c5d325fc7670be83e0b': Add a callback for the ConnectSink Call.
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_server_BluetoothA2dpService.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/core/jni/android_server_BluetoothA2dpService.cpp b/core/jni/android_server_BluetoothA2dpService.cpp
index 7a3bbbb..4eab4b3 100644
--- a/core/jni/android_server_BluetoothA2dpService.cpp
+++ b/core/jni/android_server_BluetoothA2dpService.cpp
@@ -38,6 +38,7 @@ namespace android {
#ifdef HAVE_BLUETOOTH
static jmethodID method_onSinkPropertyChanged;
+static jmethodID method_onConnectSinkResult;
typedef struct {
JavaVM *vm;
@@ -47,6 +48,7 @@ typedef struct {
} native_data_t;
static native_data_t *nat = NULL; // global native data
+static void onConnectSinkResult(DBusMessage *msg, void *user, void *n);
static Properties sink_properties[] = {
{"State", DBUS_TYPE_STRING},
@@ -133,9 +135,12 @@ static jboolean connectSinkNative(JNIEnv *env, jobject object, jstring path) {
LOGV(__FUNCTION__);
if (nat) {
const char *c_path = env->GetStringUTFChars(path, NULL);
+ int len = env->GetStringLength(path) + 1;
+ char *context_path = (char *)calloc(len, sizeof(char));
+ strlcpy(context_path, c_path, len); // for callback
- bool ret = dbus_func_args_async(env, nat->conn, -1, NULL, NULL, nat,
- c_path, "org.bluez.AudioSink", "Connect",
+ bool ret = dbus_func_args_async(env, nat->conn, -1, onConnectSinkResult, context_path,
+ nat, c_path, "org.bluez.AudioSink", "Connect",
DBUS_TYPE_INVALID);
env->ReleaseStringUTFChars(path, c_path);
@@ -237,6 +242,31 @@ DBusHandlerResult a2dp_event_filter(DBusMessage *msg, JNIEnv *env) {
return result;
}
+
+void onConnectSinkResult(DBusMessage *msg, void *user, void *n) {
+ LOGV(__FUNCTION__);
+
+ native_data_t *nat = (native_data_t *)n;
+ const char *path = (const char *)user;
+ DBusError err;
+ dbus_error_init(&err);
+ JNIEnv *env;
+ nat->vm->GetEnv((void**)&env, nat->envVer);
+
+
+ bool result = JNI_TRUE;
+ if (dbus_set_error_from_message(&err, msg)) {
+ LOG_AND_FREE_DBUS_ERROR(&err);
+ result = JNI_FALSE;
+ }
+ LOGV("... Device Path = %s, result = %d", path, result);
+ env->CallVoidMethod(nat->me,
+ method_onConnectSinkResult,
+ env->NewStringUTF(path),
+ result);
+ free(user);
+}
+
#endif
@@ -244,7 +274,7 @@ static JNINativeMethod sMethods[] = {
{"initNative", "()Z", (void *)initNative},
{"cleanupNative", "()V", (void *)cleanupNative},
- /* Bluez audio 4.40 API */
+ /* Bluez audio 4.47 API */
{"connectSinkNative", "(Ljava/lang/String;)Z", (void *)connectSinkNative},
{"disconnectSinkNative", "(Ljava/lang/String;)Z", (void *)disconnectSinkNative},
{"suspendSinkNative", "(Ljava/lang/String;)Z", (void*)suspendSinkNative},
@@ -263,6 +293,8 @@ int register_android_server_BluetoothA2dpService(JNIEnv *env) {
#ifdef HAVE_BLUETOOTH
method_onSinkPropertyChanged = env->GetMethodID(clazz, "onSinkPropertyChanged",
"(Ljava/lang/String;[Ljava/lang/String;)V");
+ method_onConnectSinkResult = env->GetMethodID(clazz, "onConnectSinkResult",
+ "(Ljava/lang/String;Z)V");
#endif
return AndroidRuntime::registerNativeMethods(env,