Loading system/stack/btm/btm_ble.cc +4 −4 Original line number Diff line number Diff line Loading @@ -1254,7 +1254,7 @@ void btm_ble_link_sec_check(const RawAddress& bd_addr, return; } if (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING || if (p_dev_rec->is_security_state_encrypting() || p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) { /* race condition: discard the security request while central is encrypting * the link */ Loading Loading @@ -1416,7 +1416,7 @@ tBTM_STATUS btm_ble_start_encrypt(const RawAddress& bda, bool use_stk, return BTM_WRONG_MODE; } if (p_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) { if (p_rec->is_security_state_encrypting()) { BTM_TRACE_WARNING("Link Encryption is active, Busy!"); return BTM_BUSY; } Loading @@ -1434,7 +1434,7 @@ tBTM_STATUS btm_ble_start_encrypt(const RawAddress& bda, bool use_stk, } if (p_rec->sec_state == BTM_SEC_STATE_IDLE) p_rec->sec_state = BTM_SEC_STATE_ENCRYPTING; p_rec->sec_state = BTM_SEC_STATE_LE_ENCRYPTING; return BTM_CMD_STARTED; } Loading Loading @@ -1462,7 +1462,7 @@ void btm_ble_link_encrypted(const RawAddress& bd_addr, uint8_t encr_enable) { BTM_TRACE_DEBUG("btm_ble_link_encrypted encr_enable=%d", encr_enable); enc_cback = (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING); enc_cback = p_dev_rec->is_security_state_le_encrypting(); smp_link_encrypted(bd_addr, encr_enable); Loading system/stack/btm/btm_sec.cc +7 −6 Original line number Diff line number Diff line Loading @@ -1195,7 +1195,7 @@ tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr, bool BTM_SecIsSecurityPending(const RawAddress& bd_addr) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); return p_dev_rec && (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING || return p_dev_rec && (p_dev_rec->is_security_state_encrypting() || p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING); } Loading Loading @@ -3071,7 +3071,7 @@ static void btm_sec_auth_collision(uint16_t handle) { p_dev_rec->sec_state); /* We will restart authentication after timeout */ if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING || p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) p_dev_rec->is_security_state_bredr_encrypting()) p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; btm_cb.p_collided_dev_rec = p_dev_rec; Loading Loading @@ -3427,7 +3427,7 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, } /* If this encryption was started by peer do not need to do anything */ if (p_dev_rec->sec_state != BTM_SEC_STATE_ENCRYPTING) { if (!p_dev_rec->is_security_state_bredr_encrypting()) { if (BTM_SEC_STATE_DELAY_FOR_ENC == p_dev_rec->sec_state) { p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; BTM_TRACE_DEBUG("%s: clearing callback. p_dev_rec=%p, p_callback=%p", Loading Loading @@ -4403,9 +4403,10 @@ tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec) { .c_str(), p_dev_rec->sec_state); if (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE) { LOG_DEBUG( "Security state is idle indicating remote name request is outstanding"); if (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE && p_dev_rec->sec_state != BTM_SEC_STATE_LE_ENCRYPTING) { LOG_INFO("No immediate action taken in busy state: %s", security_state_text(p_dev_rec->sec_state).c_str()); return (BTM_CMD_STARTED); } Loading system/stack/btm/security_device_record.h +10 −1 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ typedef enum : uint8_t { BTM_SEC_STATE_DELAY_FOR_ENC = 7, BTM_SEC_STATE_DISCONNECTING_BLE = 8, BTM_SEC_STATE_DISCONNECTING_BOTH = 9, BTM_SEC_STATE_LE_ENCRYPTING = 10, } tSECURITY_STATE; static inline std::string security_state_text(const tSECURITY_STATE& state) { Loading @@ -184,6 +185,7 @@ static inline std::string security_state_text(const tSECURITY_STATE& state) { CASE_RETURN_TEXT(BTM_SEC_STATE_DELAY_FOR_ENC); CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BLE); CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BOTH); CASE_RETURN_TEXT(BTM_SEC_STATE_LE_ENCRYPTING); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } Loading Loading @@ -334,9 +336,16 @@ struct tBTM_SEC_DEV_REC { bool is_security_state_authenticating() const { return sec_state == BTM_SEC_STATE_AUTHENTICATING; } bool is_security_state_encrypting() const { bool is_security_state_bredr_encrypting() const { return sec_state == BTM_SEC_STATE_ENCRYPTING; } bool is_security_state_le_encrypting() const { return sec_state == BTM_SEC_STATE_LE_ENCRYPTING; } bool is_security_state_encrypting() const { return (is_security_state_bredr_encrypting() || is_security_state_le_encrypting()); } bool is_security_state_getting_name() const { return sec_state == BTM_SEC_STATE_GETTING_NAME; } Loading Loading
system/stack/btm/btm_ble.cc +4 −4 Original line number Diff line number Diff line Loading @@ -1254,7 +1254,7 @@ void btm_ble_link_sec_check(const RawAddress& bd_addr, return; } if (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING || if (p_dev_rec->is_security_state_encrypting() || p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) { /* race condition: discard the security request while central is encrypting * the link */ Loading Loading @@ -1416,7 +1416,7 @@ tBTM_STATUS btm_ble_start_encrypt(const RawAddress& bda, bool use_stk, return BTM_WRONG_MODE; } if (p_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) { if (p_rec->is_security_state_encrypting()) { BTM_TRACE_WARNING("Link Encryption is active, Busy!"); return BTM_BUSY; } Loading @@ -1434,7 +1434,7 @@ tBTM_STATUS btm_ble_start_encrypt(const RawAddress& bda, bool use_stk, } if (p_rec->sec_state == BTM_SEC_STATE_IDLE) p_rec->sec_state = BTM_SEC_STATE_ENCRYPTING; p_rec->sec_state = BTM_SEC_STATE_LE_ENCRYPTING; return BTM_CMD_STARTED; } Loading Loading @@ -1462,7 +1462,7 @@ void btm_ble_link_encrypted(const RawAddress& bd_addr, uint8_t encr_enable) { BTM_TRACE_DEBUG("btm_ble_link_encrypted encr_enable=%d", encr_enable); enc_cback = (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING); enc_cback = p_dev_rec->is_security_state_le_encrypting(); smp_link_encrypted(bd_addr, encr_enable); Loading
system/stack/btm/btm_sec.cc +7 −6 Original line number Diff line number Diff line Loading @@ -1195,7 +1195,7 @@ tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr, bool BTM_SecIsSecurityPending(const RawAddress& bd_addr) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); return p_dev_rec && (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING || return p_dev_rec && (p_dev_rec->is_security_state_encrypting() || p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING); } Loading Loading @@ -3071,7 +3071,7 @@ static void btm_sec_auth_collision(uint16_t handle) { p_dev_rec->sec_state); /* We will restart authentication after timeout */ if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING || p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) p_dev_rec->is_security_state_bredr_encrypting()) p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; btm_cb.p_collided_dev_rec = p_dev_rec; Loading Loading @@ -3427,7 +3427,7 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, } /* If this encryption was started by peer do not need to do anything */ if (p_dev_rec->sec_state != BTM_SEC_STATE_ENCRYPTING) { if (!p_dev_rec->is_security_state_bredr_encrypting()) { if (BTM_SEC_STATE_DELAY_FOR_ENC == p_dev_rec->sec_state) { p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; BTM_TRACE_DEBUG("%s: clearing callback. p_dev_rec=%p, p_callback=%p", Loading Loading @@ -4403,9 +4403,10 @@ tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec) { .c_str(), p_dev_rec->sec_state); if (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE) { LOG_DEBUG( "Security state is idle indicating remote name request is outstanding"); if (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE && p_dev_rec->sec_state != BTM_SEC_STATE_LE_ENCRYPTING) { LOG_INFO("No immediate action taken in busy state: %s", security_state_text(p_dev_rec->sec_state).c_str()); return (BTM_CMD_STARTED); } Loading
system/stack/btm/security_device_record.h +10 −1 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ typedef enum : uint8_t { BTM_SEC_STATE_DELAY_FOR_ENC = 7, BTM_SEC_STATE_DISCONNECTING_BLE = 8, BTM_SEC_STATE_DISCONNECTING_BOTH = 9, BTM_SEC_STATE_LE_ENCRYPTING = 10, } tSECURITY_STATE; static inline std::string security_state_text(const tSECURITY_STATE& state) { Loading @@ -184,6 +185,7 @@ static inline std::string security_state_text(const tSECURITY_STATE& state) { CASE_RETURN_TEXT(BTM_SEC_STATE_DELAY_FOR_ENC); CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BLE); CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BOTH); CASE_RETURN_TEXT(BTM_SEC_STATE_LE_ENCRYPTING); default: return base::StringPrintf("UNKNOWN[%hhu]", state); } Loading Loading @@ -334,9 +336,16 @@ struct tBTM_SEC_DEV_REC { bool is_security_state_authenticating() const { return sec_state == BTM_SEC_STATE_AUTHENTICATING; } bool is_security_state_encrypting() const { bool is_security_state_bredr_encrypting() const { return sec_state == BTM_SEC_STATE_ENCRYPTING; } bool is_security_state_le_encrypting() const { return sec_state == BTM_SEC_STATE_LE_ENCRYPTING; } bool is_security_state_encrypting() const { return (is_security_state_bredr_encrypting() || is_security_state_le_encrypting()); } bool is_security_state_getting_name() const { return sec_state == BTM_SEC_STATE_GETTING_NAME; } Loading