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

Commit 6ea85d4c authored by Josh Wu's avatar Josh Wu
Browse files

Add Link Key Type info to dumpsys

There is very few log about link key type now and it's only logged
during pairing, so it's necessary to log them in dumpsys.

Tag: #feature
Bug: 224759516
Test: atest BluetoothInstrumentationTests
Change-Id: If79c81d2e875dce9b259def81a6fc049f2798cbb
parent f74c267d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -391,4 +391,15 @@ void btif_debug_bond_event_dump(int fd);
 ******************************************************************************/
bt_status_t btif_set_dynamic_audio_buffer_size(int codec, int size);

/*******************************************************************************
 *
 * Function         btif_debug_linkkey_type_dump
 *
 * Description     Dump exchanged linkkey types information
 *
 * Returns          void
 *
 ******************************************************************************/
void btif_debug_linkkey_type_dump(int fd);

#endif /* BTIF_API_H */
+1 −0
Original line number Diff line number Diff line
@@ -424,6 +424,7 @@ static int clear_event_filter() {
static void dump(int fd, const char** arguments) {
  btif_debug_conn_dump(fd);
  btif_debug_bond_event_dump(fd);
  btif_debug_linkkey_type_dump(fd);
  btif_debug_a2dp_dump(fd);
  btif_debug_av_dump(fd);
  bta_debug_av_dump(fd);
+27 −0
Original line number Diff line number Diff line
@@ -2303,3 +2303,30 @@ void btif_storage_remove_gatt_cl_db_hash(const RawAddress& bd_addr) {
                       },
                       bd_addr));
}

void btif_debug_linkkey_type_dump(int fd) {
  dprintf(fd, "\nLink Key Types:\n");
  for (const auto& bd_addr : btif_config_get_paired_devices()) {
    auto bdstr = bd_addr.ToString();
    int linkkey_type;
    dprintf(fd, "  %s\n", bdstr.c_str());

    dprintf(fd, "    BR: ");
    if (btif_config_get_int(bdstr, "LinkKeyType", &linkkey_type)) {
      dprintf(fd, "%s", linkkey_type_text(linkkey_type).c_str());
    }
    dprintf(fd, "\n");

    dprintf(fd, "    LE:");
    if (btif_config_exist(bdstr, "LE_KEY_PENC")) dprintf(fd, " PENC");
    if (btif_config_exist(bdstr, "LE_KEY_PID")) dprintf(fd, " PID");
    if (btif_config_exist(bdstr, "LE_KEY_PCSRK")) dprintf(fd, " PCSRK");
    if (btif_config_exist(bdstr, "LE_KEY_PLK")) dprintf(fd, " PLK");
    if (btif_config_exist(bdstr, "LE_KEY_LENC")) dprintf(fd, " LENC");
    if (btif_config_exist(bdstr, "LE_KEY_LCSRK")) dprintf(fd, " LCSRK");
    if (btif_config_exist(bdstr, "LE_KEY_LID")) dprintf(fd, " LID");
    if (btif_config_exist(bdstr, "LE_KEY_PLK")) dprintf(fd, " LLK");

    dprintf(fd, "\n");
  }
}
+24 −0
Original line number Diff line number Diff line
@@ -324,6 +324,7 @@ enum : uint16_t {
*/
#define BTM_LKEY_TYPE_COMBINATION HCI_LKEY_TYPE_COMBINATION
#define BTM_LKEY_TYPE_REMOTE_UNIT HCI_LKEY_TYPE_REMOTE_UNIT
#define BTM_LKEY_TYPE_DEBUG_COMB HCI_LKEY_TYPE_DEBUG_COMB
#define BTM_LKEY_TYPE_UNAUTH_COMB HCI_LKEY_TYPE_UNAUTH_COMB
#define BTM_LKEY_TYPE_AUTH_COMB HCI_LKEY_TYPE_AUTH_COMB
#define BTM_LKEY_TYPE_CHANGED_COMB HCI_LKEY_TYPE_CHANGED_COMB
@@ -331,6 +332,29 @@ enum : uint16_t {
#define BTM_LKEY_TYPE_UNAUTH_COMB_P_256 HCI_LKEY_TYPE_UNAUTH_COMB_P_256
#define BTM_LKEY_TYPE_AUTH_COMB_P_256 HCI_LKEY_TYPE_AUTH_COMB_P_256

inline std::string linkkey_type_text(const int linkkey_type) {
  switch (linkkey_type) {
    case BTM_LKEY_TYPE_COMBINATION:
      return std::string("COMBINATION");
    case BTM_LKEY_TYPE_REMOTE_UNIT:
      return std::string("REMOTE_UNIT");
    case BTM_LKEY_TYPE_DEBUG_COMB:
      return std::string("DEBUG_COMB");
    case BTM_LKEY_TYPE_UNAUTH_COMB:
      return std::string("UNAUTH_COMB");
    case BTM_LKEY_TYPE_AUTH_COMB:
      return std::string("AUTH_COMB");
    case BTM_LKEY_TYPE_CHANGED_COMB:
      return std::string("CHANGED_COMB");
    case BTM_LKEY_TYPE_UNAUTH_COMB_P_256:
      return std::string("UNAUTH_COMB_P_256");
    case BTM_LKEY_TYPE_AUTH_COMB_P_256:
      return std::string("AUTH_COMB_P_256");
    default:
      return base::StringPrintf("UNKNOWN[0x%02x]", linkkey_type);
  }
}

/* "easy" requirements for LK derived from LTK */
#define BTM_LTK_DERIVED_LKEY_OFFSET 0x20
#define BTM_LKEY_TYPE_IGNORE               \