summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMingbo Zhang <quic_mingboz@quicinc.com>2023-08-25 21:34:23 +0800
committerMingbo Zhang <quic_mingboz@quicinc.com>2023-08-25 21:34:23 +0800
commitf290b0b2f21ffdaa3b2bcab9902e55a90771884d (patch)
treea72f2c7d38a97b118674c083bcdc6becea36cf3b
parent87afb9daf798ea024b3bec6932522a178f282cdc (diff)
delete the added gatt services when cleanup (2/2)
When BT is turning off, if ble app is there, BT will be moved to BLE_ON state. But the added gatt services are not deleted when cleanup. As a result, several iterations from BT_ON to BLE_ON will use up all the gatts resources, then gatt services cannot be added any more. Change-Id: I466e9ada0a7e990a49303fb7d1c710cb8e249606 CRs-Fixed: 3586873
-rw-r--r--bta/direction_finder/bta_ctes_main.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/bta/direction_finder/bta_ctes_main.cc b/bta/direction_finder/bta_ctes_main.cc
index cda551fc8..a1391595d 100644
--- a/bta/direction_finder/bta_ctes_main.cc
+++ b/bta/direction_finder/bta_ctes_main.cc
@@ -165,6 +165,7 @@ class CtesManagerImpl : public CtesManager {
public:
CtesDevices remoteDevices;
+ std::vector<uint16_t> added_services;
virtual ~CtesManagerImpl() = default;
@@ -241,6 +242,13 @@ static void OnCteServiceAddedCb(uint8_t status, int serverIf,
}
for(int i=0; i< (int)service.size(); i++) {
+ if (status == GATT_SUCCESS && cte_instance &&
+ (service[i].type == BTGATT_DB_PRIMARY_SERVICE || service[i].type == BTGATT_DB_SECONDARY_SERVICE)) {
+ cte_instance->added_services.push_back(service[i].attribute_handle);
+ LOG(INFO) << __func__
+ << ": added service: uuid=" << service[i].uuid.ToString()
+ << ", handle=" << service[i].attribute_handle;
+ }
if (service[i].uuid == CONSTANT_TONE_EXT_SERVICE_UUID) {
LOG(INFO) << __func__ << " CTE service added attr handle: " << service[i].attribute_handle;
} else if(service[i].uuid == CONSTANT_TONE_EXT_ENABLE_CHAR_UUID) {
@@ -281,6 +289,11 @@ void HandleCtesEvent(uint32_t event, void* param) {
case CTES_CLEANUP_EVENT:
{
+ if (cte_instance) {
+ for (const auto& handle : cte_instance->added_services) {
+ BTA_GATTS_DeleteService(handle);
+ }
+ }
BTA_GATTS_AppDeregister(cteServiceInfo.server_if);
cte_instance->remoteDevices.RemoveDevices();
break;
@@ -718,4 +731,4 @@ void CtesCongestionUpdate(tcte_resp_t* p_data) {
GattsOpsQueue::CongestionCallback(p_data->remoteDevice->conn_id,
p_data->remoteDevice->congested);
}
-#endif //DIR_FINDING_FEATURE \ No newline at end of file
+#endif //DIR_FINDING_FEATURE