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

Commit 3398c071 authored by Henri Chataing's avatar Henri Chataing
Browse files

system: Remove most ADDRESS_TO_LOGGABLE_(CSTR|STR)

The added formatters for address types have all the same behavior.
ADDRESS_TO_LOGGABLE_STR still occurs in BTM_History, dumpsys,
log::assert_that calls

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: I950f76bd2f1d000638752759a3f08ba0be6f014c
parent e234dced
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -490,8 +490,7 @@ void bta_ag_rfc_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
    if (!btif_config_get_bin(
            p_scb->peer_addr.ToString(), BTIF_STORAGE_KEY_HFP_VERSION,
            (uint8_t*)&p_scb->peer_version, &version_value_size)) {
      log::warn("Failed read cached peer HFP version for {}",
                ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
      log::warn("Failed read cached peer HFP version for {}", p_scb->peer_addr);
      p_scb->peer_version = HFP_HSP_VERSION_UNKNOWN;
    }
    size_t sdp_features_size = sizeof(p_scb->peer_sdp_features);
@@ -512,7 +511,7 @@ void bta_ag_rfc_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
      }
    } else {
      log::warn("Failed read cached peer HFP SDP features for {}",
                ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
                p_scb->peer_addr);
    }
  }

@@ -568,8 +567,7 @@ void bta_ag_rfc_acp_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
  for (tBTA_AG_SCB& ag_scb : bta_ag_cb.scb) {
    // Cancel any pending collision timers
    if (ag_scb.in_use && alarm_is_scheduled(ag_scb.collision_timer)) {
      log::verbose("cancel collision alarm for {}",
                   ADDRESS_TO_LOGGABLE_STR(ag_scb.peer_addr));
      log::verbose("cancel collision alarm for {}", ag_scb.peer_addr);
      alarm_cancel(ag_scb.collision_timer);
      if (dev_addr != ag_scb.peer_addr && p_scb != &ag_scb) {
        // Resume outgoing connection if incoming is not on the same device
@@ -579,7 +577,7 @@ void bta_ag_rfc_acp_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
    if (dev_addr == ag_scb.peer_addr && p_scb != &ag_scb) {
      log::info(
          "close outgoing connection before accepting {} with conn_handle={}",
          ADDRESS_TO_LOGGABLE_STR(ag_scb.peer_addr), ag_scb.conn_handle);
          ag_scb.peer_addr, ag_scb.conn_handle);
      if (!IS_FLAG_ENABLED(close_rfcomm_instead_of_reset)) {
        // Fail the outgoing connection to clean up any upper layer states
        bta_ag_rfc_fail(&ag_scb, tBTA_AG_DATA::kEmpty);
@@ -591,7 +589,7 @@ void bta_ag_rfc_acp_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
        if (status != PORT_SUCCESS) {
          log::warn(
              "RFCOMM_RemoveConnection failed for {}, handle {}, error {}",
              ADDRESS_TO_LOGGABLE_STR(dev_addr), ag_scb.conn_handle, status);
              dev_addr, ag_scb.conn_handle, status);
        }
      } else if (IS_FLAG_ENABLED(reset_after_collision)) {
        // As no existing outgoing rfcomm connection, then manual reset current
@@ -599,10 +597,8 @@ void bta_ag_rfc_acp_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
        bta_ag_rfc_fail(&ag_scb, tBTA_AG_DATA::kEmpty);
      }
    }
    log::info("dev_addr={}, peer_addr={}, in_use={}, index={}",
              ADDRESS_TO_LOGGABLE_STR(dev_addr),
              ADDRESS_TO_LOGGABLE_STR(ag_scb.peer_addr), ag_scb.in_use,
              bta_ag_scb_to_idx(p_scb));
    log::info("dev_addr={}, peer_addr={}, in_use={}, index={}", dev_addr,
              ag_scb.peer_addr, ag_scb.in_use, bta_ag_scb_to_idx(p_scb));
  }

  p_scb->peer_addr = dev_addr;
