From 21fa0c69a3b0198cbfe13988f05009186bb5d7ed Mon Sep 17 00:00:00 2001 From: Hui Peng Date: Thu, 14 Dec 2023 08:31:39 +0000 Subject: [PATCH] [Invisalign2] Make BTA_DmBleConfigLocalPrivacy synchronous BTA_DmBleConfigLocalPrivacy is currently implemented as asynchronous by posting a task to main thread. With BTA_DmAddBleKey being made synchronous, this one should be made synchronous, otherwise, IRKs of bonded BLE devices won't be loaded properly if BTA_DmAddBleKey is called before local privacy is properly initialized, as reported in b/315736888. Bug: 315736888 Bug: 311196228 Bug: 301661850 Test: atest net_test_btif_stack Test: pair with a BLE device, restart Bluetooth and connec Change-Id: Idc80e068767f2bb67450145fce3e0e3c8a2c45a5 --- system/bta/dm/bta_dm_api.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system/bta/dm/bta_dm_api.cc b/system/bta/dm/bta_dm_api.cc index d1b209c4ca5..44367bb9aef 100644 --- a/system/bta/dm/bta_dm_api.cc +++ b/system/bta/dm/bta_dm_api.cc @@ -26,6 +26,7 @@ #include +#include "android_bluetooth_flags.h" #include "bta/dm/bta_dm_disc.h" #include "bta/dm/bta_dm_int.h" #include "bta/dm/bta_dm_sec_int.h" @@ -273,8 +274,12 @@ void BTA_DmBleUpdateConnectionParams(const RawAddress& bd_addr, * ******************************************************************************/ void BTA_DmBleConfigLocalPrivacy(bool privacy_enable) { - do_in_main_thread(FROM_HERE, base::BindOnce(bta_dm_ble_config_local_privacy, - privacy_enable)); + if (IS_FLAG_ENABLED(synchronous_bta_sec)) { + bta_dm_ble_config_local_privacy(privacy_enable); + } else { + do_in_main_thread(FROM_HERE, base::BindOnce(bta_dm_ble_config_local_privacy, + privacy_enable)); + } } /*******************************************************************************