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

Commit 7e20c751 authored by Bhakthavatsala Raghavendra's avatar Bhakthavatsala Raghavendra Committed by Gerrit Code Review
Browse files

Merge "Use encrypted link for avdtp and avctp channels" into main

parents aaa703d7 ee97c858
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"
#include "types/raw_address.h"
#include <com_android_bluetooth_flags.h>

using namespace bluetooth;

@@ -61,9 +62,14 @@ void AVCT_Register() {
  /* initialize AVCTP data structures */
  memset(&avct_cb, 0, sizeof(tAVCT_CB));

  uint16_t sec = BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT;
  if (!com::android::bluetooth::flags::use_encrypt_req_for_av()) {
    sec = BTA_SEC_AUTHENTICATE;
  }

  /* register PSM with L2CAP */
  if (!L2CA_RegisterWithSecurity(AVCT_PSM, avct_l2c_appl, true /* enable_snoop */, nullptr,
                                 kAvrcMtu, 0, BTA_SEC_AUTHENTICATE)) {
                                 kAvrcMtu, 0, sec)) {
    log::error("Unable to register with L2CAP AVCT profile psm:AVCT_PSM[0x0017]");
  }

@@ -72,7 +78,7 @@ void AVCT_Register() {
  ertm_info.preferred_mode = L2CAP_FCR_ERTM_MODE;

  if (!L2CA_RegisterWithSecurity(AVCT_BR_PSM, avct_l2c_br_appl, true /*enable_snoop*/, &ertm_info,
                                 kAvrcBrMtu, AVCT_MIN_BROWSE_MTU, BTA_SEC_AUTHENTICATE)) {
                                 kAvrcBrMtu, AVCT_MIN_BROWSE_MTU, sec)) {
    log::error(
            "Unable to register with L2CAP AVCT_BR profile "
            "psm:AVCT_BR_PSM[0x001b]");
+8 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include "stack/avct/avct_defs.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include <com_android_bluetooth_flags.h>

using namespace bluetooth;

@@ -115,7 +116,13 @@ void avct_bcb_chnl_open(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* /* p_data */) {

  /* call l2cap connect req */
  p_bcb->ch_state = AVCT_CH_CONN;
  p_bcb->ch_lcid = L2CA_ConnectReqWithSecurity(AVCT_BR_PSM, p_lcb->peer_addr, BTA_SEC_AUTHENTICATE);
  if (com::android::bluetooth::flags::use_encrypt_req_for_av()) {
    p_bcb->ch_lcid = L2CA_ConnectReqWithSecurity(AVCT_BR_PSM, p_lcb->peer_addr,
      BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
  } else {
    p_bcb->ch_lcid = L2CA_ConnectReqWithSecurity(AVCT_BR_PSM, p_lcb->peer_addr,
      BTA_SEC_AUTHENTICATE);
  }
  if (p_bcb->ch_lcid == 0) {
    /* if connect req failed, send ourselves close event */
    tAVCT_LCB_EVT avct_lcb_evt;
+7 −1
Original line number Diff line number Diff line
@@ -187,7 +187,13 @@ void avct_lcb_chnl_open(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* /* p_data */) {
  uint16_t result = AVCT_RESULT_FAIL;

  p_lcb->ch_state = AVCT_CH_CONN;
  p_lcb->ch_lcid = L2CA_ConnectReqWithSecurity(AVCT_PSM, p_lcb->peer_addr, BTA_SEC_AUTHENTICATE);
  if (com::android::bluetooth::flags::use_encrypt_req_for_av()) {
     p_lcb->ch_lcid = L2CA_ConnectReqWithSecurity(AVCT_PSM, p_lcb->peer_addr,
       BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
  } else {
     p_lcb->ch_lcid = L2CA_ConnectReqWithSecurity(AVCT_PSM, p_lcb->peer_addr,
       BTA_SEC_AUTHENTICATE);
  }
  if (p_lcb->ch_lcid == 0) {
    /* if connect req failed, send ourselves close event */
    tAVCT_LCB_EVT avct_lcb_evt;
+8 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "osi/include/allocator.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_sec_api_types.h"
#include <com_android_bluetooth_flags.h>

using namespace bluetooth;

@@ -532,7 +533,13 @@ void avdt_ad_open_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb, uint8_t ro
    p_tbl->state = AVDT_AD_ST_CONN;

    /* call l2cap connect req */
    lcid = L2CA_ConnectReqWithSecurity(AVDT_PSM, p_ccb->peer_addr, BTM_SEC_OUT_AUTHENTICATE);
    if (com::android::bluetooth::flags::use_encrypt_req_for_av()) {
      lcid = L2CA_ConnectReqWithSecurity(AVDT_PSM, p_ccb->peer_addr,
               BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT);
    } else {
      lcid = L2CA_ConnectReqWithSecurity(AVDT_PSM, p_ccb->peer_addr,
               BTM_SEC_OUT_AUTHENTICATE);
    }
    if (lcid != 0) {
      /* if connect req ok, store tcid in lcid table  */
      avdtp_cb.ad.lcid_tbl[lcid] = avdt_ad_tc_tbl_to_idx(p_tbl);
+6 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "stack/include/a2dp_codec_api.h"
#include "stack/include/bt_hdr.h"
#include "types/raw_address.h"
#include <com_android_bluetooth_flags.h>

using namespace bluetooth;

@@ -97,9 +98,13 @@ void avdt_scb_transport_channel_timer_timeout(void* data) {
 *
 ******************************************************************************/
void AVDT_Register(AvdtpRcb* p_reg, tAVDT_CTRL_CBACK* p_cback) {
  uint16_t sec = BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT;
  if (!com::android::bluetooth::flags::use_encrypt_req_for_av()) {
    sec = BTA_SEC_AUTHENTICATE;
  }
  /* register PSM with L2CAP */
  if (!L2CA_RegisterWithSecurity(AVDT_PSM, avdt_l2c_appl, true /* enable_snoop */, nullptr,
                                 kAvdtpMtu, 0, BTA_SEC_AUTHENTICATE)) {
                                 kAvdtpMtu, 0, sec)) {
    log::error("Unable to register with L2CAP profile AVDT psm:AVDT_PSM[0x0019]");
  }