@@ -665,14 +661,13 @@ void bta_ag_rfc_data(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& /* data */) {
    /* read data from rfcomm; if bad status, we're done */
    if (PORT_ReadData(p_scb->conn_handle, buf, BTA_AG_RFC_READ_MAX, &len) !=
        PORT_SUCCESS) {
      log::error("failed to read data {}",
                 ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
      log::error("failed to read data {}", p_scb->peer_addr);
      break;
    }

    /* if no data, we're done */
    if (len == 0) {
      log::warn("no data for {}", ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
      log::warn("no data for {}", p_scb->peer_addr);
      break;
    }

+8 −9
Original line number Diff line number Diff line
@@ -364,13 +364,13 @@ void bta_ag_collision_cback(tBTA_SYS_CONN_STATUS /* status */, tBTA_SYS_ID id,
  if (p_scb && (p_scb->state == BTA_AG_OPENING_ST)) {
    if (id == BTA_ID_SYS) {
      log::warn("AG found collision (ACL) for handle {} device {}",
                unsigned(handle), ADDRESS_TO_LOGGABLE_STR(peer_addr));
                unsigned(handle), peer_addr);
    } else if (id == BTA_ID_AG) {
      log::warn("AG found collision (RFCOMM) for handle {} device {}",
                unsigned(handle), ADDRESS_TO_LOGGABLE_STR(peer_addr));
                unsigned(handle), peer_addr);
    } else {
      log::warn("AG found collision (UNKNOWN) for handle {} device {}",
                unsigned(handle), ADDRESS_TO_LOGGABLE_STR(peer_addr));
                unsigned(handle), peer_addr);
    }
    bta_ag_sm_execute(p_scb, BTA_AG_COLLISION_EVT, tBTA_AG_DATA::kEmpty);
  }
@@ -388,14 +388,13 @@ void bta_ag_collision_cback(tBTA_SYS_CONN_STATUS /* status */, tBTA_SYS_ID id,
 ******************************************************************************/
void bta_ag_resume_open(tBTA_AG_SCB* p_scb) {
  if (p_scb->state == BTA_AG_INIT_ST) {
    log::info("Resume connection to {}, handle{}",
              ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr),
    log::info("Resume connection to {}, handle{}", p_scb->peer_addr,
              bta_ag_scb_to_idx(p_scb));
    tBTA_AG_DATA open_data = {.api_open = {.bd_addr = p_scb->peer_addr}};
    bta_ag_sm_execute(p_scb, BTA_AG_API_OPEN_EVT, open_data);
  } else {
    log::verbose("device {} is already in state {}",
                 ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr), p_scb->state);
    log::verbose("device {} is already in state {}", p_scb->peer_addr,
                 p_scb->state);
  }
}

@@ -748,7 +747,7 @@ void bta_ag_sm_execute(tBTA_AG_SCB* p_scb, uint16_t event,
  log::debug(
      "Execute AG event handle:0x{:04x} bd_addr:{} state:{}[0x{:02x}] "
      "event:{}[0x{:04x}] result:{}[0x{:02x}]",
      bta_ag_scb_to_idx(p_scb), ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr),
      bta_ag_scb_to_idx(p_scb), p_scb->peer_addr,
      bta_ag_state_str(p_scb->state), p_scb->state, bta_ag_evt_str(event),
      event, bta_ag_res_str(data.api_result.result), data.api_result.result);

@@ -759,7 +758,7 @@ void bta_ag_sm_execute(tBTA_AG_SCB* p_scb, uint16_t event,
        "State changed handle:0x{:04x} bd_addr:{} "
        "state_change:{}[0x{:02x}]->{}[0x{:02x}] event:{}[0x{:04x}] "
        "result:{}[0x{:02x}]",
        bta_ag_scb_to_idx(p_scb), ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr),
        bta_ag_scb_to_idx(p_scb), p_scb->peer_addr,
        bta_ag_state_str(previous_state), previous_state,
        bta_ag_state_str(p_scb->state), p_scb->state,
        bta_ag_evt_str(previous_event), previous_event,
+2 −2
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ static void bta_ag_port_cback(uint32_t /* code */, uint16_t port_handle,
    if (!bta_ag_scb_open(p_scb)) {
      log::error(
          "rfcomm data on an unopened control block {} peer_addr {} state {}",
          handle, ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr), p_scb->state);
          handle, p_scb->peer_addr, p_scb->state);
    }
    do_in_main_thread(
        FROM_HERE, base::BindOnce(&bta_ag_sm_execute_by_handle, handle,
@@ -344,7 +344,7 @@ void bta_ag_rfc_do_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
  } else {
    /* RFCOMM create connection failed; send ourselves RFCOMM close event */
    log::error("RFCOMM_CreateConnection ERROR {} for {}", status,
               ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
               p_scb->peer_addr);
    bta_ag_sm_execute(p_scb, BTA_AG_RFC_CLOSE_EVT, data);
  }
}
+13 −18
Original line number Diff line number Diff line
@@ -416,11 +416,8 @@ static void bta_ag_esco_connreq_cback(tBTM_ESCO_EVT event,
      log::warn(
          "reject incoming SCO connection, remote_bda={}, active_bda={}, "
          "current_bda={}",
          ADDRESS_TO_LOGGABLE_STR(remote_bda ? *remote_bda
                                             : RawAddress::kEmpty),
          ADDRESS_TO_LOGGABLE_STR(active_device_addr),
          ADDRESS_TO_LOGGABLE_STR(p_scb ? p_scb->peer_addr
                                        : RawAddress::kEmpty));
          remote_bda ? *remote_bda : RawAddress::kEmpty, active_device_addr,
          p_scb ? p_scb->peer_addr : RawAddress::kEmpty);
      BTM_EScoConnRsp(p_data->conn_evt.sco_inx, HCI_ERR_HOST_REJECT_RESOURCES,
                      (enh_esco_params_t*)nullptr);
    }
