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

Commit a2c6d747 authored by Jack He's avatar Jack He Committed by Automerger Merge Worker
Browse files

GD-Shim: Free BT_HDR after use or callback failure am: 06497da6 am: f0d90bd7

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

Change-Id: Iae2bbf52a5dc95e555588a884767a3a1ef753fd2
parents f7041191 f0d90bd7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -61,6 +61,6 @@ void bluetooth::shim::ACL_Disconnect(uint16_t handle, bool is_classic,
  mock_function_count_map[__func__]++;
}
void bluetooth::shim::ACL_Shutdown() { mock_function_count_map[__func__]++; }
void bluetooth::shim::ACL_WriteData(uint16_t handle, const BT_HDR* p_buf) {
void bluetooth::shim::ACL_WriteData(uint16_t handle, BT_HDR* p_buf) {
  mock_function_count_map[__func__]++;
}
+8 −1
Original line number Diff line number Diff line
@@ -299,7 +299,14 @@ class ShimAclConnection {
    BT_HDR* p_buf = MakeLegacyBtHdrPacket(std::move(packet), preamble);
    ASSERT_LOG(p_buf != nullptr,
               "Unable to allocate BT_HDR legacy packet handle:%04x", handle_);
    TRY_POSTING_ON_MAIN(send_data_upwards_, p_buf);
    if (send_data_upwards_ == nullptr) {
      LOG_WARN("Dropping ACL data with no callback");
      osi_free(p_buf);
    } else if (do_in_main_thread(FROM_HERE,
                                 base::Bind(send_data_upwards_, p_buf)) !=
               BT_STATUS_SUCCESS) {
      osi_free(p_buf);
    }
  }

  virtual void InitiateDisconnect(hci::DisconnectReason reason) = 0;
+2 −1
Original line number Diff line number Diff line
@@ -54,11 +54,12 @@ void bluetooth::shim::ACL_IgnoreLeConnectionFrom(
      ToAddressWithTypeFromLegacy(legacy_address_with_type));
}

void bluetooth::shim::ACL_WriteData(uint16_t handle, const BT_HDR* p_buf) {
void bluetooth::shim::ACL_WriteData(uint16_t handle, BT_HDR* p_buf) {
  std::unique_ptr<bluetooth::packet::RawBuilder> packet =
      MakeUniquePacket(p_buf->data + p_buf->offset + HCI_DATA_PREAMBLE_SIZE,
                       p_buf->len - HCI_DATA_PREAMBLE_SIZE);
  Stack::GetInstance()->GetAcl()->WriteData(handle, std::move(packet));
  osi_free(p_buf);
}

void bluetooth::shim::ACL_ConfigureLePrivacy(bool is_le_privacy_enabled) {
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ bool ACL_AcceptLeConnectionFrom(const tBLE_BD_ADDR& legacy_address_with_type);
void ACL_IgnoreLeConnectionFrom(const tBLE_BD_ADDR& legacy_address_with_type);

void ACL_Disconnect(uint16_t handle, bool is_classic, tHCI_STATUS reason);
void ACL_WriteData(uint16_t handle, const BT_HDR* p_buf);
void ACL_WriteData(uint16_t handle, BT_HDR* p_buf);
void ACL_ConfigureLePrivacy(bool is_le_privacy_enabled);
void ACL_Shutdown();
void ACL_IgnoreAllLeConnections();
+1 −0
Original line number Diff line number Diff line
@@ -877,6 +877,7 @@ tBTM_STATUS bluetooth::shim::BTM_ClearInqDb(const RawAddress* p_bda) {
tBTM_STATUS bluetooth::shim::BTM_WriteEIR(BT_HDR* p_buff) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_buff != nullptr);
  osi_free(p_buff);
  return BTM_NO_RESOURCES;
}

Loading