Loading system/stack/Android.mk +2 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ LOCAL_PATH:= $(call my-dir) # Bluetooth stack static library for target # ======================================================== include $(CLEAR_VARS) LOCAL_CPP_EXTENSION := .cc LOCAL_C_INCLUDES:= \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/avct \ Loading Loading @@ -57,7 +57,7 @@ LOCAL_SRC_FILES:= \ ./btm/btm_sec.c \ ./btm/btm_inq.c \ ./btm/btm_ble_addr.c \ ./btm/btm_ble_bgconn.c \ ./btm/btm_ble_bgconn.cc \ ./btm/btm_main.c \ ./btm/btm_dev.c \ ./btm/btm_ble_gap.c \ Loading system/stack/BUILD.gn +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ static_library("stack") { "btm/btm_sec.c", "btm/btm_inq.c", "btm/btm_ble_addr.c", "btm/btm_ble_bgconn.c", "btm/btm_ble_bgconn.cc", "btm/btm_main.c", "btm/btm_dev.c", "btm/btm_ble_gap.c", Loading system/stack/btm/btm_ble_bgconn.c→system/stack/btm/btm_ble_bgconn.cc +26 −39 Original line number Diff line number Diff line Loading @@ -24,10 +24,10 @@ #include <assert.h> #include <string.h> #include <unordered_map> #include "device/include/controller.h" #include "osi/include/allocator.h" #include "osi/include/hash_map.h" #include "bt_types.h" #include "btu.h" #include "btm_int.h" Loading @@ -49,63 +49,50 @@ static void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state); // controls whether the host should keep trying to scan for whitelisted // peripherals or not. // TODO: Move all of this to controller/le/background_list or similar? static const size_t background_connection_buckets = 42; static hash_map_t *background_connections = NULL; typedef struct background_connection_t { bt_bdaddr_t address; } background_connection_t; static bool bdaddr_equality_fn(const void *x, const void *y) { return bdaddr_equals((bt_bdaddr_t *)x, (bt_bdaddr_t *)y); } static void background_connections_lazy_init() struct KeyEqual { bool operator()(const bt_bdaddr_t *x, const bt_bdaddr_t *y) const { if (!background_connections) { background_connections = hash_map_new(background_connection_buckets, hash_function_bdaddr, NULL, osi_free, bdaddr_equality_fn); assert(background_connections); } return bdaddr_equals(x, y); } }; static std::unordered_map<bt_bdaddr_t *, background_connection_t *, std::hash<bt_bdaddr_t *>, KeyEqual> background_connections; static void background_connection_add(bt_bdaddr_t *address) { assert(address); background_connections_lazy_init(); background_connection_t *connection = hash_map_get(background_connections, address); if (!connection) { connection = osi_calloc(sizeof(background_connection_t)); auto map_iter = background_connections.find(address); if (map_iter == background_connections.end()) { background_connection_t *connection = (background_connection_t *)osi_calloc(sizeof(background_connection_t)); connection->address = *address; hash_map_set(background_connections, &(connection->address), connection); background_connections[&(connection->address)] = connection; } } static void background_connection_remove(bt_bdaddr_t *address) { if (address && background_connections) hash_map_erase(background_connections, address); background_connections.erase(address); } static void background_connections_clear() { if (background_connections) hash_map_clear(background_connections); background_connections.clear(); } static bool background_connections_pending_cb(hash_map_entry_t *hash_entry, void *context) { bool *pending_connections = context; background_connection_t *connection = hash_entry->data; static bool background_connections_pending() { for (const auto &map_el : background_connections) { background_connection_t *connection = map_el.second; const bool connected = BTM_IsAclConnectionUp(connection->address.address, BT_TRANSPORT_LE); if (!connected) { *pending_connections = true; return false; } return true; } static bool background_connections_pending() { bool pending_connections = false; if (background_connections) hash_map_foreach(background_connections, background_connections_pending_cb, &pending_connections); return pending_connections; } return false; } /******************************************************************************* Loading system/stack/include/hcimsgs.h +8 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ #include "hcidefs.h" #include "bt_types.h" #ifdef __cplusplus extern "C" { #endif void bte_main_hci_send(BT_HDR *p_msg, UINT16 event); void bte_main_lpm_allow_bt_device_sleep(void); Loading Loading @@ -808,4 +812,8 @@ extern BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle, #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0 #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2 #ifdef __cplusplus } #endif #endif Loading
system/stack/Android.mk +2 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ LOCAL_PATH:= $(call my-dir) # Bluetooth stack static library for target # ======================================================== include $(CLEAR_VARS) LOCAL_CPP_EXTENSION := .cc LOCAL_C_INCLUDES:= \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/avct \ Loading Loading @@ -57,7 +57,7 @@ LOCAL_SRC_FILES:= \ ./btm/btm_sec.c \ ./btm/btm_inq.c \ ./btm/btm_ble_addr.c \ ./btm/btm_ble_bgconn.c \ ./btm/btm_ble_bgconn.cc \ ./btm/btm_main.c \ ./btm/btm_dev.c \ ./btm/btm_ble_gap.c \ Loading
system/stack/BUILD.gn +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ static_library("stack") { "btm/btm_sec.c", "btm/btm_inq.c", "btm/btm_ble_addr.c", "btm/btm_ble_bgconn.c", "btm/btm_ble_bgconn.cc", "btm/btm_main.c", "btm/btm_dev.c", "btm/btm_ble_gap.c", Loading
system/stack/btm/btm_ble_bgconn.c→system/stack/btm/btm_ble_bgconn.cc +26 −39 Original line number Diff line number Diff line Loading @@ -24,10 +24,10 @@ #include <assert.h> #include <string.h> #include <unordered_map> #include "device/include/controller.h" #include "osi/include/allocator.h" #include "osi/include/hash_map.h" #include "bt_types.h" #include "btu.h" #include "btm_int.h" Loading @@ -49,63 +49,50 @@ static void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state); // controls whether the host should keep trying to scan for whitelisted // peripherals or not. // TODO: Move all of this to controller/le/background_list or similar? static const size_t background_connection_buckets = 42; static hash_map_t *background_connections = NULL; typedef struct background_connection_t { bt_bdaddr_t address; } background_connection_t; static bool bdaddr_equality_fn(const void *x, const void *y) { return bdaddr_equals((bt_bdaddr_t *)x, (bt_bdaddr_t *)y); } static void background_connections_lazy_init() struct KeyEqual { bool operator()(const bt_bdaddr_t *x, const bt_bdaddr_t *y) const { if (!background_connections) { background_connections = hash_map_new(background_connection_buckets, hash_function_bdaddr, NULL, osi_free, bdaddr_equality_fn); assert(background_connections); } return bdaddr_equals(x, y); } }; static std::unordered_map<bt_bdaddr_t *, background_connection_t *, std::hash<bt_bdaddr_t *>, KeyEqual> background_connections; static void background_connection_add(bt_bdaddr_t *address) { assert(address); background_connections_lazy_init(); background_connection_t *connection = hash_map_get(background_connections, address); if (!connection) { connection = osi_calloc(sizeof(background_connection_t)); auto map_iter = background_connections.find(address); if (map_iter == background_connections.end()) { background_connection_t *connection = (background_connection_t *)osi_calloc(sizeof(background_connection_t)); connection->address = *address; hash_map_set(background_connections, &(connection->address), connection); background_connections[&(connection->address)] = connection; } } static void background_connection_remove(bt_bdaddr_t *address) { if (address && background_connections) hash_map_erase(background_connections, address); background_connections.erase(address); } static void background_connections_clear() { if (background_connections) hash_map_clear(background_connections); background_connections.clear(); } static bool background_connections_pending_cb(hash_map_entry_t *hash_entry, void *context) { bool *pending_connections = context; background_connection_t *connection = hash_entry->data; static bool background_connections_pending() { for (const auto &map_el : background_connections) { background_connection_t *connection = map_el.second; const bool connected = BTM_IsAclConnectionUp(connection->address.address, BT_TRANSPORT_LE); if (!connected) { *pending_connections = true; return false; } return true; } static bool background_connections_pending() { bool pending_connections = false; if (background_connections) hash_map_foreach(background_connections, background_connections_pending_cb, &pending_connections); return pending_connections; } return false; } /******************************************************************************* Loading
system/stack/include/hcimsgs.h +8 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ #include "hcidefs.h" #include "bt_types.h" #ifdef __cplusplus extern "C" { #endif void bte_main_hci_send(BT_HDR *p_msg, UINT16 event); void bte_main_lpm_allow_bt_device_sleep(void); Loading Loading @@ -808,4 +812,8 @@ extern BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle, #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0 #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2 #ifdef __cplusplus } #endif #endif