Loading system/bta/gatt/bta_gattc_act.cc +7 −2 Original line number Diff line number Diff line Loading @@ -692,7 +692,10 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb, if (p_clcb->status != GATT_SUCCESS) { /* clean up cache */ if (p_clcb->p_srcb) p_clcb->p_srcb->srvc_cache.clear(); if (p_clcb->p_srcb) { // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_clcb->p_srcb->srvc_cache); } /* used to reset cache in application */ bta_gattc_cache_reset(p_clcb->p_srcb->server_bda); Loading Loading @@ -1101,7 +1104,9 @@ void bta_gattc_process_api_refresh(const RawAddress& remote_bda) { } } /* in all other cases, mark it and delete the cache */ p_srvc_cb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srvc_cb->srvc_cache); } /* used to reset cache in application */ Loading system/bta/gatt/bta_gattc_api.cc +1 −1 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id, * Returns returns list of tBTA_GATTC_SERVICE or NULL. * ******************************************************************************/ const std::list<tBTA_GATTC_SERVICE>* BTA_GATTC_GetServices(uint16_t conn_id) { const std::vector<tBTA_GATTC_SERVICE>* BTA_GATTC_GetServices(uint16_t conn_id) { return bta_gattc_get_services(conn_id); } Loading system/bta/gatt/bta_gattc_cache.cc +16 −13 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ typedef struct { /* debug function to display the server cache */ static void bta_gattc_display_cache_server( const std::list<tBTA_GATTC_SERVICE>& cache) { const std::vector<tBTA_GATTC_SERVICE>& cache) { LOG(ERROR) << "<================Start Server Cache =============>"; for (const tBTA_GATTC_SERVICE& service : cache) { Loading Loading @@ -155,7 +155,8 @@ static void bta_gattc_display_explore_record(tBTA_GATTC_ATTR_REC* p_rec, * ******************************************************************************/ tGATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV* p_srvc_cb) { p_srvc_cb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srvc_cb->srvc_cache); osi_free(p_srvc_cb->p_srvc_list); p_srvc_cb->p_srvc_list = Loading @@ -169,7 +170,7 @@ tGATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV* p_srvc_cb) { } tBTA_GATTC_SERVICE* bta_gattc_find_matching_service( std::list<tBTA_GATTC_SERVICE>& services, uint16_t handle) { std::vector<tBTA_GATTC_SERVICE>& services, uint16_t handle) { for (tBTA_GATTC_SERVICE& service : services) { if (handle >= service.s_handle && handle <= service.e_handle) return &service; Loading @@ -179,7 +180,7 @@ tBTA_GATTC_SERVICE* bta_gattc_find_matching_service( } /** Add a service into GATT database */ static void add_service_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, static void add_service_to_gatt_db(std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t s_handle, uint16_t e_handle, const Uuid& uuid, bool is_primary) { #if (BTA_GATT_DEBUG == TRUE) Loading @@ -197,7 +198,7 @@ static void add_service_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, /** Add a characteristic into GATT database */ static void add_characteristic_to_gatt_db( std::list<tBTA_GATTC_SERVICE>& gatt_db, uint16_t attr_handle, std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t attr_handle, uint16_t value_handle, const Uuid& uuid, uint8_t property) { #if (BTA_GATT_DEBUG == TRUE) VLOG(1) << __func__ Loading Loading @@ -228,7 +229,7 @@ static void add_characteristic_to_gatt_db( } /* Add an descriptor into database cache buffer */ static void add_descriptor_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, static void add_descriptor_to_gatt_db(std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t handle, const Uuid& uuid) { #if (BTA_GATT_DEBUG == TRUE) VLOG(1) << __func__ << ": add descriptor, handle=" << loghex(handle) Loading Loading @@ -256,7 +257,7 @@ static void add_descriptor_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, } /* Add an attribute into database cache buffer */ static void add_incl_srvc_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, static void add_incl_srvc_to_gatt_db(std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t handle, const Uuid& uuid, uint16_t incl_srvc_s_handle) { #if (BTA_GATT_DEBUG == TRUE) Loading Loading @@ -789,14 +790,14 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB* p_clcb, Uuid* p_uuid) { } } std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services_srcb( std::vector<tBTA_GATTC_SERVICE>* bta_gattc_get_services_srcb( tBTA_GATTC_SERV* p_srcb) { if (!p_srcb || p_srcb->srvc_cache.empty()) return NULL; return &p_srcb->srvc_cache; } std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id) { std::vector<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id) { tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); if (p_clcb == NULL) return NULL; Loading @@ -808,14 +809,15 @@ std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id) { static tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb( tBTA_GATTC_SERV* p_srcb, uint16_t handle) { std::list<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services_srcb(p_srcb); std::vector<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services_srcb(p_srcb); if (services == NULL) return NULL; return bta_gattc_find_matching_service(*services, handle); } const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(uint16_t conn_id, uint16_t handle) { std::list<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services(conn_id); std::vector<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services(conn_id); if (services == NULL) return NULL; return bta_gattc_find_matching_service(*services, handle); Loading Loading @@ -904,7 +906,7 @@ void bta_gattc_fill_gatt_db_el(btgatt_db_element_t* p_attr, * Returns number of elements inside db from start_handle to end_handle ******************************************************************************/ static size_t bta_gattc_get_db_size( const std::list<tBTA_GATTC_SERVICE>& services, uint16_t start_handle, const std::vector<tBTA_GATTC_SERVICE>& services, uint16_t start_handle, uint16_t end_handle) { if (services.empty()) return 0; Loading Loading @@ -1062,7 +1064,8 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV* p_srvc_cb, uint16_t num_attr, /* first attribute loading, initialize buffer */ LOG(ERROR) << __func__; p_srvc_cb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srvc_cb->srvc_cache); while (num_attr > 0 && p_attr != NULL) { switch (p_attr->attr_type) { Loading system/bta/gatt/bta_gattc_int.h +3 −2 Original line number Diff line number Diff line Loading @@ -226,7 +226,7 @@ typedef struct { uint8_t state; std::list<tBTA_GATTC_SERVICE> srvc_cache; std::vector<tBTA_GATTC_SERVICE> srvc_cache; uint8_t update_count; /* indication received */ uint8_t num_clcb; /* number of associated CLCB */ Loading Loading @@ -453,7 +453,8 @@ extern tGATT_STATUS bta_gattc_discover_pri_service(uint16_t conn_id, uint8_t disc_type); extern void bta_gattc_search_service(tBTA_GATTC_CLCB* p_clcb, bluetooth::Uuid* p_uuid); extern std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id); extern std::vector<tBTA_GATTC_SERVICE>* bta_gattc_get_services( uint16_t conn_id); extern const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle( uint16_t conn_id, uint16_t handle); tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb( Loading system/bta/gatt/bta_gattc_utils.cc +19 −19 Original line number Diff line number Diff line Loading @@ -187,10 +187,12 @@ tBTA_GATTC_CLCB* bta_gattc_find_alloc_clcb(tGATT_IF client_if, * ******************************************************************************/ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB* p_clcb) { tBTA_GATTC_SERV* p_srcb = NULL; if (!p_clcb) { LOG(ERROR) << __func__ << " p_clcb=NULL"; return; } if (p_clcb) { p_srcb = p_clcb->p_srcb; tBTA_GATTC_SERV* p_srcb = p_clcb->p_srcb; if (p_srcb->num_clcb) p_srcb->num_clcb--; if (p_clcb->p_rcb->num_clcb) p_clcb->p_rcb->num_clcb--; Loading @@ -201,15 +203,12 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB* p_clcb) { p_srcb->state = BTA_GATTC_SERV_IDLE; p_srcb->mtu = 0; /* clean up cache */ p_srcb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srcb->srvc_cache); } osi_free_and_reset((void**)&p_clcb->p_q_cmd); memset(p_clcb, 0, sizeof(tBTA_GATTC_CLCB)); } else { LOG(ERROR) << __func__ << " p_clcb=NULL"; } } /******************************************************************************* Loading Loading @@ -296,7 +295,8 @@ tBTA_GATTC_SERV* bta_gattc_srcb_alloc(const RawAddress& bda) { p_tcb = p_recycle; if (p_tcb != NULL) { p_tcb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_tcb->srvc_cache); osi_free_and_reset((void**)&p_tcb->p_srvc_list); *p_tcb = tBTA_GATTC_SERV(); Loading Loading
system/bta/gatt/bta_gattc_act.cc +7 −2 Original line number Diff line number Diff line Loading @@ -692,7 +692,10 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb, if (p_clcb->status != GATT_SUCCESS) { /* clean up cache */ if (p_clcb->p_srcb) p_clcb->p_srcb->srvc_cache.clear(); if (p_clcb->p_srcb) { // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_clcb->p_srcb->srvc_cache); } /* used to reset cache in application */ bta_gattc_cache_reset(p_clcb->p_srcb->server_bda); Loading Loading @@ -1101,7 +1104,9 @@ void bta_gattc_process_api_refresh(const RawAddress& remote_bda) { } } /* in all other cases, mark it and delete the cache */ p_srvc_cb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srvc_cb->srvc_cache); } /* used to reset cache in application */ Loading
system/bta/gatt/bta_gattc_api.cc +1 −1 Original line number Diff line number Diff line Loading @@ -269,7 +269,7 @@ void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id, * Returns returns list of tBTA_GATTC_SERVICE or NULL. * ******************************************************************************/ const std::list<tBTA_GATTC_SERVICE>* BTA_GATTC_GetServices(uint16_t conn_id) { const std::vector<tBTA_GATTC_SERVICE>* BTA_GATTC_GetServices(uint16_t conn_id) { return bta_gattc_get_services(conn_id); } Loading
system/bta/gatt/bta_gattc_cache.cc +16 −13 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ typedef struct { /* debug function to display the server cache */ static void bta_gattc_display_cache_server( const std::list<tBTA_GATTC_SERVICE>& cache) { const std::vector<tBTA_GATTC_SERVICE>& cache) { LOG(ERROR) << "<================Start Server Cache =============>"; for (const tBTA_GATTC_SERVICE& service : cache) { Loading Loading @@ -155,7 +155,8 @@ static void bta_gattc_display_explore_record(tBTA_GATTC_ATTR_REC* p_rec, * ******************************************************************************/ tGATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV* p_srvc_cb) { p_srvc_cb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srvc_cb->srvc_cache); osi_free(p_srvc_cb->p_srvc_list); p_srvc_cb->p_srvc_list = Loading @@ -169,7 +170,7 @@ tGATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV* p_srvc_cb) { } tBTA_GATTC_SERVICE* bta_gattc_find_matching_service( std::list<tBTA_GATTC_SERVICE>& services, uint16_t handle) { std::vector<tBTA_GATTC_SERVICE>& services, uint16_t handle) { for (tBTA_GATTC_SERVICE& service : services) { if (handle >= service.s_handle && handle <= service.e_handle) return &service; Loading @@ -179,7 +180,7 @@ tBTA_GATTC_SERVICE* bta_gattc_find_matching_service( } /** Add a service into GATT database */ static void add_service_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, static void add_service_to_gatt_db(std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t s_handle, uint16_t e_handle, const Uuid& uuid, bool is_primary) { #if (BTA_GATT_DEBUG == TRUE) Loading @@ -197,7 +198,7 @@ static void add_service_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, /** Add a characteristic into GATT database */ static void add_characteristic_to_gatt_db( std::list<tBTA_GATTC_SERVICE>& gatt_db, uint16_t attr_handle, std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t attr_handle, uint16_t value_handle, const Uuid& uuid, uint8_t property) { #if (BTA_GATT_DEBUG == TRUE) VLOG(1) << __func__ Loading Loading @@ -228,7 +229,7 @@ static void add_characteristic_to_gatt_db( } /* Add an descriptor into database cache buffer */ static void add_descriptor_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, static void add_descriptor_to_gatt_db(std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t handle, const Uuid& uuid) { #if (BTA_GATT_DEBUG == TRUE) VLOG(1) << __func__ << ": add descriptor, handle=" << loghex(handle) Loading Loading @@ -256,7 +257,7 @@ static void add_descriptor_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, } /* Add an attribute into database cache buffer */ static void add_incl_srvc_to_gatt_db(std::list<tBTA_GATTC_SERVICE>& gatt_db, static void add_incl_srvc_to_gatt_db(std::vector<tBTA_GATTC_SERVICE>& gatt_db, uint16_t handle, const Uuid& uuid, uint16_t incl_srvc_s_handle) { #if (BTA_GATT_DEBUG == TRUE) Loading Loading @@ -789,14 +790,14 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB* p_clcb, Uuid* p_uuid) { } } std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services_srcb( std::vector<tBTA_GATTC_SERVICE>* bta_gattc_get_services_srcb( tBTA_GATTC_SERV* p_srcb) { if (!p_srcb || p_srcb->srvc_cache.empty()) return NULL; return &p_srcb->srvc_cache; } std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id) { std::vector<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id) { tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); if (p_clcb == NULL) return NULL; Loading @@ -808,14 +809,15 @@ std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id) { static tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb( tBTA_GATTC_SERV* p_srcb, uint16_t handle) { std::list<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services_srcb(p_srcb); std::vector<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services_srcb(p_srcb); if (services == NULL) return NULL; return bta_gattc_find_matching_service(*services, handle); } const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(uint16_t conn_id, uint16_t handle) { std::list<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services(conn_id); std::vector<tBTA_GATTC_SERVICE>* services = bta_gattc_get_services(conn_id); if (services == NULL) return NULL; return bta_gattc_find_matching_service(*services, handle); Loading Loading @@ -904,7 +906,7 @@ void bta_gattc_fill_gatt_db_el(btgatt_db_element_t* p_attr, * Returns number of elements inside db from start_handle to end_handle ******************************************************************************/ static size_t bta_gattc_get_db_size( const std::list<tBTA_GATTC_SERVICE>& services, uint16_t start_handle, const std::vector<tBTA_GATTC_SERVICE>& services, uint16_t start_handle, uint16_t end_handle) { if (services.empty()) return 0; Loading Loading @@ -1062,7 +1064,8 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV* p_srvc_cb, uint16_t num_attr, /* first attribute loading, initialize buffer */ LOG(ERROR) << __func__; p_srvc_cb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srvc_cb->srvc_cache); while (num_attr > 0 && p_attr != NULL) { switch (p_attr->attr_type) { Loading
system/bta/gatt/bta_gattc_int.h +3 −2 Original line number Diff line number Diff line Loading @@ -226,7 +226,7 @@ typedef struct { uint8_t state; std::list<tBTA_GATTC_SERVICE> srvc_cache; std::vector<tBTA_GATTC_SERVICE> srvc_cache; uint8_t update_count; /* indication received */ uint8_t num_clcb; /* number of associated CLCB */ Loading Loading @@ -453,7 +453,8 @@ extern tGATT_STATUS bta_gattc_discover_pri_service(uint16_t conn_id, uint8_t disc_type); extern void bta_gattc_search_service(tBTA_GATTC_CLCB* p_clcb, bluetooth::Uuid* p_uuid); extern std::list<tBTA_GATTC_SERVICE>* bta_gattc_get_services(uint16_t conn_id); extern std::vector<tBTA_GATTC_SERVICE>* bta_gattc_get_services( uint16_t conn_id); extern const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle( uint16_t conn_id, uint16_t handle); tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb( Loading
system/bta/gatt/bta_gattc_utils.cc +19 −19 Original line number Diff line number Diff line Loading @@ -187,10 +187,12 @@ tBTA_GATTC_CLCB* bta_gattc_find_alloc_clcb(tGATT_IF client_if, * ******************************************************************************/ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB* p_clcb) { tBTA_GATTC_SERV* p_srcb = NULL; if (!p_clcb) { LOG(ERROR) << __func__ << " p_clcb=NULL"; return; } if (p_clcb) { p_srcb = p_clcb->p_srcb; tBTA_GATTC_SERV* p_srcb = p_clcb->p_srcb; if (p_srcb->num_clcb) p_srcb->num_clcb--; if (p_clcb->p_rcb->num_clcb) p_clcb->p_rcb->num_clcb--; Loading @@ -201,15 +203,12 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB* p_clcb) { p_srcb->state = BTA_GATTC_SERV_IDLE; p_srcb->mtu = 0; /* clean up cache */ p_srcb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_srcb->srvc_cache); } osi_free_and_reset((void**)&p_clcb->p_q_cmd); memset(p_clcb, 0, sizeof(tBTA_GATTC_CLCB)); } else { LOG(ERROR) << __func__ << " p_clcb=NULL"; } } /******************************************************************************* Loading Loading @@ -296,7 +295,8 @@ tBTA_GATTC_SERV* bta_gattc_srcb_alloc(const RawAddress& bda) { p_tcb = p_recycle; if (p_tcb != NULL) { p_tcb->srvc_cache.clear(); // clear reallocating std::vector<tBTA_GATTC_SERVICE>().swap(p_tcb->srvc_cache); osi_free_and_reset((void**)&p_tcb->p_srvc_list); *p_tcb = tBTA_GATTC_SERV(); Loading