diff options
-rw-r--r-- | android/app/src/com/android/bluetooth/gatt/GattService.java | 3 | ||||
-rw-r--r-- | android/app/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java | 4 | ||||
-rw-r--r-- | flags/gap.aconfig | 7 | ||||
-rw-r--r-- | framework/tests/bumble/src/android/bluetooth/GattClientTest.java | 1 | ||||
-rw-r--r-- | system/bta/gatt/bta_gattc_act.cc | 272 | ||||
-rw-r--r-- | system/bta/gatt/bta_gattc_utils.cc | 266 | ||||
-rw-r--r-- | system/stack/gatt/gatt_api.cc | 82 | ||||
-rw-r--r-- | system/stack/gatt/gatt_auth.cc | 15 | ||||
-rw-r--r-- | system/stack/gatt/gatt_cl.cc | 49 | ||||
-rw-r--r-- | system/stack/gatt/gatt_main.cc | 117 | ||||
-rw-r--r-- | system/stack/gatt/gatt_sr.cc | 46 | ||||
-rw-r--r-- | system/stack/gatt/gatt_utils.cc | 192 | ||||
-rw-r--r-- | system/stack/test/gatt/gatt_sr_test.cc | 22 |
13 files changed, 259 insertions, 817 deletions
diff --git a/android/app/src/com/android/bluetooth/gatt/GattService.java b/android/app/src/com/android/bluetooth/gatt/GattService.java index 6e5faefa9f..bc5aeb3367 100644 --- a/android/app/src/com/android/bluetooth/gatt/GattService.java +++ b/android/app/src/com/android/bluetooth/gatt/GattService.java @@ -1025,8 +1025,7 @@ public class GattService extends ProfileService { if (!checkConnectPermissionForDataDelivery(this, source, TAG, "registerClient")) { return; } - if (Flags.gattClientDynamicAllocation() - && mClientMap.countByAppUid(Binder.getCallingUid()) >= GATT_CLIENT_LIMIT_PER_APP) { + if (mClientMap.countByAppUid(Binder.getCallingUid()) >= GATT_CLIENT_LIMIT_PER_APP) { Log.w(TAG, "registerClient() - failed due to too many clients"); callbackToApp(() -> callback.onClientRegistered(BluetoothGatt.GATT_FAILURE, 0)); return; diff --git a/android/app/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java index 76d6dd53ff..1e8a55b994 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/gatt/GattServiceTest.java @@ -42,7 +42,6 @@ import android.content.res.Resources; import android.location.LocationManager; import android.os.Bundle; import android.os.Process; -import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import android.test.mock.MockContentProvider; import android.test.mock.MockContentResolver; @@ -54,7 +53,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.TestUtils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.CompanionManager; -import com.android.bluetooth.flags.Flags; import com.android.bluetooth.le_scan.PeriodicScanManager; import com.android.bluetooth.le_scan.ScanManager; import com.android.bluetooth.le_scan.ScanObjectsFactory; @@ -79,7 +77,6 @@ import java.util.UUID; @RunWith(AndroidJUnit4.class) public class GattServiceTest { @Rule public final MockitoRule mMockitoRule = new MockitoRule(); - @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private ContextMap<IBluetoothGattCallback> mClientMap; @Mock private ScanManager mScanManager; @@ -443,7 +440,6 @@ public class GattServiceTest { @Test public void registerClient_checkLimitPerApp() { - mSetFlagsRule.enableFlags(Flags.FLAG_GATT_CLIENT_DYNAMIC_ALLOCATION); doReturn(GattService.GATT_CLIENT_LIMIT_PER_APP).when(mClientMap).countByAppUid(anyInt()); UUID uuid = UUID.randomUUID(); IBluetoothGattCallback callback = mock(IBluetoothGattCallback.class); diff --git a/flags/gap.aconfig b/flags/gap.aconfig index 3dd968b7ef..b86837d0c1 100644 --- a/flags/gap.aconfig +++ b/flags/gap.aconfig @@ -50,13 +50,6 @@ flag { } flag { - name: "gatt_client_dynamic_allocation" - namespace: "bluetooth" - description: "Allocate GATT clients in heap to unlimit the number of clients" - bug: "348559823" -} - -flag { name: "android_os_identifier" namespace: "bluetooth" description: "Add a custom service to provide Android OS identifier" diff --git a/framework/tests/bumble/src/android/bluetooth/GattClientTest.java b/framework/tests/bumble/src/android/bluetooth/GattClientTest.java index 29a9668a07..2798c2a3b3 100644 --- a/framework/tests/bumble/src/android/bluetooth/GattClientTest.java +++ b/framework/tests/bumble/src/android/bluetooth/GattClientTest.java @@ -695,7 +695,6 @@ public class GattClientTest { // Check if we can have 100 simultaneous clients @Test - @RequiresFlagsEnabled(Flags.FLAG_GATT_CLIENT_DYNAMIC_ALLOCATION) public void connectGatt_multipleClients() { registerGattService(); diff --git a/system/bta/gatt/bta_gattc_act.cc b/system/bta/gatt/bta_gattc_act.cc index 3b6069b1a1..346d7c3d6a 100644 --- a/system/bta/gatt/bta_gattc_act.cc +++ b/system/bta/gatt/bta_gattc_act.cc @@ -132,28 +132,17 @@ void bta_gattc_disable() { return; } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - if (!bta_gattc_cb.cl_rcb_map.empty()) { - bta_gattc_cb.state = BTA_GATTC_STATE_DISABLING; - } - - // An entry can be erased during deregister, use a copied collection - std::vector<tGATT_IF> gatt_ifs; - for (auto& [gatt_if, p_rcb] : bta_gattc_cb.cl_rcb_map) { - gatt_ifs.push_back(gatt_if); - } - for (auto& gatt_if : gatt_ifs) { - bta_gattc_deregister(bta_gattc_cb.cl_rcb_map[gatt_if].get()); - } - } else { - for (i = 0; i < BTA_GATTC_CL_MAX; i++) { - if (!bta_gattc_cb.cl_rcb[i].in_use) { - continue; - } + if (!bta_gattc_cb.cl_rcb_map.empty()) { + bta_gattc_cb.state = BTA_GATTC_STATE_DISABLING; + } - bta_gattc_cb.state = BTA_GATTC_STATE_DISABLING; - bta_gattc_deregister(&bta_gattc_cb.cl_rcb[i]); - } + // An entry can be erased during deregister, use a copied collection + std::vector<tGATT_IF> gatt_ifs; + for (auto& [gatt_if, p_rcb] : bta_gattc_cb.cl_rcb_map) { + gatt_ifs.push_back(gatt_if); + } + for (auto& gatt_if : gatt_ifs) { + bta_gattc_deregister(bta_gattc_cb.cl_rcb_map[gatt_if].get()); } /* no registered apps, indicate disable completed */ @@ -187,55 +176,25 @@ void bta_gattc_register(const Uuid& app_uuid, const std::string& name, tBTA_GATT bta_gattc_enable(); } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - client_if = GATT_Register(app_uuid, name, &bta_gattc_cl_cback, eatt_support); - if (client_if == 0) { - log::error("Register with GATT stack failed"); - status = GATT_ERROR; - } else { - auto p_rcb = std::make_unique<tBTA_GATTC_RCB>(); - p_rcb->in_use = true; - p_rcb->p_cback = p_cback; - p_rcb->app_uuid = app_uuid; - p_rcb->client_if = client_if; - bta_gattc_cb.cl_rcb_map.emplace(client_if, std::move(p_rcb)); - - log::debug( - "Registered GATT client interface {} with uuid={}, starting it on " - "main thread", - client_if, app_uuid.ToString()); - - do_in_main_thread(base::BindOnce(&bta_gattc_start_if, client_if)); - status = GATT_SUCCESS; - } + client_if = GATT_Register(app_uuid, name, &bta_gattc_cl_cback, eatt_support); + if (client_if == 0) { + log::error("Register with GATT stack failed"); + status = GATT_ERROR; } else { - for (uint8_t i = 0; i < BTA_GATTC_CL_MAX; i++) { - if (!bta_gattc_cb.cl_rcb[i].in_use) { - bta_gattc_cb.cl_rcb[i].client_if = - GATT_Register(app_uuid, "GattClient", &bta_gattc_cl_cback, eatt_support); - if (bta_gattc_cb.cl_rcb[i].client_if == 0) { - log::error("Register with GATT stack failed with index {}, trying next index", i); - status = GATT_ERROR; - } else { - bta_gattc_cb.cl_rcb[i].in_use = true; - bta_gattc_cb.cl_rcb[i].p_cback = p_cback; - bta_gattc_cb.cl_rcb[i].app_uuid = app_uuid; - - /* BTA use the same client interface as BTE GATT statck */ - client_if = bta_gattc_cb.cl_rcb[i].client_if; - - log::debug( - "Registered GATT client interface {} with uuid={}, starting it on " - "main thread", - client_if, app_uuid.ToString()); - - do_in_main_thread(base::BindOnce(&bta_gattc_start_if, client_if)); - - status = GATT_SUCCESS; - break; - } - } - } + auto p_rcb = std::make_unique<tBTA_GATTC_RCB>(); + p_rcb->in_use = true; + p_rcb->p_cback = p_cback; + p_rcb->app_uuid = app_uuid; + p_rcb->client_if = client_if; + bta_gattc_cb.cl_rcb_map.emplace(client_if, std::move(p_rcb)); + + log::debug( + "Registered GATT client interface {} with uuid={}, starting it on " + "main thread", + client_if, app_uuid.ToString()); + + do_in_main_thread(base::BindOnce(&bta_gattc_start_if, client_if)); + status = GATT_SUCCESS; } if (!cb.is_null()) { @@ -258,26 +217,13 @@ void bta_gattc_deregister(tBTA_GATTC_RCB* p_clreg) { continue; } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - if (bta_gattc_cb.bg_track[i].cif_set.contains(p_clreg->client_if)) { - bta_gattc_mark_bg_conn(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false); - if (!GATT_CancelConnect(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false)) { - log::warn( - "Unable to cancel GATT connection client_if:{} peer:{} " - "is_direct:{}", - p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false); - } - } - } else { - if (bta_gattc_cb.bg_track[i].cif_mask & - ((tBTA_GATTC_CIF_MASK)1 << (p_clreg->client_if - 1))) { - bta_gattc_mark_bg_conn(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false); - if (!GATT_CancelConnect(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false)) { - log::warn( - "Unable to cancel GATT connection client_if:{} peer:{} " - "is_direct:{}", - p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false); - } + if (bta_gattc_cb.bg_track[i].cif_set.contains(p_clreg->client_if)) { + bta_gattc_mark_bg_conn(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false); + if (!GATT_CancelConnect(p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false)) { + log::warn( + "Unable to cancel GATT connection client_if:{} peer:{} " + "is_direct:{}", + p_clreg->client_if, bta_gattc_cb.bg_track[i].remote_bda, false); } } } @@ -288,38 +234,23 @@ void bta_gattc_deregister(tBTA_GATTC_RCB* p_clreg) { } /* close all CLCB related to this app */ - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb : bta_gattc_cb.clcb_set) { - if (!p_clcb->in_use || p_clcb->p_rcb != p_clreg) { - continue; - } - p_clreg->dereg_pending = true; - - tBTA_GATTC_DATA gattc_data = { - .hdr = - { - .event = BTA_GATTC_API_CLOSE_EVT, - .layer_specific = static_cast<uint16_t>(p_clcb->bta_conn_id), - }, - }; - bta_gattc_close(p_clcb.get(), &gattc_data); - } - // deallocated clcbs will not be accessed. Let them be claened up. - bta_gattc_cleanup_clcb(); - } else { - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) { - if (!bta_gattc_cb.clcb[i].in_use || (bta_gattc_cb.clcb[i].p_rcb != p_clreg)) { - continue; - } - - p_clreg->dereg_pending = true; - - BT_HDR_RIGID buf; - buf.event = BTA_GATTC_API_CLOSE_EVT; - buf.layer_specific = static_cast<uint16_t>(bta_gattc_cb.clcb[i].bta_conn_id); - bta_gattc_close(&bta_gattc_cb.clcb[i], (tBTA_GATTC_DATA*)&buf); + for (auto& p_clcb : bta_gattc_cb.clcb_set) { + if (!p_clcb->in_use || p_clcb->p_rcb != p_clreg) { + continue; } + p_clreg->dereg_pending = true; + + tBTA_GATTC_DATA gattc_data = { + .hdr = + { + .event = BTA_GATTC_API_CLOSE_EVT, + .layer_specific = static_cast<uint16_t>(p_clcb->bta_conn_id), + }, + }; + bta_gattc_close(p_clcb.get(), &gattc_data); } + // deallocated clcbs will not be accessed. Let them be claened up. + bta_gattc_cleanup_clcb(); } /** process connect API request */ @@ -736,21 +667,12 @@ void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) { /** when a SRCB finished discovery, tell all related clcb */ void bta_gattc_reset_discover_st(tBTA_GATTC_SERV* p_srcb, tGATT_STATUS status) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb : bta_gattc_cb.clcb_set) { - if (p_clcb->p_srcb != p_srcb) { - continue; - } - p_clcb->status = status; - bta_gattc_sm_execute(p_clcb.get(), BTA_GATTC_DISCOVER_CMPL_EVT, NULL); - } - } else { - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) { - if (bta_gattc_cb.clcb[i].p_srcb == p_srcb) { - bta_gattc_cb.clcb[i].status = status; - bta_gattc_sm_execute(&bta_gattc_cb.clcb[i], BTA_GATTC_DISCOVER_CMPL_EVT, NULL); - } + for (auto& p_clcb : bta_gattc_cb.clcb_set) { + if (p_clcb->p_srcb != p_srcb) { + continue; } + p_clcb->status = status; + bta_gattc_sm_execute(p_clcb.get(), BTA_GATTC_DISCOVER_CMPL_EVT, NULL); } } @@ -777,23 +699,13 @@ void bta_gattc_disc_close(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data /** when a SRCB start discovery, tell all related clcb and set the state */ static void bta_gattc_set_discover_st(tBTA_GATTC_SERV* p_srcb) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb : bta_gattc_cb.clcb_set) { - if (p_clcb->p_srcb != p_srcb) { - continue; - } - p_clcb->status = GATT_SUCCESS; - p_clcb->state = BTA_GATTC_DISCOVER_ST; - p_clcb->request_during_discovery = BTA_GATTC_DISCOVER_REQ_NONE; - } - } else { - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) { - if (bta_gattc_cb.clcb[i].p_srcb == p_srcb) { - bta_gattc_cb.clcb[i].status = GATT_SUCCESS; - bta_gattc_cb.clcb[i].state = BTA_GATTC_DISCOVER_ST; - bta_gattc_cb.clcb[i].request_during_discovery = BTA_GATTC_DISCOVER_REQ_NONE; - } + for (auto& p_clcb : bta_gattc_cb.clcb_set) { + if (p_clcb->p_srcb != p_srcb) { + continue; } + p_clcb->status = GATT_SUCCESS; + p_clcb->state = BTA_GATTC_DISCOVER_ST; + p_clcb->request_during_discovery = BTA_GATTC_DISCOVER_REQ_NONE; } } @@ -1422,12 +1334,8 @@ static void bta_gattc_deregister_cmpl(tBTA_GATTC_RCB* p_clreg) { memset(&cb_data, 0, sizeof(tBTA_GATTC)); GATT_Deregister(p_clreg->client_if); - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - if (bta_gattc_cb.cl_rcb_map.erase(p_clreg->client_if) == 0) { - log::warn("deregistered unknown rcb client_if={}", p_clreg->client_if); - } - } else { - memset(p_clreg, 0, sizeof(tBTA_GATTC_RCB)); + if (bta_gattc_cb.cl_rcb_map.erase(p_clreg->client_if) == 0) { + log::warn("deregistered unknown rcb client_if={}", p_clreg->client_if); } cb_data.reg_oper.client_if = client_if; @@ -1490,20 +1398,11 @@ void bta_gattc_process_api_refresh(const RawAddress& remote_bda) { if (p_srvc_cb->connected && p_srvc_cb->num_clcb != 0) { bool found = false; tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0]; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb_i : bta_gattc_cb.clcb_set) { - if (p_clcb_i->in_use && p_clcb_i->p_srcb == p_srvc_cb) { - p_clcb = p_clcb_i.get(); - found = true; - break; - } - } - } else { - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) { - if (p_clcb->in_use && p_clcb->p_srcb == p_srvc_cb) { - found = true; - break; - } + for (auto& p_clcb_i : bta_gattc_cb.clcb_set) { + if (p_clcb_i->in_use && p_clcb_i->p_srcb == p_srvc_cb) { + p_clcb = p_clcb_i.get(); + found = true; + break; } } if (found) { @@ -1563,38 +1462,19 @@ static bool bta_gattc_process_srvc_chg_ind(tCONN_ID conn_id, tBTA_GATTC_RCB* p_c /* not an opened connection; or connection busy */ /* search for first available clcb and start discovery */ if (p_clcb == NULL || (p_clcb && p_clcb->p_q_cmd != NULL)) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb_i : bta_gattc_cb.clcb_set) { - if (p_clcb_i->in_use && p_clcb_i->p_srcb == p_srcb && p_clcb_i->p_q_cmd == NULL) { - p_clcb = p_clcb_i.get(); - break; - } - } - } else { - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) { - if (bta_gattc_cb.clcb[i].in_use && bta_gattc_cb.clcb[i].p_srcb == p_srcb && - bta_gattc_cb.clcb[i].p_q_cmd == NULL) { - p_clcb = &bta_gattc_cb.clcb[i]; - break; - } + for (auto& p_clcb_i : bta_gattc_cb.clcb_set) { + if (p_clcb_i->in_use && p_clcb_i->p_srcb == p_srcb && p_clcb_i->p_q_cmd == NULL) { + p_clcb = p_clcb_i.get(); + break; } } } // Use a busy CLCB to start discovery if no CLCB is available, this will be queued. if (com::android::bluetooth::flags::start_discover_service_changed() && p_clcb == NULL) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb_i : bta_gattc_cb.clcb_set) { - if (p_clcb_i->in_use && p_clcb_i->p_srcb == p_srcb) { - p_clcb = p_clcb_i.get(); - break; - } - } - } else { - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) { - if (bta_gattc_cb.clcb[i].in_use && bta_gattc_cb.clcb[i].p_srcb == p_srcb) { - p_clcb = &bta_gattc_cb.clcb[i]; - break; - } + for (auto& p_clcb_i : bta_gattc_cb.clcb_set) { + if (p_clcb_i->in_use && p_clcb_i->p_srcb == p_srcb) { + p_clcb = p_clcb_i.get(); + break; } } } diff --git a/system/bta/gatt/bta_gattc_utils.cc b/system/bta/gatt/bta_gattc_utils.cc index 1541f391ca..523cf90fe5 100644 --- a/system/bta/gatt/bta_gattc_utils.cc +++ b/system/bta/gatt/bta_gattc_utils.cc @@ -25,7 +25,6 @@ #define LOG_TAG "bt_bta_gattc" #include <bluetooth/log.h> -#include <com_android_bluetooth_flags.h> #include <cstdint> @@ -58,23 +57,11 @@ static uint8_t ble_acceptlist_size() { * ******************************************************************************/ tBTA_GATTC_RCB* bta_gattc_cl_get_regcb(uint8_t client_if) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - auto it = bta_gattc_cb.cl_rcb_map.find(client_if); - if (it == bta_gattc_cb.cl_rcb_map.end()) { - return NULL; - } else { - return it->second.get(); - } - } else { - uint8_t i = 0; - tBTA_GATTC_RCB* p_clrcb = &bta_gattc_cb.cl_rcb[0]; - - for (i = 0; i < BTA_GATTC_CL_MAX; i++, p_clrcb++) { - if (p_clrcb->in_use && p_clrcb->client_if == client_if) { - return p_clrcb; - } - } + auto it = bta_gattc_cb.cl_rcb_map.find(client_if); + if (it == bta_gattc_cb.cl_rcb_map.end()) { return NULL; + } else { + return it->second.get(); } } /******************************************************************************* @@ -86,20 +73,7 @@ tBTA_GATTC_RCB* bta_gattc_cl_get_regcb(uint8_t client_if) { * Returns pointer to the regcb * ******************************************************************************/ -uint8_t bta_gattc_num_reg_app(void) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - return (uint8_t)bta_gattc_cb.cl_rcb_map.size(); - } else { - uint8_t i = 0, j = 0; - - for (i = 0; i < BTA_GATTC_CL_MAX; i++) { - if (bta_gattc_cb.cl_rcb[i].in_use) { - j++; - } - } - return j; - } -} +uint8_t bta_gattc_num_reg_app(void) { return (uint8_t)bta_gattc_cb.cl_rcb_map.size(); } /******************************************************************************* * * Function bta_gattc_find_clcb_by_cif @@ -111,21 +85,10 @@ uint8_t bta_gattc_num_reg_app(void) { ******************************************************************************/ tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_cif(uint8_t client_if, const RawAddress& remote_bda, tBT_TRANSPORT transport) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb : bta_gattc_cb.clcb_set) { - if (p_clcb->in_use && p_clcb->p_rcb->client_if == client_if && - p_clcb->transport == transport && p_clcb->bda == remote_bda) { - return p_clcb.get(); - } - } - } else { - tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0]; - - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) { - if (p_clcb->in_use && p_clcb->p_rcb->client_if == client_if && - p_clcb->transport == transport && p_clcb->bda == remote_bda) { - return p_clcb; - } + for (auto& p_clcb : bta_gattc_cb.clcb_set) { + if (p_clcb->in_use && p_clcb->p_rcb->client_if == client_if && p_clcb->transport == transport && + p_clcb->bda == remote_bda) { + return p_clcb.get(); } } return NULL; @@ -140,19 +103,9 @@ tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_cif(uint8_t client_if, const RawAddress& * ******************************************************************************/ tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_conn_id(tCONN_ID conn_id) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& p_clcb : bta_gattc_cb.clcb_set) { - if (p_clcb != NULL && p_clcb->in_use && p_clcb->bta_conn_id == conn_id) { - return p_clcb.get(); - } - } - } else { - tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0]; - - for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) { - if (p_clcb->in_use && p_clcb->bta_conn_id == conn_id) { - return p_clcb; - } + for (auto& p_clcb : bta_gattc_cb.clcb_set) { + if (p_clcb != NULL && p_clcb->in_use && p_clcb->bta_conn_id == conn_id) { + return p_clcb.get(); } } return NULL; @@ -171,63 +124,30 @@ tBTA_GATTC_CLCB* bta_gattc_clcb_alloc(tGATT_IF client_if, const RawAddress& remo tBT_TRANSPORT transport) { tBTA_GATTC_CLCB* p_clcb = NULL; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - bta_gattc_cleanup_clcb(); - auto [p_clcb_i, b] = bta_gattc_cb.clcb_set.emplace(std::make_unique<tBTA_GATTC_CLCB>()); - p_clcb = p_clcb_i->get(); + bta_gattc_cleanup_clcb(); + auto [p_clcb_i, b] = bta_gattc_cb.clcb_set.emplace(std::make_unique<tBTA_GATTC_CLCB>()); + p_clcb = p_clcb_i->get(); - p_clcb->in_use = true; - p_clcb->status = GATT_SUCCESS; - p_clcb->transport = transport; - p_clcb->bda = remote_bda; - p_clcb->p_q_cmd = NULL; + p_clcb->in_use = true; + p_clcb->status = GATT_SUCCESS; + p_clcb->transport = transport; + p_clcb->bda = remote_bda; + p_clcb->p_q_cmd = NULL; - p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if); + p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if); - p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda); - if (p_clcb->p_srcb == NULL) { - p_clcb->p_srcb = bta_gattc_srcb_alloc(remote_bda); - } + p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda); + if (p_clcb->p_srcb == NULL) { + p_clcb->p_srcb = bta_gattc_srcb_alloc(remote_bda); + } - if (p_clcb->p_rcb != NULL && p_clcb->p_srcb != NULL) { - p_clcb->p_srcb->num_clcb++; - p_clcb->p_rcb->num_clcb++; - } else { - /* release this clcb if clcb or srcb allocation failed */ - bta_gattc_cb.clcb_set.erase(p_clcb_i); - p_clcb = NULL; - } + if (p_clcb->p_rcb != NULL && p_clcb->p_srcb != NULL) { + p_clcb->p_srcb->num_clcb++; + p_clcb->p_rcb->num_clcb++; } else { - for (int i_clcb = 0; i_clcb < BTA_GATTC_CLCB_MAX; i_clcb++) { - if (!bta_gattc_cb.clcb[i_clcb].in_use) { -#if (BTA_GATT_DEBUG == TRUE) - log::verbose("found clcb:{} available", i_clcb); -#endif - p_clcb = &bta_gattc_cb.clcb[i_clcb]; - p_clcb->in_use = true; - p_clcb->status = GATT_SUCCESS; - p_clcb->transport = transport; - p_clcb->bda = remote_bda; - p_clcb->p_q_cmd = NULL; - - p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if); - - p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda); - if (p_clcb->p_srcb == NULL) { - p_clcb->p_srcb = bta_gattc_srcb_alloc(remote_bda); - } - - if (p_clcb->p_rcb != NULL && p_clcb->p_srcb != NULL) { - p_clcb->p_srcb->num_clcb++; - p_clcb->p_rcb->num_clcb++; - } else { - /* release this clcb if clcb or srcb allocation failed */ - p_clcb->in_use = false; - p_clcb = NULL; - } - break; - } - } + /* release this clcb if clcb or srcb allocation failed */ + bta_gattc_cb.clcb_set.erase(p_clcb_i); + p_clcb = NULL; } return p_clcb; } @@ -330,9 +250,7 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB* p_clcb) { p_clcb->status = GATT_SUCCESS; // in bta_gattc_sm_execute(), p_clcb is accessed again so we dealloc clcb later. // it will be claned up when the client is deregistered or a new clcb is allocated. - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - bta_gattc_cb.clcb_pending_dealloc.insert(p_clcb); - } + bta_gattc_cb.clcb_pending_dealloc.insert(p_clcb); } /******************************************************************************* @@ -643,39 +561,21 @@ bool bta_gattc_mark_bg_conn(tGATT_IF client_if, const RawAddress& remote_bda_ptr for (i = 0; i < ble_acceptlist_size(); i++, p_bg_tck++) { if (p_bg_tck->in_use && ((p_bg_tck->remote_bda == remote_bda_ptr) || (p_bg_tck->remote_bda.IsEmpty()))) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - auto& p_cif_set = p_bg_tck->cif_set; - if (add) { /* mask on the cif bit */ - p_cif_set.insert(client_if); - } else { - if (client_if != 0) { - p_cif_set.erase(client_if); - } else { - p_cif_set.clear(); - } - } - /* no BG connection for this device, make it available */ - if (p_bg_tck->cif_set.empty()) { - p_bg_tck->in_use = false; - p_bg_tck->remote_bda = RawAddress::kEmpty; - } + auto& p_cif_set = p_bg_tck->cif_set; + if (add) { /* mask on the cif bit */ + p_cif_set.insert(client_if); } else { - p_cif_mask = &p_bg_tck->cif_mask; - - if (add) { /* mask on the cif bit */ - *p_cif_mask |= (1 << (client_if - 1)); + if (client_if != 0) { + p_cif_set.erase(client_if); } else { - if (client_if != 0) { - *p_cif_mask &= (~(1 << (client_if - 1))); - } else { - *p_cif_mask = 0; - } - } - /* no BG connection for this device, make it available */ - if (p_bg_tck->cif_mask == 0) { - *p_bg_tck = tBTA_GATTC_BG_TCK{}; + p_cif_set.clear(); } } + /* no BG connection for this device, make it available */ + if (p_bg_tck->cif_set.empty()) { + p_bg_tck->in_use = false; + p_bg_tck->remote_bda = RawAddress::kEmpty; + } return true; } } @@ -688,12 +588,7 @@ bool bta_gattc_mark_bg_conn(tGATT_IF client_if, const RawAddress& remote_bda_ptr p_bg_tck->in_use = true; p_bg_tck->remote_bda = remote_bda_ptr; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - p_bg_tck->cif_set = {client_if}; - } else { - p_cif_mask = &p_bg_tck->cif_mask; - *p_cif_mask = ((tBTA_GATTC_CIF_MASK)1 << (client_if - 1)); - } + p_bg_tck->cif_set = {client_if}; return true; } } @@ -719,15 +614,8 @@ bool bta_gattc_check_bg_conn(tGATT_IF client_if, const RawAddress& remote_bda, u for (i = 0; i < ble_acceptlist_size() && !is_bg_conn; i++, p_bg_tck++) { if (p_bg_tck->in_use && (p_bg_tck->remote_bda == remote_bda || p_bg_tck->remote_bda.IsEmpty())) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - if (p_bg_tck->cif_set.contains(client_if) && role == HCI_ROLE_CENTRAL) { - is_bg_conn = true; - } - } else { - if (((p_bg_tck->cif_mask & ((tBTA_GATTC_CIF_MASK)1 << (client_if - 1))) != 0) && - role == HCI_ROLE_CENTRAL) { - is_bg_conn = true; - } + if (p_bg_tck->cif_set.contains(client_if) && role == HCI_ROLE_CENTRAL) { + is_bg_conn = true; } } } @@ -938,58 +826,28 @@ void bta_gatt_client_dump(int fd) { stream << " -- used: " << entry_count << "\n"; entry_count = 0; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - stream << " ->cl_rcb (dynamic)\n"; - for (auto& [i, p_cl_rcb] : bta_gattc_cb.cl_rcb_map) { - 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"; - } - } else { - 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 << " ->cl_rcb (dynamic)\n"; + for (auto& [i, p_cl_rcb] : bta_gattc_cb.cl_rcb_map) { + 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; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - stream << " ->clcb (dynamic)\n"; - for (auto& p_clcb : bta_gattc_cb.clcb_set) { - if (!p_clcb->in_use) { - continue; - } - entry_count++; - stream << " conn_id: " << loghex(p_clcb->bta_conn_id) - << " address: " << p_clcb->bda.ToRedactedStringForLogging() - << " transport: " << bt_transport_text(p_clcb->transport) - << " state: " << bta_clcb_state_text(p_clcb->state); - stream << "\n"; - } - } else { - stream << " ->clcb (BTA_GATTC_CLCB_MAX=" << BTA_GATTC_CLCB_MAX << ")\n"; - for (size_t 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: " << p_clcb->bda.ToRedactedStringForLogging() - << " transport: " << bt_transport_text(p_clcb->transport) - << " state: " << bta_clcb_state_text(p_clcb->state); - stream << "\n"; + stream << " ->clcb (dynamic)\n"; + for (auto& p_clcb : bta_gattc_cb.clcb_set) { + if (!p_clcb->in_use) { + continue; } + entry_count++; + stream << " conn_id: " << loghex(p_clcb->bta_conn_id) + << " address: " << p_clcb->bda.ToRedactedStringForLogging() + << " transport: " << bt_transport_text(p_clcb->transport) + << " state: " << bta_clcb_state_text(p_clcb->state); + stream << "\n"; } stream << " -- used: " << entry_count << "\n"; diff --git a/system/stack/gatt/gatt_api.cc b/system/stack/gatt/gatt_api.cc index 7b1a425f5e..bb5641d97d 100644 --- a/system/stack/gatt/gatt_api.cc +++ b/system/stack/gatt/gatt_api.cc @@ -75,8 +75,7 @@ static tGATT_HDL_LIST_ELEM& gatt_add_an_item_to_list(uint16_t s_handle) { return *rit; } -static tGATT_IF GATT_Register_Dynamic(const Uuid& app_uuid128, const std::string& name, - tGATT_CBACK* p_cb_info, bool eatt_support); +static tGATT_IF GATT_FindNextFreeClRcbId(); /***************************************************************************** * @@ -1229,63 +1228,6 @@ void GATT_SetIdleTimeout(const RawAddress& bd_addr, uint16_t idle_tout, tBT_TRAN ******************************************************************************/ tGATT_IF GATT_Register(const Uuid& app_uuid128, const std::string& name, tGATT_CBACK* p_cb_info, bool eatt_support) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - return GATT_Register_Dynamic(app_uuid128, name, p_cb_info, eatt_support); - } - tGATT_REG* p_reg; - uint8_t i_gatt_if = 0; - tGATT_IF gatt_if = 0; - - for (i_gatt_if = 0, p_reg = gatt_cb.cl_rcb; i_gatt_if < GATT_MAX_APPS; i_gatt_if++, p_reg++) { - if (p_reg->in_use && p_reg->app_uuid128 == app_uuid128) { - log::error("Application already registered, uuid={}", app_uuid128.ToString()); - return 0; - } - } - - if (stack_config_get_interface()->get_pts_use_eatt_for_all_services()) { - log::info("PTS: Force to use EATT for servers"); - eatt_support = true; - } - - for (i_gatt_if = 0, p_reg = gatt_cb.cl_rcb; i_gatt_if < GATT_MAX_APPS; i_gatt_if++, p_reg++) { - if (!p_reg->in_use) { - *p_reg = {}; - i_gatt_if++; /* one based number */ - p_reg->app_uuid128 = app_uuid128; - gatt_if = p_reg->gatt_if = (tGATT_IF)i_gatt_if; - p_reg->app_cb = *p_cb_info; - p_reg->in_use = true; - p_reg->eatt_support = eatt_support; - p_reg->name = name; - log::info("Allocated name:{} uuid:{} gatt_if:{} eatt_support:{}", name, - app_uuid128.ToString(), gatt_if, eatt_support); - return gatt_if; - } - } - - log::error("Unable to register GATT client, MAX client reached: {}", GATT_MAX_APPS); - return 0; -} - -static tGATT_IF GATT_FindNextFreeClRcbId() { - tGATT_IF gatt_if = gatt_cb.last_gatt_if; - for (int i = 0; i < GATT_IF_MAX; i++) { - if (++gatt_if > GATT_IF_MAX) { - gatt_if = static_cast<tGATT_IF>(1); - } - if (!gatt_cb.cl_rcb_map.contains(gatt_if)) { - gatt_cb.last_gatt_if = gatt_if; - return gatt_if; - } - } - log::error("Unable to register GATT client, MAX client reached: {}", gatt_cb.cl_rcb_map.size()); - - return GATT_IF_INVALID; -} - -static tGATT_IF GATT_Register_Dynamic(const Uuid& app_uuid128, const std::string& name, - tGATT_CBACK* p_cb_info, bool eatt_support) { for (auto& [gatt_if, p_reg] : gatt_cb.cl_rcb_map) { if (p_reg->app_uuid128 == app_uuid128) { log::error("Application already registered, uuid={}", app_uuid128.ToString()); @@ -1322,6 +1264,22 @@ static tGATT_IF GATT_Register_Dynamic(const Uuid& app_uuid128, const std::string return gatt_if; } +static tGATT_IF GATT_FindNextFreeClRcbId() { + tGATT_IF gatt_if = gatt_cb.last_gatt_if; + for (int i = 0; i < GATT_IF_MAX; i++) { + if (++gatt_if > GATT_IF_MAX) { + gatt_if = static_cast<tGATT_IF>(1); + } + if (!gatt_cb.cl_rcb_map.contains(gatt_if)) { + gatt_cb.last_gatt_if = gatt_if; + return gatt_if; + } + } + log::error("Unable to register GATT client, MAX client reached: {}", gatt_cb.cl_rcb_map.size()); + + return GATT_IF_INVALID; +} + /******************************************************************************* * * Function GATT_Deregister @@ -1385,11 +1343,7 @@ void GATT_Deregister(tGATT_IF gatt_if) { connection_manager::on_app_deregistered(gatt_if); - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - gatt_cb.cl_rcb_map.erase(gatt_if); - } else { - *p_reg = {}; - } + gatt_cb.cl_rcb_map.erase(gatt_if); } /******************************************************************************* diff --git a/system/stack/gatt/gatt_auth.cc b/system/stack/gatt/gatt_auth.cc index 7c4b935389..34dcb4886b 100644 --- a/system/stack/gatt/gatt_auth.cc +++ b/system/stack/gatt/gatt_auth.cc @@ -23,7 +23,6 @@ ******************************************************************************/ #include <bluetooth/log.h> -#include <com_android_bluetooth_flags.h> #include <string.h> #include "gatt_api.h" @@ -216,17 +215,9 @@ void gatt_notify_enc_cmpl(const RawAddress& bd_addr) { return; } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_rcb] : gatt_cb.cl_rcb_map) { - if (p_rcb->app_cb.p_enc_cmpl_cb) { - (*p_rcb->app_cb.p_enc_cmpl_cb)(p_rcb->gatt_if, bd_addr); - } - } - } else { - for (uint8_t i = 0; i < GATT_MAX_APPS; i++) { - if (gatt_cb.cl_rcb[i].in_use && gatt_cb.cl_rcb[i].app_cb.p_enc_cmpl_cb) { - (*gatt_cb.cl_rcb[i].app_cb.p_enc_cmpl_cb)(gatt_cb.cl_rcb[i].gatt_if, bd_addr); - } + for (auto& [i, p_rcb] : gatt_cb.cl_rcb_map) { + if (p_rcb->app_cb.p_enc_cmpl_cb) { + (*p_rcb->app_cb.p_enc_cmpl_cb)(p_rcb->gatt_if, bd_addr); } } diff --git a/system/stack/gatt/gatt_cl.cc b/system/stack/gatt/gatt_cl.cc index 9a241813ae..8496d425a1 100644 --- a/system/stack/gatt/gatt_cl.cc +++ b/system/stack/gatt/gatt_cl.cc @@ -25,7 +25,6 @@ #define LOG_TAG "bluetooth" #include <bluetooth/log.h> -#include <com_android_bluetooth_flags.h> #include <string.h> #include "gatt_int.h" @@ -708,17 +707,9 @@ static void gatt_process_notification(tGATT_TCB& tcb, uint16_t cid, uint8_t op_c // notification/indication // Note: need to do the indication count and start timer first then do // callback - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { - tcb.ind_count++; - } - } - } else { - for (i = 0, p_reg = gatt_cb.cl_rcb; i < GATT_MAX_APPS; i++, p_reg++) { - if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { - tcb.ind_count++; - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { + tcb.ind_count++; } } @@ -738,19 +729,10 @@ static void gatt_process_notification(tGATT_TCB& tcb, uint16_t cid, uint8_t op_c gatt_cl_complete.att_value = value; gatt_cl_complete.cid = cid; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { - conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_cmpl_cb)(conn_id, event, encrypt_status, &gatt_cl_complete); - } - } - } else { - for (i = 0, p_reg = gatt_cb.cl_rcb; i < GATT_MAX_APPS; i++, p_reg++) { - if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { - conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_cmpl_cb)(conn_id, event, encrypt_status, &gatt_cl_complete); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { + conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); + (*p_reg->app_cb.p_cmpl_cb)(conn_id, event, encrypt_status, &gatt_cl_complete); } } @@ -788,19 +770,10 @@ static void gatt_process_notification(tGATT_TCB& tcb, uint16_t cid, uint8_t op_c gatt_cl_complete.att_value = value; gatt_cl_complete.cid = cid; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { - conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_cmpl_cb)(conn_id, event, encrypt_status, &gatt_cl_complete); - } - } - } else { - for (i = 0, p_reg = gatt_cb.cl_rcb; i < GATT_MAX_APPS; i++, p_reg++) { - if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { - conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_cmpl_cb)(conn_id, event, encrypt_status, &gatt_cl_complete); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_cmpl_cb) { + conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); + (*p_reg->app_cb.p_cmpl_cb)(conn_id, event, encrypt_status, &gatt_cl_complete); } } } diff --git a/system/stack/gatt/gatt_main.cc b/system/stack/gatt/gatt_main.cc index 56d268422c..19fd83990a 100644 --- a/system/stack/gatt/gatt_main.cc +++ b/system/stack/gatt/gatt_main.cc @@ -624,21 +624,10 @@ static void gatt_channel_congestion(tGATT_TCB* p_tcb, bool congested) { gatt_cl_send_next_cmd_inq(*p_tcb); } /* notifying all applications for the connection up event */ - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_congestion_cb) { - conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_congestion_cb)(conn_id, congested); - } - } - } else { - for (i = 0, p_reg = gatt_cb.cl_rcb; i < GATT_MAX_APPS; i++, p_reg++) { - if (p_reg->in_use) { - if (p_reg->app_cb.p_congestion_cb) { - conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_congestion_cb)(conn_id, congested); - } - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_congestion_cb) { + conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); + (*p_reg->app_cb.p_congestion_cb)(conn_id, congested); } } } @@ -658,20 +647,10 @@ void gatt_notify_phy_updated(tHCI_STATUS status, uint16_t handle, uint8_t tx_phy // TODO: Clean up this status conversion. tGATT_STATUS gatt_status = static_cast<tGATT_STATUS>(status); - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_phy_update_cb) { - tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_phy_update_cb)(p_reg->gatt_if, conn_id, tx_phy, rx_phy, gatt_status); - } - } - } else { - for (int i = 0; i < GATT_MAX_APPS; i++) { - tGATT_REG* p_reg = &gatt_cb.cl_rcb[i]; - if (p_reg->in_use && p_reg->app_cb.p_phy_update_cb) { - tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_phy_update_cb)(p_reg->gatt_if, conn_id, tx_phy, rx_phy, gatt_status); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_phy_update_cb) { + tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); + (*p_reg->app_cb.p_phy_update_cb)(p_reg->gatt_if, conn_id, tx_phy, rx_phy, gatt_status); } } } @@ -684,22 +663,11 @@ void gatt_notify_conn_update(const RawAddress& remote, uint16_t interval, uint16 return; } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_conn_update_cb) { - tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_conn_update_cb)(p_reg->gatt_if, conn_id, interval, latency, timeout, - static_cast<tGATT_STATUS>(status)); - } - } - } else { - for (int i = 0; i < GATT_MAX_APPS; i++) { - tGATT_REG* p_reg = &gatt_cb.cl_rcb[i]; - if (p_reg->in_use && p_reg->app_cb.p_conn_update_cb) { - tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_conn_update_cb)(p_reg->gatt_if, conn_id, interval, latency, timeout, - static_cast<tGATT_STATUS>(status)); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_conn_update_cb) { + tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); + (*p_reg->app_cb.p_conn_update_cb)(p_reg->gatt_if, conn_id, interval, latency, timeout, + static_cast<tGATT_STATUS>(status)); } } } @@ -717,22 +685,11 @@ void gatt_notify_subrate_change(uint16_t handle, uint16_t subrate_factor, uint16 return; } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_subrate_chg_cb) { - tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_subrate_chg_cb)(p_reg->gatt_if, conn_id, subrate_factor, latency, - cont_num, timeout, static_cast<tGATT_STATUS>(status)); - } - } - } else { - for (int i = 0; i < GATT_MAX_APPS; i++) { - tGATT_REG* p_reg = &gatt_cb.cl_rcb[i]; - if (p_reg->in_use && p_reg->app_cb.p_subrate_chg_cb) { - tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_subrate_chg_cb)(p_reg->gatt_if, conn_id, subrate_factor, latency, - cont_num, timeout, static_cast<tGATT_STATUS>(status)); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_subrate_chg_cb) { + tCONN_ID conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); + (*p_reg->app_cb.p_subrate_chg_cb)(p_reg->gatt_if, conn_id, subrate_factor, latency, cont_num, + timeout, static_cast<tGATT_STATUS>(status)); } } } @@ -976,37 +933,19 @@ static void gatt_send_conn_cback(tGATT_TCB* p_tcb) { /* notifying all applications for the connection up event */ - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (!p_reg->in_use) { - continue; - } - - if (apps.find(p_reg->gatt_if) != apps.end()) { - gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); - } - - if (p_reg->app_cb.p_conn_cb) { - conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, kGattConnected, - GATT_CONN_OK, p_tcb->transport); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (!p_reg->in_use) { + continue; } - } else { - for (i = 0, p_reg = gatt_cb.cl_rcb; i < GATT_MAX_APPS; i++, p_reg++) { - if (!p_reg->in_use) { - continue; - } - if (apps.find(p_reg->gatt_if) != apps.end()) { - gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); - } + if (apps.find(p_reg->gatt_if) != apps.end()) { + gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); + } - if (p_reg->app_cb.p_conn_cb) { - conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); - (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, kGattConnected, - GATT_CONN_OK, p_tcb->transport); - } + if (p_reg->app_cb.p_conn_cb) { + conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); + (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, kGattConnected, + GATT_CONN_OK, p_tcb->transport); } } diff --git a/system/stack/gatt/gatt_sr.cc b/system/stack/gatt/gatt_sr.cc index 133080c1db..f23b8b5dc9 100644 --- a/system/stack/gatt/gatt_sr.cc +++ b/system/stack/gatt/gatt_sr.cc @@ -407,27 +407,14 @@ static void gatt_process_exec_write_req(tGATT_TCB& tcb, uint16_t cid, uint8_t op trans_id = gatt_sr_enqueue_cmd(tcb, cid, op_code, 0); gatt_sr_copy_prep_cnt_to_cback_cnt(tcb); - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - auto prep_cnt_it = tcb.prep_cnt_map.begin(); - while (prep_cnt_it != tcb.prep_cnt_map.end()) { - gatt_if = prep_cnt_it->first; - conn_id = gatt_create_conn_id(tcb.tcb_idx, gatt_if); - tGATTS_DATA gatts_data; - gatts_data.exec_write = flag; - gatt_sr_send_req_callback(conn_id, trans_id, GATTS_REQ_TYPE_WRITE_EXEC, &gatts_data); - prep_cnt_it = tcb.prep_cnt_map.erase(prep_cnt_it); - } - } else { - for (uint8_t i = 0; i < GATT_MAX_APPS; i++) { - if (tcb.prep_cnt[i]) { - gatt_if = (tGATT_IF)(i + 1); - conn_id = gatt_create_conn_id(tcb.tcb_idx, gatt_if); - tGATTS_DATA gatts_data; - gatts_data.exec_write = flag; - gatt_sr_send_req_callback(conn_id, trans_id, GATTS_REQ_TYPE_WRITE_EXEC, &gatts_data); - tcb.prep_cnt[i] = 0; - } - } + auto prep_cnt_it = tcb.prep_cnt_map.begin(); + while (prep_cnt_it != tcb.prep_cnt_map.end()) { + gatt_if = prep_cnt_it->first; + conn_id = gatt_create_conn_id(tcb.tcb_idx, gatt_if); + tGATTS_DATA gatts_data; + gatts_data.exec_write = flag; + gatt_sr_send_req_callback(conn_id, trans_id, GATTS_REQ_TYPE_WRITE_EXEC, &gatts_data); + prep_cnt_it = tcb.prep_cnt_map.erase(prep_cnt_it); } } else { /* nothing needs to be executed , send response now */ log::warn("gatt_process_exec_write_req: no prepare write pending"); @@ -911,19 +898,10 @@ static void gatts_process_mtu_req(tGATT_TCB& tcb, uint16_t cid, uint16_t len, ui gatts_data.mtu = tcb.payload_size; /* Notify all registered application with new MTU size. Use a transaction ID */ /* of 0, as no response is allowed from applications */ - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use) { - tCONN_ID conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); - gatt_sr_send_req_callback(conn_id, 0, GATTS_REQ_TYPE_MTU, &gatts_data); - } - } - } else { - for (int i = 0; i < GATT_MAX_APPS; i++) { - if (gatt_cb.cl_rcb[i].in_use) { - tCONN_ID conn_id = gatt_create_conn_id(tcb.tcb_idx, gatt_cb.cl_rcb[i].gatt_if); - gatt_sr_send_req_callback(conn_id, 0, GATTS_REQ_TYPE_MTU, &gatts_data); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use) { + tCONN_ID conn_id = gatt_create_conn_id(tcb.tcb_idx, p_reg->gatt_if); + gatt_sr_send_req_callback(conn_id, 0, GATTS_REQ_TYPE_MTU, &gatts_data); } } } diff --git a/system/stack/gatt/gatt_utils.cc b/system/stack/gatt/gatt_utils.cc index f401be9285..28590330c5 100644 --- a/system/stack/gatt/gatt_utils.cc +++ b/system/stack/gatt/gatt_utils.cc @@ -24,7 +24,6 @@ #define LOG_TAG "gatt_utils" #include <bluetooth/log.h> -#include <com_android_bluetooth_flags.h> #include <cstdint> #include <deque> @@ -1043,21 +1042,12 @@ tGATT_REG* gatt_get_regcb(tGATT_IF gatt_if) { uint8_t ii = (uint8_t)gatt_if; tGATT_REG* p_reg = NULL; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - auto it = gatt_cb.cl_rcb_map.find(gatt_if); - if (it == gatt_cb.cl_rcb_map.end()) { - log::warn("unknown gatt_if = {}", ii); - return NULL; - } - p_reg = it->second.get(); - } else { - // Index for cl_rcb is always 1 less than gatt_if. - if (ii < 1 || ii > GATT_MAX_APPS) { - log::warn("gatt_if out of range = {}", ii); - return NULL; - } - p_reg = &gatt_cb.cl_rcb[ii - 1]; + auto it = gatt_cb.cl_rcb_map.find(gatt_if); + if (it == gatt_cb.cl_rcb_map.end()) { + log::warn("unknown gatt_if = {}", ii); + return NULL; } + p_reg = it->second.get(); if (!p_reg->in_use) { log::warn("gatt_if found but not in use."); @@ -1332,16 +1322,8 @@ tGATT_TCB* gatt_find_tcb_by_cid(uint16_t lcid) { } void gatt_sr_copy_prep_cnt_to_cback_cnt(tGATT_TCB& tcb) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, cnt] : tcb.prep_cnt_map) { - tcb.sr_cmd.cback_cnt_map[i] = 1; - } - } else { - for (uint8_t i = 0; i < GATT_MAX_APPS; i++) { - if (tcb.prep_cnt[i]) { - tcb.sr_cmd.cback_cnt[i] = 1; - } - } + for (auto& [i, cnt] : tcb.prep_cnt_map) { + tcb.sr_cmd.cback_cnt_map[i] = 1; } } @@ -1385,17 +1367,7 @@ bool gatt_sr_is_cback_cnt_zero(tGATT_TCB& tcb, uint16_t cid) { sr_cmd_p = &channel->server_outstanding_cmd_; } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - return sr_cmd_p->cback_cnt_map.empty(); - } - - for (uint8_t i = 0; i < GATT_MAX_APPS; i++) { - if (sr_cmd_p->cback_cnt[i] != 0) { - return false; - } - } - - return true; + return sr_cmd_p->cback_cnt_map.empty(); } /******************************************************************************* @@ -1407,18 +1379,7 @@ bool gatt_sr_is_cback_cnt_zero(tGATT_TCB& tcb, uint16_t cid) { * Returns True no prepare write request * ******************************************************************************/ -bool gatt_sr_is_prep_cnt_zero(tGATT_TCB& tcb) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - return tcb.prep_cnt_map.empty(); - } else { - for (uint8_t i = 0; i < GATT_MAX_APPS; i++) { - if (tcb.prep_cnt[i]) { - return false; - } - } - return true; - } -} +bool gatt_sr_is_prep_cnt_zero(tGATT_TCB& tcb) { return tcb.prep_cnt_map.empty(); } /******************************************************************************* * @@ -1430,31 +1391,15 @@ bool gatt_sr_is_prep_cnt_zero(tGATT_TCB& tcb) { * ******************************************************************************/ void gatt_sr_reset_cback_cnt(tGATT_TCB& tcb, uint16_t cid) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - if (cid == tcb.att_lcid) { - tcb.sr_cmd.cback_cnt_map.clear(); - } else { - EattChannel* channel = EattExtension::GetInstance()->FindEattChannelByCid(tcb.peer_bda, cid); - if (channel == nullptr) { - log::warn("{}, cid 0x{:02x} already disconnected", tcb.peer_bda, cid); - return; - } - channel->server_outstanding_cmd_.cback_cnt_map.clear(); - } + if (cid == tcb.att_lcid) { + tcb.sr_cmd.cback_cnt_map.clear(); } else { - for (uint8_t i = 0; i < GATT_MAX_APPS; i++) { - if (cid == tcb.att_lcid) { - tcb.sr_cmd.cback_cnt[i] = 0; - } else { - EattChannel* channel = - EattExtension::GetInstance()->FindEattChannelByCid(tcb.peer_bda, cid); - if (channel == nullptr) { - log::warn("{}, cid 0x{:02x} already disconnected", tcb.peer_bda, cid); - return; - } - channel->server_outstanding_cmd_.cback_cnt[i] = 0; - } + EattChannel* channel = EattExtension::GetInstance()->FindEattChannelByCid(tcb.peer_bda, cid); + if (channel == nullptr) { + log::warn("{}, cid 0x{:02x} already disconnected", tcb.peer_bda, cid); + return; } + channel->server_outstanding_cmd_.cback_cnt_map.clear(); } } @@ -1540,25 +1485,13 @@ void gatt_sr_update_cback_cnt(tGATT_TCB& tcb, uint16_t cid, tGATT_IF gatt_if, bo gatt_sr_reset_cback_cnt(tcb, cid); } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - if (is_inc) { - sr_cmd_p->cback_cnt_map[gatt_if]++; - } else { - auto cback_cnt_it = sr_cmd_p->cback_cnt_map.find(gatt_if); - if (cback_cnt_it != sr_cmd_p->cback_cnt_map.end()) { - if ((--cback_cnt_it->second) <= 0) { - sr_cmd_p->cback_cnt_map.erase(cback_cnt_it); - } - } - } + if (is_inc) { + sr_cmd_p->cback_cnt_map[gatt_if]++; } else { - uint8_t idx = ((uint8_t)gatt_if) - 1; - - if (is_inc) { - sr_cmd_p->cback_cnt[idx]++; - } else { - if (sr_cmd_p->cback_cnt[idx]) { - sr_cmd_p->cback_cnt[idx]--; + auto cback_cnt_it = sr_cmd_p->cback_cnt_map.find(gatt_if); + if (cback_cnt_it != sr_cmd_p->cback_cnt_map.end()) { + if ((--cback_cnt_it->second) <= 0) { + sr_cmd_p->cback_cnt_map.erase(cback_cnt_it); } } } @@ -1582,23 +1515,13 @@ void gatt_sr_update_prep_cnt(tGATT_TCB& tcb, tGATT_IF gatt_if, bool is_inc, bool if (is_reset_first) { gatt_sr_reset_prep_cnt(tcb); } - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - if (is_inc) { - tcb.prep_cnt_map[gatt_if]++; - } else { - auto prep_cnt_i = tcb.prep_cnt_map.find(gatt_if); - if (prep_cnt_i != tcb.prep_cnt_map.end()) { - if (--prep_cnt_i->second <= 0) { - tcb.prep_cnt_map.erase(prep_cnt_i); - } - } - } + if (is_inc) { + tcb.prep_cnt_map[gatt_if]++; } else { - if (is_inc) { - tcb.prep_cnt[idx]++; - } else { - if (tcb.prep_cnt[idx]) { - tcb.prep_cnt[idx]--; + auto prep_cnt_i = tcb.prep_cnt_map.find(gatt_if); + if (prep_cnt_i != tcb.prep_cnt_map.end()) { + if (--prep_cnt_i->second <= 0) { + tcb.prep_cnt_map.erase(prep_cnt_i); } } } @@ -1806,24 +1729,12 @@ static void gatt_disconnect_complete_notify_user(const RawAddress& bda, tGATT_DI tBT_TRANSPORT transport) { tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bda, transport); - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (p_reg->in_use && p_reg->app_cb.p_conn_cb) { - tCONN_ID conn_id = - p_tcb ? gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if) : GATT_INVALID_CONN_ID; - (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, bda, conn_id, kGattDisconnected, reason, - transport); - } - } - } else { - for (uint8_t i = 0; i < GATT_MAX_APPS; i++) { - tGATT_REG* p_reg = &gatt_cb.cl_rcb[i]; - if (p_reg->in_use && p_reg->app_cb.p_conn_cb) { - tCONN_ID conn_id = - p_tcb ? gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if) : GATT_INVALID_CONN_ID; - (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, bda, conn_id, kGattDisconnected, reason, - transport); - } + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (p_reg->in_use && p_reg->app_cb.p_conn_cb) { + tCONN_ID conn_id = + p_tcb ? gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if) : GATT_INVALID_CONN_ID; + (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, bda, conn_id, kGattDisconnected, reason, + transport); } } } @@ -1943,41 +1854,22 @@ uint16_t gatt_get_mtu_pref(const tGATT_REG* p_reg, const RawAddress& bda) { uint16_t gatt_get_apps_preferred_mtu(const RawAddress& bda) { uint16_t preferred_mtu = 0; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (!p_reg->in_use) { - continue; - } - - preferred_mtu = std::max(preferred_mtu, gatt_get_mtu_pref(p_reg.get(), bda)); + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (!p_reg->in_use) { + continue; } - } else { - for (auto& reg : gatt_cb.cl_rcb) { - if (!reg.in_use) { - continue; - } - preferred_mtu = std::max(preferred_mtu, gatt_get_mtu_pref(®, bda)); - } + preferred_mtu = std::max(preferred_mtu, gatt_get_mtu_pref(p_reg.get(), bda)); } return preferred_mtu; } void gatt_remove_apps_mtu_prefs(const RawAddress& bda) { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { - if (!p_reg->in_use) { - continue; - } - p_reg.get()->mtu_prefs.erase(bda); - } - } else { - for (auto& reg : gatt_cb.cl_rcb) { - if (!reg.in_use) { - continue; - } - reg.mtu_prefs.erase(bda); + for (auto& [i, p_reg] : gatt_cb.cl_rcb_map) { + if (!p_reg->in_use) { + continue; } + p_reg.get()->mtu_prefs.erase(bda); } } diff --git a/system/stack/test/gatt/gatt_sr_test.cc b/system/stack/test/gatt/gatt_sr_test.cc index 9c5eb868d0..4106579080 100644 --- a/system/stack/test/gatt/gatt_sr_test.cc +++ b/system/stack/test/gatt/gatt_sr_test.cc @@ -14,7 +14,6 @@ * limitations under the License. */ -#include <com_android_bluetooth_flags.h> #include <gtest/gtest.h> #include <cstdint> @@ -141,25 +140,16 @@ protected: tcb_.att_lcid = L2CAP_ATT_CID; el_.gatt_if = 1; - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - gatt_cb.cl_rcb_map.emplace(el_.gatt_if, std::make_unique<tGATT_REG>()); - tGATT_REG* p_reg = gatt_cb.cl_rcb_map[el_.gatt_if].get(); - p_reg->in_use = true; - p_reg->gatt_if = el_.gatt_if; - p_reg->app_cb.p_req_cb = ApplicationRequestCallback; - } else { - gatt_cb.cl_rcb[el_.gatt_if - 1].in_use = true; - gatt_cb.cl_rcb[el_.gatt_if - 1].app_cb.p_req_cb = ApplicationRequestCallback; - } + gatt_cb.cl_rcb_map.emplace(el_.gatt_if, std::make_unique<tGATT_REG>()); + tGATT_REG* p_reg = gatt_cb.cl_rcb_map[el_.gatt_if].get(); + p_reg->in_use = true; + p_reg->gatt_if = el_.gatt_if; + p_reg->app_cb.p_req_cb = ApplicationRequestCallback; test_state_ = TestMutables(); } - void TearDown() override { - if (com::android::bluetooth::flags::gatt_client_dynamic_allocation()) { - gatt_cb.cl_rcb_map.erase(el_.gatt_if); - } - } + void TearDown() override { gatt_cb.cl_rcb_map.erase(el_.gatt_if); } tGATT_TCB tcb_; tGATT_SRV_LIST_ELEM el_; |