From d7ee6f2e85a1a8837b0b1e2e8ba1c72b53650cd8 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Mon, 5 Jun 2017 12:42:45 -0700 Subject: [PATCH] Get rid of BTA_GATTC_API_REFRESH_EVT Test: compilation test Change-Id: I631962183ac63d2b168005060bb1f0d4964b0884 --- bta/dm/bta_dm_act.cc | 16 ++++++++++++---- bta/gatt/bta_gattc_act.cc | 7 +++---- bta/gatt/bta_gattc_api.cc | 11 +++-------- bta/gatt/bta_gattc_int.h | 3 +-- bta/gatt/bta_gattc_main.cc | 14 -------------- bta/include/bta_gatt_api.h | 2 +- btif/src/btif_dm.cc | 2 +- btif/src/btif_gatt_client.cc | 5 +---- 8 files changed, 22 insertions(+), 38 deletions(-) diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc index d6dddd99f..5bf54ee76 100644 --- a/bta/dm/bta_dm_act.cc +++ b/bta/dm/bta_dm_act.cc @@ -665,7 +665,9 @@ void bta_dm_process_remove_device(BD_ADDR bd_addr) { BTM_SecDeleteDevice(bd_addr); /* remove all cached GATT information */ - BTA_GATTC_Refresh(bd_addr); + bt_bdaddr_t tmp_addr; + memcpy(tmp_addr.address, bd_addr, BD_ADDR_LEN); + BTA_GATTC_Refresh(tmp_addr); if (bta_dm_cb.p_sec_cback) { tBTA_DM_SEC sec_event; @@ -848,7 +850,9 @@ void bta_dm_close_acl(tBTA_DM_MSG* p_data) { /* need to remove all pending background connection if any */ BTA_GATTC_CancelOpen(0, p_remove_acl->bd_addr, false); /* remove all cached GATT information */ - BTA_GATTC_Refresh(p_remove_acl->bd_addr); + bt_bdaddr_t tmp_addr; + memcpy(tmp_addr.address, p_remove_acl->bd_addr, BD_ADDR_LEN); + BTA_GATTC_Refresh(tmp_addr); } /* otherwise, no action needed */ } @@ -3110,7 +3114,9 @@ void bta_dm_acl_change(tBTA_DM_MSG* p_data) { /* need to remove all pending background connection */ BTA_GATTC_CancelOpen(0, p_bda, false); /* remove all cached GATT information */ - BTA_GATTC_Refresh(p_bda); + bt_bdaddr_t tmp_addr; + memcpy(tmp_addr.address, p_bda, BD_ADDR_LEN); + BTA_GATTC_Refresh(tmp_addr); } bdcpy(conn.link_down.bd_addr, p_bda); @@ -3283,7 +3289,9 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr) { /* need to remove all pending background connection */ BTA_GATTC_CancelOpen(0, remote_bd_addr, false); /* remove all cached GATT information */ - BTA_GATTC_Refresh(remote_bd_addr); + bt_bdaddr_t tmp_addr; + memcpy(tmp_addr.address, remote_bd_addr, BD_ADDR_LEN); + BTA_GATTC_Refresh(tmp_addr); } } diff --git a/bta/gatt/bta_gattc_act.cc b/bta/gatt/bta_gattc_act.cc index 7c60f5a68..5d9a12771 100644 --- a/bta/gatt/bta_gattc_act.cc +++ b/bta/gatt/bta_gattc_act.cc @@ -1391,9 +1391,8 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda) { * Returns None. * ******************************************************************************/ -void bta_gattc_process_api_refresh(tBTA_GATTC_DATA* p_msg) { - tBTA_GATTC_SERV* p_srvc_cb = - bta_gattc_find_srvr_cache(p_msg->api_conn.remote_bda); +void bta_gattc_process_api_refresh(bt_bdaddr_t remote_bda) { + tBTA_GATTC_SERV* p_srvc_cb = bta_gattc_find_srvr_cache(remote_bda.address); tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0]; bool found = false; uint8_t i; @@ -1419,7 +1418,7 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_DATA* p_msg) { } } /* used to reset cache in application */ - bta_gattc_cache_reset(p_msg->api_conn.remote_bda); + bta_gattc_cache_reset(remote_bda.address); } /******************************************************************************* * diff --git a/bta/gatt/bta_gattc_api.cc b/bta/gatt/bta_gattc_api.cc index 8f10f515a..36fc36ea4 100644 --- a/bta/gatt/bta_gattc_api.cc +++ b/bta/gatt/bta_gattc_api.cc @@ -732,12 +732,7 @@ tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications(tBTA_GATTC_IF client_if, * Returns void * ******************************************************************************/ -void BTA_GATTC_Refresh(const BD_ADDR remote_bda) { - tBTA_GATTC_API_OPEN* p_buf = - (tBTA_GATTC_API_OPEN*)osi_malloc(sizeof(tBTA_GATTC_API_OPEN)); - - p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT; - memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); - - bta_sys_sendmsg(p_buf); +void BTA_GATTC_Refresh(const bt_bdaddr_t& remote_bda) { + do_in_bta_thread(FROM_HERE, + base::Bind(&bta_gattc_process_api_refresh, remote_bda)); } diff --git a/bta/gatt/bta_gattc_int.h b/bta/gatt/bta_gattc_int.h index 8acdc11c9..598262bf2 100644 --- a/bta/gatt/bta_gattc_int.h +++ b/bta/gatt/bta_gattc_int.h @@ -51,7 +51,6 @@ enum { BTA_GATTC_API_SEARCH_EVT, BTA_GATTC_API_CONFIRM_EVT, BTA_GATTC_API_READ_MULTI_EVT, - BTA_GATTC_API_REFRESH_EVT, BTA_GATTC_INT_CONN_EVT, BTA_GATTC_INT_DISCOVER_EVT, @@ -395,7 +394,7 @@ extern void bta_gattc_send_open_cback(tBTA_GATTC_RCB* p_clreg, tBTA_GATT_STATUS status, BD_ADDR remote_bda, uint16_t conn_id, tBTA_TRANSPORT transport, uint16_t mtu); -extern void bta_gattc_process_api_refresh(tBTA_GATTC_DATA* p_msg); +extern void bta_gattc_process_api_refresh(bt_bdaddr_t remote_bda); extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data); extern void bta_gattc_listen(tBTA_GATTC_DATA* p_msg); extern void bta_gattc_broadcast(tBTA_GATTC_DATA* p_msg); diff --git a/bta/gatt/bta_gattc_main.cc b/bta/gatt/bta_gattc_main.cc index 074e234cd..9a2deb6ed 100644 --- a/bta/gatt/bta_gattc_main.cc +++ b/bta/gatt/bta_gattc_main.cc @@ -125,8 +125,6 @@ static const uint8_t bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] = { /* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, /* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST}, - /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, - BTA_GATTC_IDLE_ST}, /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST}, /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, @@ -169,8 +167,6 @@ static const uint8_t bta_gattc_st_w4_conn[][BTA_GATTC_NUM_COLS] = { BTA_GATTC_W4_CONN_ST}, /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST}, - /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, - BTA_GATTC_W4_CONN_ST}, /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST}, /* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, @@ -209,8 +205,6 @@ static const uint8_t bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] = { BTA_GATTC_CONN_ST}, /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI, BTA_GATTC_CONN_ST}, - /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, - BTA_GATTC_CONN_ST}, /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}, @@ -255,8 +249,6 @@ static const uint8_t bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] = { BTA_GATTC_DISCOVER_ST}, /* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST}, - /* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, - BTA_GATTC_DISCOVER_ST}, /* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_DISCOVER_ST}, @@ -376,10 +368,6 @@ bool bta_gattc_hdl_event(BT_HDR* p_msg) { bta_gattc_process_api_open_cancel((tBTA_GATTC_DATA*)p_msg); break; - case BTA_GATTC_API_REFRESH_EVT: - bta_gattc_process_api_refresh((tBTA_GATTC_DATA*)p_msg); - break; - default: if (p_msg->event == BTA_GATTC_INT_CONN_EVT) p_clcb = bta_gattc_find_int_conn_clcb((tBTA_GATTC_DATA*)p_msg); @@ -449,8 +437,6 @@ static char* gattc_evt_code(tBTA_GATTC_INT_EVT evt_code) { return "BTA_GATTC_OP_CMPL_EVT"; case BTA_GATTC_INT_DISCONN_EVT: return "BTA_GATTC_INT_DISCONN_EVT"; - case BTA_GATTC_API_REFRESH_EVT: - return "BTA_GATTC_API_REFRESH_EVT"; case BTA_GATTC_API_CFG_MTU_EVT: return "BTA_GATTC_API_CFG_MTU_EVT"; default: diff --git a/bta/include/bta_gatt_api.h b/bta/include/bta_gatt_api.h index 40f274a00..fb8581ee7 100644 --- a/bta/include/bta_gatt_api.h +++ b/bta/include/bta_gatt_api.h @@ -959,7 +959,7 @@ extern void BTA_GATTC_ReadMultiple(uint16_t conn_id, * Returns void * ******************************************************************************/ -extern void BTA_GATTC_Refresh(const BD_ADDR remote_bda); +extern void BTA_GATTC_Refresh(const bt_bdaddr_t& remote_bda); /******************************************************************************* * diff --git a/btif/src/btif_dm.cc b/btif/src/btif_dm.cc index 511d30722..6b445f152 100644 --- a/btif/src/btif_dm.cc +++ b/btif/src/btif_dm.cc @@ -2912,7 +2912,7 @@ static void btif_dm_ble_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) { state = BT_BOND_STATE_NONE; } else { btif_dm_save_ble_bonding_keys(); - BTA_GATTC_Refresh(bd_addr.address); + BTA_GATTC_Refresh(bd_addr); btif_dm_get_remote_services_by_transport(&bd_addr, BTA_GATT_TRANSPORT_LE); } } else { diff --git a/btif/src/btif_gatt_client.cc b/btif/src/btif_gatt_client.cc index 3ce48bd35..6788fed58 100644 --- a/btif/src/btif_gatt_client.cc +++ b/btif/src/btif_gatt_client.cc @@ -349,10 +349,7 @@ bt_status_t btif_gattc_close(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(); - // Closure will own this value and free it. - uint8_t* address = new BD_ADDR; - bdcpy(address, bd_addr->address); - return do_in_jni_thread(Bind(&BTA_GATTC_Refresh, base::Owned(address))); + 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) { -- 2.11.0