Initial unified commit for Android 11, syncing up to v311
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
From 3337759a488bf320bbebcb5b7d5da981555bb758 Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Tue, 20 Feb 2018 23:04:50 +0100
|
||||
Subject: [PATCH 1/3] Make BTM_BYPASS_EXTRA_ACL_SETUP dynamic
|
||||
|
||||
Change-Id: Icb0868566b29b053ed7e83c9fd32e225af3f2e46
|
||||
---
|
||||
hci/include/bt_hci_bdroid.h | 3 +++
|
||||
internal_include/bt_target.h | 3 +++
|
||||
stack/btm/btm_acl.cc | 20 ++++++++++----------
|
||||
stack/btm/btm_sec.cc | 18 +++++++++---------
|
||||
4 files changed, 25 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/hci/include/bt_hci_bdroid.h b/hci/include/bt_hci_bdroid.h
|
||||
index 110354f05..b81185e2c 100644
|
||||
--- a/hci/include/bt_hci_bdroid.h
|
||||
+++ b/hci/include/bt_hci_bdroid.h
|
||||
@@ -32,6 +32,9 @@
|
||||
#ifdef HAS_BDROID_BUILDCFG
|
||||
#include "bdroid_buildcfg.h"
|
||||
#endif
|
||||
+#ifndef BTM_BYPASS_EXTRA_ACL_SETUP
|
||||
+#define BTM_BYPASS_EXTRA_ACL_SETUP TRUE
|
||||
+#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Constants & Macros
|
||||
diff --git a/internal_include/bt_target.h b/internal_include/bt_target.h
|
||||
index 4aca86822..57bd69e9f 100644
|
||||
--- a/internal_include/bt_target.h
|
||||
+++ b/internal_include/bt_target.h
|
||||
@@ -32,6 +32,9 @@
|
||||
#ifdef HAS_BDROID_BUILDCFG
|
||||
#include "bdroid_buildcfg.h"
|
||||
#endif
|
||||
+#ifndef BTM_BYPASS_EXTRA_ACL_SETUP
|
||||
+#define BTM_BYPASS_EXTRA_ACL_SETUP TRUE
|
||||
+#endif
|
||||
|
||||
#include "bt_types.h" /* This must be defined AFTER buildcfg.h */
|
||||
|
||||
diff --git a/stack/btm/btm_acl.cc b/stack/btm/btm_acl.cc
|
||||
index 3c8a6a69a..894459854 100644
|
||||
--- a/stack/btm/btm_acl.cc
|
||||
+++ b/stack/btm/btm_acl.cc
|
||||
@@ -1208,17 +1208,17 @@ void btm_read_remote_ext_features_failed(uint8_t status, uint16_t handle) {
|
||||
void btm_establish_continue(tACL_CONN* p_acl_cb) {
|
||||
tBTM_BL_EVENT_DATA evt_data;
|
||||
BTM_TRACE_DEBUG("btm_establish_continue");
|
||||
-#if (BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
|
||||
- if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR) {
|
||||
- /* For now there are a some devices that do not like sending */
|
||||
- /* commands events and data at the same time. */
|
||||
- /* Set the packet types to the default allowed by the device */
|
||||
- btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
|
||||
-
|
||||
- if (btm_cb.btm_def_link_policy)
|
||||
- BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
|
||||
+ if (!BTM_BYPASS_EXTRA_ACL_SETUP) {
|
||||
+ if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR) {
|
||||
+ /* For now there are a some devices that do not like sending */
|
||||
+ /* commands events and data at the same time. */
|
||||
+ /* Set the packet types to the default allowed by the device */
|
||||
+ btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
|
||||
+
|
||||
+ if (btm_cb.btm_def_link_policy)
|
||||
+ BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
|
||||
+ }
|
||||
}
|
||||
-#endif
|
||||
if (p_acl_cb->link_up_issued) {
|
||||
BTM_TRACE_ERROR("%s: Already link is up ", __func__);
|
||||
return;
|
||||
diff --git a/stack/btm/btm_sec.cc b/stack/btm/btm_sec.cc
|
||||
index 63e4f6ce1..7dea81b44 100644
|
||||
--- a/stack/btm/btm_sec.cc
|
||||
+++ b/stack/btm/btm_sec.cc
|
||||
@@ -4168,15 +4168,15 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
|
||||
if (p_acl_cb) {
|
||||
/* whatever is in btm_establish_continue() without reporting the BTM_BL_CONN_EVT
|
||||
* event */
|
||||
-#if (BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
|
||||
- /* For now there are a some devices that do not like sending */
|
||||
- /* commands events and data at the same time. */
|
||||
- /* Set the packet types to the default allowed by the device */
|
||||
- btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
|
||||
-
|
||||
- if (btm_cb.btm_def_link_policy)
|
||||
- BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
|
||||
-#endif
|
||||
+ if(!BTM_BYPASS_EXTRA_ACL_SETUP) {
|
||||
+ /* For now there are a some devices that do not like sending */
|
||||
+ /* commands events and data at the same time. */
|
||||
+ /* Set the packet types to the default allowed by the device */
|
||||
+ btm_set_packet_types(p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
|
||||
+
|
||||
+ if (btm_cb.btm_def_link_policy)
|
||||
+ BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
|
||||
+ }
|
||||
}
|
||||
btm_acl_created(bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, handle,
|
||||
HCI_ROLE_SLAVE, BT_TRANSPORT_BR_EDR);
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
From a39b9abfe1e7e1bea9c409a1680cb6f18a6ec354 Mon Sep 17 00:00:00 2001
|
||||
From: penn5 <penn5@users.noreply.github.com>
|
||||
Date: Mon, 4 Mar 2019 22:21:07 +0000
|
||||
Subject: [PATCH 2/3] Add props to control supported features and states (#1)
|
||||
|
||||
* Add bitmask for supported fields
|
||||
Use persist.sys.bt.unsupport.states, defaults to 0, left-aligned.
|
||||
Huawei suggest to use 000000000000000000000011111
|
||||
|
||||
* Add bitmask to LOCAL_SUPPORTED_FEATURES
|
||||
For Huawei, suggest to use 00000001
|
||||
|
||||
Documentation:
|
||||
- persist.sys.bt.unsupport.features matches the values:
|
||||
HCI_3_SLOT_PACKETS..HCI_LMP_EXTENDED_SUPPORTED (max 8bits * 8 bytes =
|
||||
64 bits)
|
||||
- persist.sys.bt.unsupport.states matches the values:
|
||||
BTM_BLE_STATE_INVALID..BTM_BLE_STATE_SCAN_ADV (max = 0x3ff, 11 bits)
|
||||
- persist.sys.bt.unsupport.stdfeatures ( max: 16 bits)
|
||||
HCI_LE_ENCRYPTION..HCI_LE_PERIODIC_ADVERTISING
|
||||
---
|
||||
hci/src/hci_packet_parser.cc | 77 ++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 77 insertions(+)
|
||||
|
||||
diff --git a/hci/src/hci_packet_parser.cc b/hci/src/hci_packet_parser.cc
|
||||
index b1efd444d..88dc4c6cd 100644
|
||||
--- a/hci/src/hci_packet_parser.cc
|
||||
+++ b/hci/src/hci_packet_parser.cc
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "hcimsgs.h"
|
||||
#include "osi/include/log.h"
|
||||
|
||||
+#include <cutils/properties.h>
|
||||
+
|
||||
static const command_opcode_t NO_OPCODE_CHECKING = 0;
|
||||
|
||||
static const allocator_t* buffer_allocator;
|
||||
@@ -108,6 +110,31 @@ static void parse_read_local_supported_commands_response(
|
||||
buffer_allocator->free(response);
|
||||
}
|
||||
|
||||
+static void setup_bitmask(uint8_t *v, const char* property) {
|
||||
+ char str[PROPERTY_VALUE_MAX];
|
||||
+ int len = property_get(property, str, "");
|
||||
+ memset(v, 255, 8);
|
||||
+ for(int i = 0; i<len; i++) {
|
||||
+ if(str[i] == '1') {
|
||||
+ v[i/8] &= ~(1 << (i%8));
|
||||
+ } else if(str[i] != '0') {
|
||||
+ LOG_ERROR(LOG_TAG, "invalid characters in bitmask; skipping %c", str[i]);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void filter_supported_feature(uint8_t *v) {
|
||||
+ static int setup = 0;
|
||||
+ static uint8_t unsupport_bitmask[8];
|
||||
+ if(!setup) {
|
||||
+ setup = 1;
|
||||
+ setup_bitmask(unsupport_bitmask, "persist.sys.bt.unsupport.features");
|
||||
+ }
|
||||
+
|
||||
+ for(unsigned i=0; i<sizeof(bt_device_features_t); i++)
|
||||
+ v[i] &= unsupport_bitmask[i];
|
||||
+}
|
||||
+
|
||||
static void parse_read_local_extended_features_response(
|
||||
BT_HDR* response, uint8_t* page_number_ptr, uint8_t* max_page_number_ptr,
|
||||
bt_device_features_t* feature_pages, size_t feature_pages_count) {
|
||||
@@ -123,6 +150,16 @@ static void parse_read_local_extended_features_response(
|
||||
STREAM_TO_ARRAY(feature_pages[*page_number_ptr].as_array, stream,
|
||||
(int)sizeof(bt_device_features_t));
|
||||
|
||||
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
|
||||
+ LOG_DEBUG(LOG_TAG, "supported feature 0x%x is 0x%x", i, feature_pages[*page_number_ptr].as_array[i]);
|
||||
+
|
||||
+ filter_supported_feature(feature_pages[*page_number_ptr].as_array);
|
||||
+
|
||||
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
|
||||
+ LOG_DEBUG(LOG_TAG, "post-filtering supported feature 0x%x is 0x%x", i, feature_pages[*page_number_ptr].as_array[i]);
|
||||
+
|
||||
+ LOG_DEBUG(LOG_TAG, "supported_features array done");
|
||||
+
|
||||
buffer_allocator->free(response);
|
||||
}
|
||||
|
||||
@@ -148,6 +185,19 @@ static void parse_ble_read_buffer_size_response(BT_HDR* response,
|
||||
buffer_allocator->free(response);
|
||||
}
|
||||
|
||||
+
|
||||
+static void filter_supported_states(uint8_t *v, int size) {
|
||||
+ static int setup = 0;
|
||||
+ static uint8_t unsupport_bitmask[8];
|
||||
+ if(!setup) {
|
||||
+ setup = 1;
|
||||
+ setup_bitmask(unsupport_bitmask, "persist.sys.bt.unsupport.states");
|
||||
+ }
|
||||
+
|
||||
+ for(int i=0; i<size && i<8; i++)
|
||||
+ v[i] &= unsupport_bitmask[i];
|
||||
+}
|
||||
+
|
||||
static void parse_ble_read_supported_states_response(
|
||||
BT_HDR* response, uint8_t* supported_states, size_t supported_states_size) {
|
||||
uint8_t* stream =
|
||||
@@ -156,9 +206,30 @@ static void parse_ble_read_supported_states_response(
|
||||
CHECK(stream != NULL);
|
||||
STREAM_TO_ARRAY(supported_states, stream, (int)supported_states_size);
|
||||
|
||||
+ for (int i = 0; i < ((int)supported_states_size); i++)
|
||||
+ LOG_DEBUG(LOG_TAG, "supported state 0x%x is 0x%x", i, supported_states[i]);
|
||||
+
|
||||
+ filter_supported_states(supported_states, supported_states_size);
|
||||
+
|
||||
+ for (int i = 0; i < ((int)supported_states_size); i++)
|
||||
+ LOG_DEBUG(LOG_TAG, "supported.2 state 0x%x is 0x%x", i, supported_states[i]);
|
||||
+
|
||||
+ LOG_DEBUG(LOG_TAG, "supported_states array done");
|
||||
buffer_allocator->free(response);
|
||||
}
|
||||
|
||||
+static void filter_supported_stdfeatures(uint8_t *v) {
|
||||
+ static int setup = 0;
|
||||
+ static uint8_t unsupport_bitmask[8];
|
||||
+ if(!setup) {
|
||||
+ setup = 1;
|
||||
+ setup_bitmask(unsupport_bitmask, "persist.sys.bt.unsupport.stdfeatures");
|
||||
+ }
|
||||
+
|
||||
+ for(unsigned i=0; i<sizeof(bt_device_features_t); i++)
|
||||
+ v[i] &= unsupport_bitmask[i];
|
||||
+}
|
||||
+
|
||||
static void parse_ble_read_local_supported_features_response(
|
||||
BT_HDR* response, bt_device_features_t* supported_features) {
|
||||
uint8_t* stream = read_command_complete_header(
|
||||
@@ -168,6 +239,12 @@ static void parse_ble_read_local_supported_features_response(
|
||||
STREAM_TO_ARRAY(supported_features->as_array, stream,
|
||||
(int)sizeof(bt_device_features_t));
|
||||
|
||||
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
|
||||
+ LOG_DEBUG(LOG_TAG, "supported state 0x%x is 0x%x", i, supported_features->as_array[i]);
|
||||
+ filter_supported_stdfeatures(supported_features->as_array);
|
||||
+ for (int i = 0; i < ((int)sizeof(bt_device_features_t)); i++)
|
||||
+ LOG_DEBUG(LOG_TAG, "supported.2 state 0x%x is 0x%x", i, supported_features->as_array[i]);
|
||||
+
|
||||
buffer_allocator->free(response);
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
From eba7ce1a14f942bfdc6ac93eac14188b7b2b91ec Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Mon, 25 May 2020 21:25:12 +0200
|
||||
Subject: [PATCH 3/3] Add persist.sys.phh.disable_a2dp_offload property to
|
||||
force a2dp offload
|
||||
|
||||
---
|
||||
btif/src/btif_av.cc | 7 ++++++-
|
||||
stack/a2dp/a2dp_codec_config.cc | 9 +++++++--
|
||||
2 files changed, 13 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/btif/src/btif_av.cc b/btif/src/btif_av.cc
|
||||
index 1003b0f82..b7832a478 100644
|
||||
--- a/btif/src/btif_av.cc
|
||||
+++ b/btif/src/btif_av.cc
|
||||
@@ -968,9 +968,14 @@ bt_status_t BtifAvSource::Init(
|
||||
osi_property_get("ro.bluetooth.a2dp_offload.supported", value_sup, "false");
|
||||
osi_property_get("persist.bluetooth.a2dp_offload.disabled", value_dis,
|
||||
"false");
|
||||
+ char value_phh[PROPERTY_VALUE_MAX] = {'\0'};
|
||||
+ osi_property_get("persist.sys.phh.disable_a2dp_offload", value_phh, "false");
|
||||
a2dp_offload_enabled_ =
|
||||
(strcmp(value_sup, "true") == 0) && (strcmp(value_dis, "false") == 0);
|
||||
- BTIF_TRACE_DEBUG("a2dp_offload.enable = %d", a2dp_offload_enabled_);
|
||||
+ if(strcmp(value_phh, "true") == 0)
|
||||
+ a2dp_offload_enabled_ = false;
|
||||
+
|
||||
+ LOG_ERROR(LOG_TAG, "a2dp_offload.enable = %s", a2dp_offload_enabled_ ? "on" : "off");
|
||||
|
||||
callbacks_ = callbacks;
|
||||
if (a2dp_offload_enabled_) {
|
||||
diff --git a/stack/a2dp/a2dp_codec_config.cc b/stack/a2dp/a2dp_codec_config.cc
|
||||
index edf7e0c46..795cbab9c 100644
|
||||
--- a/stack/a2dp/a2dp_codec_config.cc
|
||||
+++ b/stack/a2dp/a2dp_codec_config.cc
|
||||
@@ -560,13 +560,18 @@ bool A2dpCodecs::init() {
|
||||
char* tok = NULL;
|
||||
char* tmp_token = NULL;
|
||||
bool offload_codec_support[BTAV_A2DP_CODEC_INDEX_MAX] = {false};
|
||||
- char value_sup[PROPERTY_VALUE_MAX], value_dis[PROPERTY_VALUE_MAX];
|
||||
+ char value_sup[PROPERTY_VALUE_MAX], value_dis[PROPERTY_VALUE_MAX], value_phh[PROPERTY_VALUE_MAX];
|
||||
|
||||
osi_property_get("ro.bluetooth.a2dp_offload.supported", value_sup, "false");
|
||||
osi_property_get("persist.bluetooth.a2dp_offload.disabled", value_dis,
|
||||
"false");
|
||||
+ osi_property_get("persist.sys.phh.disable_a2dp_offload", value_phh, "false");
|
||||
a2dp_offload_status =
|
||||
(strcmp(value_sup, "true") == 0) && (strcmp(value_dis, "false") == 0);
|
||||
+ if(strcmp(value_phh, "true") == 0)
|
||||
+ a2dp_offload_status = false;
|
||||
+
|
||||
+ LOG_ERROR(LOG_TAG, "Got a2dp offload status %s", a2dp_offload_status ? "on" : "off");
|
||||
|
||||
if (a2dp_offload_status) {
|
||||
char value_cap[PROPERTY_VALUE_MAX];
|
||||
@@ -654,7 +659,7 @@ bool A2dpCodecs::init() {
|
||||
}
|
||||
}
|
||||
|
||||
- return (!ordered_source_codecs_.empty() && !ordered_sink_codecs_.empty());
|
||||
+ return (!ordered_source_codecs_.empty() && !ordered_sink_codecs_.empty()) && !a2dp_offload_status;
|
||||
}
|
||||
|
||||
A2dpCodecConfig* A2dpCodecs::findSourceCodecConfig(
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
From f40e85b84e53cccee6a80e5aff2db2adec55dfeb Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Mon, 7 Jun 2021 17:09:13 -0400
|
||||
Subject: [PATCH 5/5] Add a property to disable eSCO
|
||||
|
||||
eSCO is troublesome on some old devices.
|
||||
It is unknown whether it applies to any Treble device, but investigation
|
||||
is ongoing, this will help the investigation.
|
||||
---
|
||||
hci/src/hci_packet_parser.cc | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/hci/src/hci_packet_parser.cc b/hci/src/hci_packet_parser.cc
|
||||
index 88dc4c6cd..3bd0efe21 100644
|
||||
--- a/hci/src/hci_packet_parser.cc
|
||||
+++ b/hci/src/hci_packet_parser.cc
|
||||
@@ -107,6 +107,11 @@ static void parse_read_local_supported_commands_response(
|
||||
STREAM_TO_ARRAY(supported_commands_ptr, stream,
|
||||
(int)supported_commands_length);
|
||||
|
||||
+ bool disable_eSCO = property_get_bool("persist.sys.bt.disable_esco", false);
|
||||
+ if(disable_eSCO) {
|
||||
+ supported_commands_ptr[29] &= ~0x08;
|
||||
+ }
|
||||
+
|
||||
buffer_allocator->free(response);
|
||||
}
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Reference in New Issue
Block a user