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

Commit 393155e4 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Add forget bond info btm_log_history am: 20372826

parents eed7a6c2 20372826
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -44,6 +44,12 @@

extern tBTM_CB btm_cb;

namespace {

constexpr char kBtmLogTag[] = "BOND";

}

/*******************************************************************************
 *
 * Function         BTM_SecAddDevice
@@ -178,6 +184,11 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
    /* Tell controller to get rid of the link key, if it has one stored */
    BTM_DeleteStoredLinkKey(&bda, NULL);
    LOG_INFO("%s %s complete", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
    BTM_LogHistory(
        kBtmLogTag, bd_addr, "Device removed",
        base::StringPrintf("device_type:%s bond_type:%s",
                           DeviceTypeText(p_dev_rec->device_type).c_str(),
                           bond_type_text(p_dev_rec->bond_type).c_str()));
  } else {
    LOG_WARN("%s Unable to delete link key for unknown device %s", __func__,
             ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
+11 −0
Original line number Diff line number Diff line
@@ -459,3 +459,14 @@ struct tBTM_SEC_DEV_REC {
        PRIVATE_NAME(sec_bd_name));
  }
};

inline std::string bond_type_text(
    const tBTM_SEC_DEV_REC::tBTM_BOND_TYPE& bond_type) {
  switch (bond_type) {
    CASE_RETURN_TEXT(tBTM_SEC_DEV_REC::BOND_TYPE_UNKNOWN);
    CASE_RETURN_TEXT(tBTM_SEC_DEV_REC::BOND_TYPE_PERSISTENT);
    CASE_RETURN_TEXT(tBTM_SEC_DEV_REC::BOND_TYPE_TEMPORARY);
    default:
      return base::StringPrintf("UNKNOWN[%hhu]", bond_type);
  }
}
+21 −0
Original line number Diff line number Diff line
@@ -421,3 +421,24 @@ TEST_F(StackBtmTest, btm_oob_data_text) {
                                     std::numeric_limits<std::uint8_t>::max()))
                   .c_str());
}

TEST_F(StackBtmTest, bond_type_text) {
  std::vector<std::pair<tBTM_SEC_DEV_REC::tBTM_BOND_TYPE, std::string>> datas =
      {
          std::make_pair(tBTM_SEC_DEV_REC::BOND_TYPE_UNKNOWN,
                         "tBTM_SEC_DEV_REC::BOND_TYPE_UNKNOWN"),
          std::make_pair(tBTM_SEC_DEV_REC::BOND_TYPE_PERSISTENT,
                         "tBTM_SEC_DEV_REC::BOND_TYPE_PERSISTENT"),
          std::make_pair(tBTM_SEC_DEV_REC::BOND_TYPE_TEMPORARY,
                         "tBTM_SEC_DEV_REC::BOND_TYPE_TEMPORARY"),
      };
  for (const auto& data : datas) {
    ASSERT_STREQ(data.second.c_str(), bond_type_text(data.first).c_str());
  }
  auto unknown = base::StringPrintf("UNKNOWN[%hhu]",
                                    std::numeric_limits<std::uint8_t>::max());
  ASSERT_STREQ(unknown.c_str(),
               bond_type_text(static_cast<tBTM_SEC_DEV_REC::tBTM_BOND_TYPE>(
                                  std::numeric_limits<std::uint8_t>::max()))
                   .c_str());
}