@@ -461,9 +458,8 @@ void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
  tBTA_AG_PEER_CODEC esco_codec = UUID_CODEC_CVSD;

  if (!bta_ag_sco_is_active_device(p_scb->peer_addr)) {
    log::warn("device {} is not active, active_device={}",
              ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr),
              ADDRESS_TO_LOGGABLE_STR(active_device_addr));
    log::warn("device {} is not active, active_device={}", p_scb->peer_addr,
              active_device_addr);
    if (bta_ag_cb.sco.p_curr_scb != nullptr &&
        bta_ag_cb.sco.p_curr_scb->in_use && p_scb == bta_ag_cb.sco.p_curr_scb) {
      do_in_main_thread(FROM_HERE, base::BindOnce(&bta_ag_sm_execute, p_scb,
@@ -474,8 +470,8 @@ void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
  }
  /* Make sure this SCO handle is not already in use */
  if (p_scb->sco_idx != BTM_INVALID_SCO_INDEX) {
    log::error("device {}, index 0x{:04x} already in use!",
               ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr), p_scb->sco_idx);
    log::error("device {}, index 0x{:04x} already in use!", p_scb->peer_addr,
               p_scb->sco_idx);
    return;
  }

@@ -856,7 +852,7 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
  tBTA_AG_SCO_CB* p_sco = &bta_ag_cb.sco;
  uint8_t previous_state = p_sco->state;
  log::info("device:{} index:0x{:04x} state:{}[{}] event:{}[{}]",
            ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr), p_scb->sco_idx,
            p_scb->peer_addr, p_scb->sco_idx,
            bta_ag_sco_state_str(p_sco->state), p_sco->state,
            bta_ag_sco_evt_str(event), event);

@@ -1396,7 +1392,7 @@ bool bta_ag_sco_is_opening(tBTA_AG_SCB* p_scb) {
 *
 ******************************************************************************/
void bta_ag_sco_listen(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& /* data */) {
  log::info("{}", ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
  log::info("{}", p_scb->peer_addr);
  bta_ag_sco_event(p_scb, BTA_AG_SCO_LISTEN_E);
}

@@ -1440,13 +1436,12 @@ void bta_ag_sco_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {

  /* if another scb using sco, this is a transfer */
  if (bta_ag_cb.sco.p_curr_scb && bta_ag_cb.sco.p_curr_scb != p_scb) {
    log::info("transfer {} -> {}",
              ADDRESS_TO_LOGGABLE_STR(bta_ag_cb.sco.p_curr_scb->peer_addr),
              ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
    log::info("transfer {} -> {}", bta_ag_cb.sco.p_curr_scb->peer_addr,
              p_scb->peer_addr);
    bta_ag_sco_event(p_scb, BTA_AG_SCO_XFER_E);
  } else {
    /* else it is an open */
    log::info("open {}", ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
    log::info("open {}", p_scb->peer_addr);
    bta_ag_sco_event(p_scb, BTA_AG_SCO_OPEN_E);
  }
}
@@ -1486,13 +1481,13 @@ void bta_ag_sco_codec_nego(tBTA_AG_SCB* p_scb, bool result) {
  if (result) {
    /* Subsequent SCO connection will skip codec negotiation */
    log::info("Succeeded for index 0x{:04x}, device {}", p_scb->sco_idx,
              ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
              p_scb->peer_addr);
    p_scb->codec_updated = false;
    bta_ag_sco_event(p_scb, BTA_AG_SCO_CN_DONE_E);
  } else {
    /* codec negotiation failed */
    log::info("Failed for index 0x{:04x}, device {}", p_scb->sco_idx,
              ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
              p_scb->peer_addr);
    bta_ag_sco_event(p_scb, BTA_AG_SCO_CLOSE_E);
  }
}
+4 −5
Original line number Diff line number Diff line
@@ -389,7 +389,7 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
                (const uint8_t*)&peer_version, sizeof(peer_version))) {
        } else {
          log::warn("Failed to store peer HFP version for {}",
                    ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
                    p_scb->peer_addr);
        }
      }
      /* get features if HFP */
@@ -420,7 +420,7 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
                                  sizeof(sdp_features))) {
          } else {
            log::warn("Failed to store peer HFP SDP Features for {}",
                      ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
                      p_scb->peer_addr);
          }
        }
        if (p_scb->peer_features == 0) {
@@ -542,12 +542,11 @@ void bta_ag_do_disc(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
            bta_ag_sdp_cback_tbl[bta_ag_scb_to_idx(p_scb) - 1])) {
      return;
    } else {
      log::error("failed to start SDP discovery for {}",
                 ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
      log::error("failed to start SDP discovery for {}", p_scb->peer_addr);
    }
  } else {
    log::error("failed to init SDP discovery database for {}",
               ADDRESS_TO_LOGGABLE_STR(p_scb->peer_addr));
               p_scb->peer_addr);
  }
  // Failure actions
  bta_ag_free_db(p_scb, tBTA_AG_DATA::kEmpty);
Loading