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

Commit 192c95da authored by Nitin Arora's avatar Nitin Arora Committed by Andre Eisenbach
Browse files

Use pseudo address while re-pairing peripheral

In case of pairing to an already paired device (in an instance
where the central remote has removed the keys), the change
makes sure that the correct address is used when LTK key
request occurs at the peripheral.

Bug: 22605510
Change-Id: I959003f39f70281ff1e6af8d4c4549138bc1682c
parent 5dfd8a97
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -1968,11 +1968,25 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable)
BOOLEAN smp_proc_ltk_request(BD_ADDR bda)
{
    SMP_TRACE_DEBUG("%s state = %d",  __func__, smp_cb.state);
    if ( smp_cb.state == SMP_STATE_ENCRYPTION_PENDING &&
         !memcmp(bda, smp_cb.pairing_bda, BD_ADDR_LEN))
    BOOLEAN match = FALSE;

    if (!memcmp(bda, smp_cb.pairing_bda, BD_ADDR_LEN))
    {
        smp_sm_event(&smp_cb, SMP_ENC_REQ_EVT, NULL);
        match = TRUE;
    } else {
        BD_ADDR dummy_bda = {0};
        tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bda);
        if (p_dev_rec != NULL &&
            0 == memcmp(p_dev_rec->ble.pseudo_addr, smp_cb.pairing_bda, BD_ADDR_LEN) &&
            0 != memcmp(p_dev_rec->ble.pseudo_addr, dummy_bda, BD_ADDR_LEN))
        {
            match = TRUE;
        }
    }

    if (match && smp_cb.state == SMP_STATE_ENCRYPTION_PENDING)
    {
        smp_sm_event(&smp_cb, SMP_ENC_REQ_EVT, NULL);
        return TRUE;
    }