summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Abhishek Pandit-Subedi <abhishekpandit@google.com> 2021-03-02 22:33:10 +0000
committer Abhishek Pandit-Subedi <abhishekpandit@google.com> 2021-03-04 22:48:19 +0000
commit9bd8242a9be8402028f4b56e472c9f91d7e7e250 (patch)
tree8732ed71dbb7b8f0b32ca9b4357547d3f244215f
parentb3fe88bfc3724f08b7a37c9f22ac5cff1dbd70f0 (diff)
Build support and abstractions for Linux build
This has a large number of fixes to build on Linux/ChromeOS. In general, it is making sure the BUILD.gn and Android.bp for a directory structure match and it has all the configs + deps needed to build. Besides a number of simple fixups (missing headers), there are also a few abstractions that need to be noted: * All of audio HAL is stubbed out (using the host implementation) * Parameter provider and system_properties (under gd/os) now have a linux variant that changes where configuration files are kept. The current location for linux is now /etc/systembt. This implementation was copied from the host versions (which seems to be used for host testing). Bug: 176847256 Tag: #floss Test: atest --host bluetooth_test_gd Change-Id: I1a6b3b362cedbe5f675794a115a330cc7f85f9c1
-rw-r--r--BUILD.gn62
-rw-r--r--system/audio_hal_interface/BUILD.gn36
-rw-r--r--system/bta/include/bta_hearing_aid_api.h1
-rw-r--r--system/btcore/BUILD.gn8
-rw-r--r--system/btif/BUILD.gn33
-rw-r--r--system/common/BUILD.gn11
-rw-r--r--system/embdrv/g722/BUILD.gn3
-rw-r--r--system/gd/Android.bp1
-rw-r--r--system/gd/BUILD.gn110
-rw-r--r--system/gd/att/BUILD.gn22
-rw-r--r--system/gd/common/BUILD.gn11
-rw-r--r--system/gd/common/bind.h1
-rw-r--r--system/gd/common/init_flags.h2
-rw-r--r--system/gd/crypto_toolbox/BUILD.gn24
-rw-r--r--system/gd/crypto_toolbox/aes_cmac.cc2
-rw-r--r--system/gd/crypto_toolbox/crypto_toolbox.h4
-rw-r--r--system/gd/hal/BUILD.gn29
-rw-r--r--system/gd/hci/BUILD.gn5
-rw-r--r--system/gd/l2cap/BUILD.gn60
-rw-r--r--system/gd/neighbor/BUILD.gn30
-rw-r--r--system/gd/os/BUILD.gn18
-rw-r--r--system/gd/os/linux/parameter_provider.cc69
-rw-r--r--system/gd/os/linux/system_properties.cc52
-rw-r--r--system/gd/os/linux/system_properties_test.cc44
-rw-r--r--system/gd/rust/common/BUILD.gn38
-rw-r--r--system/gd/rust/shim/BUILD.gn59
-rw-r--r--system/gd/security/BUILD.gn57
-rw-r--r--system/gd/shim/BUILD.gn31
-rw-r--r--system/gd/storage/BUILD.gn32
-rw-r--r--system/include/hardware/avrcp/avrcp.h1
-rw-r--r--system/main/BUILD.gn9
-rw-r--r--system/main/shim/BUILD.gn14
-rw-r--r--system/service/BUILD.gn34
-rw-r--r--system/service/adapter.cc8
-rw-r--r--system/stack/BUILD.gn15
35 files changed, 822 insertions, 114 deletions
diff --git a/BUILD.gn b/BUILD.gn
index bf9b51c3ba..902a9cd9a3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -21,14 +21,10 @@
# file to your new one or GN won't know about it.
group("all") {
- deps = [
- ":bluetooth",
- ]
+ deps = [ ":bluetooth" ]
if (use.test) {
- deps += [
- ":bluetooth_tests"
- ]
+ deps += [ ":bluetooth_tests" ]
}
}
@@ -43,24 +39,34 @@ group("bluetooth") {
if (use.test) {
group("bluetooth_tests") {
deps = [
+ "//bt/btcore:net_test_btcore",
"//bt/common:bluetooth_test_common",
- "//bt/service:bluetoothtbd_test",
"//bt/profile/avrcp:net_test_avrcp",
- "//bt/btcore:net_test_btcore",
- "//bt/types:net_test_types",
+ "//bt/service:bluetoothtbd_test",
"//bt/stack:net_test_btm_iso",
+ "//bt/types:net_test_types",
+
#"//bt/packet:net_test_btpackets",
]
}
}
+if (host_cpu == target_cpu && host_os == target_os) {
+ group("tools") {
+ deps = [
+ "//bt/gd/dumpsys/bundler:bluetooth_flatbuffer_bundler",
+ "//bt/gd/packet/parser:bluetooth_packetgen",
+ ]
+ }
+}
+
if (defined(use.android) && use.android) {
group("android_bluetooth_tests") {
deps = [
- "//bt/test/suite:net_test_bluetooth",
+ "//bt/device:net_test_device",
"//bt/hci:net_test_hci",
"//bt/osi:net_test_osi",
- "//bt/device:net_test_device",
+ "//bt/test/suite:net_test_bluetooth",
]
}
}
@@ -71,11 +77,13 @@ config("target_defaults") {
"//bt/linux_include",
"//bt/types",
"//bt/include",
+
+ # For flatbuffer generated headers
+ "${root_gen_dir}/bt/gd/",
+ "${root_gen_dir}/bt/gd/dumpsys/bundler",
]
cflags = [
- "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
- "-DFALLTHROUGH_INTENDED=[[clang::fallthrough]]",
"-fPIC",
"-Wno-non-c-typedef-for-linkage",
"-Wno-unreachable-code-return",
@@ -91,20 +99,26 @@ config("target_defaults") {
"-Wno-unused-variable",
"-Wno-unused-const-variable",
"-Wno-format",
+ "-Wno-pessimizing-move",
+ "-Wno-unknown-warning-option",
+ "-Wno-final-dtor-non-final-class",
]
- cflags_cc = [
- "-std=c++17",
- ]
+ cflags_cc = [ "-std=c++17" ]
defines = [
"HAS_NO_BDROID_BUILDCFG",
"OS_GENERIC",
+ "OS_LINUX_GENERIC",
+ "EXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
+ "FALLTHROUGH_INTENDED=[[clang::fallthrough]]",
]
- configs = [
- ":external_libchrome",
- ]
+ if (!(defined(use.bt_nonstandard_codecs) && use.bt_nonstandard_codecs)) {
+ defines += [ "EXCLUDE_NONSTANDARD_CODECS" ]
+ }
+
+ configs = [ ":external_libchrome" ]
}
# Configurations to use as dependencies for GN build
@@ -135,6 +149,12 @@ config("external_tinyxml2") {
configs = [ ":pkg_tinyxml2" ]
}
+config("external_flatbuffers") {
+ lib_dirs = [ "${libdir}" ]
+
+ libs = [ "flatbuffers" ]
+}
+
# Package configurations to extract dependencies from env
pkg_config("pkg_gtest") {
pkg_deps = [ "gtest" ]
@@ -184,10 +204,10 @@ if (defined(use.bt_nonstandard_codecs) && use.bt_nonstandard_codecs) {
}
pkg_config("pkg_libldacBT_enc") {
- pkg_deps = [ "ldacBT-enc", ]
+ pkg_deps = [ "ldacBT-enc" ]
}
pkg_config("pkg_libldacBT_abr") {
- pkg_deps = [ "ldacBT-abr", ]
+ pkg_deps = [ "ldacBT-abr" ]
}
}
diff --git a/system/audio_hal_interface/BUILD.gn b/system/audio_hal_interface/BUILD.gn
new file mode 100644
index 0000000000..18abf77e3c
--- /dev/null
+++ b/system/audio_hal_interface/BUILD.gn
@@ -0,0 +1,36 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+static_library("audio_hal_interface") {
+ sources = [
+ "a2dp_encoding_host.cc",
+ "hearing_aid_software_encoding_host.cc",
+ ]
+
+ include_dirs = [
+ "//bt/bta/include",
+ "//bt/btif/include",
+ "//bt/stack/include",
+ "//bt/gd/rust/shim",
+ ]
+
+ configs += [ "//bt:target_defaults" ]
+
+ deps = [
+ "//bt/common",
+ "//bt/osi:osi",
+ ]
+}
diff --git a/system/bta/include/bta_hearing_aid_api.h b/system/bta/include/bta_hearing_aid_api.h
index 6f5205722d..613802a211 100644
--- a/system/bta/include/bta_hearing_aid_api.h
+++ b/system/bta/include/bta_hearing_aid_api.h
@@ -22,6 +22,7 @@
#include <hardware/bt_hearing_aid.h>
#include <cstdint>
#include <deque>
+#include <functional>
#include <vector>
constexpr uint16_t HEARINGAID_MAX_NUM_UUIDS = 1;
diff --git a/system/btcore/BUILD.gn b/system/btcore/BUILD.gn
index ea55aa7222..1b8ba7ec80 100644
--- a/system/btcore/BUILD.gn
+++ b/system/btcore/BUILD.gn
@@ -19,8 +19,8 @@ static_library("btcore") {
"src/device_class.cc",
"src/hal_util.cc",
"src/module.cc",
- "src/property.cc",
"src/osi_module.cc",
+ "src/property.cc",
]
include_dirs = [
@@ -28,9 +28,7 @@ static_library("btcore") {
"//bt",
]
- configs += [
- "//bt:target_defaults",
- ]
+ configs += [ "//bt:target_defaults" ]
deps = [
"//bt/gd/rust/shim:init_flags_bridge_header",
@@ -41,9 +39,9 @@ static_library("btcore") {
if (use.test) {
executable("net_test_btcore") {
sources = [
+ "//bt/osi/test/AllocationTestHarness.cc",
"test/device_class_test.cc",
"test/property_test.cc",
- "//bt/osi/test/AllocationTestHarness.cc",
]
include_dirs = [
diff --git a/system/btif/BUILD.gn b/system/btif/BUILD.gn
index 4fcfbceeec..d29e7449be 100644
--- a/system/btif/BUILD.gn
+++ b/system/btif/BUILD.gn
@@ -16,18 +16,36 @@
static_library("btif") {
sources = [
+ # TODO(abps) - Do we need this?
"//bt/audio_a2dp_hw/src/audio_a2dp_hw_utils.cc",
"//bt/audio_hearing_aid_hw/src/audio_hearing_aid_hw_utils.cc",
+
+ # AVRCP Target Service
"avrcp/avrcp_service.cc",
+ "co/bta_av_co.cc",
+
+ # Callouts
+ "co/bta_dm_co.cc",
+ "co/bta_gatts_co.cc",
+ "co/bta_hh_co.cc",
+ "co/bta_pan_co.cc",
+
+ # HAL layer
+ "src/bluetooth.cc",
+
+ # BTIF implementation
"src/btif_a2dp.cc",
+
+ # "TODO(abps) - Move this abstraction elsewhere
+ # "src/btif_a2dp_audio_interface.cc",
"src/btif_a2dp_audio_interface_linux.cc",
"src/btif_a2dp_control.cc",
"src/btif_a2dp_sink.cc",
- # "src/btif_a2dp_source.cc",
+ "src/btif_a2dp_source.cc",
"src/btif_av.cc",
- #TODO(jpawlowski): heavily depends on Android,
- # "src/btif_avrcp_audio_track.cc",
+ # TODO(abps) - Move this abstraction elsewhere
+ # "src/btif_avrcp_audio_track.cc",
"src/btif_avrcp_audio_track_linux.cc",
"src/btif_ble_advertiser.cc",
"src/btif_ble_scanner.cc",
@@ -70,15 +88,6 @@ static_library("btif") {
"src/stack_manager.cc",
]
- # BTIF callouts
- sources += [
- "co/bta_av_co.cc",
- "co/bta_dm_co.cc",
- "co/bta_gatts_co.cc",
- "co/bta_hh_co.cc",
- "co/bta_pan_co.cc",
- ]
-
include_dirs = [
"include",
"//bt/",
diff --git a/system/common/BUILD.gn b/system/common/BUILD.gn
index 253a76d7ed..94614e8912 100644
--- a/system/common/BUILD.gn
+++ b/system/common/BUILD.gn
@@ -17,10 +17,11 @@
static_library("common") {
sources = [
"address_obfuscator.cc",
- "once_timer.cc",
"message_loop_thread.cc",
"metric_id_allocator.cc",
"metrics_linux.cc",
+ "once_timer.cc",
+ "os_utils.cc",
"repeating_timer.cc",
"time_util.cc",
]
@@ -37,9 +38,7 @@ static_library("common") {
"//bt/third_party/proto_logging/stats:libbt-platform-protos",
]
- configs += [
- "//bt:target_defaults",
- ]
+ configs += [ "//bt:target_defaults" ]
}
if (use.test) {
@@ -55,9 +54,7 @@ if (use.test) {
"//bt/common",
]
- deps = [
- "//bt/common",
- ]
+ deps = [ "//bt/common" ]
configs += [
"//bt:external_gtest_main",
diff --git a/system/embdrv/g722/BUILD.gn b/system/embdrv/g722/BUILD.gn
index 083e80b918..aa5e06ea2b 100644
--- a/system/embdrv/g722/BUILD.gn
+++ b/system/embdrv/g722/BUILD.gn
@@ -19,4 +19,7 @@ static_library("g722") {
"g722_decode.cc",
"g722_encode.cc",
]
+
+ defines = [ "G722_SUPPORT_MALLOC" ]
+ configs += [ "//bt:target_defaults" ]
}
diff --git a/system/gd/Android.bp b/system/gd/Android.bp
index d6274d253b..c941aea795 100644
--- a/system/gd/Android.bp
+++ b/system/gd/Android.bp
@@ -23,7 +23,6 @@ cc_defaults {
},
host: {
cflags: [
- "-DOS_LINUX",
"-DOS_LINUX_GENERIC",
],
},
diff --git a/system/gd/BUILD.gn b/system/gd/BUILD.gn
index 5b6a524edd..6abddb1f80 100644
--- a/system/gd/BUILD.gn
+++ b/system/gd/BUILD.gn
@@ -13,19 +13,81 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import("//bt/gd/dumpsys/bundler/bundler.gni")
+import("//bt/gd/packet/parser/packetgen.gni")
import("//common-mk/flatbuffer.gni")
-config("dumpsys_config") {
- include_dirs = [
- "$target_gen_dir",
- "$target_gen_dir/common",
- "$target_gen_dir/hci",
- "$target_gen_dir/l2cap/classic",
- "$target_gen_dir/shim",
+config("gd_defaults") {
+ cflags_cc = [
+ "-DGOOGLE_PROTOBUF_NO_RTTI",
+ "-Wno-unused-parameter",
+ "-Wno-unused-result",
+ "-Wno-tautological-overlap-compare",
+ ]
+
+ defines = [
+ "OS_LINUX_GENERIC",
+ "OS_GENERIC",
+ ]
+
+ libs = [
+ "ssl",
+ "crypto",
+ ]
+
+ include_dirs = [ "//bt/gd" ]
+ configs = [ "//bt:target_defaults" ]
+}
+
+config("rust_defaults") {
+ # Empty for now
+}
+
+group("gd_default_deps") {
+ deps = [
+ "//bt/gd:BluetoothGeneratedDumpsysDataSchema_h",
+ "//bt/gd:BluetoothGeneratedPackets_h",
+ "//bt/gd/dumpsys:BluetoothGeneratedDumpsysBundledSchema_h",
+ "//bt/gd/rust/shim:init_flags_bridge_header",
+ ]
+}
+
+static_library("libbluetooth_gd") {
+ sources = [
+ "module.cc",
+ "stack_manager.cc",
+ ]
+
+ include_dirs = [ "." ]
+ configs += [ ":gd_defaults" ]
+ deps = [
+ "//bt/gd:BluetoothGeneratedPackets_h",
+ "//bt/gd/att:BluetoothAttSources",
+ "//bt/gd/common:BluetoothCommonSources",
+ "//bt/gd/crypto_toolbox:BluetoothCryptoToolboxSources",
+ "//bt/gd/dumpsys:BluetoothDumpsysSources",
+ "//bt/gd/hal:BluetoothHalSources",
+ "//bt/gd/hal:BluetoothHalSources_hci_rootcanal",
+ "//bt/gd/l2cap:BluetoothL2capSources",
+ "//bt/gd/neighbor:BluetoothNeighborSources",
+ "//bt/gd/rust/shim:libbluetooth_rust_interop",
+ "//bt/gd/security:BluetoothSecuritySources",
+ "//bt/gd/shim:BluetoothShimSources",
+ "//bt/gd/storage:BluetoothStorageSources",
+ ]
+}
+
+flatbuffer("BluetoothGeneratedDumpsysDataSchema_h") {
+ sources = [
+ "common/init_flags.fbs",
+ "dumpsys_data.fbs",
+ "hci/hci_acl_manager.fbs",
+ "l2cap/classic/l2cap_classic_module.fbs",
+ "shim/dumpsys.fbs",
]
}
-flatbuffer("dumpsys") {
+bt_flatc_binary_schema("BluetoothGeneratedDumpsysBinarySchema_bfbs") {
sources = [
"common/init_flags.fbs",
"dumpsys_data.fbs",
@@ -34,5 +96,35 @@ flatbuffer("dumpsys") {
"shim/dumpsys.fbs",
]
- all_dependent_configs = [ ":dumpsys_config" ]
+ include_dir = "bt/gd"
+}
+
+packetgen_py("BluetoothGeneratedPackets_python3_cc") {
+ sources = [
+ "hci/hci_packets.pdl",
+ "l2cap/l2cap_packets.pdl",
+ "security/smp_packets.pdl",
+ ]
+
+ include = "bt/gd"
+ source_root = "../.."
+ shards = 10
+}
+
+packetgen_headers("BluetoothGeneratedPackets_h") {
+ sources = [
+ "hci/hci_packets.pdl",
+ "l2cap/l2cap_packets.pdl",
+ "security/smp_packets.pdl",
+ ]
+
+ include = "bt/gd"
+ source_root = "../.."
+}
+
+packetgen_rust("BluetoothGeneratedPackets_rust") {
+ sources = [ "hci/hci_packets.pdl" ]
+
+ include = "bt/gd"
+ source_root = "../.."
}
diff --git a/system/gd/att/BUILD.gn b/system/gd/att/BUILD.gn
new file mode 100644
index 0000000000..fd16937510
--- /dev/null
+++ b/system/gd/att/BUILD.gn
@@ -0,0 +1,22 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+source_set("BluetoothAttSources") {
+ sources = [ "att_module.cc" ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
diff --git a/system/gd/common/BUILD.gn b/system/gd/common/BUILD.gn
index 58a836a351..a74d02ebfa 100644
--- a/system/gd/common/BUILD.gn
+++ b/system/gd/common/BUILD.gn
@@ -1,5 +1,5 @@
#
-# Copyright 2021 Google
+# Copyright 2021 Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,11 +21,6 @@ source_set("BluetoothCommonSources") {
"strings.cc",
]
- deps = [
- "//bt/gd/rust/shim:init_flags_bridge_header",
- ]
-
- include_dirs = [ "//bt/gd" ]
-
- configs += [ "//bt:target_defaults" ]
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
}
diff --git a/system/gd/common/bind.h b/system/gd/common/bind.h
index e81edb7ff1..e65d830325 100644
--- a/system/gd/common/bind.h
+++ b/system/gd/common/bind.h
@@ -23,7 +23,6 @@ namespace common {
using base::Bind;
using base::BindOnce;
-using base::ConstRef;
using base::IgnoreResult;
using base::MakeUnboundRunType;
using base::Owned;
diff --git a/system/gd/common/init_flags.h b/system/gd/common/init_flags.h
index d1dbebc7f0..11af2a1772 100644
--- a/system/gd/common/init_flags.h
+++ b/system/gd/common/init_flags.h
@@ -16,8 +16,10 @@
#pragma once
+#include <stdexcept>
#include <string>
#include <unordered_map>
+
#include "src/init_flags.rs.h"
namespace bluetooth {
diff --git a/system/gd/crypto_toolbox/BUILD.gn b/system/gd/crypto_toolbox/BUILD.gn
new file mode 100644
index 0000000000..4bca591f57
--- /dev/null
+++ b/system/gd/crypto_toolbox/BUILD.gn
@@ -0,0 +1,24 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source_set("BluetoothCryptoToolboxSources") {
+ sources = [
+ "aes.cc",
+ "aes_cmac.cc",
+ "crypto_toolbox.cc",
+ ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+}
diff --git a/system/gd/crypto_toolbox/aes_cmac.cc b/system/gd/crypto_toolbox/aes_cmac.cc
index 752027e2f2..85fdd59300 100644
--- a/system/gd/crypto_toolbox/aes_cmac.cc
+++ b/system/gd/crypto_toolbox/aes_cmac.cc
@@ -22,6 +22,8 @@
*
******************************************************************************/
+#include <algorithm>
+
#include "crypto_toolbox/aes.h"
#include "crypto_toolbox/crypto_toolbox.h"
diff --git a/system/gd/crypto_toolbox/crypto_toolbox.h b/system/gd/crypto_toolbox/crypto_toolbox.h
index d507f73169..65da0973ec 100644
--- a/system/gd/crypto_toolbox/crypto_toolbox.h
+++ b/system/gd/crypto_toolbox/crypto_toolbox.h
@@ -17,6 +17,8 @@
#pragma once
#include <array>
+#include <cstdint>
+#include <cstring>
namespace bluetooth {
namespace crypto_toolbox {
@@ -72,4 +74,4 @@ inline Octet16 aes_cmac(const Octet16& key, const Octet16& message) {
}
} // namespace crypto_toolbox
-} // namespace bluetooth \ No newline at end of file
+} // namespace bluetooth
diff --git a/system/gd/hal/BUILD.gn b/system/gd/hal/BUILD.gn
new file mode 100644
index 0000000000..1752241d3c
--- /dev/null
+++ b/system/gd/hal/BUILD.gn
@@ -0,0 +1,29 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+source_set("BluetoothHalSources") {
+ sources = [ "snoop_logger.cc" ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
+
+source_set("BluetoothHalSources_hci_rootcanal") {
+ sources = [ "hci_hal_host_rootcanal.cc" ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
diff --git a/system/gd/hci/BUILD.gn b/system/gd/hci/BUILD.gn
index 5eb2fca510..c9d10f850d 100644
--- a/system/gd/hci/BUILD.gn
+++ b/system/gd/hci/BUILD.gn
@@ -34,10 +34,7 @@ source_set("BluetoothHciSources") {
include_dirs = [ "//bt/gd" ]
- deps = [
- "//bt/gd:dumpsys",
- "//bt/gd/rust/shim:init_flags_bridge_header",
- ]
+ deps = [ "//bt/gd:gd_default_deps" ]
configs += [ "//bt:target_defaults" ]
}
diff --git a/system/gd/l2cap/BUILD.gn b/system/gd/l2cap/BUILD.gn
new file mode 100644
index 0000000000..f5350f5052
--- /dev/null
+++ b/system/gd/l2cap/BUILD.gn
@@ -0,0 +1,60 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source_set("BluetoothL2capSources") {
+ sources = [
+ "classic/dynamic_channel_manager.cc",
+ "classic/dynamic_channel_service.cc",
+ "classic/fixed_channel.cc",
+ "classic/fixed_channel_manager.cc",
+ "classic/fixed_channel_service.cc",
+ "classic/internal/dumpsys_helper.cc",
+ "classic/internal/dynamic_channel_service_manager_impl.cc",
+ "classic/internal/fixed_channel_impl.cc",
+ "classic/internal/fixed_channel_service_manager_impl.cc",
+ "classic/internal/link.cc",
+ "classic/internal/link_manager.cc",
+ "classic/internal/signalling_manager.cc",
+ "classic/l2cap_classic_module.cc",
+ "dynamic_channel.cc",
+ "fcs.cc",
+ "internal/basic_mode_channel_data_controller.cc",
+ "internal/data_pipeline_manager.cc",
+ "internal/dynamic_channel_allocator.cc",
+ "internal/dynamic_channel_impl.cc",
+ "internal/enhanced_retransmission_mode_channel_data_controller.cc",
+ "internal/le_credit_based_channel_data_controller.cc",
+ "internal/receiver.cc",
+ "internal/scheduler_fifo.cc",
+ "internal/sender.cc",
+ "le/dynamic_channel.cc",
+ "le/dynamic_channel_manager.cc",
+ "le/dynamic_channel_service.cc",
+ "le/fixed_channel.cc",
+ "le/fixed_channel_manager.cc",
+ "le/fixed_channel_service.cc",
+ "le/internal/dynamic_channel_service_manager_impl.cc",
+ "le/internal/fixed_channel_impl.cc",
+ "le/internal/fixed_channel_service_manager_impl.cc",
+ "le/internal/link.cc",
+ "le/internal/link_manager.cc",
+ "le/internal/signalling_manager.cc",
+ "le/l2cap_le_module.cc",
+ "le/link_options.cc",
+ ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
diff --git a/system/gd/neighbor/BUILD.gn b/system/gd/neighbor/BUILD.gn
new file mode 100644
index 0000000000..02e4d79237
--- /dev/null
+++ b/system/gd/neighbor/BUILD.gn
@@ -0,0 +1,30 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source_set("BluetoothNeighborSources") {
+ sources = [
+ "connectability.cc",
+ "discoverability.cc",
+ "inquiry.cc",
+ "name.cc",
+ "name_db.cc",
+ "page.cc",
+ "scan.cc",
+ ]
+
+ deps = [ "//bt/gd:gd_default_deps" ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+}
diff --git a/system/gd/os/BUILD.gn b/system/gd/os/BUILD.gn
index c96b690953..3ed05ffd93 100644
--- a/system/gd/os/BUILD.gn
+++ b/system/gd/os/BUILD.gn
@@ -1,5 +1,4 @@
-#
-# Copyright 2021 Google
+# Copyright 2021 Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
+
+source_set("BluetoothOsSources_linux") {
+ sources = [
+ "linux/parameter_provider.cc",
+ "linux/system_properties.cc",
+ ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+}
source_set("BluetoothOsSources_linux_generic") {
sources = [
@@ -25,7 +32,6 @@ source_set("BluetoothOsSources_linux_generic") {
"linux_generic/thread.cc",
]
- include_dirs = [ "//bt/gd" ]
-
- configs += [ "//bt:target_defaults" ]
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ ":BluetoothOsSources_linux" ]
}
diff --git a/system/gd/os/linux/parameter_provider.cc b/system/gd/os/linux/parameter_provider.cc
new file mode 100644
index 0000000000..f4e9175133
--- /dev/null
+++ b/system/gd/os/linux/parameter_provider.cc
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "os/parameter_provider.h"
+
+#include <unistd.h>
+
+#include <cerrno>
+#include <mutex>
+#include <string>
+
+#include "os/log.h"
+
+namespace bluetooth {
+namespace os {
+
+namespace {
+std::mutex parameter_mutex;
+std::string config_file_path;
+std::string snoop_log_file_path;
+} // namespace
+
+// Write to $PWD/bt_stack.conf if $PWD can be found, otherwise, write to $HOME/bt_stack.conf
+std::string ParameterProvider::ConfigFilePath() {
+ {
+ std::lock_guard<std::mutex> lock(parameter_mutex);
+ if (!config_file_path.empty()) {
+ return config_file_path;
+ }
+ }
+ return "/etc/systembt/bt_config.conf";
+}
+
+void ParameterProvider::OverrideConfigFilePath(const std::string& path) {
+ std::lock_guard<std::mutex> lock(parameter_mutex);
+ config_file_path = path;
+}
+
+std::string ParameterProvider::SnoopLogFilePath() {
+ {
+ std::lock_guard<std::mutex> lock(parameter_mutex);
+ if (!snoop_log_file_path.empty()) {
+ return snoop_log_file_path;
+ }
+ }
+
+ return "/etc/systembt/btsnoop_hci.log";
+}
+
+void ParameterProvider::OverrideSnoopLogFilePath(const std::string& path) {
+ std::lock_guard<std::mutex> lock(parameter_mutex);
+ snoop_log_file_path = path;
+}
+
+} // namespace os
+} // namespace bluetooth
diff --git a/system/gd/os/linux/system_properties.cc b/system/gd/os/linux/system_properties.cc
new file mode 100644
index 0000000000..0b786868ce
--- /dev/null
+++ b/system/gd/os/linux/system_properties.cc
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "os/system_properties.h"
+
+#include <mutex>
+#include <string>
+#include <unordered_map>
+
+namespace bluetooth {
+namespace os {
+
+namespace {
+std::mutex properties_mutex;
+std::unordered_map<std::string, std::string> properties;
+} // namespace
+
+std::optional<std::string> GetSystemProperty(const std::string& property) {
+ std::lock_guard<std::mutex> lock(properties_mutex);
+ auto iter = properties.find(property);
+ if (iter == properties.end()) {
+ return std::nullopt;
+ }
+ return iter->second;
+}
+
+bool SetSystemProperty(const std::string& property, const std::string& value) {
+ std::lock_guard<std::mutex> lock(properties_mutex);
+ properties.insert_or_assign(property, value);
+ return true;
+}
+
+void ClearSystemPropertiesForHost() {
+ std::lock_guard<std::mutex> lock(properties_mutex);
+ properties.clear();
+}
+
+} // namespace os
+} // namespace bluetooth \ No newline at end of file
diff --git a/system/gd/os/linux/system_properties_test.cc b/system/gd/os/linux/system_properties_test.cc
new file mode 100644
index 0000000000..d88cb9a80b
--- /dev/null
+++ b/system/gd/os/linux/system_properties_test.cc
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+
+#include <gtest/gtest.h>
+
+#include "os/system_properties.h"
+
+namespace testing {
+
+using bluetooth::os::ClearSystemPropertiesForHost;
+using bluetooth::os::GetSystemProperty;
+using bluetooth::os::SetSystemProperty;
+
+TEST(SystemPropertiesTest, set_and_get_test) {
+ ASSERT_TRUE(SetSystemProperty("persist.bluetooth.factoryreset", "true"));
+ auto ret = GetSystemProperty("persist.bluetooth.factoryreset");
+ ASSERT_TRUE(ret);
+ ASSERT_EQ(ret, "true");
+ ASSERT_TRUE(SetSystemProperty("persist.bluetooth.factoryreset", "false"));
+ ret = GetSystemProperty("persist.bluetooth.factoryreset");
+ ASSERT_TRUE(ret);
+ ASSERT_EQ(ret, "false");
+ ret = GetSystemProperty("persist.bluetooth.factoryreset_do_not_exist");
+ ASSERT_FALSE(ret);
+ ClearSystemPropertiesForHost();
+ ASSERT_FALSE(GetSystemProperty("persist.bluetooth.factoryreset"));
+}
+
+} // namespace testing \ No newline at end of file
diff --git a/system/gd/rust/common/BUILD.gn b/system/gd/rust/common/BUILD.gn
new file mode 100644
index 0000000000..35b14c87ca
--- /dev/null
+++ b/system/gd/rust/common/BUILD.gn
@@ -0,0 +1,38 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+rust("libbt_common") {
+ crate_name = "bt_common"
+
+ sources = [ "src/lib.rs" ]
+
+ configs += [ "//bt/gd:gd_rust_defaults" ]
+}
+
+cxxbridge_cc("libbt_common_sys_prop_bridge_code") {
+ sources = [ "src/sys_prop.rs" ]
+
+ configs = [ "//bt/gd:gd_defaults" ]
+}
+
+static_library("libbt_common_sys_prop_cxx") {
+ sources = [ "src/ffi/sys_props.cc" ]
+
+ include_dirs = [ "src/ffi" ]
+
+ deps = [ ":libbt_common_sys_prop_bridge_code" ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+}
diff --git a/system/gd/rust/shim/BUILD.gn b/system/gd/rust/shim/BUILD.gn
index d42f822cbe..c0912e90e4 100644
--- a/system/gd/rust/shim/BUILD.gn
+++ b/system/gd/rust/shim/BUILD.gn
@@ -17,32 +17,87 @@
import("//common-mk/cxxbridge.gni")
config("rust_shim_config") {
- include_dirs = [
- "//bt/gd/rust/shim"
+ include_dirs = [ "//bt/gd/rust/shim" ]
+
+ ldflags = [
+ # Opaque types in rust shim cause duplicate definitions of layout. Use the
+ # first defined symbol instead of aborting.
+ # i.e. T::layout::size() and T::layout::align()
+ "-Wl,--allow-multiple-definition",
]
}
cxxbridge_header("shim_bridge_header") {
sources = [ "src/stack.rs" ]
all_dependent_configs = [ ":rust_shim_config" ]
+ deps = [ ":cxxlibheader" ]
+}
+
+cxxbridge_cc("shim_bridge_code") {
+ sources = [ "src/stack.rs" ]
+ deps = [ ":shim_bridge_header" ]
+ configs = [ "//bt/gd:gd_defaults" ]
}
cxxbridge_header("init_flags_bridge_header") {
sources = [ "src/init_flags.rs" ]
all_dependent_configs = [ ":rust_shim_config" ]
+ deps = [ ":cxxlibheader" ]
+}
+
+cxxbridge_cc("init_flags_bridge_code") {
+ sources = [ "src/init_flags.rs" ]
+ deps = [ ":init_flags_bridge_header" ]
+ configs = [ "//bt/gd:gd_defaults" ]
}
cxxbridge_header("hci_bridge_header") {
sources = [ "src/hci.rs" ]
all_dependent_configs = [ ":rust_shim_config" ]
+ deps = [ ":cxxlibheader" ]
+}
+
+cxxbridge_cc("hci_bridge_code") {
+ sources = [ "src/hci.rs" ]
+ deps = [ ":hci_bridge_header" ]
+ configs = [ "//bt/gd:gd_defaults" ]
}
cxxbridge_header("message_loop_thread_bridge_header") {
sources = [ "src/message_loop_thread.rs" ]
all_dependent_configs = [ ":rust_shim_config" ]
+ deps = [ ":cxxlibheader" ]
+}
+
+cxxbridge_cc("message_loop_thread_bridge_code") {
+ sources = [ "src/message_loop_thread.rs" ]
+ deps = [ ":message_loop_thread_bridge_header" ]
+ configs = [ "//bt/gd:gd_defaults" ]
}
cxxbridge_header("controller_bridge_header") {
sources = [ "src/controller.rs" ]
all_dependent_configs = [ ":rust_shim_config" ]
+ deps = [ ":cxxlibheader" ]
+}
+
+cxxbridge_cc("controller_bridge_code") {
+ sources = [ "src/controller.rs" ]
+ deps = [ ":controller_bridge_header" ]
+ configs = [ "//bt/gd:gd_defaults" ]
+}
+
+cxxbridge_libheader("cxxlibheader") {
+ deps = []
+}
+
+static_library("libbluetooth_rust_interop") {
+ deps = [
+ ":controller_bridge_code",
+ ":cxxlibheader",
+ ":hci_bridge_code",
+ ":init_flags_bridge_code",
+ ":message_loop_thread_bridge_code",
+ ":shim_bridge_code",
+ ]
}
diff --git a/system/gd/security/BUILD.gn b/system/gd/security/BUILD.gn
new file mode 100644
index 0000000000..1280311f87
--- /dev/null
+++ b/system/gd/security/BUILD.gn
@@ -0,0 +1,57 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source_set("BluetoothSecurityChannelSources") {
+ sources = [ "channel/security_manager_channel.cc" ]
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
+
+source_set("BluetoothSecurityPairingSources") {
+ sources = [ "pairing/classic_pairing_handler.cc" ]
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
+
+source_set("BluetoothSecurityRecordSources") {
+ sources = [ "record/security_record_storage.cc" ]
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
+
+source_set("BluetoothSecuritySources") {
+ sources = [
+ "ecc/multprecision.cc",
+ "ecc/p_256_ecc_pp.cc",
+ "ecdh_keys.cc",
+ "facade_configuration_api.cc",
+ "internal/security_manager_impl.cc",
+ "l2cap_security_module_interface.cc",
+ "pairing_handler_le.cc",
+ "pairing_handler_le_legacy.cc",
+ "pairing_handler_le_secure_connections.cc",
+ "security_manager.cc",
+ "security_module.cc",
+ ]
+
+ deps = [
+ ":BluetoothSecurityChannelSources",
+ ":BluetoothSecurityPairingSources",
+ ":BluetoothSecurityRecordSources",
+ "//bt/gd:gd_default_deps",
+ ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+}
diff --git a/system/gd/shim/BUILD.gn b/system/gd/shim/BUILD.gn
new file mode 100644
index 0000000000..59dbb3721c
--- /dev/null
+++ b/system/gd/shim/BUILD.gn
@@ -0,0 +1,31 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source_set("BluetoothShimSources") {
+ sources = [
+ "dumpsys.cc",
+ "dumpsys_args.cc",
+ ]
+
+ deps = [
+ "//bt/gd/dumpsys:BluetoothGeneratedDumpsysBundledSchema_h",
+ "//bt/gd/dumpsys/bundler:BluetoothGeneratedBundlerSchema_h_bfbs",
+ ]
+
+ configs += [
+ "//bt/gd:gd_defaults",
+ "//bt:external_flatbuffers",
+ ]
+}
diff --git a/system/gd/storage/BUILD.gn b/system/gd/storage/BUILD.gn
new file mode 100644
index 0000000000..c7864e4bd5
--- /dev/null
+++ b/system/gd/storage/BUILD.gn
@@ -0,0 +1,32 @@
+#
+# Copyright 2021 Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source_set("BluetoothStorageSources") {
+ sources = [
+ "adapter_config.cc",
+ "classic_device.cc",
+ "config_cache.cc",
+ "config_cache_helper.cc",
+ "device.cc",
+ "le_device.cc",
+ "legacy_config_file.cc",
+ "mutation.cc",
+ "mutation_entry.cc",
+ "storage_module.cc",
+ ]
+
+ configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt/gd:gd_default_deps" ]
+}
diff --git a/system/include/hardware/avrcp/avrcp.h b/system/include/hardware/avrcp/avrcp.h
index 66a5058b0e..a78027d0c0 100644
--- a/system/include/hardware/avrcp/avrcp.h
+++ b/system/include/hardware/avrcp/avrcp.h
@@ -18,6 +18,7 @@
#include <set>
#include <string>
+#include <vector>
#include <base/callback_forward.h>
diff --git a/system/main/BUILD.gn b/system/main/BUILD.gn
index c694a7c35c..a4fd1fc327 100644
--- a/system/main/BUILD.gn
+++ b/system/main/BUILD.gn
@@ -60,16 +60,17 @@ shared_library("bluetooth") {
]
deps = [
+ "//bt/audio_hal_interface",
"//bt/bta",
"//bt/btcore",
"//bt/btif",
"//bt/device",
"//bt/embdrv/g722",
"//bt/embdrv/sbc",
- "//bt/gd/common:BluetoothCommonSources",
+ "//bt/gd:libbluetooth_gd",
"//bt/hci",
+ "//bt/main/shim:LibBluetoothShimSources",
"//bt/osi",
- "//bt/main/shim",
"//bt/packet",
"//bt/stack",
"//bt/udrv",
@@ -79,6 +80,7 @@ shared_library("bluetooth") {
configs += [
"//bt:target_defaults",
"//bt:external_tinyxml2",
+ "//bt:external_flatbuffers",
]
cflags_c = [
@@ -92,5 +94,8 @@ shared_library("bluetooth") {
"resolv",
"rt",
"z",
+ "bt_shim_ffi",
]
+
+ lib_dirs = [ "${root_out_dir}/rust" ]
}
diff --git a/system/main/shim/BUILD.gn b/system/main/shim/BUILD.gn
index ddfcbf02be..bc2cf68928 100644
--- a/system/main/shim/BUILD.gn
+++ b/system/main/shim/BUILD.gn
@@ -12,8 +12,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+#
-source_set("shim") {
+source_set("LibBluetoothShimSources") {
sources = [
"acl.cc",
"acl_api.cc",
@@ -44,17 +45,14 @@ source_set("shim") {
]
deps = [
- "//bt/gd:dumpsys",
+ "//bt/gd:BluetoothGeneratedDumpsysDataSchema_h",
+ "//bt/gd:BluetoothGeneratedPackets_h",
"//bt/gd/common:BluetoothCommonSources",
- "//bt/gd/dumpsys/bundler:bundler_generated",
+ "//bt/gd/dumpsys/bundler:BluetoothGeneratedBundlerSchema_h_bfbs",
"//bt/gd/hci:BluetoothHciSources",
"//bt/gd/os:BluetoothOsSources_linux_generic",
"//bt/gd/packet:BluetoothPacketSources",
- "//bt/gd/rust/shim:hci_bridge_header",
- "//bt/gd/rust/shim:init_flags_bridge_header",
- "//bt/gd/rust/shim:shim_bridge_header",
- "//bt/gd/rust/shim:message_loop_thread_bridge_header",
- "//bt/gd/rust/shim:controller_bridge_header",
+ "//bt/gd/rust/shim:libbluetooth_rust_interop",
"//bt/osi",
"//bt/stack",
"//bt/types",
diff --git a/system/service/BUILD.gn b/system/service/BUILD.gn
index 6d9ac9c058..888d1fa822 100644
--- a/system/service/BUILD.gn
+++ b/system/service/BUILD.gn
@@ -23,7 +23,7 @@ config("service_config") {
"//bt/service/common",
]
- configs = ["//bt:target_defaults"]
+ configs = [ "//bt:target_defaults" ]
}
source_set("service_daemon_src") {
@@ -45,18 +45,18 @@ source_set("service_daemon_src") {
"ipc/ipc_manager.cc",
"logging_helpers.cc",
"low_energy_advertiser.cc",
- "low_energy_scanner.cc",
"low_energy_client.cc",
+ "low_energy_scanner.cc",
"settings.cc",
]
deps = [
- "//bt/types",
- "//bt/osi",
"//bt/gd/rust/shim:init_flags_bridge_header",
+ "//bt/osi",
+ "//bt/types",
]
- configs += [":service_config"]
+ configs += [ ":service_config" ]
}
source_set("service_linux_src") {
@@ -66,12 +66,12 @@ source_set("service_linux_src") {
]
deps = [
- "//bt/types",
- "//bt/osi",
"//bt/gd/rust/shim:init_flags_bridge_header",
+ "//bt/osi",
+ "//bt/types",
]
- configs += [":service_config"]
+ configs += [ ":service_config" ]
}
source_set("service") {
@@ -98,23 +98,21 @@ source_set("service") {
deps = [
":service_daemon_src",
":service_linux_src",
- "//bt/types",
- "//bt/osi",
"//bt/gd/rust/shim:init_flags_bridge_header",
+ "//bt/osi",
+ "//bt/types",
]
-
configs += [ ":service_config" ]
}
executable("bluetoothtbd") {
- sources = [
- "main.cc",
- ]
+ sources = [ "main.cc" ]
deps = [
":service",
"//bt/btcore",
+ "//bt/main:bluetooth",
]
configs += [ ":service_config" ]
@@ -123,6 +121,8 @@ executable("bluetoothtbd") {
"dl",
"pthread",
"rt",
+ "ssl",
+ "crypto",
]
}
@@ -149,9 +149,7 @@ if (use.test) {
}
executable("bluetoothtbd_test") {
- sources = [
- "test/main.cc"
- ]
+ sources = [ "test/main.cc" ]
deps = [
":service_base_test_src",
@@ -161,7 +159,7 @@ if (use.test) {
configs += [
"//bt:external_gmock_main",
- ":service_config"
+ ":service_config",
]
}
}
diff --git a/system/service/adapter.cc b/system/service/adapter.cc
index d7964d2d92..65e58e878b 100644
--- a/system/service/adapter.cc
+++ b/system/service/adapter.cc
@@ -552,9 +552,11 @@ class AdapterImpl : public Adapter, public hal::BluetoothInterface::Observer {
}
case BT_PROPERTY_BDNAME: {
bt_bdname_t* hal_name = reinterpret_cast<bt_bdname_t*>(property->val);
- std::string name = reinterpret_cast<char*>(hal_name->name);
- LOG(INFO) << "Adapter name changed: " << name;
- name_.Set(name);
+ if (hal_name) {
+ std::string name = reinterpret_cast<char*>(hal_name->name);
+ LOG(INFO) << "Adapter name changed: " << name;
+ name_.Set(name);
+ }
break;
}
case BT_PROPERTY_LOCAL_LE_FEATURES: {
diff --git a/system/stack/BUILD.gn b/system/stack/BUILD.gn
index 2f4ea0b9fb..2eae0d89ae 100644
--- a/system/stack/BUILD.gn
+++ b/system/stack/BUILD.gn
@@ -32,6 +32,7 @@ source_set("nonstandard_codecs") {
"a2dp/a2dp_aac.cc",
"a2dp/a2dp_aac_decoder.cc",
"a2dp/a2dp_aac_encoder.cc",
+ "a2dp/a2dp_vendor.cc",
"a2dp/a2dp_vendor_aptx.cc",
"a2dp/a2dp_vendor_aptx_encoder.cc",
"a2dp/a2dp_vendor_aptx_hd.cc",
@@ -51,9 +52,7 @@ source_set("nonstandard_codecs") {
"//bt/utils/include",
]
- deps = [
- "//bt/gd/rust/shim:init_flags_bridge_header",
- ]
+ deps = [ "//bt/gd/rust/shim:init_flags_bridge_header" ]
configs += [
"//bt:target_defaults",
@@ -71,7 +70,8 @@ source_set("stack") {
"a2dp/a2dp_sbc_decoder.cc",
"a2dp/a2dp_sbc_encoder.cc",
"a2dp/a2dp_sbc_up_sample.cc",
- "a2dp/a2dp_vendor.cc",
+ "acl/acl.cc",
+ "acl/ble_acl.cc",
"acl/btm_acl.cc",
"acl/btm_ble_connection_establishment.cc",
"acl/btm_pm.cc",
@@ -112,11 +112,13 @@ source_set("stack") {
"btm/btm_ble_gap.cc",
"btm/btm_ble_multi_adv.cc",
"btm/btm_ble_privacy.cc",
+ "btm/btm_client_interface.cc",
"btm/btm_dev.cc",
"btm/btm_devctl.cc",
"btm/btm_inq.cc",
"btm/btm_iso.cc",
"btm/btm_main.cc",
+ "btm/btm_scn.cc",
"btm/btm_sco.cc",
"btm/btm_sec.cc",
"btu/btu_hcif.cc",
@@ -133,6 +135,7 @@ source_set("stack") {
"gatt/gatt_db.cc",
"gatt/gatt_main.cc",
"gatt/gatt_sr.cc",
+ "gatt/gatt_sr_hash.cc",
"gatt/gatt_utils.cc",
"hcic/hciblecmds.cc",
"hcic/hcicmds.cc",
@@ -217,10 +220,10 @@ source_set("stack") {
deps = [
":crypto_toolbox",
":nonstandard_codecs",
- "//bt/types",
"//bt/gd/rust/shim:init_flags_bridge_header",
"//bt/third_party/proto_logging/stats:libbt-platform-protos",
"//bt/types",
+ "//bt/types",
]
configs += [ "//bt:target_defaults" ]
@@ -245,8 +248,8 @@ if (use.test) {
]
deps = [
- "//bt/osi",
"//bt/common",
+ "//bt/osi",
]
configs += [