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

Commit 3699c3ac authored by Chris Manton's avatar Chris Manton Committed by Gerrit Code Review
Browse files

Merge changes Ib557fbea,I25bb743c,I99f2584c,I852e9427,Iecae9ca5

* changes:
  Use gatt_client_event_text convention for logging
  shim: Add l2cap per-channel network transfer metrics
  shim: Add hid profile to dumpsys
  Add stack/gatt::gatt_channel_state_text
  Add stack/gatt::gatt_security_action_text
parents dc3f99fa 8f678663
Loading
Loading
Loading
Loading
+23 −34
Original line number Diff line number Diff line
@@ -70,44 +70,33 @@ typedef enum : uint8_t {
  BTA_GATTC_CONN_UPDATE_EVT = 26,   /* Connection parameters update event */
} tBTA_GATTC_EVT;

inline std::string GattClientEventText(tBTA_GATTC_EVT event) {
#define CASE_RETURN_TEXT(code) \
  case code:                   \
    return #code

inline std::string gatt_client_event_text(const tBTA_GATTC_EVT& event) {
  switch (event) {
    case BTA_GATTC_DEREG_EVT:
      return std::string("deregistered");
    case BTA_GATTC_OPEN_EVT:
      return std::string("opened");
    case BTA_GATTC_CLOSE_EVT:
      return std::string("closed");
    case BTA_GATTC_SEARCH_CMPL_EVT:
      return std::string("discovery completed");
    case BTA_GATTC_SEARCH_RES_EVT:
      return std::string("discovery result");
    case BTA_GATTC_SRVC_DISC_DONE_EVT:
      return std::string("discovery done");
    case BTA_GATTC_NOTIF_EVT:
      return std::string("attribute notification");
    case BTA_GATTC_EXEC_EVT:
      return std::string("execute write completed");
    case BTA_GATTC_ACL_EVT:
      return std::string("ACL up event");
    case BTA_GATTC_CANCEL_OPEN_EVT:
      return std::string("cancel open event");
    case BTA_GATTC_SRVC_CHG_EVT:
      return std::string("service changed");
    case BTA_GATTC_ENC_CMPL_CB_EVT:
      return std::string("encryption complete");
    case BTA_GATTC_CFG_MTU_EVT:
      return std::string("configure MTU complete");
    case BTA_GATTC_CONGEST_EVT:
      return std::string("congestion");
    case BTA_GATTC_PHY_UPDATE_EVT:
      return std::string("PHY change");
    case BTA_GATTC_CONN_UPDATE_EVT:
      return std::string("connection parameters update");
    CASE_RETURN_TEXT(BTA_GATTC_DEREG_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_OPEN_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_CLOSE_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_SEARCH_CMPL_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_SEARCH_RES_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_SRVC_DISC_DONE_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_NOTIF_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_EXEC_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_ACL_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_CANCEL_OPEN_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_SRVC_CHG_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_ENC_CMPL_CB_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_CFG_MTU_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_CONGEST_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_PHY_UPDATE_EVT);
    CASE_RETURN_TEXT(BTA_GATTC_CONN_UPDATE_EVT);
    default:
      return std::string("unknown");
      return std::string("UNKNOWN[%hhu]", event);
  }
}
#undef CASE_RETURN_TEXT

typedef struct {
  uint16_t unit;  /* as UUIUD defined by SIG */
+1 −1
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param) {

static void bta_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data) {
  LOG_DEBUG(" gatt client callback event:%s [%d]",
            GattClientEventText(event).c_str(), event);
            gatt_client_event_text(event).c_str(), event);
  bt_status_t status =
      btif_transfer_context(btif_gattc_upstreams_evt, (uint16_t)event,
                            (char*)p_data, sizeof(tBTA_GATTC), NULL);
+30 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <memory>
#include <string>

#include "btif/include/btif_hh.h"
#include "device/include/controller.h"
#include "gd/common/bidi_queue.h"
#include "gd/common/bind.h"
@@ -965,6 +966,34 @@ void DumpsysAcl(int fd) {
using Record = common::TimestampedEntry<std::string>;
const std::string kTimeFormat("%Y-%m-%d %H:%M:%S");

#define DUMPSYS_TAG "shim::legacy::hid"
extern btif_hh_cb_t btif_hh_cb;

void DumpsysHid(int fd) {
  LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);
  LOG_DUMPSYS(fd, "status:%s num_devices:%u",
              btif_hh_status_text(btif_hh_cb.status).c_str(),
              btif_hh_cb.device_num);
  LOG_DUMPSYS(fd, "status:%s", btif_hh_status_text(btif_hh_cb.status).c_str());
  for (unsigned i = 0; i < BTIF_HH_MAX_HID; i++) {
    const btif_hh_device_t* p_dev = &btif_hh_cb.devices[i];
    if (p_dev->bd_addr != RawAddress::kEmpty) {
      LOG_DUMPSYS(fd, "  %u: addr:%s fd:%d state:%s ready:%s thread_id:%d", i,
                  PRIVATE_ADDRESS(p_dev->bd_addr), p_dev->fd,
                  bthh_connection_state_text(p_dev->dev_status).c_str(),
                  (p_dev->ready_for_data) ? ("T") : ("F"),
                  static_cast<int>(p_dev->hh_poll_thread_id));
    }
  }
  for (unsigned i = 0; i < BTIF_HH_MAX_ADDED_DEV; i++) {
    const btif_hh_added_device_t* p_dev = &btif_hh_cb.added_devices[i];
    if (p_dev->bd_addr != RawAddress::kEmpty) {
      LOG_DUMPSYS(fd, "  %u: addr:%s", i, PRIVATE_ADDRESS(p_dev->bd_addr));
    }
  }
}
#undef DUMPSYS_TAG

#define DUMPSYS_TAG "shim::legacy::btm"
void DumpsysBtm(int fd) {
  LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);
@@ -1004,6 +1033,7 @@ void DumpsysRecord(int fd) {
#undef DUMPSYS_TAG

void shim::legacy::Acl::Dump(int fd) const {
  DumpsysHid(fd);
  DumpsysRecord(fd);
  DumpsysAcl(fd);
  DumpsysL2cap(fd);
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <map>
#include <thread>

#include "btif/include/btif_hh.h"
#include "device/include/controller.h"
#include "gd/btaa/activity_attribution.h"
#include "gd/hal/hci_hal.h"
@@ -62,6 +63,7 @@ const uint8_t kMaxLeAcceptlistSize = 16;
std::map<std::string, int> mock_function_count_map;
tL2C_CB l2cb;
tBTM_CB btm_cb;
btif_hh_cb_t btif_hh_cb;

namespace {
std::map<std::string, std::promise<uint16_t>> mock_function_handle_promise_map;
+37 −0
Original line number Diff line number Diff line
@@ -51,6 +51,26 @@ typedef enum : uint8_t {
  GATT_SEC_ENC_PENDING = 6,     /* wait for link encryption pending */
} tGATT_SEC_ACTION;

#define CASE_RETURN_TEXT(code) \
  case code:                   \
    return #code

inline std::string gatt_security_action_text(const tGATT_SEC_ACTION& action) {
  switch (action) {
    CASE_RETURN_TEXT(GATT_SEC_NONE);
    CASE_RETURN_TEXT(GATT_SEC_OK);
    CASE_RETURN_TEXT(GATT_SEC_SIGN_DATA);
    CASE_RETURN_TEXT(GATT_SEC_ENCRYPT);
    CASE_RETURN_TEXT(GATT_SEC_ENCRYPT_NO_MITM);
    CASE_RETURN_TEXT(GATT_SEC_ENCRYPT_MITM);
    CASE_RETURN_TEXT(GATT_SEC_ENC_PENDING);
    default:
      return std::string("UNKNOWN[%hhu]", action);
  }
}

#undef CASE_RETURN_TEXT

#define GATT_INDEX_INVALID 0xff

#define GATT_WRITE_CMD_MASK 0xc0 /*0x1100-0000*/
@@ -215,6 +235,23 @@ typedef enum : uint8_t {
  GATT_CH_OPEN = 4,
} tGATT_CH_STATE;

#define CASE_RETURN_TEXT(code) \
  case code:                   \
    return #code

inline std::string gatt_channel_state_text(const tGATT_CH_STATE& state) {
  switch (state) {
    CASE_RETURN_TEXT(GATT_CH_CLOSE);
    CASE_RETURN_TEXT(GATT_CH_CLOSING);
    CASE_RETURN_TEXT(GATT_CH_CONN);
    CASE_RETURN_TEXT(GATT_CH_CFG);
    CASE_RETURN_TEXT(GATT_CH_OPEN);
    default:
      return std::string("UNKNOWN[%hhu]", state);
  }
}
#undef CASE_RETURN_TEXT

#define GATT_GATT_START_HANDLE 1
#define GATT_GAP_START_HANDLE 20
#define GATT_APP_START_HANDLE 40
Loading