From 6670e3157c8510bc4b944c6a16d92db56adbb76c Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Sat, 18 Jul 2015 00:00:50 -0700 Subject: [PATCH] Fix multi-advertising when LE Privacy is not available This patch fixes a bug that caused all multi-advertising instances to be initialized with Instance ID 0 (which is not allowed by the stack), if LE privacy is not available. The problem was that the internal data structures that represent advertising instances were not getting their |inst_id| field initialized where it's supposed to. Although far from clean, this code worked before. The culprit for the regression is "f9fdf890 Random address does not get written properly", which moved the initialization of instance IDs from the loop in BTM_BleEnableAdvInstance to btm_ble_multi_adv_enb_privacy. The latter never gets called if privacy is not available, which leads to partially initialized structures. Obviously both of these places were wrong to begin with. I saw the word "init" in a function called btm_ble_multi_adv_init. I figured this might have something to do with initializing, so I moved the logic there. Bug: 21267281 Change-Id: I38b9a2a71cd3f45feb267a13bf29f93564ee6075 --- stack/btm/btm_ble_multi_adv.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/stack/btm/btm_ble_multi_adv.c b/stack/btm/btm_ble_multi_adv.c index 6ee3e94cf..386ecac53 100644 --- a/stack/btm/btm_ble_multi_adv.c +++ b/stack/btm/btm_ble_multi_adv.c @@ -520,11 +520,7 @@ void btm_ble_multi_adv_enb_privacy(BOOLEAN enable) { p_inst->in_use = FALSE; if (enable) - { - /* Setup the instance ID before configuring the RPA */ - p_inst->inst_id = i + 1; btm_ble_multi_adv_configure_rpa (p_inst); - } else btu_stop_timer_oneshot(&p_inst->raddr_timer_ent); } @@ -837,8 +833,11 @@ void btm_ble_multi_adv_init() sizeof(UINT8)*(btm_cb.cmn_ble_vsc_cb.adv_inst_max)); } - for (i = 0; i < btm_cb.cmn_ble_vsc_cb.adv_inst_max ; i ++) + /* Initialize adv instance indices and IDs. */ + for (i = 0; i < btm_cb.cmn_ble_vsc_cb.adv_inst_max; i++) { btm_multi_adv_cb.p_adv_inst[i].index = i; + btm_multi_adv_cb.p_adv_inst[i].inst_id = i + 1; + } BTM_RegisterForVSEvents(btm_ble_multi_adv_vse_cback, TRUE); } -- 2.11.0