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

Commit 382f5449 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/stack/gap: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: I35057c3038b1e70188596659da41a3a245901c4a
parent 9a7382d0
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -16,8 +16,7 @@
 *
 ******************************************************************************/

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

#include <array>
@@ -34,8 +33,8 @@
#include "types/bt_transport.h"
#include "types/raw_address.h"

using base::StringPrintf;
using bluetooth::Uuid;
using namespace bluetooth;

namespace {

@@ -222,17 +221,16 @@ void server_attr_request_cback(uint16_t conn_id, uint32_t trans_id,

    case GATTS_REQ_TYPE_WRITE_EXEC:
      ignore = true;
      VLOG(1) << "Ignore GATTS_REQ_TYPE_WRITE_EXEC";
      log::verbose("Ignore GATTS_REQ_TYPE_WRITE_EXEC");
      break;

    case GATTS_REQ_TYPE_MTU:
      VLOG(1) << "Get MTU exchange new mtu size: " << +p_data->mtu;
      log::verbose("Get MTU exchange new mtu size: {}", +p_data->mtu);
      ignore = true;
      break;

    default:
      VLOG(1) << StringPrintf("Unknown/unexpected LE GAP ATT request: 0x%02x",
                              type);
      log::verbose("Unknown/unexpected LE GAP ATT request: 0x{:02x}", type);
      break;
  }

@@ -295,19 +293,20 @@ void client_connect_cback(tGATT_IF, const RawAddress& bda, uint16_t conn_id,
                          tBT_TRANSPORT) {
  tGAP_CLCB* p_clcb = find_clcb_by_bd_addr(bda);
  if (p_clcb == NULL) {
    LOG_INFO("No active GAP service found for peer:%s callback:%s",
             ADDRESS_TO_LOGGABLE_CSTR(bda), (connected) ? "Connected" : "Disconnected");
    log::info("No active GAP service found for peer:{} callback:{}",
              ADDRESS_TO_LOGGABLE_CSTR(bda),
              (connected) ? "Connected" : "Disconnected");
    return;
  }

  if (connected) {
    LOG_DEBUG("Connected GAP to remote device");
    log::debug("Connected GAP to remote device");
    p_clcb->conn_id = conn_id;
    p_clcb->connected = true;
    /* start operation is pending */
    send_cl_read_request(*p_clcb);
  } else {
    LOG_WARN("Disconnected GAP from remote device");
    log::warn("Disconnected GAP from remote device");
    p_clcb->connected = false;
    cl_op_cmpl(*p_clcb, false, 0, NULL);
    /* clean up clcb */
@@ -545,13 +544,13 @@ bool GAP_BleCancelReadPeerDevName(const RawAddress& peer_bda) {
  tGAP_CLCB* p_clcb = find_clcb_by_bd_addr(peer_bda);

  if (p_clcb == NULL) {
    LOG(ERROR) << "Cannot cancel current op is not get dev name";
    log::error("Cannot cancel current op is not get dev name");
    return false;
  }

  if (!p_clcb->connected) {
    if (!GATT_CancelConnect(gatt_if, peer_bda, true)) {
      LOG(ERROR) << "Cannot cancel where No connection id";
      log::error("Cannot cancel where No connection id");
      return false;
    }
  }
+13 −18
Original line number Diff line number Diff line
@@ -16,8 +16,7 @@
 *
 ******************************************************************************/

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

#include "device/include/controller.h"
@@ -32,7 +31,7 @@
#include "stack/include/bt_hdr.h"
#include "types/raw_address.h"

using base::StringPrintf;
using namespace bluetooth;

/* Define the GAP Connection Control Block */
typedef struct {
@@ -197,8 +196,8 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
  /* A client MUST have specified a bd addr to connect with */
  if (!p_ccb->rem_addr_specified && !is_server) {
    gap_release_ccb(p_ccb);
    LOG(ERROR)
        << "GAP ERROR: Client must specify a remote BD ADDR to connect to!";
    log::error(
        "GAP ERROR: Client must specify a remote BD ADDR to connect to!");
    return (GAP_INVALID_HANDLE);
  }

@@ -212,7 +211,7 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,

    uint16_t max_mps = controller_get_interface()->get_acl_data_size_ble();
    if (le_mps > max_mps) {
      LOG(INFO) << "Limiting MPS to one buffer size - " << max_mps;
      log::info("Limiting MPS to one buffer size - {}", max_mps);
      le_mps = max_mps;
    }
    p_ccb->local_coc_cfg.mps = le_mps;
@@ -241,8 +240,7 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
        L2CA_Register2(psm, conn.reg_info, false /* enable_snoop */,
                       &p_ccb->ertm_info, L2CAP_SDU_LENGTH_MAX, 0, security);
    if (p_ccb->psm == 0) {
      LOG(ERROR) << StringPrintf("%s: Failure registering PSM 0x%04x", __func__,
                                 psm);
      log::error("Failure registering PSM 0x{:04x}", psm);
      gap_release_ccb(p_ccb);
      return (GAP_INVALID_HANDLE);
    }
@@ -252,8 +250,7 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
    p_ccb->psm =
        L2CA_RegisterLECoc(psm, conn.reg_info, security, p_ccb->local_coc_cfg);
    if (p_ccb->psm == 0) {
      LOG(ERROR) << StringPrintf("%s: Failure registering PSM 0x%04x", __func__,
                                 psm);
      log::error("Failure registering PSM 0x{:04x}", psm);
      gap_release_ccb(p_ccb);
      return (GAP_INVALID_HANDLE);
    }
@@ -593,10 +590,10 @@ static void gap_connect_ind(const RawAddress& bd_addr, uint16_t l2cap_cid,
  }

  if (xx == GAP_MAX_CONNECTIONS) {
    LOG(WARNING) << "*******";
    LOG(WARNING) << "WARNING: GAP Conn Indication for Unexpected Bd "
                    "Addr...Disconnecting";
    LOG(WARNING) << "*******";
    log::warn("*******");
    log::warn(
        "WARNING: GAP Conn Indication for Unexpected Bd Addr...Disconnecting");
    log::warn("*******");

    /* Disconnect because it is an unexpected connection */
    if (BTM_UseLeLink(bd_addr)) {
@@ -829,10 +826,8 @@ static void gap_data_ind(uint16_t l2cap_cid, BT_HDR* p_msg) {
    fixed_queue_enqueue(p_ccb->rx_queue, p_msg);

    p_ccb->rx_queue_size += p_msg->len;
    /*
    VLOG(1) << StringPrintf ("gap_data_ind - rx_queue_size=%d, msg len=%d",
                                   p_ccb->rx_queue_size, p_msg->len);
     */
    // log::verbose("gap_data_ind - rx_queue_size={}, msg len={}",
    //              p_ccb->rx_queue_size, p_msg->len);

    p_ccb->p_callback(p_ccb->gap_handle, GAP_EVT_CONN_DATA_AVAIL, nullptr);
  } else {