Get rid of BTA_GATTC_API_REFRESH_EVT
Test: compilation test
Change-Id: I631962183ac63d2b168005060bb1f0d4964b0884
diff --git a/system/bta/dm/bta_dm_act.cc b/system/bta/dm/bta_dm_act.cc
index d6dddd9..5bf54ee 100644
--- a/system/bta/dm/bta_dm_act.cc
+++ b/system/bta/dm/bta_dm_act.cc
@@ -665,7 +665,9 @@
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 @@
/* 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 @@
/* 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 @@
/* 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/system/bta/gatt/bta_gattc_act.cc b/system/bta/gatt/bta_gattc_act.cc
index 7c60f5a..5d9a127 100644
--- a/system/bta/gatt/bta_gattc_act.cc
+++ b/system/bta/gatt/bta_gattc_act.cc
@@ -1391,9 +1391,8 @@
* 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 @@
}
}
/* 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/system/bta/gatt/bta_gattc_api.cc b/system/bta/gatt/bta_gattc_api.cc
index 8f10f51..36fc36e 100644
--- a/system/bta/gatt/bta_gattc_api.cc
+++ b/system/bta/gatt/bta_gattc_api.cc
@@ -732,12 +732,7 @@
* 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/system/bta/gatt/bta_gattc_int.h b/system/bta/gatt/bta_gattc_int.h
index 8acdc11..598262b 100644
--- a/system/bta/gatt/bta_gattc_int.h
+++ b/system/bta/gatt/bta_gattc_int.h
@@ -51,7 +51,6 @@
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 @@
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/system/bta/gatt/bta_gattc_main.cc b/system/bta/gatt/bta_gattc_main.cc
index 074e234..9a2deb6 100644
--- a/system/bta/gatt/bta_gattc_main.cc
+++ b/system/bta/gatt/bta_gattc_main.cc
@@ -125,8 +125,6 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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/system/bta/include/bta_gatt_api.h b/system/bta/include/bta_gatt_api.h
index 40f274a..fb8581e 100644
--- a/system/bta/include/bta_gatt_api.h
+++ b/system/bta/include/bta_gatt_api.h
@@ -959,7 +959,7 @@
* 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/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc
index 511d307..6b445f1 100644
--- a/system/btif/src/btif_dm.cc
+++ b/system/btif/src/btif_dm.cc
@@ -2912,7 +2912,7 @@
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/system/btif/src/btif_gatt_client.cc b/system/btif/src/btif_gatt_client.cc
index 3ce48bd..6788fed 100644
--- a/system/btif/src/btif_gatt_client.cc
+++ b/system/btif/src/btif_gatt_client.cc
@@ -349,10 +349,7 @@
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) {