GSI updates for system/bt
Change-Id: I542f98a1841db33e5beaf7d988027af433a05c36
diff --git a/patches/system/bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch b/patches/system/bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch
index f41620b..81df401 100644
--- a/patches/system/bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch
+++ b/patches/system/bt/0001-Make-BTM_BYPASS_EXTRA_ACL_SETUP-dynamic.patch
@@ -1,7 +1,7 @@
-From 09a639702c52b318f51ea18eacb6c45d2f9c41cb Mon Sep 17 00:00:00 2001
+From 8debec3b995c7d6570fc9c7dff2fcef53836c761 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] Make BTM_BYPASS_EXTRA_ACL_SETUP dynamic
+Subject: [PATCH 1/2] Make BTM_BYPASS_EXTRA_ACL_SETUP dynamic
Change-Id: Icb0868566b29b053ed7e83c9fd32e225af3f2e46
---
@@ -12,7 +12,7 @@
4 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/hci/include/bt_hci_bdroid.h b/hci/include/bt_hci_bdroid.h
-index cf2c113..e2844db 100644
+index cf2c1136f..e2844db82 100644
--- a/hci/include/bt_hci_bdroid.h
+++ b/hci/include/bt_hci_bdroid.h
@@ -32,6 +32,9 @@
@@ -26,7 +26,7 @@
/******************************************************************************
* Constants & Macros
diff --git a/internal_include/bt_target.h b/internal_include/bt_target.h
-index cf09b15..396114f 100644
+index 3de5510d3..4077be101 100644
--- a/internal_include/bt_target.h
+++ b/internal_include/bt_target.h
@@ -32,6 +32,9 @@
@@ -40,7 +40,7 @@
#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 ee2530a..389a998 100644
+index ee2530ac2..389a998c6 100644
--- a/stack/btm/btm_acl.cc
+++ b/stack/btm/btm_acl.cc
@@ -1184,17 +1184,17 @@ void btm_read_remote_ext_features_failed(uint8_t status, uint16_t handle) {
@@ -72,7 +72,7 @@
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 b080901..4cc1e39 100644
+index b0809010f..4cc1e39ab 100644
--- a/stack/btm/btm_sec.cc
+++ b/stack/btm/btm_sec.cc
@@ -4356,15 +4356,15 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
@@ -101,5 +101,5 @@
btm_acl_created(bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, handle,
HCI_ROLE_SLAVE, BT_TRANSPORT_BR_EDR);
--
-2.7.4
+2.17.1
diff --git a/patches/system/bt/0002-Add-props-to-control-supported-features-and-states-1.patch b/patches/system/bt/0002-Add-props-to-control-supported-features-and-states-1.patch
new file mode 100644
index 0000000..65e05f1
--- /dev/null
+++ b/patches/system/bt/0002-Add-props-to-control-supported-features-and-states-1.patch
@@ -0,0 +1,98 @@
+From 8d27edea9774e92b6b441b63f3936b3cdb1aaa88 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/2] 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
+---
+ hci/src/hci_packet_parser.cc | 55 ++++++++++++++++++++++++++++++++++++
+ 1 file changed, 55 insertions(+)
+
+diff --git a/hci/src/hci_packet_parser.cc b/hci/src/hci_packet_parser.cc
+index 3f4e46cb4..9afa0deab 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;
+@@ -137,6 +139,33 @@ 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));
+
++ int ijk;
++ for (ijk = 0; ijk < ((int)sizeof(bt_device_features_t)); ijk++) LOG_DEBUG(LOG_TAG, "supported feature 0x%x is 0x%x", ijk, feature_pages[*page_number_ptr].as_array[ijk]);
++
++ char unsupport_bitmask_str[PROPERTY_VALUE_MAX];
++ property_get("persist.sys.bt.unsupport.features", unsupport_bitmask_str, "0");
++
++ unsigned int len = strlen(unsupport_bitmask_str);
++ uint8_t unsupport_bitmask[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
++ unsigned int c;
++
++ for (c = 0; c < len; c++) {
++ if (unsupport_bitmask_str[c] == '1') {
++ unsupport_bitmask[c/8] = ~ ( (1 << c%8) | ~ unsupport_bitmask[c/8] ); // The logic here is hard to represent in C(++), basically we do a bitwise AND for the bit we are on now. But C(++) pads with 0s so we end up 0ing too much.
++ } else if (unsupport_bitmask_str[c] != '0') {
++ LOG_ERROR(LOG_TAG, "invalid characters in bitmask; skipping %c", unsupport_bitmask_str[c]);
++ goto out;
++ }
++ }
++
++
++ for (c = 0; c < ((int)sizeof(bt_device_features_t)); c++)
++ feature_pages[*page_number_ptr].as_array[c] &= unsupport_bitmask[c];
++ LOG_DEBUG(LOG_TAG, "generated bitmask 0x%x%x%x%x%x%x%x%x from prop persist.sys.bt.unsupport.features", unsupport_bitmask[0], unsupport_bitmask[1], unsupport_bitmask[2], unsupport_bitmask[3], unsupport_bitmask[4], unsupport_bitmask[5], unsupport_bitmask[6], unsupport_bitmask[7]);
++out:
++ for (ijk = 0; ijk < ((int)sizeof(bt_device_features_t)); ijk++) LOG_ERROR(LOG_TAG, "supported feature 0x%x is 0x%x", ijk, feature_pages[*page_number_ptr].as_array[ijk]);
++ LOG_DEBUG(LOG_TAG, "supported_features array done");
++
+ buffer_allocator->free(response);
+ }
+
+@@ -170,6 +199,32 @@ static void parse_ble_read_supported_states_response(
+ CHECK(stream != NULL);
+ STREAM_TO_ARRAY(supported_states, stream, (int)supported_states_size);
+
++ int ijk;
++ for (ijk = 0; ijk < ((int)supported_states_size); ijk++) LOG_DEBUG(LOG_TAG, "supported state 0x%x is 0x%x", ijk, supported_states[ijk]);
++
++ char unsupport_bitmask_str[PROPERTY_VALUE_MAX];
++ property_get("persist.sys.bt.unsupport.states", unsupport_bitmask_str, "0");
++
++ unsigned int len = strlen(unsupport_bitmask_str);
++ uint8_t unsupport_bitmask[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
++ unsigned int c;
++
++ for (c = 0; c < len; c++) {
++ if (unsupport_bitmask_str[c] == '1') {
++ unsupport_bitmask[c/8] = ~ ( (1 << c%8) | ~ unsupport_bitmask[c/8] ); // The logic here is hard to represent in C(++), basically we do a bitwise AND for the bit we are on now. But C(++) pads with 0s so we end up 0ing too much.
++ } else if (unsupport_bitmask_str[c] != '0') {
++ LOG_ERROR(LOG_TAG, "invalid characters in bitmask; skipping %c", unsupport_bitmask_str[c]);
++ goto out;
++ }
++ }
++
++
++ for (c = 0; c < supported_states_size; c++)
++ supported_states[c] &= unsupport_bitmask[c];
++ LOG_DEBUG(LOG_TAG, "generated bitmask 0x%x%x%x%x%x%x%x%x from prop persist.sys.bt.unsupport.states", unsupport_bitmask[0], unsupport_bitmask[1], unsupport_bitmask[2], unsupport_bitmask[3], unsupport_bitmask[4], unsupport_bitmask[5], unsupport_bitmask[6], unsupport_bitmask[7]);
++out:
++ for (ijk = 0; ijk < ((int)supported_states_size); ijk++) LOG_ERROR(LOG_TAG, "supported state 0x%x is 0x%x", ijk, supported_states[ijk]);
++ LOG_DEBUG(LOG_TAG, "supported_states array done");
+ buffer_allocator->free(response);
+ }
+
+--
+2.17.1
+