Reducing Gatt_Connect overloads
Test: mmm packages/modules/Bluetooth
Flag: EXEMPT manual refactor
Bug: 369329192
(cherry picked from https://android-review.googlesource.com/q/commit:4e41e7ca9d06986e95965e28cde90f44fef1f190)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:78d4cfab649aa7521d48ca5387725acb5a44ed43)
Merged-In: I35c7aa3830f5dd6760955a14728440839c3a3c59
Change-Id: I35c7aa3830f5dd6760955a14728440839c3a3c59
diff --git a/system/bta/dm/bta_dm_disc.cc b/system/bta/dm/bta_dm_disc.cc
index d2e7f95..1a671c6 100644
--- a/system/bta/dm/bta_dm_disc.cc
+++ b/system/bta/dm/bta_dm_disc.cc
@@ -138,7 +138,7 @@
[](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 9327853..e2d8deb 100644
--- a/system/bta/dm/bta_dm_gatt_client.cc
+++ b/system/bta/dm/bta_dm_gatt_client.cc
@@ -101,7 +101,7 @@
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 3e2a388..a2f0d73 100644
--- a/system/bta/gatt/bta_gattc_act.cc
+++ b/system/bta/gatt/bta_gattc_act.cc
@@ -480,7 +480,7 @@
/* 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 206cc94..d4dfc50 100644
--- a/system/bta/gatt/bta_gattc_api.cc
+++ b/system/bta/gatt/bta_gattc_api.cc
@@ -133,13 +133,6 @@
* 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 @@
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 8d951ad..938e3f7 100644
--- a/system/bta/gatt/bta_gatts_act.cc
+++ b/system/bta/gatt/bta_gatts_act.cc
@@ -416,7 +416,7 @@
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 1079e81..ba60da6 100644
--- a/system/bta/include/bta_gatt_api.h
+++ b/system/bta/include/bta_gatt_api.h
@@ -499,12 +499,6 @@
******************************************************************************/
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 fb5e8dd..64de3c6 100644
--- a/system/stack/gatt/gatt_api.cc
+++ b/system/stack/gatt/gatt_api.cc
@@ -1445,13 +1445,6 @@
* 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) {
@@ -1553,25 +1546,10 @@
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) {
+ tBT_TRANSPORT transport, bool opportunistic) {
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) {
- 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 911df29..e51ddc0 100644
--- a/system/stack/include/gatt_api.h
+++ b/system/stack/include/gatt_api.h
@@ -298,6 +298,16 @@
}
}
+/* 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 @@
*
******************************************************************************/
[[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 4ac3db6..1e79e94 100644
--- a/system/test/mock/mock_bta_gattc_api.cc
+++ b/system/test/mock/mock_bta_gattc_api.cc
@@ -99,17 +99,6 @@
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 36cb3c0..307927a 100644
--- a/system/test/mock/mock_stack_gatt_api.cc
+++ b/system/test/mock/mock_stack_gatt_api.cc
@@ -241,7 +241,7 @@
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