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

Commit e06e22de authored by Hui Peng's avatar Hui Peng
Browse files

[Invisalign2] Encapsulate tBTM_SEC_CB::RemoveServiceById

Bug: 301661850
Test: m com.android.btservices
Flag: EXEMPT, mechanical refactor
Change-Id: I32870d9e42f3ff8dca000cdf012dc409231712c7
parent 94396cb2
Loading
Loading
Loading
Loading
+1 −16
Original line number Diff line number Diff line
@@ -447,22 +447,7 @@ bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
 *
 ******************************************************************************/
uint8_t BTM_SecClrService(uint8_t service_id) {
  tBTM_SEC_SERV_REC* p_srec = &btm_sec_cb.sec_serv_rec[0];
  uint8_t num_freed = 0;
  int i;

  for (i = 0; i < BTM_SEC_MAX_SERVICE_RECORDS; i++, p_srec++) {
    /* Delete services with specified name (if in use and not SDP) */
    if ((p_srec->security_flags & BTM_SEC_IN_USE) &&
        (p_srec->psm != BT_PSM_SDP) &&
        (!service_id || (service_id == p_srec->service_id))) {
      LOG_VERBOSE("BTM_SEC_CLR[%d]: id %d", i, service_id);
      p_srec->security_flags = 0;
      num_freed++;
    }
  }

  return (num_freed);
  return btm_sec_cb.RemoveServiceById(service_id);
}

/*******************************************************************************
+19 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "osi/include/list.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/security_device_record.h"
#include "stack/include/bt_psm_types.h"
#include "types/raw_address.h"

void tBTM_SEC_CB::Init(uint8_t initial_security_mode) {
@@ -304,3 +305,21 @@ bool tBTM_SEC_CB::AddService(bool is_originator, const char* p_name,

  return (record_allocated);
}

uint8_t tBTM_SEC_CB::RemoveServiceById(uint8_t service_id) {
  tBTM_SEC_SERV_REC* p_srec = &sec_serv_rec[0];
  uint8_t num_freed = 0;
  int i;

  for (i = 0; i < BTM_SEC_MAX_SERVICE_RECORDS; i++, p_srec++) {
    /* Delete services with specified name (if in use and not SDP) */
    if ((p_srec->security_flags & BTM_SEC_IN_USE) &&
        (p_srec->psm != BT_PSM_SDP) &&
        (!service_id || (service_id == p_srec->service_id))) {
      LOG_VERBOSE("BTM_SEC_CLR[%d]: id:%d", i, service_id);
      p_srec->security_flags = 0;
      num_freed++;
    }
  }
  return (num_freed);
}
+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ class tBTM_SEC_CB {
  bool AddService(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);
  uint8_t RemoveServiceById(uint8_t service_id);
};

extern tBTM_SEC_CB btm_sec_cb;