Initial commit for Android 10, syncing up to v201

This commit is contained in:
Andy CrossGate Yan
2019-10-23 09:02:48 +00:00
commit 017c525e4f
111 changed files with 8014 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
From fef557417bece64d452454b3263ce2a8d3661ff9 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/2] 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 cf2c1136f..e2844db82 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 67a67c56d..3021ca37b 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 dcb2fb4d9..5a6c3631e 100644
--- a/stack/btm/btm_acl.cc
+++ b/stack/btm/btm_acl.cc
@@ -1186,17 +1186,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 4df0974dd..eb28b0a97 100644
--- a/stack/btm/btm_sec.cc
+++ b/stack/btm/btm_sec.cc
@@ -4366,15 +4366,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

View File

@@ -0,0 +1,153 @@
From 9bc6c5d104edf78b5f795e17560ee4f8bb39a122 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
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