From ca9366619bfefcadba6235f5637da9d8b8329889 Mon Sep 17 00:00:00 2001 From: Grzegorz Kolodziejczyk Date: Fri, 3 Oct 2014 16:04:02 +0200 Subject: [PATCH] android/hal-map-client: Add skeleton for MAP client HAL This adds skeleton with stubs and proper build system entries. --- android/Android.mk | 5 +- android/Makefile.am | 1 + android/hal-bluetooth.c | 3 ++ android/hal-map-client.c | 93 ++++++++++++++++++++++++++++++++++++ android/hal-msg.h | 3 +- android/hal.h | 2 + android/hardware/bluetooth.h | 1 + 7 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 android/hal-map-client.c diff --git a/android/Android.mk b/android/Android.mk index 3daa26058..f25d60e0d 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -134,7 +134,10 @@ LOCAL_SRC_FILES := \ bluez/android/hal-health.c \ ifeq ($(BLUEZ_EXTENSIONS), true) -LOCAL_SRC_FILES += bluez/android/hal-handsfree-client.c +LOCAL_SRC_FILES += \ + bluez/android/hal-handsfree-client.c \ + bluez/android/hal-map-client.c \ + endif LOCAL_C_INCLUDES += \ diff --git a/android/Makefile.am b/android/Makefile.am index 53bca3325..f11cff6d0 100644 --- a/android/Makefile.am +++ b/android/Makefile.am @@ -67,6 +67,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \ android/hal-handsfree.c \ android/hal-handsfree-client.c \ android/hal-gatt.c \ + android/hal-map-client.c \ android/hardware/bluetooth.h \ android/hardware/bt_av.h \ android/hardware/bt_gatt.h \ diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c index 675427901..97440e291 100644 --- a/android/hal-bluetooth.c +++ b/android/hal-bluetooth.c @@ -854,6 +854,9 @@ static const void *get_profile_interface(const char *profile_id) #if BLUEZ_EXTENSIONS if (!strcmp(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID)) return bt_get_hf_client_interface(); + + if (!strcmp(profile_id, BT_PROFILE_MAP_CLIENT_ID)) + return bt_get_map_client_interface(); #endif return NULL; diff --git a/android/hal-map-client.c b/android/hal-map-client.c new file mode 100644 index 000000000..ac7d0310c --- /dev/null +++ b/android/hal-map-client.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2014 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 + +#include "hal-log.h" +#include "hal.h" +#include "hal-msg.h" +#include "hal-ipc.h" + +static const btmce_callbacks_t *cbs = NULL; + +static bool interface_ready(void) +{ + return cbs != NULL; +} + +/* Event Handlers */ + +static void handle_remote_mas_instances(void *buf, uint16_t len, int fd) +{ + +} + +/* + * handlers will be called from notification thread context, + * index in table equals to 'opcode - HAL_MINIMUM_EVENT' + */ +static const struct hal_ipc_handler ev_handlers[] = { + /* HAL_EV_MCE_REMOTE_MAS_INSTANCES */ + { handle_remote_mas_instances, true, + sizeof(struct hal_ev_map_client_remote_mas_instances) } +}; + +/* API */ + +static bt_status_t get_remote_mas_instances(bt_bdaddr_t *bd_addr) +{ + return BT_STATUS_UNSUPPORTED; +} + +static bt_status_t init(btmce_callbacks_t *callbacks) +{ + struct hal_cmd_register_module cmd; + int ret; + + DBG(""); + + if (interface_ready()) + return BT_STATUS_DONE; + + cbs = callbacks; + + hal_ipc_register(HAL_SERVICE_ID_MAP_CLIENT, ev_handlers, + sizeof(ev_handlers)/sizeof(ev_handlers[0])); + + cmd.service_id = HAL_SERVICE_ID_MAP_CLIENT; + + ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, + sizeof(cmd), &cmd, 0, NULL, NULL); + + if (ret != BT_STATUS_SUCCESS) { + cbs = NULL; + hal_ipc_unregister(HAL_SERVICE_ID_MAP_CLIENT); + } + + return ret; +} + +static btmce_interface_t iface = { + .size = sizeof(iface), + .init = init, + .get_remote_mas_instances = get_remote_mas_instances +}; + +btmce_interface_t *bt_get_map_client_interface(void) +{ + return &iface; +} diff --git a/android/hal-msg.h b/android/hal-msg.h index 94f8e7ced..12efcefad 100644 --- a/android/hal-msg.h +++ b/android/hal-msg.h @@ -36,8 +36,9 @@ static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket"; #define HAL_SERVICE_ID_AVRCP 8 #define HAL_SERVICE_ID_GATT 9 #define HAL_SERVICE_ID_HANDSFREE_CLIENT 10 +#define HAL_SERVICE_ID_MAP_CLIENT 11 -#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_HANDSFREE_CLIENT +#define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_MAP_CLIENT /* Core Service */ diff --git a/android/hal.h b/android/hal.h index c34022d80..9b4195205 100644 --- a/android/hal.h +++ b/android/hal.h @@ -29,6 +29,7 @@ #ifdef BLUEZ_EXTENSIONS #include +#include #endif btsock_interface_t *bt_get_socket_interface(void); @@ -42,6 +43,7 @@ bthl_interface_t *bt_get_health_interface(void); #ifdef BLUEZ_EXTENSIONS bthf_client_interface_t *bt_get_hf_client_interface(void); +btmce_interface_t *bt_get_map_client_interface(void); #endif void bt_thread_associate(void); diff --git a/android/hardware/bluetooth.h b/android/hardware/bluetooth.h index 0d3283bf5..b957c6f14 100644 --- a/android/hardware/bluetooth.h +++ b/android/hardware/bluetooth.h @@ -43,6 +43,7 @@ __BEGIN_DECLS #define BT_PROFILE_SOCKETS_ID "socket" #define BT_PROFILE_HIDHOST_ID "hidhost" #define BT_PROFILE_PAN_ID "pan" +#define BT_PROFILE_MAP_CLIENT_ID "map_client" #define BT_PROFILE_GATT_ID "gatt" #define BT_PROFILE_AV_RC_ID "avrcp" -- 2.47.3