From 3f7132d419501712107cdb8dff3e8ffed14fa79f Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Sat, 20 Aug 2022 11:25:24 -0400 Subject: [PATCH] Add patch for ble crash --- ...ck-le_set_event_mask-command-resturn.patch | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 packages/modules/Bluetooth/0001-Additionally-check-le_set_event_mask-command-resturn.patch diff --git a/packages/modules/Bluetooth/0001-Additionally-check-le_set_event_mask-command-resturn.patch b/packages/modules/Bluetooth/0001-Additionally-check-le_set_event_mask-command-resturn.patch new file mode 100644 index 0000000..77ca9a4 --- /dev/null +++ b/packages/modules/Bluetooth/0001-Additionally-check-le_set_event_mask-command-resturn.patch @@ -0,0 +1,57 @@ +From a1d10cb31ae386c01a66c8bf0a028b8f33e5bd32 Mon Sep 17 00:00:00 2001 +From: "tzu-hsien.huang" +Date: Wed, 20 Jul 2022 15:12:01 +0800 +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 packet = LeSetEventMaskBuilder::Create(le_event_mask); + hci_->EnqueueCommand(std::move(packet), module_.GetHandler()->BindOnceOn( +- this, &Controller::impl::check_status)); ++ this, &Controller::impl::check_event_mask_status)); + } + + template +@@ -551,6 +551,15 @@ struct Controller::impl { + ASSERT(status_view.GetStatus() == ErrorCode::SUCCESS); + } + ++ template ++ 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; \ +-- +2.37.2 +