patches bluetooth
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
nyyu 2022-09-30 22:42:14 +02:00
parent 3e37a2a02c
commit cd2d9e7e80
6 changed files with 238 additions and 36 deletions

54
fix-bt-1.patch Normal file
View File

@ -0,0 +1,54 @@
From 56c318bf3cc9208c772c7e6d01e88380d2155c67 Mon Sep 17 00:00:00 2001
From: "tzu-hsien.huang" <tzu-hsien.huang@mediatek.com>
Date: Fri, 26 Aug 2022 11:22:03 +0200
Subject: [PATCH] Additionally check le_set_event_mask command resturn status
with UNSUPPORTED_LMP_OR_LL_PARAMETER
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In GD BT stack, stack will check each return status of HCI Commands. E.g. reset , le_set_event_mask, set_event_mask …etc.
In BT spec 5.2, SIG add some parameters for le_set_event_mask for le audio, like LE Terminate BIG Complete event: Supported.
However, some legacy chips do not support LE Audio feature, and controller will return Status: Unsupported LMP Parameter Value when it receives this HCI Command
When it checks the return value and find the status is not SUCCESS, it will cause FAIL and cannot be compatible with old legacy chip.
After brushing GSI, Bluetooth will turn off automatically when it is turned on.
So all CTS test will always fail.
Check le_set_event_mask command return status with SUCCESS or UNSUPPORTED_LMP_OR_LL_PARAMETER
Bug: 239662211
Test: CtsBluetoothTestCases
Change-Id: I2b0cede7f47eecd2124a386e958773289eb6f11c
---
system/gd/hci/controller.cc | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc
index da5986fcb7..8be21a20a3 100644
--- a/system/gd/hci/controller.cc
+++ b/system/gd/hci/controller.cc
@@ -540,7 +540,7 @@ struct Controller::impl {
void le_set_event_mask(uint64_t le_event_mask) {
std::unique_ptr<LeSetEventMaskBuilder> packet = LeSetEventMaskBuilder::Create(le_event_mask);
hci_->EnqueueCommand(std::move(packet), module_.GetHandler()->BindOnceOn(
- this, &Controller::impl::check_status<LeSetEventMaskCompleteView>));
+ this, &Controller::impl::check_event_mask_status<LeSetEventMaskCompleteView>));
}
template <class T>
@@ -551,6 +551,15 @@ struct Controller::impl {
ASSERT(status_view.GetStatus() == ErrorCode::SUCCESS);
}
+ template <class T>
+ void check_event_mask_status(CommandCompleteView view) {
+ ASSERT(view.IsValid());
+ auto status_view = T::Create(view);
+ ASSERT(status_view.IsValid());
+ ASSERT(status_view.GetStatus() == ErrorCode::SUCCESS ||
+ status_view.GetStatus() == ErrorCode::UNSUPPORTED_LMP_OR_LL_PARAMETER);
+ }
+
#define OP_CODE_MAPPING(name) \
case OpCode::name: { \
uint16_t index = (uint16_t)OpCodeIndex::name; \

40
fix-bt-2.patch Normal file
View File

@ -0,0 +1,40 @@
From bf9a555f96cceb9ce49344e5055c2afa479df21d Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Fri, 26 Aug 2022 11:23:30 +0200
Subject: [PATCH] gd: hci: Ignore unexpected status events
For some reason, on some old devices, the controller will report a
remote to support SNIFF_SUBRATING even when it does not. Just ignore the
error here (the status event comes from the failure response).
Change-Id: Ifb9a65fd77f21d15a8dc1ced9240194d38218ef6
---
system/gd/hci/hci_layer.cc | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/system/gd/hci/hci_layer.cc b/system/gd/hci/hci_layer.cc
index 57d7e55fff..b5a9d065be 100644
--- a/system/gd/hci/hci_layer.cc
+++ b/system/gd/hci/hci_layer.cc
@@ -195,14 +195,13 @@ struct HciLayer::impl {
EventView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>(std::vector<uint8_t>()))));
command_queue_.front().GetCallback<CommandCompleteView>()->Invoke(move(command_complete_view));
} else {
- ASSERT_LOG(
- command_queue_.front().waiting_for_status_ == is_status,
- "0x%02hx (%s) was not expecting %s event",
- op_code,
- OpCodeText(op_code).c_str(),
- logging_id.c_str());
-
- command_queue_.front().GetCallback<TResponse>()->Invoke(move(response_view));
+ if (command_queue_.front().waiting_for_status_ == is_status) {
+ command_queue_.front().GetCallback<TResponse>()->Invoke(move(response_view));
+ } else {
+ CommandCompleteView command_complete_view = CommandCompleteView::Create(
+ EventView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>(std::vector<uint8_t>()))));
+ command_queue_.front().GetCallback<CommandCompleteView>()->Invoke(move(command_complete_view));
+ }
}
command_queue_.pop_front();

33
fix-bt-3.patch Normal file
View File

