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

Commit 92371552 authored by Hui Peng's avatar Hui Peng
Browse files

Clean up logs in bta/hh

Bug: 305066880
Test: m com.android.btservices
Flag: EXEMPT, no-op
Change-Id: I971790c897cfd966c9484aceaf2cf3677b60d87b
parent 42363b5d
Loading
Loading
Loading
Loading
+22 −22
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
 *
 ******************************************************************************/

#define LOG_TAG "bluetooth"
#define LOG_TAG "bt_bta_hh"

#include <cstdint>
#include <string>
@@ -204,8 +204,8 @@ static void bta_hh_sdp_cback(uint16_t result, uint16_t attr_mask,
    /* security is required for the connection, add attr_mask bit*/
    attr_mask |= HID_SEC_REQUIRED;

    LOG_VERBOSE("%s: p_cb: %p result 0x%02x, attr_mask 0x%02x, handle %x",
                __func__, p_cb, result, attr_mask, p_cb->hid_handle);
    LOG_VERBOSE("p_cb:%p result:0x%02x, attr_mask:0x%02x, handle:0x%x", p_cb,
                result, attr_mask, p_cb->hid_handle);

    /* check to see type of device is supported , and should not been added
     * before */
@@ -266,7 +266,7 @@ static void bta_hh_di_sdp_cback(UNUSED_ATTR const RawAddress& bd_addr,
  tBTA_HH_STATUS status = BTA_HH_ERR_SDP;
  tSDP_DI_GET_RECORD di_rec;
  tHID_STATUS ret;
  LOG_VERBOSE("%s: p_cb: %p result 0x%02x", __func__, p_cb, result);
  LOG_VERBOSE("p_cb:%p result:0x%02x", p_cb, result);

  /* if DI record does not exist on remote device, vendor_id in
   * tBTA_HH_DEV_DSCP_INFO will be set to 0xffff and we will allow the
@@ -296,8 +296,7 @@ static void bta_hh_di_sdp_cback(UNUSED_ATTR const RawAddress& bd_addr,
    if (ret == HID_SUCCESS) {
      status = BTA_HH_OK;
    } else {
      LOG_VERBOSE("%s:  HID_HostGetSDPRecord failed: Status 0x%2x", __func__,
                  ret);
      LOG_VERBOSE("failure Status 0x%2x", ret);
    }
  }

@@ -372,7 +371,7 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
  tBTA_HH_CONN conn_dat;
  tBTA_HH_STATUS status = p_data->status;

  LOG_VERBOSE("%s:  status 0x%2X", __func__, p_data->status);
  LOG_VERBOSE("status 0x%2X", p_data->status);

  /* initialize call back data */
  memset((void*)&conn_dat, 0, sizeof(tBTA_HH_CONN));
@@ -387,17 +386,17 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {

      /* open HID connection */
      ret = HID_HostOpenDev(p_cb->hid_handle);
      LOG_VERBOSE("%s: HID_HostOpenDev returned=%d", __func__, ret);
      LOG_VERBOSE("HID_HostOpenDev returned=%d", ret);
      if (ret == HID_SUCCESS || ret == HID_ERR_ALREADY_CONN) {
        status = BTA_HH_OK;
      } else if (ret == HID_ERR_CONN_IN_PROCESS) {
        /* Connection already in progress, return from here, SDP
         * will be performed after connection is completed.
         */
        LOG_VERBOSE("%s: connection already in progress", __func__);
        LOG_VERBOSE("connection already in progress");
        return;
      } else {
        LOG_VERBOSE("%s: HID_HostOpenDev failed: Status 0x%2X", __func__, ret);
        LOG_VERBOSE("HID_HostOpenDev failed: Status 0x%2X", ret);
        /* open fail, remove device from management device list */
        HID_HostRemoveDev(p_cb->hid_handle);
        status = BTA_HH_ERR;
@@ -416,7 +415,7 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
     */
    if ((status == BTA_HH_ERR_SDP) && (p_cb->incoming_conn) &&
        (p_cb->app_id == 0)) {
      LOG_ERROR("%s: SDP failed for  incoming conn hndl: %d", __func__,
      LOG_ERROR("SDP failed for  incoming conn hndl:%d",
                p_cb->incoming_hid_handle);
      HID_HostRemoveDev(p_cb->incoming_hid_handle);
    }
@@ -457,7 +456,7 @@ static void bta_hh_bredr_conn(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data)
    tBTA_HH_DATA bta_hh_data;
    bta_hh_data.status = BTA_HH_OK;

    LOG_VERBOSE("%s: skip SDP for known devices", __func__);
    LOG_VERBOSE("skip SDP for known devices");

    if (p_cb->hid_handle == BTA_HH_INVALID_HANDLE) {
      uint8_t hdl;
@@ -673,7 +672,7 @@ void bta_hh_open_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
  uint8_t dev_handle =
      p_data ? (uint8_t)p_data->hid_cback.hdr.layer_specific : p_cb->hid_handle;

  LOG_VERBOSE("%s:  Device[%d] connected", __func__, dev_handle);
  LOG_VERBOSE("Device[%d] connected", dev_handle);

  /* SDP has been done */
  if (p_cb->app_id != 0) {
@@ -1124,9 +1123,10 @@ void bta_hh_write_dev_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
        };
        (*bta_hh_cb.p_cback)(BTA_HH_VC_UNPLUG_EVT, &cbdata);
      } else {
        LOG_ERROR("skipped executing callback in hid host error handling. "
                  "command type: %d, param: %d", p_data->api_sndcmd.t_type,
                  p_data->api_sndcmd.param);
        LOG_ERROR(
            "skipped executing callback in hid host error handling. "
            "command type:%d, param:%d",
            p_data->api_sndcmd.t_type, p_data->api_sndcmd.param);
      }
    } else {
      switch (p_data->api_sndcmd.t_type) {
@@ -1156,7 +1156,7 @@ void bta_hh_write_dev_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
        /* currently not expected */
        case HID_TRANS_DATAC:
        default:
          LOG_VERBOSE("%s: cmd type = %d", __func__, p_data->api_sndcmd.t_type);
          LOG_VERBOSE("cmd type=%d", p_data->api_sndcmd.t_type);
          break;
      }

@@ -1193,7 +1193,7 @@ static void bta_hh_cback(uint8_t dev_handle, const RawAddress& addr,
  uint16_t sm_event = BTA_HH_INVALID_EVT;
  uint8_t xx = 0;

  LOG_VERBOSE("%s::HID_event [%s]", __func__, bta_hh_hid_event_name(event));
  LOG_VERBOSE("HID_event [%s]", bta_hh_hid_event_name(event));

  switch (event) {
    case HID_HDEV_EVT_OPEN:
+1 −1
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@

#include <cstdint>

#include "bt_target.h"  // Must be first to define build configuration
#include "bta/hh/bta_hh_int.h"
#include "bta/sys/bta_sys.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "stack/include/bt_hdr.h"
+70 −83

File changed.

Preview size limit exceeded, changes collapsed.

+11 −7
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@
 *
 ******************************************************************************/

#define LOG_TAG "bt_bta_hh"

#include <string.h>  // memset

#include <cstdint>

#include "bt_target.h"  // Must be first to define build configuration
#include "bta/hh/bta_hh_int.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"

@@ -44,6 +46,8 @@ static const char* bta_hh_state_code(tBTA_HH_STATE state_code);

static void bta_hh_better_state_machine(tBTA_HH_DEV_CB* p_cb, uint16_t event,
                                        const tBTA_HH_DATA* p_data) {
  LOG_VERBOSE("state:%s, event:%s", bta_hh_state_code(p_cb->state),
              bta_hh_evt_code(static_cast<tBTA_HH_INT_EVT>(event)));
  switch (p_cb->state) {
    case BTA_HH_IDLE_ST:
      switch (event) {
@@ -195,6 +199,8 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,

  /* handle exception, no valid control block was found */
  if (!p_cb) {
    LOG_VERBOSE("Event:%s, bta_hh_cb.p_cback:%p", bta_hh_evt_code(debug_event),
                bta_hh_cb.p_cback);
    /* BTA HH enabled already? otherwise ignore the event although it's bad*/
    if (bta_hh_cb.p_cback != NULL) {
      switch (event) {
@@ -255,7 +261,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,

        default:
          /* invalid handle, call bad API event */
          LOG_ERROR("wrong device handle: [%d]", p_data->hdr.layer_specific);
          LOG_ERROR("wrong device handle:%d", p_data->hdr.layer_specific);
          /* Free the callback buffer now */
          if (p_data != NULL)
            osi_free_and_reset((void**)&p_data->hid_cback.p_data);
@@ -267,12 +273,11 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,
  /* corresponding CB is found, go to state machine */
  else {
    in_state = p_cb->state;
    LOG_VERBOSE("bta_hh_sm_execute: State 0x%02x [%s], Event [%s]", in_state,
    LOG_VERBOSE("State 0x%02x [%s], Event [%s]", in_state,
                bta_hh_state_code(in_state), bta_hh_evt_code(debug_event));

    if ((p_cb->state == BTA_HH_NULL_ST) || (p_cb->state >= BTA_HH_INVALID_ST)) {
      LOG_ERROR("bta_hh_sm_execute: Invalid state State = 0x%x, Event = %d",
                p_cb->state, event);
      LOG_ERROR("Invalid state State=0x%x, Event=%d", p_cb->state, event);
      return;
    }

@@ -332,8 +337,7 @@ bool bta_hh_hdl_event(const BT_HDR_RIGID* p_msg) {

  if (index != BTA_HH_IDX_INVALID) p_cb = &bta_hh_cb.kdev[index];

  LOG_VERBOSE("bta_hh_hdl_event:: handle = %d dev_cb[%d] ",
              p_msg->layer_specific, index);
  LOG_VERBOSE("handle=%d dev_cb[%d]", p_msg->layer_specific, index);
  bta_hh_sm_execute(p_cb, p_msg->event, (tBTA_HH_DATA*)p_msg);

  return (true);
+11 −10

File changed.

Preview size limit exceeded, changes collapsed.