OSDN Git Service

android/hal: Add initial support for handling adapter notifications
authorSzymon Janc <szymon.janc@tieto.com>
Tue, 22 Oct 2013 12:46:13 +0000 (14:46 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Tue, 22 Oct 2013 13:17:26 +0000 (16:17 +0300)
Only adapter state callback is handled for now.

android/hal-bluetooth.c
android/hal-ipc.c
android/hal.h

index 6adf0cb..5bad409 100644 (file)
 
 bt_callbacks_t *bt_hal_cbacks = NULL;
 
+static void handle_adapter_state_changed(void *buf)
+{
+       struct hal_msg_ev_bt_adapter_state_changed *ev = buf;
+
+       if (bt_hal_cbacks->adapter_state_changed_cb)
+               bt_hal_cbacks->adapter_state_changed_cb(ev->state);
+}
+
+/* will be called from notification thread context */
+void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len)
+{
+       if (!bt_hal_cbacks)
+               return;
+
+       switch (opcode) {
+       case HAL_MSG_EV_BT_ADAPTER_STATE_CHANGED:
+               handle_adapter_state_changed(buf);
+               break;
+       default:
+               DBG("Unhandled callback opcode=0x%x", opcode);
+               break;
+       }
+}
+
 static bool interface_ready(void)
 {
        return bt_hal_cbacks != NULL;
index f1a9d18..16f2bd3 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <cutils/properties.h>
 
+#include "hal.h"
 #include "hal-msg.h"
 #include "hal-log.h"
 #include "hal-ipc.h"
@@ -44,6 +45,9 @@ static pthread_t notif_th = 0;
 static void notification_dispatch(struct hal_msg_hdr *msg, int fd)
 {
        switch (msg->service_id) {
+       case HAL_SERVICE_ID_BLUETOOTH:
+               bt_notify_adapter(msg->opcode, msg->payload, msg->len);
+               break;
        default:
                DBG("Unhandled notification service=%d opcode=0x%x",
                                                msg->service_id, msg->opcode);
index e3c4122..ef9a107 100644 (file)
@@ -25,3 +25,5 @@ btsock_interface_t *bt_get_sock_interface(void);
 bthh_interface_t *bt_get_hidhost_interface(void);
 btpan_interface_t *bt_get_pan_interface(void);
 btav_interface_t *bt_get_av_interface(void);
+
+void bt_notify_adapter(uint16_t opcode, void *buf, uint16_t len);