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

Commit 93a522fe authored by Henri Chataing's avatar Henri Chataing
Browse files

system/stack/sdp: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: Ie7b18ce34e6821b6431095256cb1c7e1bf43149e
parent dce35e33
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2121,6 +2121,7 @@ cc_test {
        "libcutils",
    ],
    static_libs: [
        "libbase",
        "libbluetooth-types",
        "libbluetooth_gd",
        "libbluetooth_log",
+12 −11
Original line number Diff line number Diff line
@@ -26,13 +26,13 @@

#include "stack/include/sdp_api.h"

#include <bluetooth/log.h>
#include <string.h>

#include <cstdint>

#include "internal_include/bt_target.h"
#include "os/log.h"
#include "osi/include/osi.h"  // PTR_TO_UINT
#include "stack/include/bt_types.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/sdp_api.h"
@@ -43,6 +43,7 @@
#include "types/raw_address.h"

using bluetooth::Uuid;
using namespace bluetooth;

/**********************************************************************
 *   C L I E N T    F U N C T I O N    P R O T O T Y P E S            *
@@ -78,10 +79,10 @@ bool SDP_InitDiscoveryDb(tSDP_DISCOVERY_DB* p_db, uint32_t len,
  /* verify the parameters */
  if (p_db == NULL || (sizeof(tSDP_DISCOVERY_DB) > len) ||
      num_attr > SDP_MAX_ATTR_FILTERS || num_uuid > SDP_MAX_UUID_FILTERS) {
    LOG_ERROR(
        "SDP_InitDiscoveryDb Illegal param: p_db 0x%x, len %d, num_uuid %d, "
        "num_attr %d",
        PTR_TO_UINT(p_db), len, num_uuid, num_attr);
    log::error(
        "SDP_InitDiscoveryDb Illegal param: p_db {}, len {}, num_uuid {}, "
        "num_attr {}",
        fmt::ptr(p_db), len, num_uuid, num_attr);

    return (false);
  }
@@ -396,13 +397,14 @@ tSDP_DISC_REC* SDP_FindServiceInDb(const tSDP_DISCOVERY_DB* p_db,
             p_sattr = p_sattr->p_next_attr) {
          if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) &&
              (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2)) {
            LOG_VERBOSE(
                "SDP_FindServiceInDb - p_sattr value = 0x%x serviceuuid = 0x%x",
            log::verbose(
                "SDP_FindServiceInDb - p_sattr value = 0x{:x} serviceuuid = "
                "0x{:x}",
                p_sattr->attr_value.v.u16, service_uuid);
            if (service_uuid == UUID_SERVCLASS_HDP_PROFILE) {
              if ((p_sattr->attr_value.v.u16 == UUID_SERVCLASS_HDP_SOURCE) ||
                  (p_sattr->attr_value.v.u16 == UUID_SERVCLASS_HDP_SINK)) {
                LOG_VERBOSE("SDP_FindServiceInDb found HDP source or sink\n");
                log::verbose("SDP_FindServiceInDb found HDP source or sink\n");
                return (p_rec);
              }
            }
@@ -807,11 +809,10 @@ static void SDP_AttrStringCopy(char* dst, const tSDP_DISC_ATTR* p_attr,
      memcpy(dst, (const void*)p_attr->attr_value.v.array, len);
      dst[len] = '\0';
    } else {
      LOG_ERROR("unexpected attr type=%d, expected=%d",
                type, expected_type);
      log::error("unexpected attr type={}, expected={}", type, expected_type);
    }
  } else {
    LOG_ERROR("p_attr is NULL");
    log::error("p_attr is NULL");
  }
}

+48 −43
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#define LOG_TAG "sdp"

#include <bluetooth/log.h>
#include <string.h>

#include <cstdint>
@@ -38,6 +39,8 @@
#include "stack/sdp/sdp_discovery_db.h"
#include "stack/sdp/sdpint.h"

using namespace bluetooth;