@ -0,0 +1,33 @@
From 6c794ea2b4247a3359453cb178cfd0f8e2d38f56 Mon Sep 17 00:00:00 2001
From: Sugakesshaa <83747297+bheatleyyy@users.noreply.github.com>
Date: Fri, 9 Sep 2022 03:35:26 +0800
Subject: [PATCH] Nuke condition check for controller
---
system/gd/hci/controller.cc | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc
index 8be21a20a3..dbece21c6e 100644
--- a/system/gd/hci/controller.cc
+++ b/system/gd/hci/controller.cc
@@ -66,16 +66,9 @@ struct Controller::impl {
hci_->EnqueueCommand(ReadBufferSizeBuilder::Create(),
handler->BindOnceOn(this, &Controller::impl::read_buffer_size_complete_handler));
-
- if (is_supported(OpCode::LE_READ_BUFFER_SIZE_V2)) {
- hci_->EnqueueCommand(
- LeReadBufferSizeV2Builder::Create(),
- handler->BindOnceOn(this, &Controller::impl::le_read_buffer_size_v2_handler));
- } else {
- hci_->EnqueueCommand(
- LeReadBufferSizeV1Builder::Create(),
- handler->BindOnceOn(this, &Controller::impl::le_read_buffer_size_handler));
- }
+
+ hci_->EnqueueCommand(LeReadBufferSizeV1Builder::Create(),
+ handler->BindOnceOn(this, &Controller::impl::le_read_buffer_size_handler));
hci_->EnqueueCommand(
LeReadFilterAcceptListSizeBuilder::Create(),

90
fix-bt-le.patch Normal file
View File

@ -0,0 +1,90 @@
From 6ad0718fa87dfbaa2bd95ab23f60f485a896e84b Mon Sep 17 00:00:00 2001
From: nyyu <mail@nyyu.dev>
Date: Fri, 30 Sep 2022 22:40:43 +0200
Subject: [PATCH] bt: disable le
Change-Id: I5c258b1401fcd6fbfa98c98849db209688f52d3c
---
system/gd/hci/controller.cc | 13 +++++++------
system/gd/hci/hci_layer.cc | 4 ++--
system/stack/btm/btm_ble_gap.cc | 4 +++-
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc
index dbece21c6e..572df09bce 100644
--- a/system/gd/hci/controller.cc
+++ b/system/gd/hci/controller.cc
@@ -145,8 +145,9 @@ struct Controller::impl {
handler->BindOnceOn(this, &Controller::impl::le_set_host_feature_handler));
}
- hci_->EnqueueCommand(LeGetVendorCapabilitiesBuilder::Create(),
- handler->BindOnceOn(this, &Controller::impl::le_get_vendor_capabilities_handler));
+ /*hci_->EnqueueCommand(LeGetVendorCapabilitiesBuilder::Create(),
+ handler->BindOnceOn(this, &Controller::impl::le_get_vendor_capabilities_handler));*/
+ le_get_vendor_capabilities_handler();
// We only need to synchronize the last read. Make BD_ADDR to be the last one.
std::promise<void> promise;
@@ -400,8 +401,8 @@ struct Controller::impl {
le_periodic_advertiser_list_size_ = complete_view.GetPeriodicAdvertiserListSize();
}
- void le_get_vendor_capabilities_handler(CommandCompleteView view) {
- auto complete_view = LeGetVendorCapabilitiesCompleteView::Create(view);
+ void le_get_vendor_capabilities_handler(/*CommandCompleteView view*/) {
+ //auto complete_view = LeGetVendorCapabilitiesCompleteView::Create(view);
vendor_capabilities_.is_supported_ = 0x00;
vendor_capabilities_.max_advt_instances_ = 0x00;
@@ -420,7 +421,7 @@ struct Controller::impl {
vendor_capabilities_.a2dp_source_offload_capability_mask_ = 0x00;
vendor_capabilities_.bluetooth_quality_report_support_ = 0x00;
- if (complete_view.IsValid()) {
+ /*if (complete_view.IsValid()) {
vendor_capabilities_.is_supported_ = 0x01;
// v0.55
@@ -471,7 +472,7 @@ struct Controller::impl {
}
vendor_capabilities_.a2dp_source_offload_capability_mask_ = v98.GetA2dpSourceOffloadCapabilityMask();
vendor_capabilities_.bluetooth_quality_report_support_ = v98.GetBluetoothQualityReportSupport();
- }
+ }*/
}
void set_event_mask(uint64_t event_mask) {
diff --git a/system/gd/hci/hci_layer.cc b/system/gd/hci/hci_layer.cc
index b5a9d065be..fa0be65701 100644
--- a/system/gd/hci/hci_layer.cc
+++ b/system/gd/hci/hci_layer.cc
@@ -180,8 +180,8 @@ struct HciLayer::impl {
LOG_ERROR("Discarding event that came after timeout 0x%02hx (%s)", op_code, OpCodeText(op_code).c_str());
return;
}
- ASSERT_LOG(waiting_command_ == op_code, "Waiting for 0x%02hx (%s), got 0x%02hx (%s)", waiting_command_,
- OpCodeText(waiting_command_).c_str(), op_code, OpCodeText(op_code).c_str());
+ /*ASSERT_LOG(waiting_command_ == op_code, "Waiting for 0x%02hx (%s), got 0x%02hx (%s)", waiting_command_,
+ OpCodeText(waiting_command_).c_str(), op_code, OpCodeText(op_code).c_str());*/
bool is_vendor_specific = static_cast<int>(op_code) & (0x3f << 10);
CommandStatusView status_view = CommandStatusView::Create(event);
diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc
index 76f6c6f62c..4d7f10312c 100644
--- a/system/stack/btm/btm_ble_gap.cc
+++ b/system/stack/btm/btm_ble_gap.cc
@@ -619,7 +619,9 @@ static void btm_ble_vendor_capability_vsc_cmpl_cback(
BTM_TRACE_DEBUG("%s", __func__);
/* Check status of command complete event */
- CHECK(p_vcs_cplt_params->opcode == HCI_BLE_VENDOR_CAP);
+ if(p_vcs_cplt_params->opcode != HCI_BLE_VENDOR_CAP)
+ return;
+
CHECK(p_vcs_cplt_params->param_len > 0);
const uint8_t* p = p_vcs_cplt_params->p_param_buf;
--
2.37.3

View File

@ -1,25 +0,0 @@
From 3c8dd9d84ec1b52ddd449ccaf7a8f94f9d0f2932 Mon Sep 17 00:00:00 2001
From: nyyu <mail@nyyu.dev>
Date: Sun, 25 Sep 2022 14:54:37 +0200
Subject: [PATCH] fix: build kernel header
---
build/soong/Android.bp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build/soong/Android.bp b/build/soong/Android.bp
index 5cbcd19b..02ed36da 100644
--- a/build/soong/Android.bp
+++ b/build/soong/Android.bp
@@ -21,7 +21,7 @@ lineage_generator {
name: "generated_kernel_includes",
// The headers make command
- cmd: "$(PATH_OVERRIDE_SOONG) $(KERNEL_MAKE_CMD) $(KERNEL_MAKE_FLAGS) -C $(TARGET_KERNEL_SOURCE) O=$(KERNEL_BUILD_OUT_PREFIX)$(genDir) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) headers_install",
+ cmd: "mkdir -p $(KERNEL_BUILD_OUT_PREFIX)$(genDir) && $(PATH_OVERRIDE_SOONG) $(KERNEL_MAKE_CMD) $(KERNEL_MAKE_FLAGS) -C $(TARGET_KERNEL_SOURCE) O=$(KERNEL_BUILD_OUT_PREFIX)$(genDir) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) headers_install",
// Directories that can be imported by a cc_* module generated_headers property
export_include_dirs: [
--
2.37.3

30
sync.sh
View File

@ -1,4 +1,5 @@
#!/bin/bash -e
# shellcheck disable=SC2250,SC2154,SC2086,SC1091,SC2312
. build/envsetup.sh
@ -21,11 +22,14 @@ for i in "${tmp[@]}"; do
IFS=: read -r folder commit <<<"${i}"
if [[ "${folder}" != lineage/* && "${before[${folder}]}" != "${commit}" ]]; then
cd "${folder}" || continue
{
echo "## ${folder} ${before[${folder}]}..${commit}"
git --no-pager log --pretty=format:"- %s" "${before[${folder}]}".."${commit}"
echo
} >>"${changelog}"
log=$(git --no-pager log --pretty=format:"- %s" "${before[${folder}]}".."${commit}")
if [[ $(echo "$log" | wc -l) != 0 ]]; then
{
echo "## ${folder} ${before[${folder}]}..${commit}"
echo "$log"
echo
} >>"${changelog}"
fi
cd "${TOPDIR}" || continue
fi
done
@ -53,15 +57,21 @@ cd hardware/qcom-caf/msm8974/audio
git am $DRONE_WORKSPACE_BASE/fix-audio-build.patch || git am --abort
cd $TOPDIR
#lineage
#cd vendor/lineage
#git am $DRONE_WORKSPACE_BASE/fix-build-kernel-header.patch || git am --abort
#cd $TOPDIR
#bluetooth
cd packages/modules/Bluetooth
git am $DRONE_WORKSPACE_BASE/fix-bt-1.patch || git am --abort
git am $DRONE_WORKSPACE_BASE/fix-bt-2.patch || git am --abort
git am $DRONE_WORKSPACE_BASE/fix-bt-3.patch || git am --abort
git am $DRONE_WORKSPACE_BASE/fix-bt-le.patch || git am --abort
cd $TOPDIR
cd hardware/interfaces
git reset --hard ad2871f7
cd $TOPDIR
#safetynet
repopick -f 334348 -P system/core
repopick -f 334343 334344 -P frameworks/base
#misc
repopick 336186
repopick 338888