Diff between 81f69b15ca4b027a177875ef51d0105831f0200e and 537d14b68d34b84105c4ae9199b94fa9300c2528

Changed Files

File Additions Deletions Status
Makefile.android +4 -1 modified
android/Android.mk +1 -0 modified
android/hal-bluetooth.c +4 -0 modified
android/hal-hidhost.c +207 -0 added
android/hal.h +4 -0 modified

Full Patch

diff --git a/Makefile.android b/Makefile.android
index a9f0d11..33a8a0e 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -16,6 +16,7 @@ noinst_LTLIBRARIES += android/libhal-internal.la
 
 android_libhal_internal_la_SOURCES = android/hal.h android/hal-bluetooth.c \
 					android/hal-sock.c \
+					android/hal-hidhost.c \
 					android/hardware/bluetooth.h \
 					android/hardware/bt_av.h \
 					android/hardware/bt_gatt.h \
@@ -53,7 +54,9 @@ EXTRA_DIST += android/Android.mk android/log.c android/device.c \
 		android/adapter.c android/main.c android/hal-msg.h \
 		android/hal.h
 
-EXTRA_DIST += android/hal-sock.c android/hal-bluetooth.c
+EXTRA_DIST += android/hal-bluetooth.c \
+		android/hal-sock.c \
+		android/hal-hidhost.c
 
 EXTRA_DIST += android/client/terminal.c \
 		android/client/haltest.c \
diff --git a/android/Android.mk b/android/Android.mk
index 53e328b..2ba73a5 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -53,6 +53,7 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES := \
 	hal-bluetooth.c \
 	hal-sock.c \
+	hal-hidhost.c \
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index b909bf9..9e5a84b 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -22,6 +22,7 @@
 
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
+#include <hardware/bt_hh.h>
 
 #include <cutils/properties.h>
 
@@ -284,6 +285,9 @@ static const void *get_profile_interface(const char *profile_id)
 	if (!strcmp(profile_id, BT_PROFILE_SOCKETS_ID))
 		return bt_get_sock_interface();
 
+	if (!strcmp(profile_id, BT_PROFILE_HIDHOST_ID))
+		return bt_get_hidhost_interface();
+
 	return NULL;
 }
 
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
new file mode 100644
index 0000000..7436864
--- /dev/null
+++ b/android/hal-hidhost.c
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hh.h>
+
+#define LOG_TAG "BlueZ"
+#include <cutils/log.h>
+
+#include "hal.h"
+
+bthh_callbacks_t *bt_hh_cbacks;
+
+static bool interface_ready(void)
+{
+	return bt_hh_cbacks != NULL;
+}
+
+static bt_status_t bt_hidhost_connect(bt_bdaddr_t *bd_addr)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_disconnect(bt_bdaddr_t *bd_addr)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_virtual_unplug(bt_bdaddr_t *bd_addr)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_set_info(bt_bdaddr_t *bd_addr,
+						bthh_hid_info_t hid_info)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_get_protocol(bt_bdaddr_t *bd_addr,
+					bthh_protocol_mode_t protocolMode)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_set_protocol(bt_bdaddr_t *bd_addr,
+					bthh_protocol_mode_t protocolMode)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_get_report(bt_bdaddr_t *bd_addr,
+						bthh_report_type_t reportType,
+						uint8_t reportId,
+						int bufferSize)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_set_report(bt_bdaddr_t *bd_addr,
+						bthh_report_type_t reportType,
+						char *report)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr || !report)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_send_data(bt_bdaddr_t *bd_addr, char *data)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return BT_STATUS_NOT_READY;
+
+	if (!bd_addr || !data)
+		return BT_STATUS_PARM_INVALID;
+
+	return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_init(bthh_callbacks_t *callbacks)
+{
+	ALOGI(__func__);
+
+	/* store reference to user callbacks */
+	bt_hh_cbacks = callbacks;
+
+	/* TODO: start HID Host thread */
+
+	/* TODO: enable service */
+
+	return BT_STATUS_SUCCESS;
+}
+
+static void bt_hidhost_cleanup(void)
+{
+	ALOGD(__func__);
+
+	if (!interface_ready())
+		return;
+
+	/* TODO: disable service */
+
+	/* TODO: stop HID Host thread */
+
+	bt_hh_cbacks = NULL;
+}
+
+static bthh_interface_t bt_hidhost_if = {
+	.size = sizeof(bt_hidhost_if),
+	.init = bt_hidhost_init,
+	.connect = bt_hidhost_connect,
+	.disconnect = bt_hidhost_disconnect,
+	.virtual_unplug = bt_hidhost_virtual_unplug,
+	.set_info = bt_hidhost_set_info,
+	.get_protocol = bt_hidhost_get_protocol,
+	.set_protocol = bt_hidhost_set_protocol,
+	.get_report = bt_hidhost_get_report,
+	.set_report = bt_hidhost_set_report,
+	.send_data = bt_hidhost_send_data,
+	.cleanup = bt_hidhost_cleanup
+};
+
+bthh_interface_t *bt_get_hidhost_interface(void)
+{
+	return &bt_hidhost_if;
+}
diff --git a/android/hal.h b/android/hal.h
index 40fbf03..68f75b7 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -15,4 +15,8 @@
  *
  */
 
+#include <hardware/bt_sock.h>
+#include <hardware/bt_hh.h>
+
 btsock_interface_t *bt_get_sock_interface(void);
+bthh_interface_t *bt_get_hidhost_interface(void);