/******************************************************************************/
/*            L O C A L    F U N C T I O N     P R O T O T Y P E S            */
/******************************************************************************/
@@ -125,7 +128,7 @@ static bool find_uuid_in_seq(uint8_t* p, uint32_t seq_len,
    type = *p++;
    p = sdpu_get_len_from_type(p, p_end, type, &len);
    if (p == NULL || (p + len) > p_end) {
      LOG_WARN("%s: bad length", __func__);
      log::warn("bad length");
      break;
    }
    type = type >> 3;
@@ -275,7 +278,7 @@ uint32_t SDP_CreateRecord(void) {
    p_db->record[p_db->num_records].record_handle = handle;

    p_db->num_records++;
    LOG_VERBOSE("SDP_CreateRecord ok, num_records:%d", p_db->num_records);
    log::verbose("SDP_CreateRecord ok, num_records:{}", p_db->num_records);
    /* Add the first attribute (the handle) automatically */
    UINT32_TO_BE_FIELD(buf, handle);
    SDP_AddAttribute(handle, ATTR_ID_SERVICE_RECORD_HDL, UINT_DESC_TYPE, 4,
@@ -283,7 +286,7 @@ uint32_t SDP_CreateRecord(void) {

    return (p_db->record[p_db->num_records - 1].record_handle);
  } else
    LOG_ERROR("SDP_CreateRecord fail, exceed maximum records:%d",
    log::error("SDP_CreateRecord fail, exceed maximum records:{}",
               SDP_MAX_RECORDS);
  return (0);
}
@@ -328,7 +331,7 @@ bool SDP_DeleteRecord(uint32_t handle) {

        sdp_cb.server_db.num_records--;

        LOG_VERBOSE("SDP_DeleteRecord ok, num_records:%d",
        log::verbose("SDP_DeleteRecord ok, num_records:{}",
                     sdp_cb.server_db.num_records);
        /* if we're deleting the primary DI record, clear the */
        /* value in the control block */
@@ -363,7 +366,7 @@ bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type,
  tSDP_RECORD* p_rec = &sdp_cb.server_db.record[0];

  if (p_val == nullptr) {
    LOG_WARN("Trying to add attribute with p_val == nullptr, skipped");
    log::warn("Trying to add attribute with p_val == nullptr, skipped");
    return (false);
  }

@@ -378,39 +381,41 @@ bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type,

      #define MAX_ARR_LEN 200
      // one extra byte for storing terminating zero byte
      uint8_t num_array[2 * MAX_ARR_LEN + 1] = {0};
      char num_array[2 * MAX_ARR_LEN + 1] = {0};
      uint32_t len = (attr_len > MAX_ARR_LEN) ? MAX_ARR_LEN : attr_len;
      #undef MAX_ARR_LEN

      for (uint32_t i = 0; i < len; i++) {
        snprintf((char*)&num_array[i * 2], sizeof(num_array) - i * 2, "%02X",
        snprintf(&num_array[i * 2], sizeof(num_array) - i * 2, "%02X",
                 (uint8_t)(p_val[i]));
      }
      LOG_VERBOSE(
          "SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p, "
          "*p_val:%s",
          handle, attr_id, attr_type, attr_len, p_val, num_array);
      log::verbose(
          "SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, "
          "p_val:{}, *p_val:{}",
          handle, attr_id, attr_type, attr_len, fmt::ptr(p_val), num_array);
    } else if (attr_type == BOOLEAN_DESC_TYPE) {
      LOG_VERBOSE(
          "SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p, "
          "*p_val:%d",
          handle, attr_id, attr_type, attr_len, p_val, *p_val);
      log::verbose(
          "SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, "
          "p_val:{}, *p_val:{}",
          handle, attr_id, attr_type, attr_len, fmt::ptr(p_val), *p_val);
    } else if ((attr_type == TEXT_STR_DESC_TYPE) ||
               (attr_type == URL_DESC_TYPE)) {
      if (p_val[attr_len - 1] == '\0') {
        LOG_VERBOSE(
            "SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p, "
            "*p_val:%s",
            handle, attr_id, attr_type, attr_len, p_val, (char*)p_val);
        log::verbose(
            "SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, "
            "p_val:{}, *p_val:{}",
            handle, attr_id, attr_type, attr_len, fmt::ptr(p_val),
            (char*)p_val);
      } else {
        LOG_VERBOSE(
            "SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p",
            handle, attr_id, attr_type, attr_len, p_val);
        log::verbose(
            "SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, "
            "p_val:{}",
            handle, attr_id, attr_type, attr_len, fmt::ptr(p_val));
      }
    } else {
      LOG_VERBOSE(
          "SDP_AddAttribute: handle:%X, id:%04X, type:%d, len:%d, p_val:%p",
          handle, attr_id, attr_type, attr_len, p_val);
      log::verbose(
          "SDP_AddAttribute: handle:{:X}, id:{:04X}, type:{}, len:{}, p_val:{}",
          handle, attr_id, attr_type, attr_len, fmt::ptr(p_val));
    }
  }

@@ -420,9 +425,9 @@ bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type,

      // error out early, no need to look up
      if (p_rec->free_pad_ptr >= SDP_MAX_PAD_LEN) {
        LOG_ERROR(
            "the free pad for SDP record with handle %d is "
            "full, skip adding the attribute",
        log::error(
            "the free pad for SDP record with handle {} is full, skip adding "
            "the attribute",
            handle);
        return (false);
      }
@@ -481,17 +486,17 @@ bool SDP_AddAttributeToRecord(tSDP_RECORD* p_rec, uint16_t attr_id,

  if (p_rec->free_pad_ptr + attr_len >= SDP_MAX_PAD_LEN) {
    if (p_rec->free_pad_ptr >= SDP_MAX_PAD_LEN) {
      LOG_ERROR(
          "SDP_AddAttributeToRecord failed: free pad %d equals or exceeds max "
          "padding length %d",
      log::error(
          "SDP_AddAttributeToRecord failed: free pad {} equals or exceeds max "
          "padding length {}",
          p_rec->free_pad_ptr, SDP_MAX_PAD_LEN);
      return (false);
    }

    /* do truncate only for text string type descriptor */
    if (attr_type == TEXT_STR_DESC_TYPE) {
      LOG_WARN(
          "SDP_AddAttributeToRecord: attr_len:%d too long. truncate to (%d)",
      log::warn(
          "SDP_AddAttributeToRecord: attr_len:{} too long. truncate to ({})",
          attr_len, SDP_MAX_PAD_LEN - p_rec->free_pad_ptr);

      attr_len = SDP_MAX_PAD_LEN - p_rec->free_pad_ptr;
@@ -507,9 +512,9 @@ bool SDP_AddAttributeToRecord(tSDP_RECORD* p_rec, uint16_t attr_id,
    p_rec->free_pad_ptr += attr_len;
  } else if (attr_len == 0 && p_attr->len != 0) {
    /* if truncate to 0 length, simply don't add */
    LOG_ERROR(
        "SDP_AddAttributeToRecord fail, length exceed maximum: ID %d: "
        "attr_len:%d ",
    log::error(
        "SDP_AddAttributeToRecord fail, length exceed maximum: ID {}: "
        "attr_len:{}",
        attr_id, attr_len);
    p_attr->id = p_attr->type = p_attr->len = 0;
    return (false);
@@ -575,11 +580,11 @@ bool SDP_AddSequence(uint32_t handle, uint16_t attr_id, uint16_t num_elem,
      p = p_head;
      if (p_head == p_buff) {
        /* the first element exceed the max length */
        LOG_ERROR("SDP_AddSequence - too long(attribute is not added)!!");
        log::error("SDP_AddSequence - too long(attribute is not added)!!");
        osi_free(p_buff);
        return false;
      } else
        LOG_ERROR("SDP_AddSequence - too long, add %d elements of %d", xx,
        log::error("SDP_AddSequence - too long, add {} elements of {}", xx,
                   num_elem);
      break;
    }
@@ -619,7 +624,7 @@ bool SDP_AddUuidSequence(uint32_t handle, uint16_t attr_id, uint16_t num_uuids,
    UINT16_TO_BE_STREAM(p, *p_uuids);

    if ((p - p_buff) > max_len) {
      LOG_WARN("SDP_AddUuidSequence - too long, add %d uuids of %d", xx,
      log::warn("SDP_AddUuidSequence - too long, add {} uuids of {}", xx,
                num_uuids);
      break;
    }
+26 −22
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@

#define LOG_TAG "sdp_discovery"

#include <bluetooth/log.h>

#include <cstdint>

#include "internal_include/bt_target.h"
@@ -38,6 +40,7 @@
#include "types/raw_address.h"

using bluetooth::Uuid;
using namespace bluetooth;

/******************************************************************************/
/*            L O C A L    F U N C T I O N     P R O T O T Y P E S            */
@@ -277,7 +280,7 @@ void sdp_disc_server_rsp(tCONN_CB* p_ccb, BT_HDR* p_msg) {
  }

  if (invalid_pdu) {
    LOG_WARN("SDP - Unexp. PDU: %d in state: %d", rsp_pdu, p_ccb->disc_state);
    log::warn("SDP - Unexp. PDU: {} in state: {}", rsp_pdu, p_ccb->disc_state);
    sdp_disconnect(p_ccb, SDP_GENERIC_ERROR);
  }
}
@@ -310,7 +313,7 @@ static void process_service_search_rsp(tCONN_CB* p_ccb, uint8_t* p_reply,
  orig = p_ccb->num_handles;
  p_ccb->num_handles += cur_handles;
  if (p_ccb->num_handles == 0 || p_ccb->num_handles < orig) {
    LOG_WARN("SDP - Rcvd ServiceSearchRsp, no matches");
    log::warn("SDP - Rcvd ServiceSearchRsp, no matches");
    sdp_disconnect(p_ccb, SDP_NO_RECS_MATCH);
    return;
  }
@@ -380,11 +383,11 @@ static bool sdp_copy_raw_data(tCONN_CB* p_ccb, bool offset) {
      uint8_t* old_p = p;
      p = sdpu_get_len_from_type(p, p_end, type, &list_len);
      if (p == NULL || (p + list_len) > p_end) {
        LOG_WARN("%s: bad length", __func__);
        log::warn("bad length");
        return false;
      }
      if ((int)cpy_len < (p - old_p)) {
        LOG_WARN("%s: no bytes left for data", __func__);
        log::warn("no bytes left for data");
        return false;
      }
      cpy_len -= (p - old_p);
@@ -394,7 +397,7 @@ static bool sdp_copy_raw_data(tCONN_CB* p_ccb, bool offset) {
    }
    rem_len = SDP_MAX_LIST_BYTE_COUNT - (unsigned int)(p - &p_ccb->rsp_list[0]);
    if (cpy_len > rem_len) {
      LOG_WARN("rem_len :%d less than cpy_len:%d", rem_len, cpy_len);
      log::warn("rem_len :{} less than cpy_len:{}", rem_len, cpy_len);
      cpy_len = rem_len;
    }
    memcpy(&p_ccb->p_db->raw_data[p_ccb->p_db->raw_used], p, cpy_len);
@@ -456,9 +459,9 @@ static void process_service_attr_rsp(tCONN_CB* p_ccb, uint8_t* p_reply,
      }
      cont_request_needed = true;
    } else {
      LOG_WARN("process_service_attr_rsp");
      log::warn("process_service_attr_rsp");
      if (!sdp_copy_raw_data(p_ccb, false)) {
        LOG_ERROR("sdp_copy_raw_data failed");
        log::error("sdp_copy_raw_data failed");
        sdp_disconnect(p_ccb, SDP_ILLEGAL_PARAMETER);
        return;
      }
@@ -666,7 +669,7 @@ static void process_service_search_attr_rsp(tCONN_CB* p_ccb, uint8_t* p_reply,
/*******************************************************************/

  if (!sdp_copy_raw_data(p_ccb, true)) {
    LOG_ERROR("sdp_copy_raw_data failed");
    log::error("sdp_copy_raw_data failed");
    sdp_disconnect(p_ccb, SDP_ILLEGAL_PARAMETER);
    return;
  }
@@ -677,13 +680,13 @@ static void process_service_search_attr_rsp(tCONN_CB* p_ccb, uint8_t* p_reply,
  type = *p++;

  if ((type >> 3) != DATA_ELE_SEQ_DESC_TYPE) {
    LOG_WARN("Wrong element in attr_rsp type:0x%02x", type);
    log::warn("Wrong element in attr_rsp type:0x{:02x}", type);
    sdp_disconnect(p_ccb, SDP_ILLEGAL_PARAMETER);
    return;
  }
  p = sdpu_get_len_from_type(p, p + p_ccb->list_len, type, &seq_len);
  if (p == NULL || (p + seq_len) > (p + p_ccb->list_len)) {
    LOG_WARN("Illegal search attribute length");
    log::warn("Illegal search attribute length");
    sdp_disconnect(p_ccb, SDP_ILLEGAL_PARAMETER);
    return;
  }
@@ -726,19 +729,19 @@ static uint8_t* save_attr_seq(tCONN_CB* p_ccb, uint8_t* p, uint8_t* p_msg_end) {
  type = *p++;

  if ((type >> 3) != DATA_ELE_SEQ_DESC_TYPE) {
    LOG_WARN("SDP - Wrong type: 0x%02x in attr_rsp", type);
    log::warn("SDP - Wrong type: 0x{:02x} in attr_rsp", type);
    return (NULL);
  }
  p = sdpu_get_len_from_type(p, p_msg_end, type, &seq_len);
  if (p == NULL || (p + seq_len) > p_msg_end) {
    LOG_WARN("SDP - Bad len in attr_rsp %d", seq_len);
    log::warn("SDP - Bad len in attr_rsp {}", seq_len);
    return (NULL);
  }

  /* Create a record */
  p_rec = add_record(p_ccb->p_db, p_ccb->device_address);
  if (!p_rec) {
    LOG_WARN("SDP - DB full add_record");
    log::warn("SDP - DB full add_record");
    return (NULL);
  }

@@ -749,11 +752,12 @@ static uint8_t* save_attr_seq(tCONN_CB* p_ccb, uint8_t* p, uint8_t* p_msg_end) {
    type = *p++;
    p = sdpu_get_len_from_type(p, p_msg_end, type, &attr_len);
    if (p == NULL || (p + attr_len) > p_seq_end) {
      LOG_WARN("%s: Bad len in attr_rsp %d", __func__, attr_len);
      log::warn("Bad len in attr_rsp {}", attr_len);
      return (NULL);
    }
    if (((type >> 3) != UINT_DESC_TYPE) || (attr_len != 2)) {
      LOG_WARN("SDP - Bad type: 0x%02x or len: %d in attr_rsp", type, attr_len);
      log::warn("SDP - Bad type: 0x{:02x} or len: {} in attr_rsp", type,
                attr_len);
      return (NULL);
    }
    BE_STREAM_TO_UINT16(attr_id, p);
@@ -762,7 +766,7 @@ static uint8_t* save_attr_seq(tCONN_CB* p_ccb, uint8_t* p, uint8_t* p_msg_end) {
    p = add_attr(p, p_seq_end, p_ccb->p_db, p_rec, attr_id, NULL, 0);

    if (!p) {
      LOG_WARN("SDP - DB full add_attr");
      log::warn("SDP - DB full add_attr");
      return (NULL);
    }
  }
@@ -836,7 +840,7 @@ static uint8_t* add_attr(uint8_t* p, uint8_t* p_end, tSDP_DISCOVERY_DB* p_db,
  type = *p++;
  p = sdpu_get_len_from_type(p, p_end, type, &attr_len);
  if (p == NULL || (p + attr_len) > p_end) {
    LOG_WARN("%s: bad length in attr_rsp", __func__);
    log::warn("bad length in attr_rsp");
    return NULL;
  }
  attr_len &= SDP_DISC_ATTR_LEN_MASK;
@@ -850,7 +854,7 @@ static uint8_t* add_attr(uint8_t* p, uint8_t* p_end, tSDP_DISCOVERY_DB* p_db,

  p_attr_end = p + attr_len;
  if (p_attr_end > p_end) {
    LOG_WARN("%s: SDP - Attribute length beyond p_end", __func__);
    log::warn("SDP - Attribute length beyond p_end");
    return NULL;
  }

@@ -881,7 +885,7 @@ static uint8_t* add_attr(uint8_t* p, uint8_t* p_end, tSDP_DISCOVERY_DB* p_db,

          /* LOG_VERBOSE ("SDP - attr nest level:%d(list)", nest_level); */
          if (nest_level >= MAX_NEST_LEVELS) {
            LOG_ERROR("SDP - attr nesting too deep");
            log::error("SDP - attr nesting too deep");
            return p_attr_end;
          }

@@ -945,7 +949,7 @@ static uint8_t* add_attr(uint8_t* p, uint8_t* p_end, tSDP_DISCOVERY_DB* p_db,
          }
          break;
        default:
          LOG_WARN("SDP - bad len in UUID attr: %d", attr_len);
          log::warn("SDP - bad len in UUID attr: {}", attr_len);
          return p_attr_end;
      }
      break;
@@ -960,7 +964,7 @@ static uint8_t* add_attr(uint8_t* p, uint8_t* p_end, tSDP_DISCOVERY_DB* p_db,

      /* LOG_VERBOSE ("SDP - attr nest level:%d", nest_level); */
      if (nest_level >= MAX_NEST_LEVELS) {
        LOG_ERROR("SDP - attr nesting too deep");
        log::error("SDP - attr nesting too deep");
        return p_attr_end;
      }
      if (is_additional_list != 0 ||
@@ -988,7 +992,7 @@ static uint8_t* add_attr(uint8_t* p, uint8_t* p_end, tSDP_DISCOVERY_DB* p_db,
          p_attr->attr_value.v.u8 = *p++;
          break;
        default:
          LOG_WARN("SDP - bad len in boolean attr: %d", attr_len);
          log::warn("SDP - bad len in boolean attr: {}", attr_len);
          return p_attr_end;
      }
      break;
+28 −26
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#define LOG_TAG "sdp"

#include <base/logging.h>
#include <bluetooth/log.h>
#include <string.h>  // memset

#include "common/init_flags.h"
@@ -39,6 +40,8 @@
#include "stack/sdp/sdpint.h"
#include "types/raw_address.h"

using namespace bluetooth;

/******************************************************************************/
/*                     G L O B A L      S D P       D A T A                   */
/******************************************************************************/
@@ -95,7 +98,7 @@ void sdp_init(void) {
  /* Now, register with L2CAP */
  if (!L2CA_Register2(BT_PSM_SDP, sdp_cb.reg_info, true /* enable_snoop */,
                      nullptr, SDP_MTU_SIZE, 0, BTM_SEC_NONE)) {
    LOG_ERROR("SDP Registration failed");
    log::error("SDP Registration failed");
  }
}

@@ -153,7 +156,7 @@ static void sdp_connect_cfm(uint16_t l2cap_cid, uint16_t result) {
  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    LOG_WARN("SDP - Rcvd conn cnf for unknown CID 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd conn cnf for unknown CID 0x{:x}", l2cap_cid);
    return;
  }

@@ -162,7 +165,7 @@ static void sdp_connect_cfm(uint16_t l2cap_cid, uint16_t result) {
  if ((result == L2CAP_CONN_OK) && (p_ccb->con_state == SDP_STATE_CONN_SETUP)) {
    p_ccb->con_state = SDP_STATE_CFG_SETUP;
  } else {
    LOG(ERROR) << __func__ << ": invoked with non OK status";
    log::error("invoked with non OK status");
  }
}

@@ -182,7 +185,7 @@ static void sdp_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) {
  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    LOG_WARN("SDP - Rcvd L2CAP cfg ind, unknown CID: 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd L2CAP cfg ind, unknown CID: 0x{:x}", l2cap_cid);
    return;
  }

@@ -198,7 +201,7 @@ static void sdp_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) {
      p_ccb->rem_mtu_size = p_cfg->mtu;
  }

  LOG_VERBOSE("SDP - Rcvd cfg ind, sent cfg cfm, CID: 0x%x", l2cap_cid);
  log::verbose("SDP - Rcvd cfg ind, sent cfg cfm, CID: 0x{:x}", l2cap_cid);
}

/*******************************************************************************
@@ -217,12 +220,12 @@ static void sdp_config_cfm(uint16_t l2cap_cid, uint16_t initiator,

  tCONN_CB* p_ccb;

  LOG_VERBOSE("SDP - Rcvd cfg cfm, CID: 0x%x", l2cap_cid);
  log::verbose("SDP - Rcvd cfg cfm, CID: 0x{:x}", l2cap_cid);

  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    LOG_WARN("SDP - Rcvd L2CAP cfg ind, unknown CID: 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd L2CAP cfg ind, unknown CID: 0x{:x}", l2cap_cid);
    return;
  }

@@ -254,7 +257,7 @@ static void sdp_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) {
  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    LOG_WARN("SDP - Rcvd L2CAP disc, unknown CID: 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd L2CAP disc, unknown CID: 0x{:x}", l2cap_cid);
    return;
  }
  tCONN_CB& ccb = *p_ccb;
@@ -264,10 +267,10 @@ static void sdp_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) {
  sdpu_callback(ccb, reason);

  if (ack_needed) {
    LOG_WARN("SDP - Rcvd L2CAP disc, process pend sdp ccb: 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd L2CAP disc, process pend sdp ccb: 0x{:x}", l2cap_cid);
    sdpu_process_pend_ccb_new_cid(ccb);
  } else {
    LOG_WARN("SDP - Rcvd L2CAP disc, clear pend sdp ccb: 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd L2CAP disc, clear pend sdp ccb: 0x{:x}", l2cap_cid);
    sdpu_clear_pend_ccb(ccb);
  }

@@ -301,11 +304,11 @@ static void sdp_data_ind(uint16_t l2cap_cid, BT_HDR* p_msg) {
      else
        sdp_server_handle_client_req(p_ccb, p_msg);
    } else {
      LOG_WARN("SDP - Ignored L2CAP data while in state: %d, CID: 0x%x",
      log::warn("SDP - Ignored L2CAP data while in state: {}, CID: 0x{:x}",
                p_ccb->con_state, l2cap_cid);
    }
  } else {
    LOG_WARN("SDP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd L2CAP data, unknown CID: 0x{:x}", l2cap_cid);
  }

  osi_free(p_msg);
@@ -328,12 +331,11 @@ tCONN_CB* sdp_conn_originate(const RawAddress& p_bd_addr) {
  /* Allocate a new CCB. Return if none available. */
  p_ccb = sdpu_allocate_ccb();
  if (p_ccb == NULL) {
    LOG_WARN("%s: no spare CCB for peer %s", __func__,
             ADDRESS_TO_LOGGABLE_CSTR(p_bd_addr));
    log::warn("no spare CCB for peer {}", ADDRESS_TO_LOGGABLE_CSTR(p_bd_addr));
    return (NULL);
  }

  LOG_VERBOSE("%s: SDP - Originate started for peer %s", __func__,
  log::verbose("SDP - Originate started for peer {}",
               ADDRESS_TO_LOGGABLE_CSTR(p_bd_addr));

  /* Look for any active sdp connection on the remote device */
@@ -352,13 +354,13 @@ tCONN_CB* sdp_conn_originate(const RawAddress& p_bd_addr) {
    cid = L2CA_ConnectReq2(BT_PSM_SDP, p_bd_addr, BTM_SEC_NONE);
  } else {
    p_ccb->con_state = SDP_STATE_CONN_PEND;
    LOG_WARN("SDP already active for peer %s. cid=%#0x",
    log::warn("SDP already active for peer {}. cid={:#0x}",
              ADDRESS_TO_LOGGABLE_CSTR(p_bd_addr), cid);
  }

  /* Check if L2CAP started the connection process */
  if (cid == 0) {
    LOG_WARN("%s: SDP - Originate failed for peer %s", __func__,
    log::warn("SDP - Originate failed for peer {}",
              ADDRESS_TO_LOGGABLE_CSTR(p_bd_addr));
    sdpu_release_ccb(*p_ccb);
    return (NULL);
@@ -378,7 +380,7 @@ tCONN_CB* sdp_conn_originate(const RawAddress& p_bd_addr) {
 ******************************************************************************/
void sdp_disconnect(tCONN_CB* p_ccb, tSDP_REASON reason) {
  tCONN_CB& ccb = *p_ccb;
  LOG_VERBOSE("SDP - disconnect  CID: 0x%x", ccb.connection_id);
  log::verbose("SDP - disconnect  CID: 0x{:x}", ccb.connection_id);

  /* Check if we have a connection ID */
  if (ccb.connection_id != 0) {
@@ -417,12 +419,12 @@ static void sdp_disconnect_cfm(uint16_t l2cap_cid,
  /* Find CCB based on CID */
  p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
  if (p_ccb == NULL) {
    LOG_WARN("SDP - Rcvd L2CAP disc cfm, unknown CID: 0x%x", l2cap_cid);
    log::warn("SDP - Rcvd L2CAP disc cfm, unknown CID: 0x{:x}", l2cap_cid);
    return;
  }
  tCONN_CB& ccb = *p_ccb;

  LOG_VERBOSE("SDP - Rcvd L2CAP disc cfm, CID: 0x%x", l2cap_cid);
  log::verbose("SDP - Rcvd L2CAP disc cfm, CID: 0x{:x}", l2cap_cid);

  sdpu_callback(ccb, static_cast<tSDP_STATUS>(ccb.disconnect_reason));
  sdpu_process_pend_ccb_new_cid(ccb);
@@ -442,7 +444,7 @@ static void sdp_disconnect_cfm(uint16_t l2cap_cid,
void sdp_conn_timer_timeout(void* data) {
  tCONN_CB& ccb = *(tCONN_CB*)data;

  LOG_VERBOSE("SDP - CCB timeout in state: %d  CID: 0x%x", ccb.con_state,
  log::verbose("SDP - CCB timeout in state: {}  CID: 0x{:x}", ccb.con_state,
               ccb.connection_id);

  L2CA_DisconnectReq(ccb.connection_id);
Loading