Loading system/bta/csis/csis_client.cc +10 −12 Original line number Diff line number Diff line Loading @@ -1317,12 +1317,11 @@ class CsisClientImpl : public CsisClient { /* Make sure device is not already bonded which could * be a case for dual mode devices where */ tBTM_SEC_DEV_REC* p_dev = btm_find_dev(result->bd_addr); if (p_dev && p_dev->is_le_link_key_known()) { LOG_VERBOSE( "Device %s already bonded. Identity address: %s", if (BTM_BleIsLinkKeyKnown(result->bd_addr)) { LOG_VERBOSE("Device %s already bonded. Identity address: %s", ADDRESS_TO_LOGGABLE_CSTR(result->bd_addr), ADDRESS_TO_LOGGABLE_CSTR(p_dev->ble.identity_address_with_type)); ADDRESS_TO_LOGGABLE_CSTR( *BTM_BleGetIdentityAddress(result->bd_addr))); return; } Loading Loading @@ -1468,12 +1467,11 @@ class CsisClientImpl : public CsisClient { /* Make sure device is not already bonded which could * be a case for dual mode devices where */ tBTM_SEC_DEV_REC* p_dev = btm_find_dev(result->bd_addr); if (p_dev && p_dev->is_le_link_key_known()) { LOG_VERBOSE( "Device %s already bonded. Identity address: %s", if (BTM_BleIsLinkKeyKnown(result->bd_addr)) { LOG_VERBOSE("Device %s already bonded. Identity address: %s", ADDRESS_TO_LOGGABLE_CSTR(result->bd_addr), ADDRESS_TO_LOGGABLE_CSTR(p_dev->ble.identity_address_with_type)); ADDRESS_TO_LOGGABLE_CSTR( *BTM_BleGetIdentityAddress(result->bd_addr))); return; } Loading system/bta/test/common/btm_api_mock.cc +11 −0 Original line number Diff line number Diff line Loading @@ -117,3 +117,14 @@ std::optional<Octet16> BTM_BleGetPeerIRK(const RawAddress address) { LOG_ASSERT(btm_interface) << "Mock btm interface not set!"; return btm_interface->BTM_BleGetPeerIRK(address); } bool BTM_BleIsLinkKeyKnown(const RawAddress address) { LOG_ASSERT(btm_interface) << "Mock btm interface not set!"; return btm_interface->BTM_BleIsLinkKeyKnown(address); } std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress( const RawAddress address) { LOG_ASSERT(btm_interface) << "Mock btm interface not set!"; return btm_interface->BTM_BleGetIdentityAddress(address); } system/bta/test/common/btm_api_mock.h +10 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "bt_octets.h" #include "btm_api.h" #include "stack/btm/security_device_record.h" #include "types/ble_address_with_type.h" #include "types/raw_address.h" namespace bluetooth { Loading Loading @@ -62,6 +63,10 @@ class BtmInterface { virtual std::optional<Octet16> BTM_BleGetPeerIRK( const RawAddress address) = 0; virtual bool BTM_BleIsLinkKeyKnown(const RawAddress address) = 0; virtual std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress( const RawAddress address) = 0; virtual ~BtmInterface() = default; }; Loading Loading @@ -107,6 +112,11 @@ class MockBtmInterface : public BtmInterface { (const RawAddress address), (override)); MOCK_METHOD((std::optional<Octet16>), BTM_BleGetPeerIRK, (const RawAddress address), (override)); MOCK_METHOD((bool), BTM_BleIsLinkKeyKnown, (const RawAddress address), (override)); MOCK_METHOD((std::optional<tBLE_BD_ADDR>), BTM_BleGetIdentityAddress, (const RawAddress address), (override)); }; /** Loading system/stack/btm/btm_ble_sec.cc +15 −0 Original line number Diff line number Diff line Loading @@ -1961,3 +1961,18 @@ std::optional<Octet16> BTM_BleGetPeerIRK(const RawAddress address) { return p_dev_rec->ble_keys.irk; } bool BTM_BleIsLinkKeyKnown(const RawAddress address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); return p_dev_rec != nullptr && p_dev_rec->is_le_link_key_known(); } std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress( const RawAddress address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); if (p_dev_rec == nullptr) { return std::nullopt; } return p_dev_rec->ble.identity_address_with_type; } system/stack/include/btm_ble_sec_api.h +31 −0 Original line number Diff line number Diff line Loading @@ -235,3 +235,34 @@ std::optional<Octet16> BTM_BleGetPeerLTK(const RawAddress address); * ******************************************************************************/ std::optional<Octet16> BTM_BleGetPeerIRK(const RawAddress address); /******************************************************************************* * * Function BTM_BleIsLinkKeyKnown * * Description This function is used to check whether the link key * of a peer (LE) device is known or not * * Parameters: address: address of the peer device * * Returns true if the link key is known * false otherwise * ******************************************************************************/ bool BTM_BleIsLinkKeyKnown(const RawAddress address); /******************************************************************************* * * Function BTM_BleGetIdentityAddress * * Description This function is called to get the identity address * (with type) of a peer (LE) device. * * Parameters: address: address of the peer device * * Returns the identity address in std::optional if the remote device * is present in security database * std::nullopt if the device is not present * ******************************************************************************/ std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress(const RawAddress address); Loading
system/bta/csis/csis_client.cc +10 −12 Original line number Diff line number Diff line Loading @@ -1317,12 +1317,11 @@ class CsisClientImpl : public CsisClient { /* Make sure device is not already bonded which could * be a case for dual mode devices where */ tBTM_SEC_DEV_REC* p_dev = btm_find_dev(result->bd_addr); if (p_dev && p_dev->is_le_link_key_known()) { LOG_VERBOSE( "Device %s already bonded. Identity address: %s", if (BTM_BleIsLinkKeyKnown(result->bd_addr)) { LOG_VERBOSE("Device %s already bonded. Identity address: %s", ADDRESS_TO_LOGGABLE_CSTR(result->bd_addr), ADDRESS_TO_LOGGABLE_CSTR(p_dev->ble.identity_address_with_type)); ADDRESS_TO_LOGGABLE_CSTR( *BTM_BleGetIdentityAddress(result->bd_addr))); return; } Loading Loading @@ -1468,12 +1467,11 @@ class CsisClientImpl : public CsisClient { /* Make sure device is not already bonded which could * be a case for dual mode devices where */ tBTM_SEC_DEV_REC* p_dev = btm_find_dev(result->bd_addr); if (p_dev && p_dev->is_le_link_key_known()) { LOG_VERBOSE( "Device %s already bonded. Identity address: %s", if (BTM_BleIsLinkKeyKnown(result->bd_addr)) { LOG_VERBOSE("Device %s already bonded. Identity address: %s", ADDRESS_TO_LOGGABLE_CSTR(result->bd_addr), ADDRESS_TO_LOGGABLE_CSTR(p_dev->ble.identity_address_with_type)); ADDRESS_TO_LOGGABLE_CSTR( *BTM_BleGetIdentityAddress(result->bd_addr))); return; } Loading
system/bta/test/common/btm_api_mock.cc +11 −0 Original line number Diff line number Diff line Loading @@ -117,3 +117,14 @@ std::optional<Octet16> BTM_BleGetPeerIRK(const RawAddress address) { LOG_ASSERT(btm_interface) << "Mock btm interface not set!"; return btm_interface->BTM_BleGetPeerIRK(address); } bool BTM_BleIsLinkKeyKnown(const RawAddress address) { LOG_ASSERT(btm_interface) << "Mock btm interface not set!"; return btm_interface->BTM_BleIsLinkKeyKnown(address); } std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress( const RawAddress address) { LOG_ASSERT(btm_interface) << "Mock btm interface not set!"; return btm_interface->BTM_BleGetIdentityAddress(address); }
system/bta/test/common/btm_api_mock.h +10 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "bt_octets.h" #include "btm_api.h" #include "stack/btm/security_device_record.h" #include "types/ble_address_with_type.h" #include "types/raw_address.h" namespace bluetooth { Loading Loading @@ -62,6 +63,10 @@ class BtmInterface { virtual std::optional<Octet16> BTM_BleGetPeerIRK( const RawAddress address) = 0; virtual bool BTM_BleIsLinkKeyKnown(const RawAddress address) = 0; virtual std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress( const RawAddress address) = 0; virtual ~BtmInterface() = default; }; Loading Loading @@ -107,6 +112,11 @@ class MockBtmInterface : public BtmInterface { (const RawAddress address), (override)); MOCK_METHOD((std::optional<Octet16>), BTM_BleGetPeerIRK, (const RawAddress address), (override)); MOCK_METHOD((bool), BTM_BleIsLinkKeyKnown, (const RawAddress address), (override)); MOCK_METHOD((std::optional<tBLE_BD_ADDR>), BTM_BleGetIdentityAddress, (const RawAddress address), (override)); }; /** Loading
system/stack/btm/btm_ble_sec.cc +15 −0 Original line number Diff line number Diff line Loading @@ -1961,3 +1961,18 @@ std::optional<Octet16> BTM_BleGetPeerIRK(const RawAddress address) { return p_dev_rec->ble_keys.irk; } bool BTM_BleIsLinkKeyKnown(const RawAddress address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); return p_dev_rec != nullptr && p_dev_rec->is_le_link_key_known(); } std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress( const RawAddress address) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address); if (p_dev_rec == nullptr) { return std::nullopt; } return p_dev_rec->ble.identity_address_with_type; }
system/stack/include/btm_ble_sec_api.h +31 −0 Original line number Diff line number Diff line Loading @@ -235,3 +235,34 @@ std::optional<Octet16> BTM_BleGetPeerLTK(const RawAddress address); * ******************************************************************************/ std::optional<Octet16> BTM_BleGetPeerIRK(const RawAddress address); /******************************************************************************* * * Function BTM_BleIsLinkKeyKnown * * Description This function is used to check whether the link key * of a peer (LE) device is known or not * * Parameters: address: address of the peer device * * Returns true if the link key is known * false otherwise * ******************************************************************************/ bool BTM_BleIsLinkKeyKnown(const RawAddress address); /******************************************************************************* * * Function BTM_BleGetIdentityAddress * * Description This function is called to get the identity address * (with type) of a peer (LE) device. * * Parameters: address: address of the peer device * * Returns the identity address in std::optional if the remote device * is present in security database * std::nullopt if the device is not present * ******************************************************************************/ std::optional<tBLE_BD_ADDR> BTM_BleGetIdentityAddress(const RawAddress address);