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

Commit 5c520135 authored by Łukasz Rymanowski (xWF)'s avatar Łukasz Rymanowski (xWF) Committed by Automerger Merge Worker
Browse files

Merge changes I3527e5a0,Ia93c888e into main am: 91d5767a

parents d9bb73da 91d5767a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1553,6 +1553,7 @@ cc_test {
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/bta",
        "packages/modules/Bluetooth/system/gd",
    ],
    generated_headers: [
@@ -1564,6 +1565,7 @@ cc_test {
        ":TestCommonStackConfig",
        ":TestMockMainShim",
        ":TestMockMainShimEntry",
        ":TestStubOsi",
        "eatt/eatt.cc",
        "test/common/mock_btif_storage.cc",
        "test/common/mock_btm_api_layer.cc",
@@ -1577,6 +1579,7 @@ cc_test {
        "libcutils",
    ],
    static_libs: [
        "bluetooth_flags_c_lib_for_test",
        "libbase",
        "libbluetooth-types",
        "libbluetooth_gd",
@@ -1593,6 +1596,7 @@ cc_test {
        "libosi",
        "libprotobuf-cpp-lite",
        "libstatslog_bt",
        "server_configurable_flags",
    ],
    target: {
        android: {
+7 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
 */

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

#include <map>
#include <vector>
@@ -710,9 +711,13 @@ struct eatt_impl {
    EattChannel* channel = (EattChannel*)data;
    tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(channel->bda_, BT_TRANSPORT_LE);

    log::warn("disconnecting...");
    log::warn("disconnecting channel {:#x} for {}", channel->cid_, channel->bda_);
    if (com::android::bluetooth::flags::gatt_disconnect_fix()) {
      EattExtension::GetInstance()->Disconnect(channel->bda_, channel->cid_);
    } else {
      gatt_disconnect(p_tcb);
    }
  }

  void start_indication_confirm_timer(const RawAddress& bd_addr, uint16_t cid) {
    EattChannel* channel = find_eatt_channel_by_cid(bd_addr, cid);
+6 −0
Original line number Diff line number Diff line
@@ -302,6 +302,12 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) {

  if (p_tcb->att_lcid == L2CAP_ATT_CID) {
    if (ch_state == GATT_CH_OPEN) {
      if (com::android::bluetooth::flags::gatt_disconnect_fix() && p_tcb->eatt) {
        /* ATT is fixed channel and it is expected to drop ACL.
         * Make sure all EATT channels are disconnected before doing that.
         */
        EattExtension::GetInstance()->Disconnect(p_tcb->peer_bda);
      }
      if (!L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_tcb->peer_bda)) {
        log::warn("Unable to remove L2CAP ATT fixed channel peer:{}", p_tcb->peer_bda);
      }
+17 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
 */

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

@@ -32,6 +33,7 @@
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_psm_types.h"
#include "stack/include/l2cdefs.h"
#include "test/common/fake_osi.h"
#include "test/mock/mock_main_shim_entry.h"
#include "types/raw_address.h"

@@ -51,6 +53,8 @@ using namespace bluetooth;

#define BLE_GATT_SVR_SUP_FEAT_EATT_BITMASK 0x01

extern struct fake_osi_alarm_set_on_mloop fake_osi_alarm_set_on_mloop_;

/* Needed for testing context */
static tGATT_TCB test_tcb;
void btif_storage_add_eatt_supported(const RawAddress& addr) { return; }
@@ -63,6 +67,7 @@ tGATT_TCB* gatt_find_tcb_by_addr(const RawAddress& bda, tBT_TRANSPORT transport)

namespace {
const RawAddress test_address({0x11, 0x11, 0x11, 0x11, 0x11, 0x11});
std::vector<uint16_t> test_local_cids{61, 62, 63, 64, 65};

class EattTest : public testing::Test {
protected:
@@ -77,7 +82,6 @@ protected:
      return true;
    });

    std::vector<uint16_t> test_local_cids{61, 62, 63, 64, 65};
    EXPECT_CALL(l2cap_interface_, ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
            .WillOnce(Return(test_local_cids));

@@ -230,6 +234,8 @@ protected:
  }

  void TearDown() override {
    com::android::bluetooth::flags::provider_->reset_flags();

    EXPECT_CALL(l2cap_interface_, DeregisterLECoc(BT_PSM_EATT)).Times(1);

    eatt_instance_->Stop();
@@ -619,4 +625,14 @@ TEST_F(EattTest, ChannelUnavailableWhileReconfiguring) {
  ASSERT_EQ(available_channel_for_indication, nullptr);
}

TEST_F(EattTest, DisconnectChannelOnIndicationConfirmationTimeout) {
  com::android::bluetooth::flags::provider_->gatt_disconnect_fix(true);
  ConnectDeviceEattSupported(1);

  eatt_instance_->StartIndicationConfirmationTimer(test_address, test_local_cids[0]);

  EXPECT_CALL(l2cap_interface_, DisconnectRequest(test_local_cids[0])).Times(1);
  fake_osi_alarm_set_on_mloop_.cb(fake_osi_alarm_set_on_mloop_.data);
}

}  // namespace