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

Commit 3fc880b7 authored by Chris Manton's avatar Chris Manton
Browse files

Re-log stack/l2cap/l2c_api::L2CA_RegisterLECoc

Toward loggable code

Bug: 163134718
Tag: #refactor
Test: CtsVerifier

Change-Id: Ifd0cf6aff270624dfe5968b02ffe58f8994d823f
parent bee05ed7
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -381,7 +381,6 @@ uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
  }

  BTM_SetSecurityLevel(false, "", 0, sec_level, psm, 0, 0);
  L2CAP_TRACE_API("%s called for LE PSM: 0x%04x", __func__, psm);

  /* Verify that the required callback info has been filled in
  **      Note:  Connection callbacks are required but not checked
@@ -389,13 +388,13 @@ uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
  **             or only a server.
  */
  if ((!p_cb_info.pL2CA_DataInd_Cb) || (!p_cb_info.pL2CA_DisconnectInd_Cb)) {
    L2CAP_TRACE_ERROR("%s No cb registering BLE PSM: 0x%04x", __func__, psm);
    LOG_ERROR("No cb registering BLE PSM: 0x%04x", psm);
    return 0;
  }

  /* Verify PSM is valid */
  if (!L2C_IS_VALID_LE_PSM(psm)) {
    L2CAP_TRACE_ERROR("%s Invalid BLE PSM value, PSM: 0x%04x", __func__, psm);
    LOG_ERROR("Invalid BLE PSM value, PSM: 0x%04x", psm);
    return 0;
  }

@@ -408,26 +407,25 @@ uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
      (p_cb_info.pL2CA_ConnectInd_Cb == NULL)) {
    vpsm = L2CA_AllocateLePSM();
    if (vpsm == 0) {
      L2CAP_TRACE_ERROR("%s: Out of free BLE PSM", __func__);
      LOG_ERROR("Out of free BLE PSM");
      return 0;
    }

    L2CAP_TRACE_API("%s Real PSM: 0x%04x  Virtual PSM: 0x%04x", __func__, psm,
                    vpsm);
    LOG_DEBUG("Real PSM: 0x%04x  Virtual PSM: 0x%04x", psm, vpsm);
  }

  /* If registration block already there, just overwrite it */
  p_rcb = l2cu_find_ble_rcb_by_psm(vpsm);
  if (p_rcb == NULL) {
    L2CAP_TRACE_API("%s Allocate rcp for Virtual PSM: 0x%04x", __func__, vpsm);
    LOG_DEBUG("Allocate rcp for Virtual PSM: 0x%04x", vpsm);
    p_rcb = l2cu_allocate_ble_rcb(vpsm);
    if (p_rcb == NULL) {
      L2CAP_TRACE_WARNING("%s No BLE RCB available, PSM: 0x%04x  vPSM: 0x%04x",
                          __func__, psm, vpsm);
      LOG_WARN("No BLE RCB available, PSM: 0x%04x  vPSM: 0x%04x", psm, vpsm);
      return 0;
    }
  }

  LOG_INFO("Registered service LE COC PSM: 0x%04x", psm);
  p_rcb->api = p_cb_info;
  p_rcb->real_psm = psm;
  p_rcb->coc_cfg = cfg;