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

Commit 5450eaaa authored by IHLHO KIM's avatar IHLHO KIM Committed by Automerger Merge Worker
Browse files

Fix GATT data loss due to segmentation error am: ab2c1e84

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/bt/+/15959971

Change-Id: Id28cdcecea37d66bbdb2fb27f5d4aec2cc1439b0
parents e57daa8d ab2c1e84
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -1048,6 +1048,8 @@ void l2c_OnHciModeChangeSendPendingPackets(RawAddress remote) {
static void l2c_link_send_to_lower_br_edr(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
  const uint16_t acl_packet_size_classic =
      controller_get_interface()->get_acl_packet_size_classic();
  const uint16_t acl_data_size_classic =
      controller_get_interface()->get_acl_data_size_classic();
  const uint16_t link_xmit_quota = p_lcb->link_xmit_quota;
  const bool is_bdr_and_fits_in_buffer =
      bluetooth::shim::is_gd_acl_enabled()
@@ -1063,8 +1065,8 @@ static void l2c_link_send_to_lower_br_edr(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
    l2cb.controller_xmit_window--;
  } else {
    uint16_t num_segs =
        (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_packet_size_classic - 1) /
        acl_packet_size_classic;
        (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size_classic - 1) /
        acl_data_size_classic;

    /* If doing round-robin, then only 1 segment each time */
    if (p_lcb->link_xmit_quota == 0) {
@@ -1098,6 +1100,8 @@ static void l2c_link_send_to_lower_br_edr(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
static void l2c_link_send_to_lower_ble(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
  const uint16_t acl_packet_size_ble =
      controller_get_interface()->get_acl_packet_size_ble();
  const uint16_t acl_data_size_ble =
      controller_get_interface()->get_acl_data_size_ble();
  const uint16_t link_xmit_quota = p_lcb->link_xmit_quota;
  const bool is_ble_and_fits_in_buffer = (p_buf->len <= acl_packet_size_ble);

@@ -1110,8 +1114,8 @@ static void l2c_link_send_to_lower_ble(tL2C_LCB* p_lcb, BT_HDR* p_buf) {
    l2cb.controller_le_xmit_window--;
  } else {
    uint16_t num_segs =
        (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_packet_size_ble - 1) /
        acl_packet_size_ble;
        (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size_ble - 1) /
        acl_data_size_ble;

    /* If doing round-robin, then only 1 segment each time */
    if (p_lcb->link_xmit_quota == 0) {