Use references in GATT client/server API (2/3)
This allows to get rid of some unnecessary null checks, and guarantee
proper values are passed.
Test: compilation test
Change-Id: I1b790dba0cfc3ab02984c3911d83a6f413a1e7e6
diff --git a/btif/src/btif_gatt_client.cc b/btif/src/btif_gatt_client.cc
index 136ffe4..debdaac 100644
--- a/btif/src/btif_gatt_client.cc
+++ b/btif/src/btif_gatt_client.cc
@@ -56,8 +56,8 @@
using base::Owned;
using std::vector;
-extern bt_status_t btif_gattc_test_command_impl(int command,
- btgatt_test_params_t* params);
+extern bt_status_t btif_gattc_test_command_impl(
+ int command, const btgatt_test_params_t* params);
extern const btgatt_callbacks_t* bt_gatt_callbacks;
/*******************************************************************************
@@ -126,7 +126,7 @@
data.len = p_data->notify.len;
HAL_CBACK(bt_gatt_callbacks, client->notify_cb, p_data->notify.conn_id,
- &data);
+ data);
if (p_data->notify.is_notify == false)
BTA_GATTC_SendIndConfirm(p_data->notify.conn_id, p_data->notify.handle);
@@ -138,7 +138,7 @@
DVLOG(1) << "BTA_GATTC_OPEN_EVT " << p_data->open.remote_bda;
HAL_CBACK(bt_gatt_callbacks, client->open_cb, p_data->open.conn_id,
p_data->open.status, p_data->open.client_if,
- &p_data->open.remote_bda);
+ p_data->open.remote_bda);
if (GATT_DEF_BLE_MTU_SIZE != p_data->open.mtu && p_data->open.mtu) {
HAL_CBACK(bt_gatt_callbacks, client->configure_mtu_cb,
@@ -154,7 +154,7 @@
case BTA_GATTC_CLOSE_EVT: {
HAL_CBACK(bt_gatt_callbacks, client->close_cb, p_data->close.conn_id,
p_data->status, p_data->close.client_if,
- &p_data->close.remote_bda);
+ p_data->close.remote_bda);
break;
}
@@ -207,21 +207,19 @@
void btm_read_rssi_cb(tBTM_RSSI_RESULTS* p_result) {
if (!p_result) return;
- bt_bdaddr_t* addr = new bt_bdaddr_t;
- *addr = p_result->rem_bda;
CLI_CBACK_IN_JNI(read_remote_rssi_cb, rssi_request_client_if,
- base::Owned(addr), p_result->rssi, p_result->status);
+ p_result->rem_bda, p_result->rssi, p_result->status);
}
/*******************************************************************************
* Client API Functions
******************************************************************************/
-bt_status_t btif_gattc_register_app(bt_uuid_t* uuid) {
+bt_status_t btif_gattc_register_app(const bt_uuid_t& uuid) {
CHECK_BTGATT_INIT();
tBT_UUID bt_uuid;
- btif_to_bta_uuid(&bt_uuid, uuid);
+ btif_to_bta_uuid(&bt_uuid, &uuid);
return do_in_jni_thread(Bind(
[](tBT_UUID bt_uuid) {
@@ -234,7 +232,7 @@
bt_uuid_t app_uuid;
bta_to_btif_uuid(&app_uuid, &bt_uuid);
HAL_CBACK(bt_gatt_callbacks, client->register_client_cb,
- status, client_id, &app_uuid);
+ status, client_id, app_uuid);
},
bt_uuid, client_id, status));
},
@@ -276,7 +274,7 @@
BTM_BleGetVendorCapabilities(&vnd_capabilities);
if (!vnd_capabilities.rpa_offloading) {
HAL_CBACK(bt_gatt_callbacks, client->open_cb, 0, BT_STATUS_UNSUPPORTED,
- client_if, &address);
+ client_if, address);
return;
}
}
@@ -312,12 +310,12 @@
initiating_phys);
}
-bt_status_t btif_gattc_open(int client_if, const bt_bdaddr_t* bd_addr,
+bt_status_t btif_gattc_open(int client_if, const bt_bdaddr_t& bd_addr,
bool is_direct, int transport,
int initiating_phys) {
CHECK_BTGATT_INIT();
// Closure will own this value and free it.
- return do_in_jni_thread(Bind(&btif_gattc_open_impl, client_if, *bd_addr,
+ return do_in_jni_thread(Bind(&btif_gattc_open_impl, client_if, bd_addr,
is_direct, transport, initiating_phys));
}
@@ -332,19 +330,20 @@
BTA_GATTC_CancelOpen(client_if, address, false);
}
-bt_status_t btif_gattc_close(int client_if, const bt_bdaddr_t* bd_addr,
+bt_status_t btif_gattc_close(int client_if, const bt_bdaddr_t& bd_addr,
int conn_id) {
CHECK_BTGATT_INIT();
return do_in_jni_thread(
- Bind(&btif_gattc_close_impl, client_if, *bd_addr, conn_id));
+ Bind(&btif_gattc_close_impl, client_if, bd_addr, conn_id));
}
-bt_status_t btif_gattc_refresh(int client_if, const bt_bdaddr_t* bd_addr) {
+bt_status_t btif_gattc_refresh(int client_if, const bt_bdaddr_t& bd_addr) {
CHECK_BTGATT_INIT();
- return do_in_jni_thread(Bind(&BTA_GATTC_Refresh, *bd_addr));
+ return do_in_jni_thread(Bind(&BTA_GATTC_Refresh, bd_addr));
}
-bt_status_t btif_gattc_search_service(int conn_id, bt_uuid_t* filter_uuid) {
+bt_status_t btif_gattc_search_service(int conn_id,
+ const bt_uuid_t* filter_uuid) {
CHECK_BTGATT_INIT();
if (filter_uuid) {
@@ -358,11 +357,9 @@
}
}
-void btif_gattc_discover_service_by_uuid(int conn_id, bt_uuid_t* p_uuid) {
- LOG_ASSERT(p_uuid);
-
+void btif_gattc_discover_service_by_uuid(int conn_id, const bt_uuid_t& p_uuid) {
tBT_UUID* uuid = new tBT_UUID;
- btif_to_bta_uuid(uuid, p_uuid);
+ btif_to_bta_uuid(uuid, &p_uuid);
do_in_jni_thread(
Bind(&BTA_GATTC_DiscoverServiceByUuid, conn_id, base::Owned(uuid)));
}
@@ -420,12 +417,12 @@
base::Owned(params));
}
-bt_status_t btif_gattc_read_using_char_uuid(int conn_id, bt_uuid_t* uuid,
+bt_status_t btif_gattc_read_using_char_uuid(int conn_id, const bt_uuid_t& uuid,
uint16_t s_handle,
uint16_t e_handle, int auth_req) {
CHECK_BTGATT_INIT();
tBT_UUID bt_uuid;
- btif_to_bta_uuid(&bt_uuid, uuid);
+ btif_to_bta_uuid(&bt_uuid, &uuid);
return do_in_jni_thread(Bind(&BTA_GATTC_ReadUsingCharUuid, conn_id, bt_uuid,
s_handle, e_handle, auth_req,
read_using_char_uuid_cb, nullptr));
@@ -433,18 +430,15 @@
void read_desc_cb(uint16_t conn_id, tGATT_STATUS status, uint16_t handle,
uint16_t len, uint8_t* value, void* data) {
- btgatt_read_params_t* params = new btgatt_read_params_t;
- params->value_type = 0x00 /* GATTC_READ_VALUE_TYPE_VALUE */;
- params->status = status;
- params->handle = handle;
- params->value.len = len;
+ btgatt_read_params_t params;
+ params.value_type = 0x00 /* GATTC_READ_VALUE_TYPE_VALUE */;
+ params.status = status;
+ params.handle = handle;
+ params.value.len = len;
CHECK(len <= BTGATT_MAX_ATTR_LEN);
- if (len > 0) memcpy(params->value.value, value, len);
+ if (len > 0) memcpy(params.value.value, value, len);
- // clang-tidy analyzer complains about |params| is leaked. It doesn't know
- // that |param| will be freed by the callback function.
- CLI_CBACK_IN_JNI(read_descriptor_cb, conn_id, status,
- base::Owned(params)); /* NOLINT */
+ CLI_CBACK_IN_JNI(read_descriptor_cb, conn_id, status, params);
}
bt_status_t btif_gattc_read_char_descr(int conn_id, uint16_t handle,
@@ -493,7 +487,7 @@
}
void btif_gattc_reg_for_notification_impl(tBTA_GATTC_IF client_if,
- const bt_bdaddr_t bda,
+ const bt_bdaddr_t& bda,
uint16_t handle) {
tBTA_GATT_STATUS status =
BTA_GATTC_RegisterForNotifications(client_if, bda, handle);
@@ -504,17 +498,17 @@
}
bt_status_t btif_gattc_reg_for_notification(int client_if,
- const bt_bdaddr_t* bd_addr,
+ const bt_bdaddr_t& bd_addr,
uint16_t handle) {
CHECK_BTGATT_INIT();
return do_in_jni_thread(
Bind(base::IgnoreResult(&btif_gattc_reg_for_notification_impl), client_if,
- *bd_addr, handle));
+ bd_addr, handle));
}
void btif_gattc_dereg_for_notification_impl(tBTA_GATTC_IF client_if,
- const bt_bdaddr_t bda,
+ const bt_bdaddr_t& bda,
uint16_t handle) {
tBTA_GATT_STATUS status =
BTA_GATTC_DeregisterForNotifications(client_if, bda, handle);
@@ -525,21 +519,21 @@
}
bt_status_t btif_gattc_dereg_for_notification(int client_if,
- const bt_bdaddr_t* bd_addr,
+ const bt_bdaddr_t& bd_addr,
uint16_t handle) {
CHECK_BTGATT_INIT();
return do_in_jni_thread(
Bind(base::IgnoreResult(&btif_gattc_dereg_for_notification_impl),
- client_if, *bd_addr, handle));
+ client_if, bd_addr, handle));
}
bt_status_t btif_gattc_read_remote_rssi(int client_if,
- const bt_bdaddr_t* bd_addr) {
+ const bt_bdaddr_t& bd_addr) {
CHECK_BTGATT_INIT();
rssi_request_client_if = client_if;
- return do_in_jni_thread(Bind(base::IgnoreResult(&BTM_ReadRSSI), *bd_addr,
+ return do_in_jni_thread(Bind(base::IgnoreResult(&BTM_ReadRSSI), bd_addr,
(tBTM_CMPL_CB*)btm_read_rssi_cb));
}
@@ -560,12 +554,12 @@
timeout);
}
-bt_status_t btif_gattc_conn_parameter_update(const bt_bdaddr_t* bd_addr,
+bt_status_t btif_gattc_conn_parameter_update(const bt_bdaddr_t& bd_addr,
int min_interval, int max_interval,
int latency, int timeout) {
CHECK_BTGATT_INIT();
return do_in_jni_thread(
- Bind(base::IgnoreResult(&btif_gattc_conn_parameter_update_impl), *bd_addr,
+ Bind(base::IgnoreResult(&btif_gattc_conn_parameter_update_impl), bd_addr,
min_interval, max_interval, latency, timeout));
}
@@ -587,18 +581,19 @@
return BT_STATUS_SUCCESS;
}
-int btif_gattc_get_device_type(const bt_bdaddr_t* bd_addr) {
+int btif_gattc_get_device_type(const bt_bdaddr_t& bd_addr) {
int device_type = 0;
char bd_addr_str[18] = {0};
- bdaddr_to_string(bd_addr, bd_addr_str, sizeof(bd_addr_str));
+ bdaddr_to_string(&bd_addr, bd_addr_str, sizeof(bd_addr_str));
if (btif_config_get_int(bd_addr_str, "DevType", &device_type))
return device_type;
return 0;
}
-bt_status_t btif_gattc_test_command(int command, btgatt_test_params_t* params) {
- return btif_gattc_test_command_impl(command, params);
+bt_status_t btif_gattc_test_command(int command,
+ const btgatt_test_params_t& params) {
+ return btif_gattc_test_command_impl(command, ¶ms);
}
} // namespace
diff --git a/btif/src/btif_gatt_server.cc b/btif/src/btif_gatt_server.cc
index ed7ad73..f72e028 100644
--- a/btif/src/btif_gatt_server.cc
+++ b/btif/src/btif_gatt_server.cc
@@ -131,7 +131,7 @@
bt_uuid_t app_uuid;
bta_to_btif_uuid(&app_uuid, &p_data->reg_oper.uuid);
HAL_CBACK(bt_gatt_callbacks, server->register_server_cb,
- p_data->reg_oper.status, p_data->reg_oper.server_if, &app_uuid);
+ p_data->reg_oper.status, p_data->reg_oper.server_if, app_uuid);
break;
}
@@ -143,13 +143,13 @@
p_data->conn.transport);
HAL_CBACK(bt_gatt_callbacks, server->connection_cb, p_data->conn.conn_id,
- p_data->conn.server_if, true, &p_data->conn.remote_bda);
+ p_data->conn.server_if, true, p_data->conn.remote_bda);
break;
}
case BTA_GATTS_DISCONNECT_EVT: {
HAL_CBACK(bt_gatt_callbacks, server->connection_cb, p_data->conn.conn_id,
- p_data->conn.server_if, false, &p_data->conn.remote_bda);
+ p_data->conn.server_if, false, p_data->conn.remote_bda);
break;
}
@@ -168,7 +168,7 @@
case BTA_GATTS_READ_CHARACTERISTIC_EVT: {
HAL_CBACK(bt_gatt_callbacks, server->request_read_characteristic_cb,
p_data->req_data.conn_id, p_data->req_data.trans_id,
- &p_data->req_data.remote_bda,
+ p_data->req_data.remote_bda,
p_data->req_data.p_data->read_req.handle,
p_data->req_data.p_data->read_req.offset,
p_data->req_data.p_data->read_req.is_long);
@@ -178,7 +178,7 @@
case BTA_GATTS_READ_DESCRIPTOR_EVT: {
HAL_CBACK(bt_gatt_callbacks, server->request_read_descriptor_cb,
p_data->req_data.conn_id, p_data->req_data.trans_id,
- &p_data->req_data.remote_bda,
+ p_data->req_data.remote_bda,
p_data->req_data.p_data->read_req.handle,
p_data->req_data.p_data->read_req.offset,
p_data->req_data.p_data->read_req.is_long);
@@ -190,7 +190,7 @@
vector<uint8_t> value(req.value, req.value + req.len);
HAL_CBACK(bt_gatt_callbacks, server->request_write_characteristic_cb,
p_data->req_data.conn_id, p_data->req_data.trans_id,
- &p_data->req_data.remote_bda, req.handle, req.offset,
+ p_data->req_data.remote_bda, req.handle, req.offset,
req.need_rsp, req.is_prep, value);
break;
}
@@ -200,7 +200,7 @@
vector<uint8_t> value(req.value, req.value + req.len);
HAL_CBACK(bt_gatt_callbacks, server->request_write_descriptor_cb,
p_data->req_data.conn_id, p_data->req_data.trans_id,
- &p_data->req_data.remote_bda, req.handle, req.offset,
+ p_data->req_data.remote_bda, req.handle, req.offset,
req.need_rsp, req.is_prep, value);
break;
}
@@ -208,7 +208,7 @@
case BTA_GATTS_EXEC_WRITE_EVT: {
HAL_CBACK(bt_gatt_callbacks, server->request_exec_write_cb,
p_data->req_data.conn_id, p_data->req_data.trans_id,
- &p_data->req_data.remote_bda,
+ p_data->req_data.remote_bda,
p_data->req_data.p_data->exec_write);
break;
}
@@ -266,10 +266,10 @@
/*******************************************************************************
* Server API Functions
******************************************************************************/
-static bt_status_t btif_gatts_register_app(bt_uuid_t* bt_uuid) {
+static bt_status_t btif_gatts_register_app(const bt_uuid_t& bt_uuid) {
CHECK_BTGATT_INIT();
tBT_UUID* uuid = new tBT_UUID;
- btif_to_bta_uuid(uuid, bt_uuid);
+ btif_to_bta_uuid(uuid, &bt_uuid);
return do_in_jni_thread(
Bind(&BTA_GATTS_AppRegister, base::Owned(uuid), &btapp_gatts_cback));
@@ -280,7 +280,7 @@
return do_in_jni_thread(Bind(&BTA_GATTS_AppDeregister, server_if));
}
-static void btif_gatts_open_impl(int server_if, bt_bdaddr_t address,
+static void btif_gatts_open_impl(int server_if, const bt_bdaddr_t& address,
bool is_direct, int transport_param) {
// Ensure device is in inquiry database
int addr_type = 0;
@@ -322,11 +322,11 @@
BTA_GATTS_Open(server_if, address, is_direct, transport);
}
-static bt_status_t btif_gatts_open(int server_if, const bt_bdaddr_t* bd_addr,
+static bt_status_t btif_gatts_open(int server_if, const bt_bdaddr_t& bd_addr,
bool is_direct, int transport) {
CHECK_BTGATT_INIT();
return do_in_jni_thread(
- Bind(&btif_gatts_open_impl, server_if, *bd_addr, is_direct, transport));
+ Bind(&btif_gatts_open_impl, server_if, bd_addr, is_direct, transport));
}
static void btif_gatts_close_impl(int server_if, const bt_bdaddr_t& address,
@@ -341,11 +341,11 @@
BTA_GATTS_CancelOpen(server_if, address, false);
}
-static bt_status_t btif_gatts_close(int server_if, const bt_bdaddr_t* bd_addr,
+static bt_status_t btif_gatts_close(int server_if, const bt_bdaddr_t& bd_addr,
int conn_id) {
CHECK_BTGATT_INIT();
return do_in_jni_thread(
- Bind(&btif_gatts_close_impl, server_if, *bd_addr, conn_id));
+ Bind(&btif_gatts_close_impl, server_if, bd_addr, conn_id));
}
static void add_service_impl(int server_if,
@@ -415,10 +415,10 @@
static bt_status_t btif_gatts_send_response(int conn_id, int trans_id,
int status,
- btgatt_response_t* response) {
+ const btgatt_response_t& response) {
CHECK_BTGATT_INIT();
return do_in_jni_thread(Bind(&btif_gatts_send_response_impl, conn_id,
- trans_id, status, *response));
+ trans_id, status, response));
}
static bt_status_t btif_gatts_set_preferred_phy(const bt_bdaddr_t& bd_addr,
diff --git a/btif/src/btif_gatt_test.cc b/btif/src/btif_gatt_test.cc
index 489eb5d..b1552e2 100644
--- a/btif/src/btif_gatt_test.cc
+++ b/btif/src/btif_gatt_test.cc
@@ -199,7 +199,7 @@
******************************************************************************/
bt_status_t btif_gattc_test_command_impl(int command,
- btgatt_test_params_t* params) {
+ const btgatt_test_params_t* params) {
switch (command) {
case 0x01: /* Enable */
{
diff --git a/service/gatt_client.cc b/service/gatt_client.cc
index 0567dd7..80f5ebf 100644
--- a/service/gatt_client.cc
+++ b/service/gatt_client.cc
@@ -68,7 +68,7 @@
hal::BluetoothGattInterface::Get()->GetClientHALInterface();
bt_uuid_t app_uuid = uuid.GetBlueDroid();
- if (hal_iface->register_client(&app_uuid) != BT_STATUS_SUCCESS) return false;
+ if (hal_iface->register_client(app_uuid) != BT_STATUS_SUCCESS) return false;
pending_calls_[uuid] = callback;
diff --git a/service/gatt_server.cc b/service/gatt_server.cc
index 79d9c35..d2550cd 100644
--- a/service/gatt_server.cc
+++ b/service/gatt_server.cc
@@ -159,7 +159,7 @@
bt_status_t result =
hal::BluetoothGattInterface::Get()
->GetServerHALInterface()
- ->send_response(connection->conn_id, request_id, error, &response);
+ ->send_response(connection->conn_id, request_id, error, response);
if (result != BT_STATUS_SUCCESS) {
LOG(ERROR) << "Failed to initiate call to send GATT response";
return false;
@@ -583,7 +583,7 @@
hal::BluetoothGattInterface::Get()->GetServerHALInterface();
bt_uuid_t app_uuid = uuid.GetBlueDroid();
- if (hal_iface->register_server(&app_uuid) != BT_STATUS_SUCCESS) return false;
+ if (hal_iface->register_server(app_uuid) != BT_STATUS_SUCCESS) return false;
pending_calls_[uuid] = callback;
diff --git a/service/gatt_server_old.cc b/service/gatt_server_old.cc
index d32ac8f..eadc13a 100644
--- a/service/gatt_server_old.cc
+++ b/service/gatt_server_old.cc
@@ -129,13 +129,14 @@
namespace {
/** Callback invoked in response to register_server */
-void RegisterServerCallback(int status, int server_if, bt_uuid_t* app_uuid) {
+void RegisterServerCallback(int status, int server_if,
+ const bt_uuid_t& app_uuid) {
LOG_INFO(LOG_TAG, "%s: status:%d server_if:%d app_uuid:%p", __func__, status,
- server_if, app_uuid);
+ server_if, &app_uuid);
g_internal->server_if = server_if;
pending_svc_decl.push_back(
- {.type = BTGATT_DB_PRIMARY_SERVICE, .uuid = *app_uuid});
+ {.type = BTGATT_DB_PRIMARY_SERVICE, .uuid = app_uuid});
}
void ServiceAddedCallback(int status, int server_if,
@@ -197,13 +198,13 @@
bt_uuid_t client_id = service[0].uuid;
++client_id.uu[15];
- bt_status_t btstat = g_internal->gatt->client->register_client(&client_id);
+ bt_status_t btstat = g_internal->gatt->client->register_client(client_id);
if (btstat != BT_STATUS_SUCCESS) {
LOG_ERROR(LOG_TAG, "%s: Failed to register client", __func__);
}
}
-void RequestReadCallback(int conn_id, int trans_id, bt_bdaddr_t* bda,
+void RequestReadCallback(int conn_id, int trans_id, const bt_bdaddr_t& bda,
int attr_handle, int attribute_offset_octets,
bool is_long) {
std::lock_guard<std::mutex> lock(g_internal->lock);
@@ -223,7 +224,7 @@
const size_t blob_remaining = ch.blob.size() - blob_offset_octets;
const size_t attribute_size = std::min(kMaxGattAttributeSize, blob_remaining);
- std::string addr(BtAddrString(bda));
+ std::string addr(BtAddrString(&bda));
LOG_INFO(LOG_TAG,
"%s: connection:%d (%s) reading attr:%d attribute_offset_octets:%d "
"blob_section:%u (is_long:%u)",
@@ -243,13 +244,13 @@
response.attr_value.handle = attr_handle;
response.attr_value.offset = attribute_offset_octets;
response.attr_value.auth_req = 0;
- g_internal->gatt->server->send_response(conn_id, trans_id, 0, &response);
+ g_internal->gatt->server->send_response(conn_id, trans_id, 0, response);
}
-void RequestWriteCallback(int conn_id, int trans_id, bt_bdaddr_t* bda,
+void RequestWriteCallback(int conn_id, int trans_id, const bt_bdaddr_t& bda,
int attr_handle, int attribute_offset, bool need_rsp,
bool is_prep, std::vector<uint8_t> value) {
- std::string addr(BtAddrString(bda));
+ std::string addr(BtAddrString(&bda));
LOG_INFO(LOG_TAG,
"%s: connection:%d (%s:trans:%d) write attr:%d attribute_offset:%d "
"length:%zu "
@@ -299,19 +300,19 @@
// Provide written data back to sender for the response.
// Remote stacks use this to validate the success of the write.
std::copy(value.begin(), value.end(), response.attr_value.value);
- g_internal->gatt->server->send_response(conn_id, trans_id, 0, &response);
+ g_internal->gatt->server->send_response(conn_id, trans_id, 0, response);
}
-void RequestExecWriteCallback(int conn_id, int trans_id, bt_bdaddr_t* bda,
+void RequestExecWriteCallback(int conn_id, int trans_id, const bt_bdaddr_t& bda,
int exec_write) {
- std::string addr(BtAddrString(bda));
+ std::string addr(BtAddrString(&bda));
LOG_INFO(LOG_TAG, "%s: connection:%d (%s:trans:%d) exec_write:%d", __func__,
conn_id, addr.c_str(), trans_id, exec_write);
// This 'response' data is unused for ExecWriteResponses.
// It is only used to pass BlueDroid argument validation.
btgatt_response_t response = {};
- g_internal->gatt->server->send_response(conn_id, trans_id, 0, &response);
+ g_internal->gatt->server->send_response(conn_id, trans_id, 0, response);
if (!exec_write) return;
@@ -327,8 +328,8 @@
}
void ConnectionCallback(int conn_id, int server_if, int connected,
- bt_bdaddr_t* bda) {
- std::string addr(BtAddrString(bda));
+ const bt_bdaddr_t& bda) {
+ std::string addr(BtAddrString(&bda));
LOG_INFO(LOG_TAG, "%s: connection:%d server_if:%d connected:%d addr:%s",
__func__, conn_id, server_if, connected, addr.c_str());
if (connected == 1) {
@@ -345,9 +346,10 @@
g_internal->api_synchronize.notify_one();
}
-void RegisterClientCallback(int status, int client_if, bt_uuid_t* app_uuid) {
+void RegisterClientCallback(int status, int client_if,
+ const bt_uuid_t& app_uuid) {
LOG_INFO(LOG_TAG, "%s: status:%d client_if:%d uuid[0]:%u", __func__, status,
- client_if, app_uuid->uu[0]);
+ client_if, app_uuid.uu[0]);
g_internal->client_if = client_if;
// Setup our advertisement. This has no callback.
@@ -381,15 +383,15 @@
}
void ClientConnectCallback(int conn_id, int status, int client_if,
- bt_bdaddr_t* bda) {
- std::string addr(BtAddrString(bda));
+ const bt_bdaddr_t& bda) {
+ std::string addr(BtAddrString(&bda));
LOG_INFO(LOG_TAG, "%s: conn_id:%d status:%d client_if:%d %s", __func__,
conn_id, status, client_if, addr.c_str());
}
void ClientDisconnectCallback(int conn_id, int status, int client_if,
- bt_bdaddr_t* bda) {
- std::string addr(BtAddrString(bda));
+ const bt_bdaddr_t& bda) {
+ std::string addr(BtAddrString(&bda));
LOG_INFO(LOG_TAG, "%s: conn_id:%d status:%d client_if:%d %s", __func__,
conn_id, status, client_if, addr.c_str());
}
@@ -547,7 +549,7 @@
bt_uuid_t uuid = service_id.GetBlueDroid();
- bt_status_t btstat = internal_->gatt->server->register_server(&uuid);
+ bt_status_t btstat = internal_->gatt->server->register_server(uuid);
if (btstat != BT_STATUS_SUCCESS) {
LOG_ERROR(LOG_TAG, "Failed to register server");
return false;
diff --git a/service/hal/bluetooth_gatt_interface.cc b/service/hal/bluetooth_gatt_interface.cc
index 936a053..652318e 100644
--- a/service/hal/bluetooth_gatt_interface.cc
+++ b/service/hal/bluetooth_gatt_interface.cc
@@ -78,14 +78,14 @@
} \
} while (0)
-void RegisterClientCallback(int status, int client_if, bt_uuid_t* app_uuid) {
+void RegisterClientCallback(int status, int client_if,
+ const bt_uuid_t& app_uuid) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - status: " << status << " client_if: " << client_if;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(app_uuid);
FOR_EACH_CLIENT_OBSERVER(
- RegisterClientCallback(g_interface, status, client_if, *app_uuid));
+ RegisterClientCallback(g_interface, status, client_if, app_uuid));
}
void ScanResultCallback(
@@ -104,28 +104,28 @@
ScanResultCallback(g_interface, *bda, rssi, adv_data));
}
-void ConnectCallback(int conn_id, int status, int client_if, bt_bdaddr_t* bda) {
+void ConnectCallback(int conn_id, int status, int client_if,
+ const bt_bdaddr_t& bda) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
VLOG(2) << __func__ << " - status: " << status << " client_if: " << client_if
- << " - BD_ADDR: " << BtAddrString(bda) << " - conn_id: " << conn_id;
+ << " - BD_ADDR: " << BtAddrString(&bda) << " - conn_id: " << conn_id;
FOR_EACH_CLIENT_OBSERVER(
- ConnectCallback(g_interface, conn_id, status, client_if, *bda));
+ ConnectCallback(g_interface, conn_id, status, client_if, bda));
}
void DisconnectCallback(int conn_id, int status, int client_if,
- bt_bdaddr_t* bda) {
+ const bt_bdaddr_t& bda) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
VLOG(2) << __func__ << " - conn_id: " << conn_id << " - status: " << status
- << " client_if: " << client_if << " - BD_ADDR: " << BtAddrString(bda);
+ << " client_if: " << client_if
+ << " - BD_ADDR: " << BtAddrString(&bda);
FOR_EACH_CLIENT_OBSERVER(
- DisconnectCallback(g_interface, conn_id, status, client_if, *bda));
+ DisconnectCallback(g_interface, conn_id, status, client_if, bda));
}
void SearchCompleteCallback(int conn_id, int status) {
@@ -148,14 +148,14 @@
g_interface, conn_id, status, registered, handle));
}
-void NotifyCallback(int conn_id, btgatt_notify_params_t* p_data) {
+void NotifyCallback(int conn_id, const btgatt_notify_params_t& p_data) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VERIFY_INTERFACE_OR_RETURN();
VLOG(2) << __func__ << " - conn_id: " << conn_id
- << " - address: " << BtAddrString(&p_data->bda)
- << " - handle: " << p_data->handle << " - len: " << p_data->len
- << " - is_notify: " << p_data->is_notify;
+ << " - address: " << BtAddrString(&p_data.bda)
+ << " - handle: " << p_data.handle << " - len: " << p_data.len
+ << " - is_notify: " << p_data.is_notify;
FOR_EACH_CLIENT_OBSERVER(NotifyCallback(g_interface, conn_id, p_data));
}
@@ -191,7 +191,7 @@
MtuChangedCallback(g_interface, conn_id, status, mtu));
}
-void GetGattDbCallback(int conn_id, btgatt_db_element_t* db, int size) {
+void GetGattDbCallback(int conn_id, const btgatt_db_element_t* db, int size) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id << " size: " << size;
VERIFY_INTERFACE_OR_RETURN();
@@ -210,7 +210,7 @@
ServicesRemovedCallback(g_interface, conn_id, start_handle, end_handle));
}
-void ServicesAddedCallback(int conn_id, btgatt_db_element_t* added,
+void ServicesAddedCallback(int conn_id, const btgatt_db_element_t& added,
int added_count) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id
@@ -221,26 +221,25 @@
ServicesAddedCallback(g_interface, conn_id, added, added_count));
}
-void RegisterServerCallback(int status, int server_if, bt_uuid_t* app_uuid) {
+void RegisterServerCallback(int status, int server_if,
+ const bt_uuid_t& app_uuid) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - status: " << status << " server_if: " << server_if;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(app_uuid);
FOR_EACH_SERVER_OBSERVER(
- RegisterServerCallback(g_interface, status, server_if, *app_uuid));
+ RegisterServerCallback(g_interface, status, server_if, app_uuid));
}
void ConnectionCallback(int conn_id, int server_if, int connected,
- bt_bdaddr_t* bda) {
+ const bt_bdaddr_t& bda) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id
<< " server_if: " << server_if << " connected: " << connected;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
FOR_EACH_SERVER_OBSERVER(
- ConnectionCallback(g_interface, conn_id, server_if, connected, *bda));
+ ConnectionCallback(g_interface, conn_id, server_if, connected, bda));
}
void ServiceAddedCallback(
@@ -277,34 +276,33 @@
}
void RequestReadCharacteristicCallback(int conn_id, int trans_id,
- bt_bdaddr_t* bda, int attr_handle,
+ const bt_bdaddr_t& bda, int attr_handle,
int offset, bool is_long) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id
<< " attr_handle: " << attr_handle << " offset: " << offset
<< " is_long: " << is_long;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
FOR_EACH_SERVER_OBSERVER(RequestReadCharacteristicCallback(
- g_interface, conn_id, trans_id, *bda, attr_handle, offset, is_long));
+ g_interface, conn_id, trans_id, bda, attr_handle, offset, is_long));
}
-void RequestReadDescriptorCallback(int conn_id, int trans_id, bt_bdaddr_t* bda,
- int attr_handle, int offset, bool is_long) {
+void RequestReadDescriptorCallback(int conn_id, int trans_id,
+ const bt_bdaddr_t& bda, int attr_handle,
+ int offset, bool is_long) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id
<< " attr_handle: " << attr_handle << " offset: " << offset
<< " is_long: " << is_long;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
FOR_EACH_SERVER_OBSERVER(RequestReadDescriptorCallback(
- g_interface, conn_id, trans_id, *bda, attr_handle, offset, is_long));
+ g_interface, conn_id, trans_id, bda, attr_handle, offset, is_long));
}
void RequestWriteCharacteristicCallback(int conn_id, int trans_id,
- bt_bdaddr_t* bda, int attr_handle,
+ const bt_bdaddr_t& bda, int attr_handle,
int offset, bool need_rsp, bool is_prep,
std::vector<uint8_t> value) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
@@ -313,16 +311,15 @@
<< " length: " << value.size() << " need_rsp: " << need_rsp
<< " is_prep: " << is_prep;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
FOR_EACH_SERVER_OBSERVER(RequestWriteCharacteristicCallback(
- g_interface, conn_id, trans_id, *bda, attr_handle, offset, need_rsp,
+ g_interface, conn_id, trans_id, bda, attr_handle, offset, need_rsp,
is_prep, value));
}
void RequestWriteDescriptorCallback(
- int conn_id, int trans_id, bt_bdaddr_t* bda, int attr_handle, int offset,
- bool need_rsp, bool is_prep,
+ int conn_id, int trans_id, const bt_bdaddr_t& bda, int attr_handle,
+ int offset, bool need_rsp, bool is_prep,
std::vector<uint8_t> value) { // NOLINT(pass-by-value)
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id
@@ -330,23 +327,21 @@
<< " length: " << value.size() << " need_rsp: " << need_rsp
<< " is_prep: " << is_prep;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
FOR_EACH_SERVER_OBSERVER(RequestWriteDescriptorCallback(
- g_interface, conn_id, trans_id, *bda, attr_handle, offset, need_rsp,
+ g_interface, conn_id, trans_id, bda, attr_handle, offset, need_rsp,
is_prep, value));
}
-void RequestExecWriteCallback(int conn_id, int trans_id, bt_bdaddr_t* bda,
+void RequestExecWriteCallback(int conn_id, int trans_id, const bt_bdaddr_t& bda,
int exec_write) {
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id
<< " exec_write: " << exec_write;
VERIFY_INTERFACE_OR_RETURN();
- CHECK(bda);
- FOR_EACH_SERVER_OBSERVER(RequestExecWriteCallback(
- g_interface, conn_id, trans_id, *bda, exec_write));
+ FOR_EACH_SERVER_OBSERVER(RequestExecWriteCallback(g_interface, conn_id,
+ trans_id, bda, exec_write));
}
void ResponseConfirmationCallback(int status, int handle) {
@@ -602,7 +597,7 @@
void BluetoothGattInterface::ClientObserver::NotifyCallback(
BluetoothGattInterface* /* gatt_iface */, int /* conn_id */,
- btgatt_notify_params_t* /* p_data */) {
+ const btgatt_notify_params_t& /* p_data */) {
// Do nothing
}
@@ -626,7 +621,7 @@
void BluetoothGattInterface::ClientObserver::GetGattDbCallback(
BluetoothGattInterface* /* gatt_iface */, int /* conn_id */,
- btgatt_db_element_t* /* gatt_db */, int /* size */) {
+ const btgatt_db_element_t* /* gatt_db */, int /* size */) {
// Do nothing.
}
@@ -638,7 +633,7 @@
void BluetoothGattInterface::ClientObserver::ServicesAddedCallback(
BluetoothGattInterface* /* gatt_iface */, int /* conn_id */,
- btgatt_db_element_t* /* added */, int /* added_count */) {
+ const btgatt_db_element_t& /* added */, int /* added_count */) {
// Do nothing.
}
diff --git a/service/hal/bluetooth_gatt_interface.h b/service/hal/bluetooth_gatt_interface.h
index 9627dc1..b88bd4b 100644
--- a/service/hal/bluetooth_gatt_interface.h
+++ b/service/hal/bluetooth_gatt_interface.h
@@ -85,7 +85,7 @@
int registered, uint16_t handle);
virtual void NotifyCallback(BluetoothGattInterface* gatt_iface, int conn_id,
- btgatt_notify_params_t* p_data);
+ const btgatt_notify_params_t& p_data);
virtual void WriteCharacteristicCallback(BluetoothGattInterface* gatt_iface,
int conn_id, int status,
@@ -99,7 +99,8 @@
int conn_id, int status, int mtu);
virtual void GetGattDbCallback(BluetoothGattInterface* gatt_iface,
- int conn_id, btgatt_db_element_t* gatt_db,
+ int conn_id,
+ const btgatt_db_element_t* gatt_db,
int size);
virtual void ServicesRemovedCallback(BluetoothGattInterface* gatt_iface,
@@ -107,7 +108,8 @@
uint16_t end_handle);
virtual void ServicesAddedCallback(BluetoothGattInterface* gatt_iface,
- int conn_id, btgatt_db_element_t* added,
+ int conn_id,
+ const btgatt_db_element_t& added,
int added_count);
};
diff --git a/service/hal/fake_bluetooth_gatt_interface.cc b/service/hal/fake_bluetooth_gatt_interface.cc
index 1250e85..82c1a47 100644
--- a/service/hal/fake_bluetooth_gatt_interface.cc
+++ b/service/hal/fake_bluetooth_gatt_interface.cc
@@ -28,7 +28,7 @@
std::shared_ptr<FakeBluetoothGattInterface::TestClientHandler> g_client_handler;
std::shared_ptr<FakeBluetoothGattInterface::TestServerHandler> g_server_handler;
-bt_status_t FakeRegisterClient(bt_uuid_t* app_uuid) {
+bt_status_t FakeRegisterClient(const bt_uuid_t& app_uuid) {
if (g_client_handler) return g_client_handler->RegisterClient(app_uuid);
return BT_STATUS_FAIL;
@@ -40,7 +40,7 @@
return BT_STATUS_FAIL;
}
-bt_status_t FakeConnect(int client_if, const bt_bdaddr_t* bd_addr,
+bt_status_t FakeConnect(int client_if, const bt_bdaddr_t& bd_addr,
bool is_direct, int transport, int phy) {
if (g_client_handler)
return g_client_handler->Connect(client_if, bd_addr, is_direct, transport);
@@ -48,7 +48,7 @@
return BT_STATUS_FAIL;
}
-bt_status_t FakeDisconnect(int client_if, const bt_bdaddr_t* bd_addr,
+bt_status_t FakeDisconnect(int client_if, const bt_bdaddr_t& bd_addr,
int conn_id) {
if (g_client_handler)
return g_client_handler->Disconnect(client_if, bd_addr, conn_id);
@@ -56,7 +56,7 @@
return BT_STATUS_FAIL;
}
-bt_status_t FakeRegisterServer(bt_uuid_t* app_uuid) {
+bt_status_t FakeRegisterServer(const bt_uuid_t& app_uuid) {
if (g_server_handler) return g_server_handler->RegisterServer(app_uuid);
return BT_STATUS_FAIL;
@@ -93,7 +93,7 @@
}
bt_status_t FakeSendResponse(int conn_id, int trans_id, int status,
- btgatt_response_t* response) {
+ const btgatt_response_t& response) {
if (g_server_handler)
return g_server_handler->SendResponse(conn_id, trans_id, status, response);
diff --git a/service/hal/fake_bluetooth_gatt_interface.h b/service/hal/fake_bluetooth_gatt_interface.h
index fc10434..77ce6ba 100644
--- a/service/hal/fake_bluetooth_gatt_interface.h
+++ b/service/hal/fake_bluetooth_gatt_interface.h
@@ -35,12 +35,12 @@
public:
virtual ~TestClientHandler() = default;
- virtual bt_status_t RegisterClient(bt_uuid_t* app_uuid) = 0;
+ virtual bt_status_t RegisterClient(const bt_uuid_t& app_uuid) = 0;
virtual bt_status_t UnregisterClient(int client_if) = 0;
- virtual bt_status_t Connect(int client_if, const bt_bdaddr_t* bd_addr,
+ virtual bt_status_t Connect(int client_if, const bt_bdaddr_t& bd_addr,
bool is_direct, int transport) = 0;
- virtual bt_status_t Disconnect(int client_if, const bt_bdaddr_t* bd_addr,
+ virtual bt_status_t Disconnect(int client_if, const bt_bdaddr_t& bd_addr,
int conn_id) = 0;
};
@@ -51,7 +51,7 @@
public:
virtual ~TestServerHandler() = default;
- virtual bt_status_t RegisterServer(bt_uuid_t* app_uuid) = 0;
+ virtual bt_status_t RegisterServer(const bt_uuid_t& app_uuid) = 0;
virtual bt_status_t UnregisterServer(int server_if) = 0;
virtual bt_status_t AddService(
int server_if, std::vector<btgatt_db_element_t> service) = 0;
@@ -60,7 +60,7 @@
int conn_id, int confirm,
std::vector<uint8_t> value) = 0;
virtual bt_status_t SendResponse(int conn_id, int trans_id, int status,
- btgatt_response_t* response) = 0;
+ const btgatt_response_t& response) = 0;
};
// Constructs the fake with the given handlers. Implementations can
diff --git a/service/low_energy_client.cc b/service/low_energy_client.cc
index 1e2d7f3..c43c492 100644
--- a/service/low_energy_client.cc
+++ b/service/low_energy_client.cc
@@ -59,7 +59,7 @@
bt_status_t status =
hal::BluetoothGattInterface::Get()->GetClientHALInterface()->connect(
- client_id_, &bda, is_direct, BT_TRANSPORT_LE, PHY_LE_1M_MASK);
+ client_id_, bda, is_direct, BT_TRANSPORT_LE, PHY_LE_1M_MASK);
if (status != BT_STATUS_SUCCESS) {
LOG(ERROR) << "HAL call to connect failed";
return false;
@@ -86,7 +86,7 @@
bt_status_t status =
hal::BluetoothGattInterface::Get()->GetClientHALInterface()->disconnect(
- client_id_, &bda, conn_id->second);
+ client_id_, bda, conn_id->second);
if (status != BT_STATUS_SUCCESS) {
LOG(ERROR) << "HAL call to disconnect failed";
return false;
@@ -220,7 +220,7 @@
hal::BluetoothGattInterface::Get()->GetClientHALInterface();
bt_uuid_t app_uuid = uuid.GetBlueDroid();
- if (hal_iface->register_client(&app_uuid) != BT_STATUS_SUCCESS) return false;
+ if (hal_iface->register_client(app_uuid) != BT_STATUS_SUCCESS) return false;
pending_calls_[uuid] = callback;
diff --git a/service/test/gatt_client_unittest.cc b/service/test/gatt_client_unittest.cc
index 7527e8b..c3926eb 100644
--- a/service/test/gatt_client_unittest.cc
+++ b/service/test/gatt_client_unittest.cc
@@ -33,11 +33,11 @@
MockGattHandler() = default;
~MockGattHandler() override = default;
- MOCK_METHOD1(RegisterClient, bt_status_t(bt_uuid_t*));
+ MOCK_METHOD1(RegisterClient, bt_status_t(const bt_uuid_t&));
MOCK_METHOD1(UnregisterClient, bt_status_t(int));
MOCK_METHOD1(Scan, bt_status_t(bool));
- MOCK_METHOD4(Connect, bt_status_t(int, const bt_bdaddr_t*, bool, int));
- MOCK_METHOD3(Disconnect, bt_status_t(int, const bt_bdaddr_t*, int));
+ MOCK_METHOD4(Connect, bt_status_t(int, const bt_bdaddr_t&, bool, int));
+ MOCK_METHOD3(Disconnect, bt_status_t(int, const bt_bdaddr_t&, int));
private:
DISALLOW_COPY_AND_ASSIGN(MockGattHandler);
diff --git a/service/test/gatt_server_unittest.cc b/service/test/gatt_server_unittest.cc
index ee88b99..ab12ff2 100644
--- a/service/test/gatt_server_unittest.cc
+++ b/service/test/gatt_server_unittest.cc
@@ -33,7 +33,7 @@
MockGattHandler() = default;
~MockGattHandler() override = default;
- MOCK_METHOD1(RegisterServer, bt_status_t(bt_uuid_t*));
+ MOCK_METHOD1(RegisterServer, bt_status_t(const bt_uuid_t&));
MOCK_METHOD1(UnregisterServer, bt_status_t(int));
MOCK_METHOD2(AddService, bt_status_t(int, std::vector<btgatt_db_element_t>));
MOCK_METHOD5(AddCharacteristic, bt_status_t(int, int, bt_uuid_t*, int, int));
@@ -42,7 +42,8 @@
MOCK_METHOD2(DeleteService, bt_status_t(int, int));
MOCK_METHOD5(SendIndication,
bt_status_t(int, int, int, int, std::vector<uint8_t>));
- MOCK_METHOD4(SendResponse, bt_status_t(int, int, int, btgatt_response_t*));
+ MOCK_METHOD4(SendResponse,
+ bt_status_t(int, int, int, const btgatt_response_t&));
private:
DISALLOW_COPY_AND_ASSIGN(MockGattHandler);
diff --git a/service/test/low_energy_client_unittest.cc b/service/test/low_energy_client_unittest.cc
index 99eb934..0fa98b8 100644
--- a/service/test/low_energy_client_unittest.cc
+++ b/service/test/low_energy_client_unittest.cc
@@ -40,10 +40,10 @@
MockGattHandler(){};
~MockGattHandler() override = default;
- MOCK_METHOD1(RegisterClient, bt_status_t(bt_uuid_t*));
+ MOCK_METHOD1(RegisterClient, bt_status_t(const bt_uuid_t&));
MOCK_METHOD1(UnregisterClient, bt_status_t(int));
- MOCK_METHOD4(Connect, bt_status_t(int, const bt_bdaddr_t*, bool, int));
- MOCK_METHOD3(Disconnect, bt_status_t(int, const bt_bdaddr_t*, int));
+ MOCK_METHOD4(Connect, bt_status_t(int, const bt_bdaddr_t&, bool, int));
+ MOCK_METHOD3(Disconnect, bt_status_t(int, const bt_bdaddr_t&, int));
private:
DISALLOW_COPY_AND_ASSIGN(MockGattHandler);
@@ -268,13 +268,13 @@
// success, fix it when it becomes important.
// These should succeed and result in a HAL call
EXPECT_CALL(*mock_handler_,
- Connect(le_client_->GetInstanceId(), Pointee(BitEq(kTestAddress)),
+ Connect(le_client_->GetInstanceId(), BitEq(kTestAddress),
kTestDirect, BT_TRANSPORT_LE))
.Times(1)
- .WillOnce(DoAll(Invoke([&](int client_id, const bt_bdaddr_t* bd_addr,
+ .WillOnce(DoAll(Invoke([&](int client_id, const bt_bdaddr_t& bd_addr,
bool is_direct, int transport) {
fake_hal_gatt_iface_->NotifyConnectCallback(
- connId, BT_STATUS_SUCCESS, client_id, *bd_addr);
+ connId, BT_STATUS_SUCCESS, client_id, bd_addr);
}),
Return(BT_STATUS_SUCCESS)));
@@ -284,12 +284,12 @@
// TODO(jpawlowski): same as above
// These should succeed and result in a HAL call
EXPECT_CALL(*mock_handler_, Disconnect(le_client_->GetInstanceId(),
- Pointee(BitEq(kTestAddress)), connId))
+ BitEq(kTestAddress), connId))
.Times(1)
.WillOnce(DoAll(
- Invoke([&](int client_id, const bt_bdaddr_t* bd_addr, int connId) {
+ Invoke([&](int client_id, const bt_bdaddr_t& bd_addr, int connId) {
fake_hal_gatt_iface_->NotifyDisconnectCallback(
- connId, BT_STATUS_SUCCESS, client_id, *bd_addr);
+ connId, BT_STATUS_SUCCESS, client_id, bd_addr);
}),
Return(BT_STATUS_SUCCESS)));
diff --git a/test/suite/gatt/gatt_unittest.cc b/test/suite/gatt/gatt_unittest.cc
index 598ae41..079a213 100644
--- a/test/suite/gatt/gatt_unittest.cc
+++ b/test/suite/gatt/gatt_unittest.cc
@@ -41,7 +41,7 @@
// Registers gatt client.
bt_uuid_t gatt_client_uuid;
create_random_uuid(&gatt_client_uuid, DEFAULT_RANDOM_SEED);
- gatt_client_interface()->register_client(&gatt_client_uuid);
+ gatt_client_interface()->register_client(gatt_client_uuid);
semaphore_wait(register_client_callback_sem_);
EXPECT_TRUE(status() == BT_STATUS_SUCCESS)
<< "Error registering GATT client app callback.";
@@ -54,7 +54,7 @@
// Registers gatt server.
bt_uuid_t gatt_server_uuid;
create_random_uuid(&gatt_server_uuid, DEFAULT_RANDOM_SEED);
- gatt_server_interface()->register_server(&gatt_server_uuid);
+ gatt_server_interface()->register_server(gatt_server_uuid);
semaphore_wait(register_server_callback_sem_);
EXPECT_TRUE(status() == BT_STATUS_SUCCESS)
<< "Error registering GATT server app callback.";
@@ -67,7 +67,7 @@
// Registers gatt server.
bt_uuid_t gatt_server_uuid;
create_random_uuid(&gatt_server_uuid, DEFAULT_RANDOM_SEED);
- gatt_server_interface()->register_server(&gatt_server_uuid);
+ gatt_server_interface()->register_server(gatt_server_uuid);
semaphore_wait(register_server_callback_sem_);
EXPECT_TRUE(status() == BT_STATUS_SUCCESS)
<< "Error registering GATT server app callback.";