@@ -69,7 +69,7 @@ static void background_connections_lazy_init()
69
69
}
70
70
}
71
71
72
- static void background_connection_add (bt_bdaddr_t * address )
72
+ static BOOLEAN background_connection_add (bt_bdaddr_t * address )
73
73
{
74
74
assert (address );
75
75
background_connections_lazy_init ();
@@ -78,14 +78,17 @@ static void background_connection_add(bt_bdaddr_t *address)
78
78
connection = osi_calloc (sizeof (background_connection_t ));
79
79
connection -> address = * address ;
80
80
hash_map_set (background_connections , & (connection -> address ), connection );
81
+ return TRUE;
81
82
}
83
+ return FALSE;
82
84
}
83
85
84
- static void background_connection_remove (bt_bdaddr_t * address )
86
+ static BOOLEAN background_connection_remove (bt_bdaddr_t * address )
85
87
{
86
88
if (address && background_connections ) {
87
- hash_map_erase (background_connections , address );
89
+ return hash_map_erase (background_connections , address );
88
90
}
91
+ return FALSE;
89
92
}
90
93
91
94
static void background_connections_clear ()
@@ -265,17 +268,30 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBTM_ADD_W
265
268
}
266
269
return FALSE;
267
270
}
268
- if (add_wl_cb ){
269
- //save add whitelist complete callback
270
- p_cb -> add_wl_cb = add_wl_cb ;
271
- }
272
271
273
272
if (to_add ) {
274
273
/* added the bd_addr to the connection hash map queue */
275
- background_connection_add ((bt_bdaddr_t * )bd_addr );
274
+ if (!background_connection_add ((bt_bdaddr_t * )bd_addr )) {
275
+ /* if the bd_addr already exist in whitelist, just callback return TRUE */
276
+ if (add_wl_cb ){
277
+ add_wl_cb (HCI_SUCCESS ,to_add );
278
+ }
279
+ return TRUE;
280
+ }
276
281
} else {
277
282
/* remove the bd_addr to the connection hash map queue */
278
- background_connection_remove ((bt_bdaddr_t * )bd_addr );
283
+ if (!background_connection_remove ((bt_bdaddr_t * )bd_addr )){
284
+ /* if the bd_addr don't exist in whitelist, just callback return TRUE */
285
+ if (add_wl_cb ){
286
+ add_wl_cb (HCI_SUCCESS ,to_add );
287
+ }
288
+ return TRUE;
289
+ }
290
+ }
291
+
292
+ if (add_wl_cb ){
293
+ //save add whitelist complete callback
294
+ p_cb -> add_wl_cb = add_wl_cb ;
279
295
}
280
296
/* stop the auto connect */
281
297
btm_suspend_wl_activity (p_cb -> wl_state );
0 commit comments