Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c87a4af authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Reset device security flags when pairing fails

Bug: 29998634
Test: manual
(cherry picked from commit 54ee9431e8bf0ec1c47d7306fd7a3d0975590733)

Change-Id: I8bd0ce5b797e30009260f7fe673f389d066db9ac
parent 8eabdd75
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -3494,24 +3494,19 @@ static void bta_dm_reset_sec_dev_pending(BD_ADDR remote_bd_addr)
*******************************************************************************/
static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
{
    uint16_t index = 0;
    if ( BTM_IsAclConnectionUp(remote_bd_addr, BT_TRANSPORT_LE) ||
         BTM_IsAclConnectionUp(remote_bd_addr, BT_TRANSPORT_BR_EDR))
    {
        APPL_TRACE_DEBUG("%s ACL is not down. Schedule for  Dev Removal when ACL closes",
                            __func__);
        for (index = 0; index < bta_dm_cb.device_list.count; index ++)
        BTM_SecClearSecurityFlags (remote_bd_addr);
        for (int i = 0; i < bta_dm_cb.device_list.count; i++)
        {
            if (!bdcmp( bta_dm_cb.device_list.peer_device[index].peer_bdaddr, remote_bd_addr))
                break;
        }
        if (index != bta_dm_cb.device_list.count)
            if (!bdcmp( bta_dm_cb.device_list.peer_device[i].peer_bdaddr, remote_bd_addr))
            {
            bta_dm_cb.device_list.peer_device[index].remove_dev_pending = true;
                bta_dm_cb.device_list.peer_device[i].remove_dev_pending = TRUE;
                break;
            }
        else
        {
            APPL_TRACE_ERROR(" %s Device does not exist in DB", __func__);
        }
    }
    else
+19 −0
Original line number Diff line number Diff line
@@ -188,6 +188,25 @@ bool BTM_SecDeleteDevice (BD_ADDR bd_addr)
    return true;
}

/*******************************************************************************
**
** Function         BTM_SecClearSecurityFlags
**
** Description      Reset the security flags (mark as not-paired) for a given
**                  remove device.
**
*******************************************************************************/
extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr)
{
    tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
    if (p_dev_rec == NULL)
        return;

    p_dev_rec->sec_flags = 0;
    p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
    p_dev_rec->sm4 = BTM_SM4_UNKNOWN;
}

/*******************************************************************************
**
** Function         BTM_SecReadDevName
+9 −0
Original line number Diff line number Diff line
@@ -1452,6 +1452,15 @@ extern bool BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
*******************************************************************************/
extern bool    BTM_SecDeleteDevice (BD_ADDR bd_addr);

/*******************************************************************************
**
** Function         BTM_SecClearSecurityFlags
**
** Description      Reset the security flags (mark as not-paired) for a given
**                  remove device.
**
*******************************************************************************/
extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr);

/*******************************************************************************
**