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

Commit 36d43ec2 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Android Git Automerger
Browse files

am f5eb7853: Add flag indicating encrypted connections to btif_dm_get_connection_state()

* commit 'f5eb7853':
  Add flag indicating encrypted connections to btif_dm_get_connection_state()
parents 35f26a64 f5eb7853
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ BOOLEAN blacklistPairingRetries(BD_ADDR bd_addr)
#define BOND_TYPE_PERSISTENT  1
#define BOND_TYPE_TEMPORARY   2

#define ENCRYPTED_BREDR       2
#define ENCRYPTED_LE          4

typedef struct
{
    bt_bond_state_t state;
@@ -700,13 +703,33 @@ void btif_dm_cb_remove_bond(bt_bdaddr_t *bd_addr)
** Function         btif_dm_get_connection_state
**
** Description      Returns whether the remote device is currently connected
**                  and whether encryption is active for the connection
**
** Returns          0 if not connected
** Returns          0 if not connected; 1 if connected and > 1 if connection is
**                  encrypted
**
*******************************************************************************/
uint16_t btif_dm_get_connection_state(const bt_bdaddr_t *bd_addr)
{
    return BTA_DmGetConnectionState((UINT8 *)bd_addr->address);
    uint8_t *bda = (uint8_t*)bd_addr->address;
    uint16_t rc = BTA_DmGetConnectionState(bda);

    if (rc != 0)
    {
        uint8_t flags = 0;

        BTM_GetSecurityFlagsByTransport(bda, &flags, BT_TRANSPORT_BR_EDR);
        BTIF_TRACE_DEBUG("%s: security flags (BR/EDR)=0x%02x", __FUNCTION__, flags);
        if (flags & BTM_SEC_FLAG_ENCRYPTED)
            rc |= ENCRYPTED_BREDR;

        BTM_GetSecurityFlagsByTransport(bda, &flags, BT_TRANSPORT_LE);
        BTIF_TRACE_DEBUG("%s: security flags (LE)=0x%02x", __FUNCTION__, flags);
        if (flags & BTM_SEC_FLAG_ENCRYPTED)
            rc |= ENCRYPTED_LE;
    }

    return rc;
}

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