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

Commit 0c65cc78 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Convert gap_connections to new l2cap + security" am: 550c1d60

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1412800

Change-Id: I31ee30c7733e38318da1956329048ff731d53dd6
parents 6450d413 550c1d60
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -244,8 +244,8 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,

  /* Register the PSM with L2CAP */
  if (transport == BT_TRANSPORT_BR_EDR) {
    p_ccb->psm = L2CA_Register(psm, &conn.reg_info, false /* enable_snoop */,
                               &p_ccb->ertm_info, L2CAP_MTU_SIZE);
    p_ccb->psm = L2CA_Register2(psm, &conn.reg_info, false /* enable_snoop */,
                                &p_ccb->ertm_info, L2CAP_MTU_SIZE, security);
    if (p_ccb->psm == 0) {
      LOG(ERROR) << StringPrintf("%s: Failure registering PSM 0x%04x", __func__,
                                 psm);
@@ -255,7 +255,8 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
  }

  if (transport == BT_TRANSPORT_LE) {
    p_ccb->psm = L2CA_RegisterLECoc(psm, (tL2CAP_APPL_INFO*)&conn.reg_info);
    p_ccb->psm =
        L2CA_RegisterLECoc(psm, (tL2CAP_APPL_INFO*)&conn.reg_info, security);
    if (p_ccb->psm == 0) {
      LOG(ERROR) << StringPrintf("%s: Failure registering PSM 0x%04x", __func__,
                                 psm);
@@ -264,14 +265,6 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
    }
  }

  /* Register with Security Manager for the specific security level */
  if (!BTM_SetSecurityLevel((uint8_t)!is_server, p_serv_name, p_ccb->service_id,
                            security, p_ccb->psm, 0, 0)) {
    LOG(ERROR) << "GAP_CONN - Security Error";
    gap_release_ccb(p_ccb);
    return (GAP_INVALID_HANDLE);
  }

  /* optional FCR channel modes */
  if (ertm_info != NULL) {
    p_ccb->ertm_info.allowed_modes =
@@ -297,7 +290,8 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,

    /* Check if L2CAP started the connection process */
    if (p_rem_bda && (transport == BT_TRANSPORT_BR_EDR)) {
      cid = L2CA_ErtmConnectReq(p_ccb->psm, *p_rem_bda, &p_ccb->ertm_info);
      cid = L2CA_ErtmConnectReq2(p_ccb->psm, *p_rem_bda, &p_ccb->ertm_info,
                                 security);
      if (cid != 0) {
        p_ccb->connection_id = cid;
        return (p_ccb->gap_handle);
@@ -305,7 +299,8 @@ uint16_t GAP_ConnOpen(const char* p_serv_name, uint8_t service_id,
    }

    if (p_rem_bda && (transport == BT_TRANSPORT_LE)) {
      cid = L2CA_ConnectLECocReq(p_ccb->psm, *p_rem_bda, &p_ccb->local_coc_cfg);
      cid = L2CA_ConnectLECocReq(p_ccb->psm, *p_rem_bda, &p_ccb->local_coc_cfg,
                                 security);
      if (cid != 0) {
        p_ccb->connection_id = cid;
        return (p_ccb->gap_handle);
+4 −2
Original line number Diff line number Diff line
@@ -431,7 +431,8 @@ extern uint16_t L2CA_ErtmConnectReq(uint16_t psm, const RawAddress& p_bd_addr,
 *                  and BTM_SetSecurityLevel().
 *
 ******************************************************************************/
extern uint16_t L2CA_RegisterLECoc(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info);
extern uint16_t L2CA_RegisterLECoc(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
                                   uint16_t sec_level);

/*******************************************************************************
 *
@@ -458,7 +459,8 @@ extern void L2CA_DeregisterLECoc(uint16_t psm);
 *
 ******************************************************************************/
extern uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr,
                                     tL2CAP_LE_CFG_INFO* p_cfg);
                                     tL2CAP_LE_CFG_INFO* p_cfg,
                                     uint16_t sec_level);

/*******************************************************************************
 *
+6 −2
Original line number Diff line number Diff line
@@ -450,11 +450,13 @@ uint16_t L2CA_ErtmConnectReq(uint16_t psm, const RawAddress& p_bd_addr,
 *                  and L2CA_DeregisterLECoc()
 *
 ******************************************************************************/
uint16_t L2CA_RegisterLECoc(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info) {
uint16_t L2CA_RegisterLECoc(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
                            uint16_t sec_level) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_RegisterLECoc(psm, 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
@@ -568,11 +570,13 @@ void L2CA_DeregisterLECoc(uint16_t psm) {
 *
 ******************************************************************************/
uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr,
                              tL2CAP_LE_CFG_INFO* p_cfg) {
                              tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_ConnectLECocReq(psm, p_bd_addr, p_cfg);
  }

  BTM_SetSecurityLevel(true, "", 0, sec_level, psm, 0, 0);

  VLOG(1) << __func__ << " BDA: " << p_bd_addr
          << StringPrintf(" PSM: 0x%04x", psm);