Loading system/bta/dm/bta_dm_act.cc +36 −23 Original line number Diff line number Diff line Loading @@ -76,7 +76,8 @@ static uint8_t bta_dm_new_link_key_cback(const RawAddress& bd_addr, const LinkKey& key, uint8_t key_type); static void bta_dm_authentication_complete_cback(const RawAddress& bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result); BD_NAME bd_name, tHCI_REASON result); static void bta_dm_local_name_cback(void* p_name); static void bta_dm_check_av(); Loading Loading @@ -2059,30 +2060,40 @@ static uint8_t bta_dm_new_link_key_cback(const RawAddress& bd_addr, ******************************************************************************/ static void bta_dm_authentication_complete_cback( const RawAddress& bd_addr, UNUSED_ATTR DEV_CLASS dev_class, BD_NAME bd_name, int result) { tBTA_DM_SEC sec_event; if (result != BTM_SUCCESS) { memset(&sec_event, 0, sizeof(tBTA_DM_SEC)); sec_event.auth_cmpl.bd_addr = bd_addr; tHCI_REASON reason) { if (reason != HCI_SUCCESS) { if (bta_dm_cb.p_sec_cback) { // Build out the security event data structure tBTA_DM_SEC sec_event = { .auth_cmpl = { .bd_addr = bd_addr, }, }; memcpy(sec_event.auth_cmpl.bd_name, bd_name, BD_NAME_LEN); sec_event.auth_cmpl.bd_name[BD_NAME_LEN] = 0; // Report the BR link key based on the BR/EDR address and type BTM_ReadDevInfo(bd_addr, &sec_event.auth_cmpl.dev_type, &sec_event.auth_cmpl.addr_type); sec_event.auth_cmpl.fail_reason = (uint8_t)result; sec_event.auth_cmpl.fail_reason = reason; if (bta_dm_cb.p_sec_cback) bta_dm_cb.p_sec_cback(BTA_DM_AUTH_CMPL_EVT, &sec_event); } if (result == HCI_ERR_AUTH_FAILURE || result == HCI_ERR_KEY_MISSING || result == HCI_ERR_HOST_REJECT_SECURITY || result == HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE) { APPL_TRACE_WARNING("%s deleting %s - result: 0x%02x", __func__, bd_addr.ToString().c_str(), result); bta_dm_remove_sec_dev_entry(bd_addr); switch (reason) { case HCI_ERR_AUTH_FAILURE: case HCI_ERR_KEY_MISSING: case HCI_ERR_HOST_REJECT_SECURITY: case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE: LOG_WARN( "Deleting device record as authentication failed entry:%s " "reason:%s", PRIVATE_ADDRESS(bd_addr), hci_reason_code_text(reason).c_str()); break; default: break; } } } Loading Loading @@ -3452,9 +3463,11 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda, else sec_event.auth_cmpl.bd_name[0] = 0; if (p_data->complt.reason != 0) { if (p_data->complt.reason != HCI_SUCCESS) { // TODO This is not a proper use of this type sec_event.auth_cmpl.fail_reason = BTA_DM_AUTH_CONVERT_SMP_CODE(((uint8_t)p_data->complt.reason)); static_cast<tHCI_STATUS>(BTA_DM_AUTH_CONVERT_SMP_CODE( (static_cast<uint8_t>(p_data->complt.reason)))); if (btm_sec_is_a_bonded_dev(bda) && p_data->complt.reason == SMP_CONN_TOUT) { Loading system/bta/include/bta_api.h +3 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include "stack/include/bt_types.h" #include "stack/include/btm_api_types.h" #include "stack/include/btm_ble_api_types.h" #include "stack/include/hci_error_code.h" #include "stack/include/sdp_api.h" #include "types/ble_address_with_type.h" #include "types/bluetooth/uuid.h" Loading Loading @@ -291,7 +292,8 @@ typedef struct { LinkKey key; /* Link key associated with peer device. */ uint8_t key_type; /* The type of Link Key */ bool success; /* true of authentication succeeded, false if failed. */ uint8_t fail_reason; /* The HCI reason/error code for when success=false */ tHCI_REASON fail_reason; /* The HCI reason/error code for when success=false */ tBLE_ADDR_TYPE addr_type; /* Peer device address type */ tBT_DEVICE_TYPE dev_type; } tBTA_DM_AUTH_CMPL; Loading system/btif/src/btif_dm.cc +3 −1 Original line number Diff line number Diff line Loading @@ -2416,7 +2416,9 @@ static void btif_dm_ble_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) { } } else { /*Map the HCI fail reason to bt status */ switch (p_auth_cmpl->fail_reason) { // TODO This is not a proper use of the type uint8_t fail_reason = static_cast<uint8_t>(p_auth_cmpl->fail_reason); switch (fail_reason) { case BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL: case BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL: case BTA_DM_AUTH_SMP_UNKNOWN_ERR: Loading system/main/shim/btm_api.cc +2 −2 Original line number Diff line number Diff line Loading @@ -456,7 +456,7 @@ class ShimBondListener : public bluetooth::security::ISecurityManagerListener { } if (*bta_callbacks_->p_auth_complete_callback) { (*bta_callbacks_->p_auth_complete_callback)( bluetooth::ToRawAddress(device.GetAddress()), 0, name, BTM_SUCCESS); bluetooth::ToRawAddress(device.GetAddress()), 0, name, HCI_SUCCESS); } } MetricIdAllocator::GetInstance().AllocateId( Loading Loading @@ -489,7 +489,7 @@ class ShimBondListener : public bluetooth::security::ISecurityManagerListener { if (bta_callbacks_->p_auth_complete_callback) { (*bta_callbacks_->p_auth_complete_callback)( bluetooth::ToRawAddress(device.GetAddress()), 0, name, BTM_NOT_AUTHORIZED); HCI_ERR_AUTH_FAILURE); } } Loading system/stack/include/security_client_callbacks.h +3 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "stack/include/btm_api_types.h" #include "stack/include/btm_ble_api_types.h" #include "stack/include/hci_error_code.h" /**************************************** * Security Manager Callback Functions Loading Loading @@ -63,7 +64,8 @@ typedef void(tBTM_RMT_NAME_CALLBACK)(const RawAddress& bd_addr, DEV_CLASS dc, */ typedef void(tBTM_AUTH_COMPLETE_CALLBACK)(const RawAddress& bd_addr, DEV_CLASS dev_class, tBTM_BD_NAME bd_name, int result); tBTM_BD_NAME bd_name, tHCI_REASON reason); struct tBTM_APPL_INFO { tBTM_PIN_CALLBACK* p_pin_callback{nullptr}; Loading Loading
system/bta/dm/bta_dm_act.cc +36 −23 Original line number Diff line number Diff line Loading @@ -76,7 +76,8 @@ static uint8_t bta_dm_new_link_key_cback(const RawAddress& bd_addr, const LinkKey& key, uint8_t key_type); static void bta_dm_authentication_complete_cback(const RawAddress& bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result); BD_NAME bd_name, tHCI_REASON result); static void bta_dm_local_name_cback(void* p_name); static void bta_dm_check_av(); Loading Loading @@ -2059,30 +2060,40 @@ static uint8_t bta_dm_new_link_key_cback(const RawAddress& bd_addr, ******************************************************************************/ static void bta_dm_authentication_complete_cback( const RawAddress& bd_addr, UNUSED_ATTR DEV_CLASS dev_class, BD_NAME bd_name, int result) { tBTA_DM_SEC sec_event; if (result != BTM_SUCCESS) { memset(&sec_event, 0, sizeof(tBTA_DM_SEC)); sec_event.auth_cmpl.bd_addr = bd_addr; tHCI_REASON reason) { if (reason != HCI_SUCCESS) { if (bta_dm_cb.p_sec_cback) { // Build out the security event data structure tBTA_DM_SEC sec_event = { .auth_cmpl = { .bd_addr = bd_addr, }, }; memcpy(sec_event.auth_cmpl.bd_name, bd_name, BD_NAME_LEN); sec_event.auth_cmpl.bd_name[BD_NAME_LEN] = 0; // Report the BR link key based on the BR/EDR address and type BTM_ReadDevInfo(bd_addr, &sec_event.auth_cmpl.dev_type, &sec_event.auth_cmpl.addr_type); sec_event.auth_cmpl.fail_reason = (uint8_t)result; sec_event.auth_cmpl.fail_reason = reason; if (bta_dm_cb.p_sec_cback) bta_dm_cb.p_sec_cback(BTA_DM_AUTH_CMPL_EVT, &sec_event); } if (result == HCI_ERR_AUTH_FAILURE || result == HCI_ERR_KEY_MISSING || result == HCI_ERR_HOST_REJECT_SECURITY || result == HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE) { APPL_TRACE_WARNING("%s deleting %s - result: 0x%02x", __func__, bd_addr.ToString().c_str(), result); bta_dm_remove_sec_dev_entry(bd_addr); switch (reason) { case HCI_ERR_AUTH_FAILURE: case HCI_ERR_KEY_MISSING: case HCI_ERR_HOST_REJECT_SECURITY: case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE: LOG_WARN( "Deleting device record as authentication failed entry:%s " "reason:%s", PRIVATE_ADDRESS(bd_addr), hci_reason_code_text(reason).c_str()); break; default: break; } } } Loading Loading @@ -3452,9 +3463,11 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda, else sec_event.auth_cmpl.bd_name[0] = 0; if (p_data->complt.reason != 0) { if (p_data->complt.reason != HCI_SUCCESS) { // TODO This is not a proper use of this type sec_event.auth_cmpl.fail_reason = BTA_DM_AUTH_CONVERT_SMP_CODE(((uint8_t)p_data->complt.reason)); static_cast<tHCI_STATUS>(BTA_DM_AUTH_CONVERT_SMP_CODE( (static_cast<uint8_t>(p_data->complt.reason)))); if (btm_sec_is_a_bonded_dev(bda) && p_data->complt.reason == SMP_CONN_TOUT) { Loading
system/bta/include/bta_api.h +3 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include "stack/include/bt_types.h" #include "stack/include/btm_api_types.h" #include "stack/include/btm_ble_api_types.h" #include "stack/include/hci_error_code.h" #include "stack/include/sdp_api.h" #include "types/ble_address_with_type.h" #include "types/bluetooth/uuid.h" Loading Loading @@ -291,7 +292,8 @@ typedef struct { LinkKey key; /* Link key associated with peer device. */ uint8_t key_type; /* The type of Link Key */ bool success; /* true of authentication succeeded, false if failed. */ uint8_t fail_reason; /* The HCI reason/error code for when success=false */ tHCI_REASON fail_reason; /* The HCI reason/error code for when success=false */ tBLE_ADDR_TYPE addr_type; /* Peer device address type */ tBT_DEVICE_TYPE dev_type; } tBTA_DM_AUTH_CMPL; Loading
system/btif/src/btif_dm.cc +3 −1 Original line number Diff line number Diff line Loading @@ -2416,7 +2416,9 @@ static void btif_dm_ble_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) { } } else { /*Map the HCI fail reason to bt status */ switch (p_auth_cmpl->fail_reason) { // TODO This is not a proper use of the type uint8_t fail_reason = static_cast<uint8_t>(p_auth_cmpl->fail_reason); switch (fail_reason) { case BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL: case BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL: case BTA_DM_AUTH_SMP_UNKNOWN_ERR: Loading
system/main/shim/btm_api.cc +2 −2 Original line number Diff line number Diff line Loading @@ -456,7 +456,7 @@ class ShimBondListener : public bluetooth::security::ISecurityManagerListener { } if (*bta_callbacks_->p_auth_complete_callback) { (*bta_callbacks_->p_auth_complete_callback)( bluetooth::ToRawAddress(device.GetAddress()), 0, name, BTM_SUCCESS); bluetooth::ToRawAddress(device.GetAddress()), 0, name, HCI_SUCCESS); } } MetricIdAllocator::GetInstance().AllocateId( Loading Loading @@ -489,7 +489,7 @@ class ShimBondListener : public bluetooth::security::ISecurityManagerListener { if (bta_callbacks_->p_auth_complete_callback) { (*bta_callbacks_->p_auth_complete_callback)( bluetooth::ToRawAddress(device.GetAddress()), 0, name, BTM_NOT_AUTHORIZED); HCI_ERR_AUTH_FAILURE); } } Loading
system/stack/include/security_client_callbacks.h +3 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "stack/include/btm_api_types.h" #include "stack/include/btm_ble_api_types.h" #include "stack/include/hci_error_code.h" /**************************************** * Security Manager Callback Functions Loading Loading @@ -63,7 +64,8 @@ typedef void(tBTM_RMT_NAME_CALLBACK)(const RawAddress& bd_addr, DEV_CLASS dc, */ typedef void(tBTM_AUTH_COMPLETE_CALLBACK)(const RawAddress& bd_addr, DEV_CLASS dev_class, tBTM_BD_NAME bd_name, int result); tBTM_BD_NAME bd_name, tHCI_REASON reason); struct tBTM_APPL_INFO { tBTM_PIN_CALLBACK* p_pin_callback{nullptr}; Loading