Loading system/bta/gatt/bta_gattc_int.h +55 −13 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ typedef uint16_t tBTA_GATTC_INT_EVT; #define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE typedef enum : uint8_t { BTA_GATTC_SERV_IDLE = 0, BTA_GATTC_SERV_LOAD, BTA_GATTC_SERV_SAVE, BTA_GATTC_SERV_DISC, BTA_GATTC_SERV_DISC_ACT } tBTA_GATTC_SERV_STATE; /* internal strucutre for GATTC register API */ typedef struct { BT_HDR_RIGID hdr; Loading Loading @@ -211,26 +219,19 @@ typedef union { tBTA_GATTC_INT_CONN int_conn; } tBTA_GATTC_DATA; enum { typedef enum : uint8_t { BTA_GATTC_IDLE_ST = 0, /* Idle */ BTA_GATTC_W4_CONN_ST, /* Wait for connection - (optional) */ BTA_GATTC_CONN_ST, /* connected state */ BTA_GATTC_DISCOVER_ST /* discover is in progress */ }; typedef uint8_t tBTA_GATTC_STATE; } tBTA_GATTC_STATE; typedef struct { bool in_use; RawAddress server_bda; bool connected; #define BTA_GATTC_SERV_IDLE 0 #define BTA_GATTC_SERV_LOAD 1 #define BTA_GATTC_SERV_SAVE 2 #define BTA_GATTC_SERV_DISC 3 #define BTA_GATTC_SERV_DISC_ACT 4 uint8_t state; tBTA_GATTC_SERV_STATE state; gatt::Database gatt_database; uint8_t update_count; /* indication received */ Loading Loading @@ -325,15 +326,15 @@ typedef struct { RawAddress remote_bda; } tBTA_GATTC_CONN; enum { typedef enum : uint8_t { BTA_GATTC_STATE_DISABLED, BTA_GATTC_STATE_ENABLING, BTA_GATTC_STATE_ENABLED, BTA_GATTC_STATE_DISABLING }; } tBTA_GATTC_CB_STATE; typedef struct { uint8_t state; tBTA_GATTC_CB_STATE state; tBTA_GATTC_CONN conn_track[GATT_MAX_PHY_CHANNEL]; tBTA_GATTC_BG_TCK bg_track[BTA_GATTC_KNOWN_SR_MAX]; Loading Loading @@ -523,8 +524,49 @@ void bta_gattc_cache_write(const RawAddress& server_bda, void bta_gattc_cache_link(const RawAddress& server_bda, const Octet16& hash); void bta_gattc_cache_reset(const RawAddress& server_bda); inline std::string bta_clcb_state_text(const tBTA_GATTC_STATE& state) { switch (state) { CASE_RETURN_TEXT(BTA_GATTC_IDLE_ST); CASE_RETURN_TEXT(BTA_GATTC_W4_CONN_ST); CASE_RETURN_TEXT(BTA_GATTC_CONN_ST); CASE_RETURN_TEXT(BTA_GATTC_DISCOVER_ST); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } } inline std::string bta_server_state_text(const tBTA_GATTC_SERV_STATE& state) { switch (state) { CASE_RETURN_TEXT(BTA_GATTC_SERV_IDLE); CASE_RETURN_TEXT(BTA_GATTC_SERV_LOAD); CASE_RETURN_TEXT(BTA_GATTC_SERV_SAVE); CASE_RETURN_TEXT(BTA_GATTC_SERV_DISC); CASE_RETURN_TEXT(BTA_GATTC_SERV_DISC_ACT); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } } inline std::string bta_gattc_state_text(const tBTA_GATTC_CB_STATE& state) { switch (state) { CASE_RETURN_TEXT(BTA_GATTC_STATE_DISABLED); CASE_RETURN_TEXT(BTA_GATTC_STATE_ENABLING); CASE_RETURN_TEXT(BTA_GATTC_STATE_ENABLED); CASE_RETURN_TEXT(BTA_GATTC_STATE_DISABLING); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } } namespace fmt { template <> struct formatter<tBTA_GATTC_CB_STATE> : enum_formatter<tBTA_GATTC_CB_STATE> {}; template <> struct formatter<tBTA_GATTC_SERV_STATE> : enum_formatter<tBTA_GATTC_SERV_STATE> {}; template <> struct formatter<tBTA_GATTC_STATE> : enum_formatter<tBTA_GATTC_STATE> {}; template <> struct formatter<RobustCachingSupport> : enum_formatter<RobustCachingSupport> { }; } // namespace fmt Loading system/bta/gatt/bta_gattc_main.cc +1 −1 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ bool bta_gattc_sm_execute(tBTA_GATTC_CLCB* p_clcb, uint16_t event, event &= 0x00FF; /* set next state */ p_clcb->state = state_table[event][BTA_GATTC_NEXT_STATE]; p_clcb->state = (tBTA_GATTC_STATE)(state_table[event][BTA_GATTC_NEXT_STATE]); /* execute action functions */ for (i = 0; i < BTA_GATTC_ACTIONS; i++) { Loading system/bta/gatt/bta_gattc_utils.cc +99 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "common/init_flags.h" #include "device/include/controller.h" #include "internal_include/bt_target.h" #include "internal_include/bt_trace.h" #include "os/log.h" #include "osi/include/allocator.h" #include "types/bt_transport.h" Loading Loading @@ -813,3 +814,101 @@ tBTA_GATTC_CLCB* bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA* p_msg) { bool bta_gattc_is_robust_caching_enabled() { return bluetooth::common::init_flags::gatt_robust_caching_client_is_enabled(); } void bta_gatt_client_dump(int fd) { std::stringstream stream; int entry_count = 0; stream << " ->conn_track (GATT_MAX_PHY_CHANNEL=" << GATT_MAX_PHY_CHANNEL << ")\n"; for (int i = 0; i < GATT_MAX_PHY_CHANNEL; i++) { tBTA_GATTC_CONN* p_conn_track = &bta_gattc_cb.conn_track[i]; if (p_conn_track->in_use) { entry_count++; stream << " address: " << ADDRESS_TO_LOGGABLE_STR(p_conn_track->remote_bda); stream << "\n"; } } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->bg_track (BTA_GATTC_KNOWN_SR_MAX=" << BTA_GATTC_KNOWN_SR_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i++) { tBTA_GATTC_BG_TCK* p_bg_track = &bta_gattc_cb.bg_track[i]; if (!p_bg_track->in_use) { continue; } entry_count++; stream << " address: " << ADDRESS_TO_LOGGABLE_STR(p_bg_track->remote_bda) << " cif_mask: " << loghex(p_bg_track->cif_mask); stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->cl_rcb (BTA_GATTC_CL_MAX=" << BTA_GATTC_CL_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_CL_MAX; i++) { tBTA_GATTC_RCB* p_cl_rcb = &bta_gattc_cb.cl_rcb[i]; if (!p_cl_rcb->in_use) { continue; } entry_count++; stream << " client_if: " << +p_cl_rcb->client_if << " app uuids: " << p_cl_rcb->app_uuid << " clcb_num: " << +p_cl_rcb->num_clcb; stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->clcb (BTA_GATTC_CLCB_MAX=" << BTA_GATTC_CLCB_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_CLCB_MAX; i++) { tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[i]; if (!p_clcb->in_use) { continue; } entry_count++; stream << " conn_id: " << loghex(p_clcb->bta_conn_id) << " address: " << ADDRESS_TO_LOGGABLE_STR(p_clcb->bda) << " transport: " << bt_transport_text(p_clcb->transport) << " state: " << bta_clcb_state_text(p_clcb->state); stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->known_server (BTA_GATTC_KNOWN_SR_MAX=" << BTA_GATTC_KNOWN_SR_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_CL_MAX; i++) { tBTA_GATTC_SERV* p_known_server = &bta_gattc_cb.known_server[i]; if (!p_known_server->in_use) { continue; } entry_count++; stream << " server_address: " << ADDRESS_TO_LOGGABLE_STR(p_known_server->server_bda) << " mtu: " << p_known_server->mtu << " blocked_conn_id: " << loghex(p_known_server->blocked_conn_id) << " pending_discovery: " << p_known_server->pending_discovery.ToString() << " num_clcb: " << +p_known_server->num_clcb << " state: " << bta_server_state_text(p_known_server->state) << " connected: " << p_known_server->connected << " srvc_disc_count: " << p_known_server->srvc_disc_count << " disc_blocked_waiting_on_version: " << p_known_server->disc_blocked_waiting_on_version << " srvc_hdl_chg: " << +p_known_server->srvc_hdl_chg << " srvc_hdl_db_hash: " << p_known_server->srvc_hdl_db_hash << " update_count: " << +p_known_server->update_count; stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; dprintf(fd, "BTA_GATTC_CB state %s \n%s\n", bta_gattc_state_text(bta_gattc_cb.state).c_str(), stream.str().c_str()); } No newline at end of file system/btif/src/bluetooth.cc +2 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,7 @@ bt_status_t btif_hh_connect(const tAclLinkSpec* link_spec); bt_status_t btif_hd_execute_service(bool b_enable); extern void gatt_tcb_dump(int fd); extern void bta_gatt_client_dump(int fd); /******************************************************************************* * Callbacks from bluetooth::core (see go/invisalign-bt) Loading Loading @@ -824,6 +825,7 @@ static void dump(int fd, const char** arguments) { bluetooth::avrcp::AvrcpService::DebugDump(fd); btif_debug_config_dump(fd); gatt_tcb_dump(fd); bta_gatt_client_dump(fd); device_debug_iot_config_dump(fd); BTA_HfClientDumpStatistics(fd); wakelock_debug_dump(fd); Loading system/stack/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -1051,6 +1051,7 @@ cc_test { shared_libs: [ "libcrypto", "libcutils", "server_configurable_flags", ], static_libs: [ "libbase", Loading Loading @@ -1354,6 +1355,7 @@ cc_test { shared_libs: [ "libcrypto", "libcutils", "server_configurable_flags", ], static_libs: [ "libbase", Loading Loading
system/bta/gatt/bta_gattc_int.h +55 −13 Original line number Diff line number Diff line Loading @@ -86,6 +86,14 @@ typedef uint16_t tBTA_GATTC_INT_EVT; #define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE typedef enum : uint8_t { BTA_GATTC_SERV_IDLE = 0, BTA_GATTC_SERV_LOAD, BTA_GATTC_SERV_SAVE, BTA_GATTC_SERV_DISC, BTA_GATTC_SERV_DISC_ACT } tBTA_GATTC_SERV_STATE; /* internal strucutre for GATTC register API */ typedef struct { BT_HDR_RIGID hdr; Loading Loading @@ -211,26 +219,19 @@ typedef union { tBTA_GATTC_INT_CONN int_conn; } tBTA_GATTC_DATA; enum { typedef enum : uint8_t { BTA_GATTC_IDLE_ST = 0, /* Idle */ BTA_GATTC_W4_CONN_ST, /* Wait for connection - (optional) */ BTA_GATTC_CONN_ST, /* connected state */ BTA_GATTC_DISCOVER_ST /* discover is in progress */ }; typedef uint8_t tBTA_GATTC_STATE; } tBTA_GATTC_STATE; typedef struct { bool in_use; RawAddress server_bda; bool connected; #define BTA_GATTC_SERV_IDLE 0 #define BTA_GATTC_SERV_LOAD 1 #define BTA_GATTC_SERV_SAVE 2 #define BTA_GATTC_SERV_DISC 3 #define BTA_GATTC_SERV_DISC_ACT 4 uint8_t state; tBTA_GATTC_SERV_STATE state; gatt::Database gatt_database; uint8_t update_count; /* indication received */ Loading Loading @@ -325,15 +326,15 @@ typedef struct { RawAddress remote_bda; } tBTA_GATTC_CONN; enum { typedef enum : uint8_t { BTA_GATTC_STATE_DISABLED, BTA_GATTC_STATE_ENABLING, BTA_GATTC_STATE_ENABLED, BTA_GATTC_STATE_DISABLING }; } tBTA_GATTC_CB_STATE; typedef struct { uint8_t state; tBTA_GATTC_CB_STATE state; tBTA_GATTC_CONN conn_track[GATT_MAX_PHY_CHANNEL]; tBTA_GATTC_BG_TCK bg_track[BTA_GATTC_KNOWN_SR_MAX]; Loading Loading @@ -523,8 +524,49 @@ void bta_gattc_cache_write(const RawAddress& server_bda, void bta_gattc_cache_link(const RawAddress& server_bda, const Octet16& hash); void bta_gattc_cache_reset(const RawAddress& server_bda); inline std::string bta_clcb_state_text(const tBTA_GATTC_STATE& state) { switch (state) { CASE_RETURN_TEXT(BTA_GATTC_IDLE_ST); CASE_RETURN_TEXT(BTA_GATTC_W4_CONN_ST); CASE_RETURN_TEXT(BTA_GATTC_CONN_ST); CASE_RETURN_TEXT(BTA_GATTC_DISCOVER_ST); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } } inline std::string bta_server_state_text(const tBTA_GATTC_SERV_STATE& state) { switch (state) { CASE_RETURN_TEXT(BTA_GATTC_SERV_IDLE); CASE_RETURN_TEXT(BTA_GATTC_SERV_LOAD); CASE_RETURN_TEXT(BTA_GATTC_SERV_SAVE); CASE_RETURN_TEXT(BTA_GATTC_SERV_DISC); CASE_RETURN_TEXT(BTA_GATTC_SERV_DISC_ACT); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } } inline std::string bta_gattc_state_text(const tBTA_GATTC_CB_STATE& state) { switch (state) { CASE_RETURN_TEXT(BTA_GATTC_STATE_DISABLED); CASE_RETURN_TEXT(BTA_GATTC_STATE_ENABLING); CASE_RETURN_TEXT(BTA_GATTC_STATE_ENABLED); CASE_RETURN_TEXT(BTA_GATTC_STATE_DISABLING); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } } namespace fmt { template <> struct formatter<tBTA_GATTC_CB_STATE> : enum_formatter<tBTA_GATTC_CB_STATE> {}; template <> struct formatter<tBTA_GATTC_SERV_STATE> : enum_formatter<tBTA_GATTC_SERV_STATE> {}; template <> struct formatter<tBTA_GATTC_STATE> : enum_formatter<tBTA_GATTC_STATE> {}; template <> struct formatter<RobustCachingSupport> : enum_formatter<RobustCachingSupport> { }; } // namespace fmt Loading
system/bta/gatt/bta_gattc_main.cc +1 −1 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ bool bta_gattc_sm_execute(tBTA_GATTC_CLCB* p_clcb, uint16_t event, event &= 0x00FF; /* set next state */ p_clcb->state = state_table[event][BTA_GATTC_NEXT_STATE]; p_clcb->state = (tBTA_GATTC_STATE)(state_table[event][BTA_GATTC_NEXT_STATE]); /* execute action functions */ for (i = 0; i < BTA_GATTC_ACTIONS; i++) { Loading
system/bta/gatt/bta_gattc_utils.cc +99 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ #include "common/init_flags.h" #include "device/include/controller.h" #include "internal_include/bt_target.h" #include "internal_include/bt_trace.h" #include "os/log.h" #include "osi/include/allocator.h" #include "types/bt_transport.h" Loading Loading @@ -813,3 +814,101 @@ tBTA_GATTC_CLCB* bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA* p_msg) { bool bta_gattc_is_robust_caching_enabled() { return bluetooth::common::init_flags::gatt_robust_caching_client_is_enabled(); } void bta_gatt_client_dump(int fd) { std::stringstream stream; int entry_count = 0; stream << " ->conn_track (GATT_MAX_PHY_CHANNEL=" << GATT_MAX_PHY_CHANNEL << ")\n"; for (int i = 0; i < GATT_MAX_PHY_CHANNEL; i++) { tBTA_GATTC_CONN* p_conn_track = &bta_gattc_cb.conn_track[i]; if (p_conn_track->in_use) { entry_count++; stream << " address: " << ADDRESS_TO_LOGGABLE_STR(p_conn_track->remote_bda); stream << "\n"; } } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->bg_track (BTA_GATTC_KNOWN_SR_MAX=" << BTA_GATTC_KNOWN_SR_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i++) { tBTA_GATTC_BG_TCK* p_bg_track = &bta_gattc_cb.bg_track[i]; if (!p_bg_track->in_use) { continue; } entry_count++; stream << " address: " << ADDRESS_TO_LOGGABLE_STR(p_bg_track->remote_bda) << " cif_mask: " << loghex(p_bg_track->cif_mask); stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->cl_rcb (BTA_GATTC_CL_MAX=" << BTA_GATTC_CL_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_CL_MAX; i++) { tBTA_GATTC_RCB* p_cl_rcb = &bta_gattc_cb.cl_rcb[i]; if (!p_cl_rcb->in_use) { continue; } entry_count++; stream << " client_if: " << +p_cl_rcb->client_if << " app uuids: " << p_cl_rcb->app_uuid << " clcb_num: " << +p_cl_rcb->num_clcb; stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->clcb (BTA_GATTC_CLCB_MAX=" << BTA_GATTC_CLCB_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_CLCB_MAX; i++) { tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[i]; if (!p_clcb->in_use) { continue; } entry_count++; stream << " conn_id: " << loghex(p_clcb->bta_conn_id) << " address: " << ADDRESS_TO_LOGGABLE_STR(p_clcb->bda) << " transport: " << bt_transport_text(p_clcb->transport) << " state: " << bta_clcb_state_text(p_clcb->state); stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; stream << " ->known_server (BTA_GATTC_KNOWN_SR_MAX=" << BTA_GATTC_KNOWN_SR_MAX << ")\n"; for (int i = 0; i < BTA_GATTC_CL_MAX; i++) { tBTA_GATTC_SERV* p_known_server = &bta_gattc_cb.known_server[i]; if (!p_known_server->in_use) { continue; } entry_count++; stream << " server_address: " << ADDRESS_TO_LOGGABLE_STR(p_known_server->server_bda) << " mtu: " << p_known_server->mtu << " blocked_conn_id: " << loghex(p_known_server->blocked_conn_id) << " pending_discovery: " << p_known_server->pending_discovery.ToString() << " num_clcb: " << +p_known_server->num_clcb << " state: " << bta_server_state_text(p_known_server->state) << " connected: " << p_known_server->connected << " srvc_disc_count: " << p_known_server->srvc_disc_count << " disc_blocked_waiting_on_version: " << p_known_server->disc_blocked_waiting_on_version << " srvc_hdl_chg: " << +p_known_server->srvc_hdl_chg << " srvc_hdl_db_hash: " << p_known_server->srvc_hdl_db_hash << " update_count: " << +p_known_server->update_count; stream << "\n"; } stream << " -- used: " << entry_count << "\n"; entry_count = 0; dprintf(fd, "BTA_GATTC_CB state %s \n%s\n", bta_gattc_state_text(bta_gattc_cb.state).c_str(), stream.str().c_str()); } No newline at end of file
system/btif/src/bluetooth.cc +2 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,7 @@ bt_status_t btif_hh_connect(const tAclLinkSpec* link_spec); bt_status_t btif_hd_execute_service(bool b_enable); extern void gatt_tcb_dump(int fd); extern void bta_gatt_client_dump(int fd); /******************************************************************************* * Callbacks from bluetooth::core (see go/invisalign-bt) Loading Loading @@ -824,6 +825,7 @@ static void dump(int fd, const char** arguments) { bluetooth::avrcp::AvrcpService::DebugDump(fd); btif_debug_config_dump(fd); gatt_tcb_dump(fd); bta_gatt_client_dump(fd); device_debug_iot_config_dump(fd); BTA_HfClientDumpStatistics(fd); wakelock_debug_dump(fd); Loading
system/stack/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -1051,6 +1051,7 @@ cc_test { shared_libs: [ "libcrypto", "libcutils", "server_configurable_flags", ], static_libs: [ "libbase", Loading Loading @@ -1354,6 +1355,7 @@ cc_test { shared_libs: [ "libcrypto", "libcutils", "server_configurable_flags", ], static_libs: [ "libbase", Loading