#define LOG_NDDEBUG 0
#define LOG_TAG "bt_btif"
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "btif_debug.h"
#include "btsnoop.h"
#include "btsnoop_mem.h"
+#include "device/include/interop.h"
#include "osi/include/allocation_tracker.h"
+#include "osi/include/alarm.h"
#include "osi/include/log.h"
+#include "osi/include/metrics.h"
#include "osi/include/osi.h"
+#include "osi/include/wakelock.h"
#include "stack_manager.h"
#include "btif_config.h"
-
-/************************************************************************************
-** Constants & Macros
-************************************************************************************/
-
-#define is_profile(profile, str) ((strlen(str) == strlen(profile)) && strncmp((const char *)profile, str, strlen(str)) == 0)
+#include "btif/include/btif_debug_btsnoop.h"
+#include "btif/include/btif_debug_conn.h"
+#include "btif/include/btif_media.h"
/************************************************************************************
** Static variables
bt_callbacks_t *bt_hal_cbacks = NULL;
-/** Operating System specific callouts for resource management */
-bt_os_callouts_t *bt_os_callouts = NULL;
-
/************************************************************************************
** Externs
************************************************************************************/
return bt_hal_cbacks != NULL;
}
+static bool is_profile(const char *p1, const char *p2) {
+ assert(p1);
+ assert(p2);
+ return strlen(p1) == strlen(p2) && strncmp(p1, p2, strlen(p2)) == 0;
+}
+
/*****************************************************************************
**
** BLUETOOTH HAL INTERFACE FUNCTIONS
return btif_dm_create_bond(bd_addr, transport);
}
+static int create_bond_out_of_band(const bt_bdaddr_t *bd_addr, int transport,
+ const bt_out_of_band_data_t *oob_data)
+{
+ /* sanity check */
+ if (interface_ready() == FALSE)
+ return BT_STATUS_NOT_READY;
+
+ return btif_dm_create_bond_out_of_band(bd_addr, transport, oob_data);
+}
+
static int cancel_bond(const bt_bdaddr_t *bd_addr)
{
/* sanity check */
return BT_STATUS_SUCCESS;
}
-static void dump(int fd)
+static void dump(int fd, const char **arguments)
{
- btif_debug_dump(fd);
+ if (arguments != NULL && arguments[0] != NULL) {
+ if (strncmp(arguments[0], "--proto-text", 12) == 0) {
+ btif_update_a2dp_metrics();
+ metrics_print(fd, true);
+ return;
+ }
+ if (strncmp(arguments[0], "--proto-bin", 11) == 0) {
+ btif_update_a2dp_metrics();
+ metrics_write(fd, true);
+ return;
+ }
+ }
+ btif_debug_conn_dump(fd);
+ btif_debug_bond_event_dump(fd);
+ btif_debug_a2dp_dump(fd);
+ btif_debug_config_dump(fd);
+ wakelock_debug_dump(fd);
+ alarm_debug_dump(fd);
+#if defined(BTSNOOP_MEM) && (BTSNOOP_MEM == TRUE)
+ btif_debug_btsnoop_dump(fd);
+#endif
+
+ close(fd);
}
static const void* get_profile_interface (const char *profile_id)
}
static int set_os_callouts(bt_os_callouts_t *callouts) {
- bt_os_callouts = callouts;
+ wakelock_set_os_callouts(callouts);
return BT_STATUS_SUCCESS;
}
static int config_clear(void) {
- LOG_INFO("%s", __func__);
- return btif_config_clear();
+ LOG_INFO(LOG_TAG, "%s", __func__);
+ return btif_config_clear() ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}
static const bt_interface_t bluetoothInterface = {
start_discovery,
cancel_discovery,
create_bond,
+ create_bond_out_of_band,
remove_bond,
cancel_bond,
get_connection_state,
set_os_callouts,
read_energy_info,
dump,
- config_clear
+ config_clear,
+ interop_database_clear,
+ interop_database_add,
};
const bt_interface_t* bluetooth__get_bluetooth_interface ()