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

Commit 8837fe8e authored by Hui Peng's avatar Hui Peng Committed by Gerrit Code Review
Browse files

Merge "[Invisalign2] move btm_sec_find_first_serv to tBTM_SEC_CB" into main

parents eefa4c5d ec88e94b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -717,7 +717,8 @@ tBTM_STATUS btm_ble_start_sec_check(const RawAddress& bd_addr, uint16_t psm,
                                    tBTM_SEC_CALLBACK* p_callback,
                                    void* p_ref_data) {
  /* Find the service record for the PSM */
  tBTM_SEC_SERV_REC* p_serv_rec = btm_sec_find_first_serv(is_originator, psm);
  tBTM_SEC_SERV_REC* p_serv_rec =
      btm_sec_cb.find_first_serv_rec(is_originator, psm);

  /* If there is no application registered with this PSM do not allow connection
   */
+2 −36
Original line number Diff line number Diff line
@@ -95,11 +95,6 @@ void bta_dm_remove_device(const RawAddress& bd_addr);
void bta_dm_process_remove_device(const RawAddress& bd_addr);
void btm_inq_clear_ssp(void);

/*******************************************************************************
 *             L O C A L    F U N C T I O N     P R O T O T Y P E S            *
 ******************************************************************************/
tBTM_SEC_SERV_REC* btm_sec_find_first_serv(bool is_originator, uint16_t psm);

static tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec);
static bool btm_sec_start_get_name(tBTM_SEC_DEV_REC* p_dev_rec);
static void btm_sec_wait_and_start_authentication(tBTM_SEC_DEV_REC* p_dev_rec);
@@ -1858,7 +1853,8 @@ tBTM_STATUS btm_sec_l2cap_access_req(const RawAddress& bd_addr, uint16_t psm,
  LOG_DEBUG("is_originator:%d, psm=0x%04x", is_originator, psm);

  // Find the service record for the PSM
  tBTM_SEC_SERV_REC* p_serv_rec = btm_sec_find_first_serv(is_originator, psm);
  tBTM_SEC_SERV_REC* p_serv_rec =
      btm_sec_cb.find_first_serv_rec(is_originator, psm);

  // If there is no application registered with this PSM do not allow connection
  if (!p_serv_rec) {
@@ -4692,36 +4688,6 @@ static void btm_sec_auth_timer_timeout(void* data) {
  }
}

/*******************************************************************************
 *
 * Function         btm_sec_find_first_serv
 *
 * Description      Look for the first record in the service database
 *                  with specified PSM
 *
 * Returns          Pointer to the record or NULL
 *
 ******************************************************************************/
tBTM_SEC_SERV_REC* btm_sec_find_first_serv(bool is_originator, uint16_t psm) {
  tBTM_SEC_SERV_REC* p_serv_rec = &btm_sec_cb.sec_serv_rec[0];
  int i;

  if (is_originator && btm_sec_cb.p_out_serv &&
      btm_sec_cb.p_out_serv->psm == psm) {
    /* If this is outgoing connection and the PSM matches p_out_serv,
     * use it as the current service */
    return btm_sec_cb.p_out_serv;
  }

  /* otherwise, just find the first record with the specified PSM */
  for (i = 0; i < BTM_SEC_MAX_SERVICE_RECORDS; i++, p_serv_rec++) {
    if ((p_serv_rec->security_flags & BTM_SEC_IN_USE) &&
        (p_serv_rec->psm == psm))
      return (p_serv_rec);
  }
  return (NULL);
}

/*******************************************************************************
 *
 * Function         btm_sec_collision_timeout
+0 −17
Original line number Diff line number Diff line
@@ -41,11 +41,6 @@

#define BTM_SEC_MAX_COLLISION_DELAY (5000)

/*******************************************************************************
 *             L O C A L    F U N C T I O N     P R O T O T Y P E S            *
 ******************************************************************************/
tBTM_SEC_SERV_REC* btm_sec_find_first_serv(bool is_originator, uint16_t psm);

/*******************************************************************************
 *
 * Function         BTM_SecRegister
@@ -715,18 +710,6 @@ void btm_sec_pin_code_request(const RawAddress bda);
 ******************************************************************************/
void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset);

/*******************************************************************************
 *
 * Function         btm_sec_find_first_serv
 *
 * Description      Look for the first record in the service database
 *                  with specified PSM
 *
 * Returns          Pointer to the record or NULL
 *
 ******************************************************************************/
tBTM_SEC_SERV_REC* btm_sec_find_first_serv(bool is_originator, uint16_t psm);

/*******************************************************************************
 *
 * Function         btm_sec_dev_rec_cback_event
+30 −0
Original line number Diff line number Diff line
@@ -77,3 +77,33 @@ void BTM_Sec_Init() {
}

void BTM_Sec_Free() { btm_sec_cb.Free(); }

/*******************************************************************************
 *
 * Function         find_first_serv_rec
 *
 * Description      Look for the first record in the service database
 *                  with specified PSM
 *
 * Returns          Pointer to the record or NULL
 *
 ******************************************************************************/
tBTM_SEC_SERV_REC* tBTM_SEC_CB::find_first_serv_rec(bool is_originator,
                                                    uint16_t psm) {
  tBTM_SEC_SERV_REC* p_serv_rec = &sec_serv_rec[0];
  int i;

  if (is_originator && p_out_serv && p_out_serv->psm == psm) {
    /* If this is outgoing connection and the PSM matches p_out_serv,
     * use it as the current service */
    return p_out_serv;
  }

  /* otherwise, just find the first record with the specified PSM */
  for (i = 0; i < BTM_SEC_MAX_SERVICE_RECORDS; i++, p_serv_rec++) {
    if ((p_serv_rec->security_flags & BTM_SEC_IN_USE) &&
        (p_serv_rec->psm == psm))
      return (p_serv_rec);
  }
  return (NULL);
}
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ class tBTM_SEC_CB {

  void Init(uint8_t initial_security_mode);
  void Free();

  tBTM_SEC_SERV_REC* find_first_serv_rec(bool is_originator, uint16_t psm);
};

extern tBTM_SEC_CB btm_sec_cb;
Loading