summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Himanshu Rawat <rwt@google.com> 2024-09-27 21:16:27 +0000
committer Himanshu Rawat <rwt@google.com> 2024-09-28 00:23:07 +0000
commit4e41e7ca9d06986e95965e28cde90f44fef1f190 (patch)
tree2b51a072ec42ab72dce8588c33110b94890e0eaf
parentcc53561d4ec107b0d1ed354ccdda8270c542b0ee (diff)
Reducing Gatt_Connect overloads
Test: mmm packages/modules/Bluetooth Flag: EXEMPT manual refactor Bug: 369329192 Change-Id: I35c7aa3830f5dd6760955a14728440839c3a3c59
-rw-r--r--system/bta/dm/bta_dm_disc.cc2
-rw-r--r--system/bta/dm/bta_dm_gatt_client.cc2
-rw-r--r--system/bta/gatt/bta_gattc_act.cc2
-rw-r--r--system/bta/gatt/bta_gattc_api.cc19
-rw-r--r--system/bta/gatt/bta_gatts_act.cc2
-rw-r--r--system/bta/include/bta_gatt_api.h6
-rw-r--r--system/stack/gatt/gatt_api.cc26
-rw-r--r--system/stack/include/gatt_api.h27
-rw-r--r--system/test/mock/mock_bta_gattc_api.cc11
-rw-r--r--system/test/mock/mock_stack_gatt_api.cc2
10 files changed, 23 insertions, 76 deletions
diff --git a/system/bta/dm/bta_dm_disc.cc b/system/bta/dm/bta_dm_disc.cc
index 980f2d45f2..f22870f900 100644
--- a/system/bta/dm/bta_dm_disc.cc
+++ b/system/bta/dm/bta_dm_disc.cc
@@ -141,7 +141,7 @@ struct gatt_interface_t {
[](tGATT_IF client_if, const RawAddress& remote_bda,
tBTM_BLE_CONN_TYPE connection_type, bool opportunistic, uint16_t preferred_mtu) {
BTA_GATTC_Open(client_if, remote_bda, BLE_ADDR_PUBLIC, connection_type,
- BT_TRANSPORT_LE, opportunistic, 1, preferred_mtu);
+ BT_TRANSPORT_LE, opportunistic, LE_PHY_1M, preferred_mtu);
},
};
diff --git a/system/bta/dm/bta_dm_gatt_client.cc b/system/bta/dm/bta_dm_gatt_client.cc
index c9fec2d392..63ef540afa 100644
--- a/system/bta/dm/bta_dm_gatt_client.cc
+++ b/system/bta/dm/bta_dm_gatt_client.cc
@@ -104,7 +104,7 @@ gatt_interface_t default_gatt_interface = {
ADDRESS_TO_LOGGABLE_CSTR(remote_bda), client_if, connection_type,
(opportunistic) ? 'T' : 'F'));
BTA_GATTC_Open(client_if, remote_bda, BLE_ADDR_PUBLIC, connection_type,
- BT_TRANSPORT_LE, opportunistic, 1, preferred_mtu);
+ BT_TRANSPORT_LE, opportunistic, LE_PHY_1M, preferred_mtu);
},
};
diff --git a/system/bta/gatt/bta_gattc_act.cc b/system/bta/gatt/bta_gattc_act.cc
index 3437f15266..636951cb8c 100644
--- a/system/bta/gatt/bta_gattc_act.cc
+++ b/system/bta/gatt/bta_gattc_act.cc
@@ -485,7 +485,7 @@ static void bta_gattc_init_bk_conn(const tBTA_GATTC_API_OPEN* p_data, tBTA_GATTC
/* always call open to hold a connection */
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, BLE_ADDR_PUBLIC, p_data->connection_type,
- p_data->transport, false, 1, p_data->preferred_mtu)) {
+ p_data->transport, false, LE_PHY_1M, p_data->preferred_mtu)) {
log::error("Unable to connect to remote bd_addr={}", p_data->remote_bda);
bta_gattc_send_open_cback(p_clreg, GATT_ILLEGAL_PARAMETER, p_data->remote_bda,
GATT_INVALID_CONN_ID, BT_TRANSPORT_LE, 0);
diff --git a/system/bta/gatt/bta_gattc_api.cc b/system/bta/gatt/bta_gattc_api.cc
index 206cc94364..d4dfc500b1 100644
--- a/system/bta/gatt/bta_gattc_api.cc
+++ b/system/bta/gatt/bta_gattc_api.cc
@@ -133,13 +133,6 @@ void BTA_GATTC_AppDeregister(tGATT_IF client_if) {
* opportunistic, and don't impact the disconnection timer
*
******************************************************************************/
-void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
- tBTM_BLE_CONN_TYPE connection_type, bool opportunistic) {
- constexpr uint8_t kPhyLe1M = 0x01; // From the old controller shim.
- uint8_t phy = kPhyLe1M;
- BTA_GATTC_Open(client_if, remote_bda, connection_type, BT_TRANSPORT_LE, opportunistic, phy);
-}
-
void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_TYPE addr_type,
tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
uint8_t initiating_phys, uint16_t preferred_mtu) {
@@ -164,18 +157,10 @@ void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_
post_on_bt_main([data]() { bta_gattc_process_api_open(&data); });
}
-void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_TYPE addr_type,
- tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
- uint8_t initiating_phys) {
- BTA_GATTC_Open(client_if, remote_bda, addr_type, connection_type, transport, opportunistic,
- initiating_phys, 0);
-}
-
void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
- tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
- uint8_t initiating_phys) {
+ tBTM_BLE_CONN_TYPE connection_type, bool opportunistic) {
BTA_GATTC_Open(client_if, remote_bda, BLE_ADDR_PUBLIC, connection_type, BT_TRANSPORT_LE,
- opportunistic, initiating_phys);
+ opportunistic, LE_PHY_1M, 0);
}
/*******************************************************************************
diff --git a/system/bta/gatt/bta_gatts_act.cc b/system/bta/gatt/bta_gatts_act.cc
index 47abf7106d..78bfb8bfcf 100644
--- a/system/bta/gatt/bta_gatts_act.cc
+++ b/system/bta/gatt/bta_gatts_act.cc
@@ -419,7 +419,7 @@ void bta_gatts_open(tBTA_GATTS_CB* /* p_cb */, tBTA_GATTS_DATA* p_msg) {
if (com::android::bluetooth::flags::ble_gatt_server_use_address_type_in_connection()) {
success = GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda,
p_msg->api_open.remote_addr_type, p_msg->api_open.connection_type,
- p_msg->api_open.transport, false);
+ p_msg->api_open.transport, false, LE_PHY_1M, 0);
} else {
success = GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda,
p_msg->api_open.connection_type, p_msg->api_open.transport, false);
diff --git a/system/bta/include/bta_gatt_api.h b/system/bta/include/bta_gatt_api.h
index 1079e813ad..ba60da6ee4 100644
--- a/system/bta/include/bta_gatt_api.h
+++ b/system/bta/include/bta_gatt_api.h
@@ -499,12 +499,6 @@ void BTA_GATTC_AppDeregister(tGATT_IF client_if);
******************************************************************************/
void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
tBTM_BLE_CONN_TYPE connection_type, bool opportunistic);
-void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda,
- tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
- uint8_t initiating_phys);
-void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_TYPE addr_type,
- tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
- uint8_t initiating_phys);
void BTA_GATTC_Open(tGATT_IF client_if, const RawAddress& remote_bda, tBLE_ADDR_TYPE addr_type,
tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
uint8_t initiating_phys, uint16_t preferred_mtu);
diff --git a/system/stack/gatt/gatt_api.cc b/system/stack/gatt/gatt_api.cc
index 13705aace0..a5a863708f 100644
--- a/system/stack/gatt/gatt_api.cc
+++ b/system/stack/gatt/gatt_api.cc
@@ -1448,13 +1448,6 @@ void GATT_StartIf(tGATT_IF gatt_if) {
* failure.
*
******************************************************************************/
-bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBTM_BLE_CONN_TYPE connection_type,
- tBT_TRANSPORT transport, bool opportunistic) {
- constexpr uint8_t kPhyLe1M = 0x01; // From the old controller shim.
- uint8_t phy = kPhyLe1M;
- return GATT_Connect(gatt_if, bd_addr, connection_type, transport, opportunistic, phy);
-}
-
bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic,
uint8_t initiating_phys, uint16_t preferred_mtu) {
@@ -1556,25 +1549,10 @@ bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBLE_ADDR_TYPE ad
return ret;
}
-bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
- tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport, bool opportunistic) {
- constexpr uint8_t kPhyLe1M = 0x01; // From the old controller shim.
- uint8_t phy = kPhyLe1M;
- return GATT_Connect(gatt_if, bd_addr, addr_type, connection_type, transport, opportunistic, phy,
- 0);
-}
-
-bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBTM_BLE_CONN_TYPE connection_type,
- tBT_TRANSPORT transport, bool opportunistic, uint8_t initiating_phys) {
- return GATT_Connect(gatt_if, bd_addr, BLE_ADDR_PUBLIC, connection_type, transport, opportunistic,
- initiating_phys, 0);
-}
-
bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBTM_BLE_CONN_TYPE connection_type,
- tBT_TRANSPORT transport, bool opportunistic, uint8_t initiating_phys,
- uint16_t preferred_mtu) {
+ tBT_TRANSPORT transport, bool opportunistic) {
return GATT_Connect(gatt_if, bd_addr, BLE_ADDR_PUBLIC, connection_type, transport, opportunistic,
- initiating_phys, preferred_mtu);
+ LE_PHY_1M, 0);
}
/*******************************************************************************
diff --git a/system/stack/include/gatt_api.h b/system/stack/include/gatt_api.h
index 911df29023..e51ddc0825 100644
--- a/system/stack/include/gatt_api.h
+++ b/system/stack/include/gatt_api.h
@@ -298,6 +298,16 @@ inline std::string gatt_disconnection_reason_text(const tGATT_DISCONN_REASON& re
}
}
+/* LE PHY bits */
+constexpr uint8_t LE_PHY_1M_BIT = 0;
+constexpr uint8_t LE_PHY_2M_BIT = 1;
+constexpr uint8_t LE_PHY_CODED_BIT = 2;
+
+/* LE PHY bit mask values */
+constexpr uint8_t LE_PHY_1M = (1 << LE_PHY_1M_BIT);
+constexpr uint8_t LE_PHY_2M = (1 << LE_PHY_2M_BIT);
+constexpr uint8_t LE_PHY_CODED = (1 << LE_PHY_CODED_BIT);
+
/* MAX GATT MTU size
*/
#ifndef GATT_MAX_MTU_SIZE
@@ -1166,22 +1176,13 @@ void GATT_StartIf(tGATT_IF gatt_if);
*
******************************************************************************/
[[nodiscard]] bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr,
- tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport,
- bool opportunistic);
-[[nodiscard]] bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr,
- tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport,
- bool opportunistic, uint8_t initiating_phys);
-[[nodiscard]] bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr,
- tBLE_ADDR_TYPE addr_type, tBTM_BLE_CONN_TYPE connection_type,
- tBT_TRANSPORT transport, bool opportunistic);
-[[nodiscard]] bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr,
- tBLE_ADDR_TYPE addr_type, tBTM_BLE_CONN_TYPE connection_type,
- tBT_TRANSPORT transport, bool opportunistic,
- uint8_t initiating_phys);
-[[nodiscard]] bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr,
tBLE_ADDR_TYPE addr_type, tBTM_BLE_CONN_TYPE connection_type,
tBT_TRANSPORT transport, bool opportunistic,
uint8_t initiating_phys, uint16_t preferred_transport);
+[[nodiscard]] bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr,
+ tBTM_BLE_CONN_TYPE connection_type, tBT_TRANSPORT transport,
+ bool opportunistic);
+
/*******************************************************************************
*
* Function GATT_CancelConnect
diff --git a/system/test/mock/mock_bta_gattc_api.cc b/system/test/mock/mock_bta_gattc_api.cc
index 686868455c..7bea0245ce 100644
--- a/system/test/mock/mock_bta_gattc_api.cc
+++ b/system/test/mock/mock_bta_gattc_api.cc
@@ -102,17 +102,6 @@ void BTA_GATTC_Open(tGATT_IF /* client_if */, const RawAddress& /* remote_bda */
inc_func_call_count(__func__);
}
void BTA_GATTC_Open(tGATT_IF /* client_if */, const RawAddress& /* remote_bda */,
- tBTM_BLE_CONN_TYPE /* connection_type */, tBT_TRANSPORT /* transport */,
- bool /* opportunistic */, uint8_t /* initiating_phys */) {
- inc_func_call_count(__func__);
-}
-void BTA_GATTC_Open(tGATT_IF /* client_if */, const RawAddress& /* remote_bda */,
- tBLE_ADDR_TYPE /* addr_type */, tBTM_BLE_CONN_TYPE /* connection_type */,
- tBT_TRANSPORT /* transport */, bool /* opportunistic */,
- uint8_t /* initiating_phys */) {
- inc_func_call_count(__func__);
-}
-void BTA_GATTC_Open(tGATT_IF /* client_if */, const RawAddress& /* remote_bda */,
tBLE_ADDR_TYPE /* addr_type */, tBTM_BLE_CONN_TYPE /* connection_type */,
tBT_TRANSPORT /* transport */, bool /* opportunistic */,
uint8_t /* initiating_phys */, uint16_t /* preferred_mtu */) {
diff --git a/system/test/mock/mock_stack_gatt_api.cc b/system/test/mock/mock_stack_gatt_api.cc
index 88b7af29a0..cde6c3fa6b 100644
--- a/system/test/mock/mock_stack_gatt_api.cc
+++ b/system/test/mock/mock_stack_gatt_api.cc
@@ -244,7 +244,7 @@ bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBTM_BLE_CONN_TYP
tBT_TRANSPORT transport, bool opportunistic) {
inc_func_call_count(__func__);
return test::mock::stack_gatt_api::GATT_Connect(gatt_if, bd_addr, 0, connection_type, transport,
- opportunistic, 0, 0);
+ opportunistic, LE_PHY_1M, 0);
}
// END mockcify generation