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

Commit 379ca35e authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

stack::rnr Extract RNR notify callbacks into rnr module am: 0a74d438

parents 4fe5d1f3 0a74d438
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -274,6 +274,7 @@ cc_library_static {
        "rfcomm/rfc_port_if.cc",
        "rfcomm/rfc_ts_frames.cc",
        "rfcomm/rfc_utils.cc",
        "rnr/remote_name_request.cc",
        "smp/p_256_curvepara.cc",
        "smp/p_256_ecc_pp.cc",
        "smp/p_256_multprecision.cc",
@@ -1683,6 +1684,7 @@ cc_test {
        "btm/hfp_msbc_encoder.cc",
        "btm/security_event_parser.cc",
        "metrics/stack_metrics_logging.cc",
        "rnr/remote_name_request.cc",
        "test/btm/peer_packet_types_test.cc",
        "test/btm/sco_hci_test.cc",
        "test/btm/sco_pkt_status_test.cc",
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ source_set("stack") {
    "rfcomm/rfc_port_if.cc",
    "rfcomm/rfc_ts_frames.cc",
    "rfcomm/rfc_utils.cc",
    "rnr/remote_name_request.cc",
    "sdp/sdp_api.cc",
    "sdp/sdp_db.cc",
    "sdp/sdp_discovery.cc",
+0 −46
Original line number Diff line number Diff line
@@ -412,52 +412,6 @@ bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info) {
  return (true);
}

/*******************************************************************************
 *
 * Function         BTM_SecAddRmtNameNotifyCallback
 *
 * Description      Any profile can register to be notified when name of the
 *                  remote device is resolved.
 *
 * Returns          true if registered OK, else false
 *
 ******************************************************************************/
bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback) {
  int i;

  for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
    if (btm_cb.rnr.p_rmt_name_callback[i] == NULL) {
      btm_cb.rnr.p_rmt_name_callback[i] = p_callback;
      return (true);
    }
  }

  return (false);
}

/*******************************************************************************
 *
 * Function         BTM_SecDeleteRmtNameNotifyCallback
 *
 * Description      Any profile can deregister notification when a new Link Key
 *                  is generated per connection.
 *
 * Returns          true if OK, else false
 *
 ******************************************************************************/
bool BTM_SecDeleteRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback) {
  int i;

  for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
    if (btm_cb.rnr.p_rmt_name_callback[i] == p_callback) {
      btm_cb.rnr.p_rmt_name_callback[i] = NULL;
      return (true);
    }
  }

  return (false);
}

bool BTM_IsEncrypted(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
  return btm_sec_cb.IsDeviceEncrypted(bd_addr, transport);
}
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "stack/rnr/remote_name_request.h"

#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>

#include "stack/btm/btm_int_types.h"

extern tBTM_CB btm_cb;
using namespace bluetooth;

bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback) {
  int i;

  for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
    if (btm_cb.rnr.p_rmt_name_callback[i] == NULL) {
      btm_cb.rnr.p_rmt_name_callback[i] = p_callback;
      return true;
    }
  }

  return false;
}

bool BTM_SecDeleteRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback) {
  int i;

  for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
    if (btm_cb.rnr.p_rmt_name_callback[i] == p_callback) {
      btm_cb.rnr.p_rmt_name_callback[i] = NULL;
      return true;
    }
  }

  return false;
}
+30 −0
Original line number Diff line number Diff line
@@ -51,3 +51,33 @@ class RemoteNameRequest {

}  // namespace rnr
}  // namespace bluetooth

/*******************************************************************************
 *
 * Function         BTM_SecAddRmtNameNotifyCallback
 *
 * Description      Any profile can register to be notified when name of the
 *                  remote device is resolved.
 *
 * Parameters:      p_callback: Callback to add after each remote name
 *                  request has completed or timed out.
 *
 * Returns          true if registered OK, else false
 *
 ******************************************************************************/
bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);

/*******************************************************************************
 *
 * Function         BTM_SecDeleteRmtNameNotifyCallback
 *
 * Description      Any profile can deregister notification when a new Link Key
 *                  is generated per connection.
 *
 * Parameters:      p_callback: Callback to remove after each remote name
 *                  request has completed or timed out.
 *
 * Returns          true if unregistered OK, else false
 *
 ******************************************************************************/
bool BTM_SecDeleteRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);