summaryrefslogtreecommitdiffstats
path: root/core/jni/android_server_BluetoothService.cpp
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2010-12-10 12:48:58 -0800
committerJaikumar Ganesh <jaikumar@google.com>2010-12-13 11:37:41 -0800
commit84690c88f37f395094147d27ace8319a2803a522 (patch)
treea86fc084ae94b4d841a8101d0cd415f5e0ac2b5c /core/jni/android_server_BluetoothService.cpp
parent7400be47b7644c27151d79f77a10067024c96875 (diff)
downloadframeworks_base-84690c88f37f395094147d27ace8319a2803a522.zip
frameworks_base-84690c88f37f395094147d27ace8319a2803a522.tar.gz
frameworks_base-84690c88f37f395094147d27ace8319a2803a522.tar.bz2
Add direct calls to Bluez to add SDP records.
This helps Settings app to enable just the Headset service. Change-Id: Ia9c39467df1e83d665e377313e16e6c54991f6d6
Diffstat (limited to 'core/jni/android_server_BluetoothService.cpp')
-rw-r--r--core/jni/android_server_BluetoothService.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp
index 848b8f5..cd4d029 100644
--- a/core/jni/android_server_BluetoothService.cpp
+++ b/core/jni/android_server_BluetoothService.cpp
@@ -928,6 +928,79 @@ static jboolean discoverServicesNative(JNIEnv *env, jobject object,
return JNI_FALSE;
}
+static jintArray extract_handles(JNIEnv *env, DBusMessage *reply) {
+#ifdef HAVE_BLUETOOTH
+ jint *handles;
+ jintArray handleArray = NULL;
+ int len;
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ if (dbus_message_get_args(reply, &err,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &handles, &len,
+ DBUS_TYPE_INVALID)) {
+ handleArray = env->NewIntArray(len);
+ if (handleArray) {
+ env->SetIntArrayRegion(handleArray, 0, len, handles);
+ } else {
+ LOGE("Null array in extract_handles");
+ }
+ } else {
+ LOG_AND_FREE_DBUS_ERROR(&err);
+ }
+ return handleArray;
+#endif
+ return NULL;
+}
+
+static jintArray addReservedServiceRecordsNative(JNIEnv *env, jobject object,
+ jintArray uuids) {
+ LOGV(__FUNCTION__);
+#ifdef HAVE_BLUETOOTH
+ DBusMessage *reply = NULL;
+
+ native_data_t *nat = get_native_data(env, object);
+
+ jint* svc_classes = env->GetIntArrayElements(uuids, NULL);
+ if (!svc_classes) return NULL;
+
+ int len = env->GetArrayLength(uuids);
+ reply = dbus_func_args(env, nat->conn,
+ get_adapter_path(env, object),
+ DBUS_ADAPTER_IFACE, "AddReservedServiceRecords",
+ DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
+ &svc_classes, len, DBUS_TYPE_INVALID);
+ env->ReleaseIntArrayElements(uuids, svc_classes, 0);
+ return reply ? extract_handles(env, reply) : NULL;
+
+#endif
+ return NULL;
+}
+
+static jboolean removeReservedServiceRecordsNative(JNIEnv *env, jobject object,
+ jintArray handles) {
+ LOGV(__FUNCTION__);
+#ifdef HAVE_BLUETOOTH
+ native_data_t *nat = get_native_data(env, object);
+ jint *values = env->GetIntArrayElements(handles, NULL);
+ DBusMessage *msg = NULL;
+ DBusMessage *reply = NULL;
+ if (values == NULL) return JNI_FALSE;
+
+ jsize len = env->GetArrayLength(handles);
+
+ reply = dbus_func_args(env, nat->conn,
+ get_adapter_path(env, object),
+ DBUS_ADAPTER_IFACE, "RemoveReservedServiceRecords",
+ DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
+ &values, len, DBUS_TYPE_INVALID);
+ env->ReleaseIntArrayElements(handles, values, NULL);
+ return reply ? JNI_TRUE : JNI_FALSE;
+#endif
+ return JNI_FALSE;
+}
+
static jint addRfcommServiceRecordNative(JNIEnv *env, jobject object,
jstring name, jlong uuidMsb, jlong uuidLsb, jshort channel) {
LOGV(__FUNCTION__);
@@ -1193,6 +1266,8 @@ static JNINativeMethod sMethods[] = {
{"discoverServicesNative", "(Ljava/lang/String;Ljava/lang/String;)Z", (void *)discoverServicesNative},
{"addRfcommServiceRecordNative", "(Ljava/lang/String;JJS)I", (void *)addRfcommServiceRecordNative},
{"removeServiceRecordNative", "(I)Z", (void *)removeServiceRecordNative},
+ {"addReservedServiceRecordsNative", "([I)[I", (void *) addReservedServiceRecordsNative},
+ {"removeReservedServiceRecordsNative", "([I)Z", (void *) removeReservedServiceRecordsNative},
{"setLinkTimeoutNative", "(Ljava/lang/String;I)Z", (void *)setLinkTimeoutNative},
// HID functions
{"connectInputDeviceNative", "(Ljava/lang/String;)Z", (void *)connectInputDeviceNative},