summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Łukasz Rymanowski <rlukasz@google.com> 2022-06-24 23:47:08 +0000
committer Łukasz Rymanowski <rlukasz@google.com> 2022-06-30 17:36:48 +0000
commitfb42ad05fdbc935869d780e68487a9dc1b1524b9 (patch)
tree78e1b2177051d0c1c1b77a11239defe5a72ef07f
parentb5b1508332082e5e98c00f670a6c7c4d3b3bae2a (diff)
eatt: Use pts mode to pass some L2CAP test cases
PTS uses EATT for some L2CAP test cases. Allow to start ECOC just after device got connected. To enable it use: PTS_ConnectEattUncondictionally=true Bug: 236216322 Test: atest BluetoothInstrumentationTests Tag: #feature Change-Id: I855a9babf6a24284fca46607b767a661e8d30740
-rw-r--r--system/conf/bt_stack.conf3
-rw-r--r--system/internal_include/stack_config.h1
-rw-r--r--system/main/stack_config.cc8
-rw-r--r--system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc2
-rw-r--r--system/profile/avrcp/tests/avrcp_device_test.cc2
-rw-r--r--system/stack/Android.bp3
-rw-r--r--system/stack/eatt/eatt_impl.h22
-rw-r--r--system/stack/test/btm/stack_btm_test.cc3
-rw-r--r--system/stack/test/stack_smp_test.cc3
-rw-r--r--system/test/common/stack_config.cc3
10 files changed, 42 insertions, 8 deletions
diff --git a/system/conf/bt_stack.conf b/system/conf/bt_stack.conf
index 0cf3a11825..8a13213071 100644
--- a/system/conf/bt_stack.conf
+++ b/system/conf/bt_stack.conf
@@ -47,6 +47,9 @@ TRC_HID_DEV=2
# Use EATT for the notifications
#PTS_ForceEattForNotifications=true
+# Start EATT without validation Server Supported Features
+#PTS_ConnectEattUncondictionally=true
+
# Disable BR/EDR discovery after LE pairing to avoid cross key derivation errors
#PTS_DisableSDPOnLEPair=true
diff --git a/system/internal_include/stack_config.h b/system/internal_include/stack_config.h
index a8b8e6bb49..4c13c54910 100644
--- a/system/internal_include/stack_config.h
+++ b/system/internal_include/stack_config.h
@@ -34,6 +34,7 @@ typedef struct {
const std::string* (*get_pts_smp_options)(void);
int (*get_pts_smp_failure_case)(void);
bool (*get_pts_force_eatt_for_notifications)(void);
+ bool (*get_pts_connect_eatt_unconditionally)(void);
config_t* (*get_all)(void);
} stack_config_t;
diff --git a/system/main/stack_config.cc b/system/main/stack_config.cc
index 1007858310..50fbde2e74 100644
--- a/system/main/stack_config.cc
+++ b/system/main/stack_config.cc
@@ -34,6 +34,8 @@ const char* PTS_DISABLE_SDP_LE_PAIR = "PTS_DisableSDPOnLEPair";
const char* PTS_SMP_PAIRING_OPTIONS_KEY = "PTS_SmpOptions";
const char* PTS_SMP_FAILURE_CASE_KEY = "PTS_SmpFailureCase";
const char* PTS_FORCE_EATT_FOR_NOTIFICATIONS = "PTS_ForceEattForNotifications";
+const char* PTS_CONNECT_EATT_UNCONDITIONALLY =
+ "PTS_ConnectEattUncondictionally";
static std::unique_ptr<config_t> config;
} // namespace
@@ -116,6 +118,11 @@ static bool get_pts_force_eatt_for_notifications(void) {
PTS_FORCE_EATT_FOR_NOTIFICATIONS, false);
}
+static bool get_pts_connect_eatt_unconditionally(void) {
+ return config_get_bool(*config, CONFIG_DEFAULT_SECTION,
+ PTS_CONNECT_EATT_UNCONDITIONALLY, false);
+}
+
static config_t* get_all(void) { return config.get(); }
const stack_config_t interface = {get_trace_config_enabled,
@@ -126,6 +133,7 @@ const stack_config_t interface = {get_trace_config_enabled,
get_pts_smp_options,
get_pts_smp_failure_case,
get_pts_force_eatt_for_notifications,
+ get_pts_connect_eatt_unconditionally,
get_all};
const stack_config_t* stack_config_get_interface(void) { return &interface; }
diff --git a/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc b/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc
index 0e8fa2e9f5..b39bbdd9c5 100644
--- a/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc
+++ b/system/profile/avrcp/tests/avrcp_device_fuzz/avrcp_device_fuzz.cc
@@ -58,7 +58,7 @@ const stack_config_t interface = {nullptr, get_pts_avrcp_test,
nullptr, nullptr,
nullptr, nullptr,
nullptr, nullptr,
- nullptr};
+ nullptr, nullptr};
void Callback(uint8_t, bool, std::unique_ptr<::bluetooth::PacketBuilder>) {}
diff --git a/system/profile/avrcp/tests/avrcp_device_test.cc b/system/profile/avrcp/tests/avrcp_device_test.cc
index f75f2e2b1f..f6c258be89 100644
--- a/system/profile/avrcp/tests/avrcp_device_test.cc
+++ b/system/profile/avrcp/tests/avrcp_device_test.cc
@@ -54,7 +54,7 @@ const stack_config_t interface = {nullptr, get_pts_avrcp_test,
nullptr, nullptr,
nullptr, nullptr,
nullptr, nullptr,
- nullptr};
+ nullptr, nullptr};
// TODO (apanicke): All the tests below are just basic positive unit tests.
// Add more tests to increase code coverage.
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index 36e8e8c530..3fc65b32e6 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -730,6 +730,7 @@ cc_test {
include_dirs:[
"packages/modules/Bluetooth/system",
"packages/modules/Bluetooth/system/gd",
+ "packages/modules/Bluetooth/system/internal_include"
],
srcs: [
"eatt/eatt.cc",
@@ -740,6 +741,7 @@ cc_test {
"test/common/mock_l2cap_layer.cc",
"test/gatt/mock_gatt_utils_ref.cc",
"test/eatt/eatt_test.cc",
+ ":TestCommonStackConfig",
],
shared_libs: [
"libcutils",
@@ -1032,6 +1034,7 @@ cc_test {
],
srcs: [
":OsiCompatSources",
+ ":TestCommonStackConfig",
":TestMockBta",
":TestMockBtif",
":TestMockHci",
diff --git a/system/stack/eatt/eatt_impl.h b/system/stack/eatt/eatt_impl.h
index b2ea48d37c..9a73f9b5a1 100644
--- a/system/stack/eatt/eatt_impl.h
+++ b/system/stack/eatt/eatt_impl.h
@@ -24,6 +24,9 @@
#include "bind_helpers.h"
#include "device/include/controller.h"
#include "eatt.h"
+#include "gd/common/init_flags.h"
+#include "gd/common/strings.h"
+#include "internal_include/stack_config.h"
#include "l2c_api.h"
#include "osi/include/alarm.h"
#include "osi/include/allocator.h"
@@ -658,12 +661,19 @@ struct eatt_impl {
return;
}
- /* For new device, first read GATT server supported features. */
- if (gatt_cl_read_sr_supp_feat_req(
- bd_addr, base::BindOnce(&eatt_impl::supported_features_cb,
- base::Unretained(this), role)) == false) {
- LOG(INFO) << __func__ << "Eatt is not supported. Checked for device "
- << bd_addr;
+ /* This is needed for L2CAP test cases */
+ if (stack_config_get_interface()->get_pts_connect_eatt_unconditionally()) {
+ /* For PTS just start connecting EATT right away, */
+ eatt_device* eatt_dev = add_eatt_device(bd_addr);
+ connect_eatt(eatt_dev);
+ } else {
+ /* For new device, first read GATT server supported features. */
+ if (gatt_cl_read_sr_supp_feat_req(
+ bd_addr, base::BindOnce(&eatt_impl::supported_features_cb,
+ base::Unretained(this), role)) == false) {
+ LOG_INFO("Read server supported features failed for device %s",
+ bd_addr.ToString().c_str());
+ }
}
}
diff --git a/system/stack/test/btm/stack_btm_test.cc b/system/stack/test/btm/stack_btm_test.cc
index b9d75011c6..d685d2104e 100644
--- a/system/stack/test/btm/stack_btm_test.cc
+++ b/system/stack/test/btm/stack_btm_test.cc
@@ -71,6 +71,7 @@ bool get_pts_crosskey_sdp_disable(void) { return false; }
const std::string* get_pts_smp_options(void) { return &kSmpOptions; }
int get_pts_smp_failure_case(void) { return 123; }
bool get_pts_force_eatt_for_notifications(void) { return false; }
+bool get_pts_connect_eatt_unconditionally(void) { return false; }
config_t* get_all(void) { return nullptr; }
const packet_fragmenter_t* packet_fragmenter_get_interface() { return nullptr; }
@@ -84,6 +85,8 @@ stack_config_t mock_stack_config{
.get_pts_smp_failure_case = get_pts_smp_failure_case,
.get_pts_force_eatt_for_notifications =
get_pts_force_eatt_for_notifications,
+ .get_pts_connect_eatt_unconditionally =
+ get_pts_connect_eatt_unconditionally,
.get_all = get_all,
};
const stack_config_t* stack_config_get_interface(void) {
diff --git a/system/stack/test/stack_smp_test.cc b/system/stack/test/stack_smp_test.cc
index 125eeb39b8..62fbd695ae 100644
--- a/system/stack/test/stack_smp_test.cc
+++ b/system/stack/test/stack_smp_test.cc
@@ -46,6 +46,7 @@ bool get_pts_crosskey_sdp_disable(void) { return false; }
const std::string* get_pts_smp_options(void) { return &kSmpOptions; }
int get_pts_smp_failure_case(void) { return 123; }
bool get_pts_force_eatt_for_notifications(void) { return false; }
+bool get_pts_connect_eatt_unconditionally(void) { return false; }
config_t* get_all(void) { return nullptr; }
const packet_fragmenter_t* packet_fragmenter_get_interface() { return nullptr; }
@@ -59,6 +60,8 @@ stack_config_t mock_stack_config{
.get_pts_smp_failure_case = get_pts_smp_failure_case,
.get_pts_force_eatt_for_notifications =
get_pts_force_eatt_for_notifications,
+ .get_pts_connect_eatt_unconditionally =
+ get_pts_connect_eatt_unconditionally,
.get_all = get_all,
};
const stack_config_t* stack_config_get_interface(void) {
diff --git a/system/test/common/stack_config.cc b/system/test/common/stack_config.cc
index 1b6f651d74..211970762e 100644
--- a/system/test/common/stack_config.cc
+++ b/system/test/common/stack_config.cc
@@ -31,6 +31,7 @@ bool get_pts_crosskey_sdp_disable(void) { return false; }
const std::string* get_pts_smp_options(void) { return &kSmpOptions; }
int get_pts_smp_failure_case(void) { return 123; }
bool get_pts_force_eatt_for_notifications(void) { return false; }
+bool get_pts_connect_eatt_unconditionally(void) { return false; }
struct config_t;
config_t* get_all(void) { return nullptr; }
struct packet_fragmenter_t;
@@ -46,6 +47,8 @@ stack_config_t mock_stack_config{
.get_pts_smp_failure_case = get_pts_smp_failure_case,
.get_pts_force_eatt_for_notifications =
get_pts_force_eatt_for_notifications,
+ .get_pts_connect_eatt_unconditionally =
+ get_pts_connect_eatt_unconditionally,
.get_all = get_all,
};