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

Commit 5242037b authored by Myles Watson's avatar Myles Watson Committed by Jakub Pawlowski
Browse files

Le: Bring back l2cble_process_rc_parameter_request_evt

Bug: 322230000
Bug: 348355226
Test: mma -j32
Flag: EXEMPT, no logical change
Change-Id: I3c542f085ac576641577133957f3a2eb1426122d
parent 7e045318
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ bt_status_t do_in_main_thread_delayed(base::Location const&,
  abort();
}
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }
bluetooth::common::PostableContext* get_main() { return nullptr; }

namespace bluetooth {
namespace os {
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ void l2cble_notify_le_connection(const RawAddress& bda);

void l2cble_use_preferred_conn_params(const RawAddress& bda);

void l2cble_process_rc_param_request_evt(uint16_t handle, uint16_t int_min,
                                         uint16_t int_max, uint16_t latency,
                                         uint16_t timeout);

// Invoked when HCI mode is changed to HCI_MODE_ACTIVE or HCI_MODE_SNIFF
void l2c_OnHciModeChangeSendPendingPackets(RawAddress remote);

+48 −0
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@
#include <bluetooth/log.h>

#include "hci/controller_interface.h"
#include "hci/event_checkers.h"
#include "hci/hci_interface.h"
#include "hci/hci_packets.h"
#include "internal_include/stack_config.h"
#include "main/shim/acl_api.h"
#include "main/shim/entry.h"
@@ -35,6 +38,7 @@
#include "stack/include/acl_api.h"
#include "stack/include/btm_ble_api_types.h"
#include "stack/include/l2c_api.h"
#include "stack/include/main_thread.h"
#include "stack/l2cap/l2c_int.h"
#include "types/raw_address.h"

@@ -310,6 +314,50 @@ void l2cble_process_conn_update_evt(uint16_t handle, uint8_t status,
               p_lcb->conn_update_mask, p_lcb->subrate_req_mask);
}

/*******************************************************************************
 *
 * Function         l2cble_process_rc_param_request_evt
 *
 * Description      process LE Remote Connection Parameter Request Event.
 *
 * Returns          void
 *
 ******************************************************************************/
void l2cble_process_rc_param_request_evt(uint16_t handle, uint16_t int_min,
                                         uint16_t int_max, uint16_t latency,
                                         uint16_t timeout) {
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle);
  if (!p_lcb) {
    log::warn("No link to update connection parameter");
    return;
  }

  p_lcb->min_interval = int_min;
  p_lcb->max_interval = int_max;
  p_lcb->latency = latency;
  p_lcb->timeout = timeout;

  /* if update is enabled, always accept connection parameter update */
  if ((p_lcb->conn_update_mask & L2C_BLE_CONN_UPDATE_DISABLE) == 0) {
    shim::GetHciLayer()->EnqueueCommand(
        hci::LeRemoteConnectionParameterRequestReplyBuilder::Create(
            handle, int_min, int_max, latency, timeout, 0, 0),
        get_main()->BindOnce(
            hci::check_complete<
                hci::LeRemoteConnectionParameterRequestReplyCompleteView>));
  } else {
    log::verbose("L2CAP - LE - update currently disabled");
    p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
    shim::GetHciLayer()->EnqueueCommand(
        hci::LeRemoteConnectionParameterRequestNegativeReplyBuilder::Create(
            handle, hci::ErrorCode::UNACCEPTABLE_CONNECTION_PARAMETERS),
        get_main()->BindOnce(
            hci::check_complete<
                hci::
                    LeRemoteConnectionParameterRequestNegativeReplyCompleteView>));
  }
}

void l2cble_use_preferred_conn_params(const RawAddress& bda) {
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bda, BT_TRANSPORT_LE);
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(bda);
+8 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ struct l2cble_process_sig_cmd l2cble_process_sig_cmd;
struct l2cble_create_conn l2cble_create_conn;
struct l2c_link_processs_ble_num_bufs l2c_link_processs_ble_num_bufs;
struct l2c_ble_link_adjust_allocation l2c_ble_link_adjust_allocation;
struct l2cble_process_rc_param_request_evt l2cble_process_rc_param_request_evt;
struct l2cble_update_data_length l2cble_update_data_length;
struct l2cble_process_data_length_change_event
    l2cble_process_data_length_change_event;
@@ -132,6 +133,13 @@ void l2c_ble_link_adjust_allocation(void) {
  inc_func_call_count(__func__);
  test::mock::stack_l2cap_ble::l2c_ble_link_adjust_allocation();
}
void l2cble_process_rc_param_request_evt(uint16_t handle, uint16_t int_min,
                                         uint16_t int_max, uint16_t latency,
                                         uint16_t timeout) {
  inc_func_call_count(__func__);
  test::mock::stack_l2cap_ble::l2cble_process_rc_param_request_evt(
      handle, int_min, int_max, latency, timeout);
}
void l2cble_update_data_length(tL2C_LCB* p_lcb) {
  inc_func_call_count(__func__);
  test::mock::stack_l2cap_ble::l2cble_update_data_length(p_lcb);
+16 −0
Original line number Diff line number Diff line
@@ -179,6 +179,22 @@ struct l2c_ble_link_adjust_allocation {
  void operator()(void) { body(); };
};
extern struct l2c_ble_link_adjust_allocation l2c_ble_link_adjust_allocation;
// Name: l2cble_process_rc_param_request_evt
// Params: uint16_t handle, uint16_t int_min, uint16_t int_max, uint16_t
// latency, uint16_t timeout Returns: void
struct l2cble_process_rc_param_request_evt {
  std::function<void(uint16_t handle, uint16_t int_min, uint16_t int_max,
                     uint16_t latency, uint16_t timeout)>
      body{[](uint16_t /* handle */, uint16_t /* int_min */,
              uint16_t /* int_max */, uint16_t /* latency */,
              uint16_t /* timeout */) {}};
  void operator()(uint16_t handle, uint16_t int_min, uint16_t int_max,
                  uint16_t latency, uint16_t timeout) {
    body(handle, int_min, int_max, latency, timeout);
  };
};
extern struct l2cble_process_rc_param_request_evt
    l2cble_process_rc_param_request_evt;
// Name: l2cble_update_data_length
// Params: tL2C_LCB* p_lcb
// Returns: void