mirror of
https://github.com/ponces/treble_aosp.git
synced 2025-05-01 13:54:03 +00:00
133 lines
5.3 KiB
Diff
133 lines
5.3 KiB
Diff
From 8e1051930a3d75865aa3f470f70b2785a43308cc Mon Sep 17 00:00:00 2001
|
|
From: Pierre-Hugues Husson <phh@phh.me>
|
|
Date: Sat, 27 May 2023 06:41:32 -0400
|
|
Subject: [PATCH 6/8] Add properties to disable some features/commands/states
|
|
that the ble chip declared but doesnt actually support
|
|
|
|
---
|
|
system/gd/hci/controller.cc | 73 +++++++++++++++++++++++++++++++++++--
|
|
1 file changed, 69 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc
|
|
index eaba7da848..a34eb1efac 100644
|
|
--- a/system/gd/hci/controller.cc
|
|
+++ b/system/gd/hci/controller.cc
|
|
@@ -20,6 +20,7 @@
|
|
#include <bluetooth/log.h>
|
|
#include <com_android_bluetooth_flags.h>
|
|
|
|
+#include <base/strings/string_split.h>
|
|
#include <future>
|
|
#include <memory>
|
|
#include <string>
|
|
@@ -35,6 +36,8 @@
|
|
#include "sysprops/sysprops_module.h"
|
|
#endif
|
|
|
|
+using bluetooth::os::GetSystemProperty;
|
|
+
|
|
namespace bluetooth {
|
|
namespace hci {
|
|
|
|
@@ -359,7 +362,23 @@ struct Controller::impl {
|
|
ASSERT(complete_view.IsValid());
|
|
ErrorCode status = complete_view.GetStatus();
|
|
log::assert_that(status == ErrorCode::SUCCESS, "Status {}", ErrorCodeText(status));
|
|
- local_supported_commands_ = complete_view.GetSupportedCommands();
|
|
+ //local_supported_commands_ = complete_view.GetSupportedCommands();
|
|
+
|
|
+ auto local_commands = complete_view.GetSupportedCommands();
|
|
+ std::string ignored_commands = GetSystemProperty("persist.sys.bt.unsupported.commands").value_or("");
|
|
+
|
|
+ if (ignored_commands != "") {
|
|
+ auto s = base::SplitString(ignored_commands, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
|
+ for(auto command: s) {
|
|
+ int index = std::stoi(command);
|
|
+ log::warn("Ignoring local supported command {}", index);
|
|
+ uint16_t byte_index = index / 10;
|
|
+ uint16_t bit_index = index % 10;
|
|
+ local_commands[byte_index] &= ~(1 << bit_index);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ local_supported_commands_ = local_commands;
|
|
}
|
|
|
|
void read_local_extended_features_complete_handler(std::promise<void> promise,
|
|
@@ -369,7 +388,25 @@ struct Controller::impl {
|
|
ErrorCode status = complete_view.GetStatus();
|
|
log::assert_that(status == ErrorCode::SUCCESS, "Status {}", ErrorCodeText(status));
|
|
uint8_t page_number = complete_view.GetPageNumber();
|
|
- extended_lmp_features_array_.push_back(complete_view.GetExtendedLmpFeatures());
|
|
+
|
|
+ //extended_lmp_features_array_.push_back(complete_view.GetExtendedLmpFeatures());
|
|
+ auto lmp_features = complete_view.GetExtendedLmpFeatures();
|
|
+
|
|
+ std::string ignored_features = GetSystemProperty("persist.sys.bt.unsupported.ogfeatures").value_or("");
|
|
+
|
|
+ if (ignored_features != "") {
|
|
+ auto s = base::SplitString(ignored_features, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
|
+ int offset = page_number * 64;
|
|
+ for(auto feature: s) {
|
|
+ int index = std::stoi(feature) - offset;
|
|
+ if(index >= 0 && index < 64) {
|
|
+ log::warn("Ignoring local supported feature {}", index);
|
|
+ lmp_features &= ~(1ULL << index);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ extended_lmp_features_array_.push_back(lmp_features);
|
|
+
|
|
if (page_number == 0 && local_version_information_.manufacturer_name_ == LMP_COMPID_INTEL &&
|
|
local_version_information_.lmp_version_ == LmpVersion::V_4_2 &&
|
|
local_version_information_.lmp_subversion_ == LMP_SUBVERSION_INTEL_AC7265) {
|
|
@@ -532,7 +569,21 @@ struct Controller::impl {
|
|
ASSERT(complete_view.IsValid());
|
|
ErrorCode status = complete_view.GetStatus();
|
|
log::assert_that(status == ErrorCode::SUCCESS, "Status {}", status, ErrorCodeText(status));
|
|
- le_local_supported_features_ = complete_view.GetLeFeatures();
|
|
+
|
|
+ //le_local_supported_features_ = complete_view.GetLeFeatures();
|
|
+ auto local_features = complete_view.GetLeFeatures();
|
|
+ std::string ignored_features = GetSystemProperty("persist.sys.bt.unsupported.lefeatures").value_or("");
|
|
+
|
|
+ if (ignored_features != "") {
|
|
+ auto s = base::SplitString(ignored_features, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
|
+ for(auto feature: s) {
|
|
+ int index = std::stoi(feature);
|
|
+ log::warn("Ignoring local supported feature {}", index);
|
|
+ local_features &= ~(1ULL << index);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ le_local_supported_features_ = local_features;
|
|
}
|
|
|
|
void le_read_supported_states_handler(CommandCompleteView view) {
|
|
@@ -540,7 +591,21 @@ struct Controller::impl {
|
|
ASSERT(complete_view.IsValid());
|
|
ErrorCode status = complete_view.GetStatus();
|
|
log::assert_that(status == ErrorCode::SUCCESS, "Status {}", ErrorCodeText(status));
|
|
- le_supported_states_ = complete_view.GetLeStates();
|
|
+
|
|
+ //le_supported_states_ = complete_view.GetLeStates();
|
|
+ auto local_states = complete_view.GetLeStates();
|
|
+ std::string ignored_states = GetSystemProperty("persist.sys.bt.unsupported.states").value_or("");
|
|
+
|
|
+ if (ignored_states != "") {
|
|
+ auto s = base::SplitString(ignored_states, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
|
+ for(auto state: s) {
|
|
+ int index = std::stoi(state);
|
|
+ log::warn("Ignoring local supported state {}", index);
|
|
+ local_states &= ~(1ULL << index);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ le_supported_states_ = local_states;
|
|
}
|
|
|
|
void le_read_accept_list_size_handler(CommandCompleteView view) {
|
|
--
|
|
2.43.0
|
|
|