Modulizification of bt_utils
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index 96cd8fb..529f54e 100644
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -617,8 +617,6 @@
btif_dut_mode = 0;
- bt_utils_cleanup();
-
BTIF_TRACE_DEBUG("%s done", __FUNCTION__);
return BT_STATUS_SUCCESS;
diff --git a/btif/src/stack_manager.c b/btif/src/stack_manager.c
index a95ef10..f017b99 100644
--- a/btif/src/stack_manager.c
+++ b/btif/src/stack_manager.c
@@ -32,6 +32,7 @@
// Temp includes
#include "btif_config.h"
+#include "bt_utils.h"
static thread_t *management_thread;
@@ -91,7 +92,7 @@
if (!stack_is_initialized) {
module_management_start();
- bt_utils_init();
+ module_init(get_module(BT_UTILS_MODULE));
module_init(get_module(BTIF_CONFIG_MODULE));
btif_init_bluetooth();
@@ -179,6 +180,7 @@
btif_shutdown_bluetooth();
module_clean_up(get_module(BTIF_CONFIG_MODULE));
+ module_clean_up(get_module(BT_UTILS_MODULE));
future_await(hack_future);
module_management_stop();
diff --git a/utils/Android.mk b/utils/Android.mk
index fb337bb..4bbeaea 100644
--- a/utils/Android.mk
+++ b/utils/Android.mk
@@ -4,7 +4,9 @@
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
+ $(LOCAL_PATH)/../btcore/include \
$(LOCAL_PATH)/../gki/ulinux \
+ $(LOCAL_PATH)/../osi/include \
$(bdroid_C_INCLUDES)
LOCAL_CFLAGS += $(bdroid_CFLAGS) -std=c99
diff --git a/utils/include/bt_utils.h b/utils/include/bt_utils.h
index f2bd2ed..7c112ce 100644
--- a/utils/include/bt_utils.h
+++ b/utils/include/bt_utils.h
@@ -38,8 +38,7 @@
** Functions
********************************************************************************/
-void bt_utils_init();
-void bt_utils_cleanup();
+#define BT_UTILS_MODULE "bt_utils_module"
void raise_priority_a2dp(tHIGH_PRIORITY_TASK high_task);
void adjust_priority_a2dp(int start);
#define UNUSED(x) (void)(x)
diff --git a/utils/src/bt_utils.c b/utils/src/bt_utils.c
index ab618b0..cf9fab7 100644
--- a/utils/src/bt_utils.c
+++ b/utils/src/bt_utils.c
@@ -41,7 +41,7 @@
#include "data_types.h"
#include "bt_utils.h"
-
+#include "module.h"
/*******************************************************************************
** Type definitions for callback functions
@@ -53,41 +53,38 @@
static int g_TaskIDs[TASK_HIGH_MAX];
#define INVALID_TASK_ID (-1)
-/*****************************************************************************
-**
-** Function bt_utils_init
-**
-** Description Initialize bluedroid util
-**
-** Returns void
-**
-*******************************************************************************/
-void bt_utils_init() {
- int i;
- pthread_mutexattr_t lock_attr;
+static future_t *init(void) {
+ int i;
+ pthread_mutexattr_t lock_attr;
- for(i = 0; i < TASK_HIGH_MAX; i++) {
- g_DoSchedulingGroupOnce[i] = PTHREAD_ONCE_INIT;
- g_DoSchedulingGroup[i] = TRUE;
- g_TaskIDs[i] = INVALID_TASK_ID;
- }
- pthread_mutexattr_init(&lock_attr);
- pthread_mutex_init(&gIdxLock, &lock_attr);
+ for(i = 0; i < TASK_HIGH_MAX; i++) {
+ g_DoSchedulingGroupOnce[i] = PTHREAD_ONCE_INIT;
+ g_DoSchedulingGroup[i] = TRUE;
+ g_TaskIDs[i] = INVALID_TASK_ID;
+ }
+
+ pthread_mutexattr_init(&lock_attr);
+ pthread_mutex_init(&gIdxLock, &lock_attr);
+ return NULL;
}
-/*****************************************************************************
-**
-** Function bt_utils_cleanup
-**
-** Description Clean up bluedroid util
-**
-** Returns void
-**
-*******************************************************************************/
-void bt_utils_cleanup() {
- pthread_mutex_destroy(&gIdxLock);
+static future_t *clean_up(void) {
+ pthread_mutex_destroy(&gIdxLock);
+ return NULL;
}
+const module_t bt_utils_module = {
+ .name = BT_UTILS_MODULE,
+ .init = init,
+ .start_up = NULL,
+ .shut_down = NULL,
+ .clean_up = clean_up,
+ .dependencies = {
+ NULL
+ }
+};
+
+
/*****************************************************************************
**
** Function check_do_scheduling_group