summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Łukasz Rymanowski <rlukasz@google.com> 2024-08-22 20:21:01 +0000
committer Łukasz Rymanowski <rlukasz@google.com> 2024-08-22 21:00:19 +0000
commit0e9573a8cc508626e933ac8ac144e139aeb23e40 (patch)
tree261e5a9b7ff4c632fc490dc7d7701b77c48cbbe4
parent20b0bee7e6640821305c30e23c9e94c8f347ee88 (diff)
eatt: Fix handling indication confirmation timeout
Disconnect EATT channel on which timeout happen instead of ATT fixed channel. Bug: 361538527 Bug: 315241296 Test: atest net_test_eatt Flag: com.android.bluetooth.flags.gatt_disconnect_fix Change-Id: I3527e5a098782d43b34c192a68e8d20b0a54044b
-rw-r--r--system/stack/Android.bp4
-rw-r--r--system/stack/eatt/eatt_impl.h9
-rw-r--r--system/stack/test/eatt/eatt_test.cc18
3 files changed, 28 insertions, 3 deletions
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index 84c7015983..8b0de12abf 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -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: {
diff --git a/system/stack/eatt/eatt_impl.h b/system/stack/eatt/eatt_impl.h
index 0014666156..08c81f2a40 100644
--- a/system/stack/eatt/eatt_impl.h
+++ b/system/stack/eatt/eatt_impl.h
@@ -16,6 +16,7 @@
*/
#include <bluetooth/log.h>
+#include <com_android_bluetooth_flags.h>
#include <map>
#include <vector>
@@ -710,8 +711,12 @@ struct eatt_impl {
EattChannel* channel = (EattChannel*)data;
tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(channel->bda_, BT_TRANSPORT_LE);
- log::warn("disconnecting...");
- gatt_disconnect(p_tcb);
+ 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) {
diff --git a/system/stack/test/eatt/eatt_test.cc b/system/stack/test/eatt/eatt_test.cc
index 52f888f778..18c4cfa1f8 100644
--- a/system/stack/test/eatt/eatt_test.cc
+++ b/system/stack/test/eatt/eatt_test.cc
@@ -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