OSDN Git Service

Get rid of BTA_GATTC_API_REFRESH_EVT
authorJakub Pawlowski <jpawlowski@google.com>
Mon, 5 Jun 2017 19:42:45 +0000 (12:42 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Tue, 6 Jun 2017 21:09:12 +0000 (21:09 +0000)
Test: compilation test
Change-Id: I631962183ac63d2b168005060bb1f0d4964b0884

bta/dm/bta_dm_act.cc
bta/gatt/bta_gattc_act.cc
bta/gatt/bta_gattc_api.cc
bta/gatt/bta_gattc_int.h
bta/gatt/bta_gattc_main.cc
bta/include/bta_gatt_api.h
btif/src/btif_dm.cc
btif/src/btif_gatt_client.cc

index d6dddd9..5bf54ee 100644 (file)
@@ -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);
   }
 }
 
index 7c60f5a..5d9a127 100644 (file)
@@ -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);
 }
 /*******************************************************************************
  *
index 8f10f51..36fc36e 100644 (file)
@@ -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));
 }
index 8acdc11..598262b 100644 (file)
@@ -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);
index 074e234..9a2deb6 100644 (file)
@@ -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:
index 40f274a..fb8581e 100644 (file)
@@ -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);
 
 /*******************************************************************************
  *
index 511d307..6b445f1 100644 (file)
@@ -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 {
index 3ce48bd..6788fed 100644 (file)
@@ -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) {