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

Commit 5bbc7ee2 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/stack/hid: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: Ia01c229d0e798874f1d95c76a40e5accec88c1ed
parent f57dd95a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1696,6 +1696,7 @@ cc_test {
        "test/hid/stack_hid_test.cc",
    ],
    static_libs: [
        "libbase",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_log",
+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#define HID_CONN_H

#include <base/strings/stringprintf.h>
#include <bluetooth/log.h>

#include "macros.h"
#include "osi/include/alarm.h"
@@ -77,4 +78,9 @@ typedef struct hid_conn {

#define HIDD_SEC_CHN 3

namespace fmt {
template <>
struct formatter<tHID_CONN_STATE> : enum_formatter<tHID_CONN_STATE> {};
}  // namespace fmt

#endif
+16 −15
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@

#include "hidd_api.h"

#include <bluetooth/log.h>
#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h>
#include <stdio.h>
#include <stdlib.h>
@@ -44,6 +45,7 @@
#include "stack/include/stack_metrics_logging.h"
#include "types/raw_address.h"

using namespace bluetooth;
using namespace bluetooth::legacy::stack::sdp;

tHID_DEV_CTB hd_cb;
@@ -58,7 +60,7 @@ tHID_DEV_CTB hd_cb;
 *
 ******************************************************************************/
void HID_DevInit(void) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  memset(&hd_cb, 0, sizeof(tHID_DEV_CTB));
}
@@ -75,7 +77,7 @@ void HID_DevInit(void) {
tHID_STATUS HID_DevRegister(tHID_DEV_HOST_CALLBACK* host_cback) {
  tHID_STATUS st;

  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  if (hd_cb.reg_flag) {
    log_counter_metrics(
@@ -116,7 +118,7 @@ tHID_STATUS HID_DevRegister(tHID_DEV_HOST_CALLBACK* host_cback) {
 *
 ******************************************************************************/
tHID_STATUS HID_DevDeregister(void) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  if (!hd_cb.reg_flag) {
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
@@ -146,7 +148,7 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description,
                             uint16_t desc_len, uint8_t* p_desc_data) {
  bool result = TRUE;

  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  // Service Class ID List
  if (result) {
@@ -266,8 +268,8 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description,
      uint8_t seq_len = 4 + desc_len;

      if (desc_len > HIDD_APP_DESCRIPTOR_LEN) {
        LOG_ERROR("%s: descriptor length = %d, larger than max %d", __func__,
                  desc_len, HIDD_APP_DESCRIPTOR_LEN);
        log::error("descriptor length = {}, larger than max {}", desc_len,
                   HIDD_APP_DESCRIPTOR_LEN);
        log_counter_metrics(
            android::bluetooth::CodePathCounterKeyEnum::
                HIDD_ERR_NOT_REGISTERED_DUE_TO_DESCRIPTOR_LENGTH,
@@ -278,7 +280,7 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description,
      p_buf = (uint8_t*)osi_malloc(HIDD_APP_DESCRIPTOR_LEN + 6);

      if (p_buf == NULL) {
        LOG_ERROR("%s: Buffer allocation failure for size = 2048 ", __func__);
        log::error("Buffer allocation failure for size = 2048");
        log_counter_metrics(
            android::bluetooth::CodePathCounterKeyEnum::
                HIDD_ERR_NOT_REGISTERED_DUE_TO_BUFFER_ALLOCATION,
@@ -352,7 +354,7 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description,
  }

  if (!result) {
    LOG_ERROR("%s: failed to complete SDP record", __func__);
    log::error("failed to complete SDP record");
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
                            HIDD_ERR_NOT_REGISTERED_AT_SDP,
                        1);
@@ -373,8 +375,7 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description,
 ******************************************************************************/
tHID_STATUS HID_DevSendReport(uint8_t channel, uint8_t type, uint8_t id,
                              uint16_t len, uint8_t* p_data) {
  LOG_VERBOSE("%s: channel=%d type=%d id=%d len=%d", __func__, channel, type,
              id, len);
  log::verbose("channel={} type={} id={} len={}", channel, type, id, len);

  if (channel == HID_CHANNEL_CTRL) {
    return hidd_conn_send_data(HID_CHANNEL_CTRL, HID_TRANS_DATA, type, id, len,
@@ -402,7 +403,7 @@ tHID_STATUS HID_DevSendReport(uint8_t channel, uint8_t type, uint8_t id,
 *
 ******************************************************************************/
tHID_STATUS HID_DevVirtualCableUnplug(void) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  return hidd_conn_send_data(HID_CHANNEL_CTRL, HID_TRANS_CONTROL,
                             HID_PAR_CONTROL_VIRTUAL_CABLE_UNPLUG, 0, 0, NULL);
@@ -549,7 +550,7 @@ tHID_STATUS HID_DevSetIncomingPolicy(bool allow) {
tHID_STATUS HID_DevReportError(uint8_t error) {
  uint8_t handshake_param;

  LOG_VERBOSE("%s: error = %d", __func__, error);
  log::verbose("error = {}", error);

  switch (error) {
    case HID_PAR_HANDSHAKE_RSP_SUCCESS:
@@ -580,7 +581,7 @@ tHID_STATUS HID_DevReportError(uint8_t error) {
 *
 ******************************************************************************/
tHID_STATUS HID_DevGetDevice(RawAddress* addr) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  if (hd_cb.device.in_use) {
    *addr = hd_cb.device.addr;
@@ -607,7 +608,7 @@ tHID_STATUS HID_DevSetIncomingQos(uint8_t service_type, uint32_t token_rate,
                                  uint32_t token_bucket_size,
                                  uint32_t peak_bandwidth, uint32_t latency,
                                  uint32_t delay_variation) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  hd_cb.use_in_qos = TRUE;

@@ -634,7 +635,7 @@ tHID_STATUS HID_DevSetOutgoingQos(uint8_t service_type, uint32_t token_rate,
                                  uint32_t token_bucket_size,
                                  uint32_t peak_bandwidth, uint32_t latency,
                                  uint32_t delay_variation) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  hd_cb.l2cap_intr_cfg.qos_present = TRUE;

+49 −53
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#include <base/functional/callback.h>
#include <base/logging.h>
#include <bluetooth/log.h>
#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h>

#include <cstdint>
@@ -40,6 +41,8 @@
#include "stack/include/stack_metrics_logging.h"
#include "types/raw_address.h"

using namespace bluetooth;

static void hidd_l2cif_connect_ind(const RawAddress& bd_addr, uint16_t cid,
                                   uint16_t psm, uint8_t id);
static void hidd_l2cif_connect_cfm(uint16_t cid, uint16_t result);
@@ -107,12 +110,12 @@ static void hidd_l2cif_connect_ind(const RawAddress& bd_addr, uint16_t cid,
  tHID_DEV_DEV_CTB* p_dev;
  bool accept = TRUE;  // accept by default

  LOG_VERBOSE("%s: psm=%04x cid=%04x", __func__, psm, cid);
  log::verbose("psm={:04x} cid={:04x}", psm, cid);

  p_dev = &hd_cb.device;

  if (!hd_cb.allow_incoming) {
    LOG_WARN("%s: incoming connections not allowed, rejecting", __func__);
    log::warn("incoming connections not allowed, rejecting");
    L2CA_DisconnectReq(cid);

    return;
@@ -124,12 +127,12 @@ static void hidd_l2cif_connect_ind(const RawAddress& bd_addr, uint16_t cid,
    case HID_PSM_INTERRUPT:
      if (p_hcon->ctrl_cid == 0) {
        accept = FALSE;
        LOG_WARN("%s: incoming INTR without CTRL, rejecting", __func__);
        log::warn("incoming INTR without CTRL, rejecting");
      }

      if (p_hcon->conn_state != HID_CONN_STATE_CONNECTING_INTR) {
        accept = FALSE;
        LOG_WARN("%s: incoming INTR in invalid state (%d), rejecting", __func__,
        log::warn("incoming INTR in invalid state ({}), rejecting",
                  p_hcon->conn_state);
      }

@@ -138,7 +141,7 @@ static void hidd_l2cif_connect_ind(const RawAddress& bd_addr, uint16_t cid,
    case HID_PSM_CONTROL:
      if (p_hcon->conn_state != HID_CONN_STATE_UNUSED) {
        accept = FALSE;
        LOG_WARN("%s: incoming CTRL in invalid state (%d), rejecting", __func__,
        log::warn("incoming CTRL in invalid state ({}), rejecting",
                  p_hcon->conn_state);
      }

@@ -146,7 +149,7 @@ static void hidd_l2cif_connect_ind(const RawAddress& bd_addr, uint16_t cid,

    default:
      accept = FALSE;
      LOG_ERROR("%s: received invalid PSM, rejecting", __func__);
      log::error("received invalid PSM, rejecting");
      break;
  }

@@ -176,7 +179,7 @@ static void hidd_l2cif_connect_ind(const RawAddress& bd_addr, uint16_t cid,
}

static void hidd_on_l2cap_error(uint16_t lcid, uint16_t result) {
  LOG_WARN("%s: connection of config failed, now disconnect", __func__);
  log::warn("connection of config failed, now disconnect");

  hidd_conn_disconnect();

@@ -197,10 +200,10 @@ static void hidd_on_l2cap_error(uint16_t lcid, uint16_t result) {
static void hidd_l2cif_connect_cfm(uint16_t cid, uint16_t result) {
  tHID_CONN* p_hcon = &hd_cb.device.conn;

  LOG_VERBOSE("%s: cid=%04x result=%d", __func__, cid, result);
  log::verbose("cid={:04x} result={}", cid, result);

  if (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid) {
    LOG_WARN("%s: unknown cid", __func__);
    log::warn("unknown cid");
    return;
  }

@@ -209,12 +212,12 @@ static void hidd_l2cif_connect_cfm(uint16_t cid, uint16_t result) {
       (p_hcon->conn_state != HID_CONN_STATE_CONNECTING_CTRL)) ||
      ((cid == p_hcon->intr_cid) &&
       (p_hcon->conn_state != HID_CONN_STATE_CONNECTING_INTR))) {
    LOG_WARN("%s: unexpected", __func__);
    log::warn("unexpected");
    return;
  }

  if (result != L2CAP_CONN_OK) {
    LOG(ERROR) << __func__ << ": invoked with non OK status";
    log::error("invoked with non OK status");
    return;
  }

@@ -239,12 +242,12 @@ static void hidd_l2cif_connect_cfm(uint16_t cid, uint16_t result) {
 *
 ******************************************************************************/
static void hidd_l2cif_config_ind(uint16_t cid, tL2CAP_CFG_INFO* p_cfg) {
  LOG_VERBOSE("%s: cid=%04x", __func__, cid);
  log::verbose("cid={:04x}", cid);

  tHID_CONN* p_hcon = &hd_cb.device.conn;

  if (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid) {
    LOG_WARN("%s: unknown cid", __func__);
    log::warn("unknown cid");
    return;
  }

@@ -267,12 +270,12 @@ static void hidd_l2cif_config_cfm(uint16_t cid, uint16_t initiator,
                                  tL2CAP_CFG_INFO* p_cfg) {
  hidd_l2cif_config_ind(cid, p_cfg);

  LOG_VERBOSE("%s: cid=%04x", __func__, cid);
  log::verbose("cid={:04x}", cid);

  tHID_CONN* p_hcon = &hd_cb.device.conn;

  if (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid) {
    LOG_WARN("%s: unknown cid", __func__);
    log::warn("unknown cid");
    return;
  }

@@ -286,7 +289,7 @@ static void hidd_l2cif_config_cfm(uint16_t cid, uint16_t initiator,
        hidd_conn_disconnect();
        p_hcon->conn_state = HID_CONN_STATE_UNUSED;

        LOG_WARN("%s: could not start L2CAP connection for INTR", __func__);
        log::warn("could not start L2CAP connection for INTR");
        hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE,
                       HID_ERR_L2CAP_FAILED, NULL);
        log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
@@ -312,13 +315,13 @@ static void hidd_l2cif_config_cfm(uint16_t cid, uint16_t initiator,
 *
 ******************************************************************************/
static void hidd_l2cif_disconnect_ind(uint16_t cid, bool ack_needed) {
  LOG_VERBOSE("%s: cid=%04x ack_needed=%d", __func__, cid, ack_needed);
  log::verbose("cid={:04x} ack_needed={}", cid, ack_needed);

  tHID_CONN* p_hcon = &hd_cb.device.conn;

  if (p_hcon->conn_state == HID_CONN_STATE_UNUSED ||
      (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid)) {
    LOG_WARN("%s: unknown cid", __func__);
    log::warn("unknown cid");
    return;
  }

@@ -330,7 +333,7 @@ static void hidd_l2cif_disconnect_ind(uint16_t cid, bool ack_needed) {
    p_hcon->intr_cid = 0;

  if ((p_hcon->ctrl_cid == 0) && (p_hcon->intr_cid == 0)) {
    LOG_VERBOSE("%s: INTR and CTRL disconnected", __func__);
    log::verbose("INTR and CTRL disconnected");

    // clean any outstanding data on intr
    if (hd_cb.pending_data) {
@@ -349,13 +352,13 @@ static void hidd_l2cif_disconnect_ind(uint16_t cid, bool ack_needed) {
static void hidd_l2cif_disconnect(uint16_t cid) {
  L2CA_DisconnectReq(cid);

  LOG_VERBOSE("%s: cid=%04x", __func__, cid);
  log::verbose("cid={:04x}", cid);

  tHID_CONN* p_hcon = &hd_cb.device.conn;

  if (p_hcon->conn_state == HID_CONN_STATE_UNUSED ||
      (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid)) {
    LOG_WARN("%s: unknown cid", __func__);
    log::warn("unknown cid");
    return;
  }

@@ -373,7 +376,7 @@ static void hidd_l2cif_disconnect(uint16_t cid) {
  }

  if ((p_hcon->ctrl_cid == 0) && (p_hcon->intr_cid == 0)) {
    LOG_VERBOSE("%s: INTR and CTRL disconnected", __func__);
    log::verbose("INTR and CTRL disconnected");

    hd_cb.device.state = HIDD_DEV_NO_CONN;
    p_hcon->conn_state = HID_CONN_STATE_UNUSED;
@@ -399,13 +402,13 @@ static void hidd_l2cif_disconnect(uint16_t cid) {
 *
 ******************************************************************************/
static void hidd_l2cif_cong_ind(uint16_t cid, bool congested) {
  LOG_VERBOSE("%s: cid=%04x congested=%d", __func__, cid, congested);
  log::verbose("cid={:04x} congested={}", cid, congested);

  tHID_CONN* p_hcon = &hd_cb.device.conn;

  if (p_hcon->conn_state == HID_CONN_STATE_UNUSED ||
      (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid)) {
    LOG_WARN("%s: unknown cid", __func__);
    log::warn("unknown cid");
    return;
  }

@@ -430,10 +433,10 @@ static void hidd_l2cif_data_ind(uint16_t cid, BT_HDR* p_msg) {
  uint8_t msg_type, param;
  bool err = FALSE;

  LOG_VERBOSE("%s: cid=%04x", __func__, cid);
  log::verbose("cid={:04x}", cid);

  if (p_msg->len < 1) {
    LOG_ERROR("Invalid data length, ignore");
    log::error("Invalid data length, ignore");
    osi_free(p_msg);
    return;
  }
@@ -442,7 +445,7 @@ static void hidd_l2cif_data_ind(uint16_t cid, BT_HDR* p_msg) {

  if (p_hcon->conn_state == HID_CONN_STATE_UNUSED ||
      (p_hcon->ctrl_cid != cid && p_hcon->intr_cid != cid)) {
    LOG_WARN("%s: unknown cid", __func__);
    log::warn("unknown cid");
    osi_free(p_msg);
    return;
  }
@@ -481,15 +484,14 @@ static void hidd_l2cif_data_ind(uint16_t cid, BT_HDR* p_msg) {

    case HID_TRANS_SET_IDLE:
      if (p_msg->len != 2) {
        LOG_ERROR("%s: invalid len (%d) set idle request received", __func__,
                  p_msg->len);
        log::error("invalid len ({}) set idle request received", p_msg->len);
        err = TRUE;
      } else {
        hd_cb.device.idle_time = p_data[1];
        LOG_VERBOSE("%s: idle_time = %d", __func__, hd_cb.device.idle_time);
        log::verbose("idle_time = {}", hd_cb.device.idle_time);
        if (hd_cb.device.idle_time) {
          LOG_WARN("%s: idle_time of %d ms not supported by HID Device",
                   __func__, (hd_cb.device.idle_time * 4));
          log::warn("idle_time of {} ms not supported by HID Device",
                    (hd_cb.device.idle_time * 4));
          err = TRUE;
        }
      }
@@ -544,7 +546,7 @@ static void hidd_l2cif_data_ind(uint16_t cid, BT_HDR* p_msg) {

    case HID_TRANS_DATA:
    default:
      LOG_WARN("%s: got unsupported msg (%d)", __func__, msg_type);
      log::warn("got unsupported msg ({})", msg_type);
      hidd_conn_send_data(0, HID_TRANS_HANDSHAKE,
                          HID_PAR_HANDSHAKE_RSP_ERR_UNSUPPORTED_REQ, 0, 0,
                          NULL);
@@ -563,7 +565,7 @@ static void hidd_l2cif_data_ind(uint16_t cid, BT_HDR* p_msg) {
 *
 ******************************************************************************/
tHID_STATUS hidd_conn_reg(void) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  memset(&hd_cb.l2cap_cfg, 0, sizeof(tL2CAP_CFG_INFO));

@@ -576,7 +578,7 @@ tHID_STATUS hidd_conn_reg(void) {
  if (!L2CA_Register2(HID_PSM_CONTROL, dev_reg_info, false /* enable_snoop */,
                      nullptr, HID_DEV_MTU_SIZE, 0,
                      BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) {
    LOG_ERROR("HID Control (device) registration failed");
    log::error("HID Control (device) registration failed");
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
                            HIDD_ERR_L2CAP_FAILED_CONTROL,
                        1);
@@ -587,7 +589,7 @@ tHID_STATUS hidd_conn_reg(void) {
                      nullptr, HID_DEV_MTU_SIZE, 0,
                      BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) {
    L2CA_Deregister(HID_PSM_CONTROL);
    LOG_ERROR("HID Interrupt (device) registration failed");
    log::error("HID Interrupt (device) registration failed");
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
                            HIDD_ERR_L2CAP_FAILED_INTERRUPT,
                        1);
@@ -607,7 +609,7 @@ tHID_STATUS hidd_conn_reg(void) {
 *
 ******************************************************************************/
void hidd_conn_dereg(void) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  L2CA_Deregister(HID_PSM_CONTROL);
  L2CA_Deregister(HID_PSM_INTERRUPT);
@@ -625,10 +627,10 @@ void hidd_conn_dereg(void) {
tHID_STATUS hidd_conn_initiate(void) {
  tHID_DEV_DEV_CTB* p_dev = &hd_cb.device;

  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  if (!p_dev->in_use) {
    LOG_WARN("%s: no virtual cable established", __func__);
    log::warn("no virtual cable established");
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
                            HIDD_ERR_NOT_REGISTERED_AT_INITIATE,
                        1);
@@ -636,7 +638,7 @@ tHID_STATUS hidd_conn_initiate(void) {
  }

  if (p_dev->conn.conn_state != HID_CONN_STATE_UNUSED) {
    LOG_WARN("%s: connection already in progress", __func__);
    log::warn("connection already in progress");
    log_counter_metrics(
        android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_CONN_IN_PROCESS,
        1);
@@ -653,7 +655,7 @@ tHID_STATUS hidd_conn_initiate(void) {
  if ((p_dev->conn.ctrl_cid =
           L2CA_ConnectReq2(HID_PSM_CONTROL, p_dev->addr,
                            BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) == 0) {
    LOG_WARN("%s: could not start L2CAP connection", __func__);
    log::warn("could not start L2CAP connection");
    hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, HID_ERR_L2CAP_FAILED,
                   NULL);
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
@@ -676,7 +678,7 @@ tHID_STATUS hidd_conn_initiate(void) {
 *
 ******************************************************************************/
tHID_STATUS hidd_conn_disconnect(void) {
  LOG_VERBOSE("%s", __func__);
  log::verbose("");

  // clean any outstanding data on intr
  if (hd_cb.pending_data) {
@@ -699,7 +701,7 @@ tHID_STATUS hidd_conn_disconnect(void) {
      hidd_l2cif_disconnect(p_hcon->ctrl_cid);
    }
  } else {
    LOG_WARN("%s: already disconnected", __func__);
    log::warn("already disconnected");
    p_hcon->conn_state = HID_CONN_STATE_UNUSED;
  }

@@ -723,8 +725,7 @@ tHID_STATUS hidd_conn_send_data(uint8_t channel, uint8_t msg_type,
  uint16_t cid;
  uint16_t buf_size;

  LOG_VERBOSE("%s: channel(%d), msg_type(%d), len(%d)", __func__, channel,
              msg_type, len);
  log::verbose("channel({}), msg_type({}), len({})", channel, msg_type, len);

  tHID_CONN* p_hcon = &hd_cb.device.conn;

@@ -808,12 +809,7 @@ tHID_STATUS hidd_conn_send_data(uint8_t channel, uint8_t msg_type,
    return HID_ERR_NO_CONNECTION;
  }

#ifdef REPORT_TRANSFER_TIMESTAMP
  if (report_transfer) {
    LOG_ERROR("%s: report sent", __func__);
  }
#endif
  LOG_VERBOSE("%s: report sent", __func__);
  log::verbose("report sent");

  if (!L2CA_DataWrite(cid, p_buf)) {
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
+6 −4
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@

#include "hidh_api.h"

#include <bluetooth/log.h>
#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h>
#include <stdio.h>
#include <stdlib.h>
@@ -44,6 +45,7 @@
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"

using namespace bluetooth;
using namespace bluetooth::legacy::stack::sdp;
using bluetooth::Uuid;

@@ -107,7 +109,7 @@ void hidh_get_str_attr(tSDP_DISC_REC* p_rec, uint16_t attr_id, uint16_t max_len,
      }
    } else {
      str[0] = '\0';
      LOG_ERROR("attr type not str!!");
      log::error("attr type not str!!");
    }
  } else
    str[0] = '\0';
@@ -496,13 +498,13 @@ tHID_STATUS HID_HostWriteDev(uint8_t dev_handle, uint8_t t_type, uint8_t param,
  tHID_STATUS status = HID_SUCCESS;

  if (!hh_cb.reg_flag) {
    LOG_ERROR("HID_ERR_NOT_REGISTERED");
    log::error("HID_ERR_NOT_REGISTERED");
    status = HID_ERR_NOT_REGISTERED;
  }

  if ((dev_handle >= HID_HOST_MAX_DEVICES) ||
      (!hh_cb.devices[dev_handle].in_use)) {
    LOG_ERROR("HID_ERR_INVALID_PARAM");
    log::error("HID_ERR_INVALID_PARAM");
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
                            HIDH_ERR_INVALID_PARAM_AT_HOST_WRITE_DEV,
                        1);
@@ -510,7 +512,7 @@ tHID_STATUS HID_HostWriteDev(uint8_t dev_handle, uint8_t t_type, uint8_t param,
  }

  else if (hh_cb.devices[dev_handle].state != HID_DEV_CONNECTED) {
    LOG_ERROR("HID_ERR_NO_CONNECTION dev_handle %d", dev_handle);
    log::error("HID_ERR_NO_CONNECTION dev_handle {}", dev_handle);
    log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::
                            HIDH_ERR_NO_CONNECTION_AT_HOST_WRITE_DEV,
                        1);
Loading