Skip to content
Snippets Groups Projects
Commit 9ab6c8d1 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Use device privacy mode as default

This change configures device privacy mode for each
remote device added to the resolving list.
Before exercising the privacy command it confirms
whether the set privacy HCI command is supported.

This patch is based on CAF patch by niarora@codeaurora.org
36fa3c528d2ae58e0b3f969665e3d25986dcdbaa

Test: manual
Bug: 35935853
Change-Id: I839045ccc3ddb73dc9c0cbe05d87c25dae9b9236
(cherry picked from commit f6db7cb9a30b34493df8658d59b2fe2232bc828a)
parent ae8e8f1e
No related branches found
No related tags found
No related merge requests found
......@@ -710,6 +710,12 @@ bool btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC* p_dev_rec) {
btsnd_hcic_ble_add_device_resolving_list(
p_dev_rec->ble.static_addr_type, p_dev_rec->ble.static_addr,
peer_irk, local_irk);
if (controller_get_interface()->supports_ble_privacy()) {
BTM_TRACE_DEBUG("%s: adding device privacy mode", __func__);
btsnd_hcic_ble_set_privacy_mode(p_dev_rec->ble.static_addr_type,
p_dev_rec->ble.static_addr, 0x01);
}
} else {
uint8_t param[40] = {0};
uint8_t* p = param;
......
......@@ -595,6 +595,23 @@ void btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer,
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
void btsnd_hcic_ble_set_privacy_mode(uint8_t addr_type_peer, BD_ADDR bda_peer,
uint8_t privacy_type) {
BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
uint8_t* pp = (uint8_t*)(p + 1);
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE;
p->offset = 0;
UINT16_TO_STREAM(pp, HCI_BLE_SET_PRIVACY_MODE);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE);
UINT8_TO_STREAM(pp, addr_type_peer);
BDADDR_TO_STREAM(pp, bda_peer);
UINT8_TO_STREAM(pp, privacy_type);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
void btsnd_hcic_ble_clear_resolving_list(void) {
BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
uint8_t* pp = (uint8_t*)(p + 1);
......
......@@ -374,6 +374,7 @@
#define HCI_LE_SET_EXTENDED_SCAN_PARAMETERS (0x0041 | HCI_GRP_BLE_CMDS)
#define HCI_LE_SET_EXTENDED_SCAN_ENABLE (0x0042 | HCI_GRP_BLE_CMDS)
#define HCI_LE_EXTENDED_CREATE_CONNECTION (0x0043 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PRIVACY_MODE (0x004E | HCI_GRP_BLE_CMDS)
/* LE Get Vendor Capabilities Command OCF */
#define HCI_BLE_VENDOR_CAP_OCF (0x0153 | HCI_GRP_VENDOR_SPECIFIC)
......
......@@ -676,6 +676,7 @@ extern void btsnd_hcic_vendor_spec_cmd(void* buffer, uint16_t opcode,
#define HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST (7 + HCIC_BLE_IRK_SIZE * 2)
#define HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST 7
#define HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE 8
#define HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST 0
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVING_LIST_SIZE 0
#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER 7
......@@ -835,6 +836,10 @@ extern void btsnd_hcic_ble_add_device_resolving_list(
extern void btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer,
BD_ADDR bda_peer);
extern void btsnd_hcic_ble_set_privacy_mode(uint8_t addr_type_peer,
BD_ADDR bda_peer,
uint8_t privacy_type);
extern void btsnd_hcic_ble_clear_resolving_list(void);
extern void btsnd_hcic_ble_read_resolvable_addr_peer(uint8_t addr_type_peer,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment