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

Commit 59053d12 authored by Zach Johnson's avatar Zach Johnson
Browse files

Add BTM_SimpleSetSecurityLevel

Simplify security a bit

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ia6ffaa4f1ff843891695a06e1034131f72e6b4d7
parent a6a0f79b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1443,6 +1443,8 @@ bool BTM_GetSecurityFlagsByTransport(const RawAddress& bd_addr,
 ******************************************************************************/
void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len);

bool BTM_SimpleSetSecurityLevel(uint8_t service_id, uint16_t sec_level,
                                uint16_t psm);
/*******************************************************************************
 *
 * Function         BTM_SetSecurityLevel
+2 −9
Original line number Diff line number Diff line
@@ -67,11 +67,7 @@ void AVCT_Register(uint16_t mtu, UNUSED_ATTR uint16_t mtu_br,
  L2CA_Register(AVCT_PSM, (tL2CAP_APPL_INFO*)&avct_l2c_appl,
                true /* enable_snoop */, nullptr, avct_cb.mtu);

  /* set security level */
  BTM_SetSecurityLevel(true, "", BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_PSM, 0,
                       0);
  BTM_SetSecurityLevel(false, "", BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_PSM, 0,
                       0);
  BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_PSM);

  /* Include the browsing channel which uses eFCR */
  tL2CAP_ERTM_INFO ertm_info;
@@ -90,10 +86,7 @@ void AVCT_Register(uint16_t mtu, UNUSED_ATTR uint16_t mtu_br,

  /* AVCTP browsing channel uses the same security service as AVCTP control
   * channel */
  BTM_SetSecurityLevel(true, "", BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_BR_PSM,
                       0, 0);
  BTM_SetSecurityLevel(false, "", BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_BR_PSM,
                       0, 0);
  BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_BR_PSM);

#if defined(AVCT_INITIAL_TRACE_LEVEL)
  avct_cb.trace_level = AVCT_INITIAL_TRACE_LEVEL;
+1 −5
Original line number Diff line number Diff line
@@ -94,11 +94,7 @@ void AVDT_Register(AvdtpRcb* p_reg, tAVDT_CTRL_CBACK* p_cback) {
  L2CA_Register(AVDT_PSM, (tL2CAP_APPL_INFO*)&avdt_l2c_appl,
                true /* enable_snoop */, nullptr, L2CAP_DEFAULT_MTU);

  /* set security level */
  BTM_SetSecurityLevel(true, "", BTM_SEC_SERVICE_AVDTP, p_reg->sec_mask,
                       AVDT_PSM, 0, 0);
  BTM_SetSecurityLevel(false, "", BTM_SEC_SERVICE_AVDTP, p_reg->sec_mask,
                       AVDT_PSM, 0, 0);
  BTM_SimpleSetSecurityLevel(BTM_SEC_SERVICE_AVDTP, p_reg->sec_mask, AVDT_PSM);

  /* initialize AVDTP data structures */
  avdt_scb_init();
+6 −0
Original line number Diff line number Diff line
@@ -351,6 +351,12 @@ void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len) {

#define BTM_NO_AVAIL_SEC_SERVICES ((uint16_t)0xffff)

bool BTM_SimpleSetSecurityLevel(uint8_t service_id, uint16_t sec_level,
                                uint16_t psm) {
  return BTM_SetSecurityLevel(true, "", service_id, sec_level, psm, 0, 0) &&
         BTM_SetSecurityLevel(false, "", service_id, sec_level, psm, 0, 0);
}

/*******************************************************************************
 *
 * Function         BTM_SetSecurityLevel
+2 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len);
 * Returns          true if registered OK, else false
 *
 ******************************************************************************/
bool BTM_SimpleSetSecurityLevel(uint8_t service_id, uint16_t sec_level,
                                uint16_t psm);
bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
                          uint8_t service_id, uint16_t sec_level, uint16_t psm,
                          uint32_t mx_proto_id, uint32_t mx_chan_id);
Loading