From 75847f0c0b1ba86b18f4b36f25d68364d00486c0 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Mon, 1 Mar 2021 17:52:04 -0800 Subject: [PATCH] Add host support for libbluetooth.so Bug: 181590011 Tag: #refactor Test: compile Change-Id: I9a53eeaac5a5c612d47671bca4f95cf252faeb93 --- btif/Android.bp | 4 +--- btif/src/btif_debug_btsnoop.cc | 27 ++++++++++++++++----------- gd/btaa/host/activity_attribution.cc | 2 ++ main/Android.bp | 22 +++++++++++++++------- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/btif/Android.bp b/btif/Android.bp index 5b356c028..7ab5b991b 100755 --- a/btif/Android.bp +++ b/btif/Android.bp @@ -118,9 +118,6 @@ cc_library_static { "libaaudio", "libfmq", ], - whole_static_libs: [ - "libbt-audio-hal-interface", - ], srcs: ["src/btif_avrcp_audio_track.cc"], }, host: { @@ -130,6 +127,7 @@ cc_library_static { whole_static_libs: [ "avrcp-target-service", "lib-bt-packets", + "libbt-audio-hal-interface", "libaudio-a2dp-hw-utils", ], cflags: [ diff --git a/btif/src/btif_debug_btsnoop.cc b/btif/src/btif_debug_btsnoop.cc index e72a87519..5ebfdae7b 100644 --- a/btif/src/btif_debug_btsnoop.cc +++ b/btif/src/btif_debug_btsnoop.cc @@ -35,12 +35,6 @@ static const size_t BTSNOOP_MEM_BUFFER_SIZE = (256 * 1024); #endif -// Block size for copying buffers (for compression/encoding etc.) -static const size_t BLOCK_SIZE = 16384; - -// Maximum line length in bugreport (should be multiple of 4 for base64 output) -static const uint8_t MAX_LINE_LENGTH = 128; - static std::mutex buffer_mutex; static ringbuffer_t* buffer = NULL; static uint64_t last_timestamp_ms = 0; @@ -134,6 +128,18 @@ static size_t btsnoop_calculate_packet_length(uint16_t type, } } +void btif_debug_btsnoop_init(void) { + if (buffer == NULL) buffer = ringbuffer_init(BTSNOOP_MEM_BUFFER_SIZE); + btsnoop_mem_set_callback(btsnoop_cb); +} + +#ifndef OS_ANDROID +void btif_debug_btsnoop_dump(int fd) {} +#else + +// Block size for copying buffers (for compression/encoding etc.) +static constexpr size_t BLOCK_SIZE = 16384; + static bool btsnoop_compress(ringbuffer_t* rb_dst, ringbuffer_t* rb_src) { CHECK(rb_dst != NULL); CHECK(rb_src != NULL); @@ -175,11 +181,6 @@ static bool btsnoop_compress(ringbuffer_t* rb_dst, ringbuffer_t* rb_src) { return rc; } -void btif_debug_btsnoop_init(void) { - if (buffer == NULL) buffer = ringbuffer_init(BTSNOOP_MEM_BUFFER_SIZE); - btsnoop_mem_set_callback(btsnoop_cb); -} - void btif_debug_btsnoop_dump(int fd) { ringbuffer_t* ringbuffer = ringbuffer_init(BTSNOOP_MEM_BUFFER_SIZE); if (ringbuffer == NULL) { @@ -219,6 +220,9 @@ void btif_debug_btsnoop_dump(int fd) { while (ringbuffer_size(ringbuffer) > 0) { size_t read = ringbuffer_pop(ringbuffer, b64_in, 3); + // Maximum line length in bugreport (should be multiple of 4 for base64 + // output) + constexpr uint8_t MAX_LINE_LENGTH = 128; if (line_length >= MAX_LINE_LENGTH) { dprintf(fd, "\n"); line_length = 0; @@ -232,3 +236,4 @@ void btif_debug_btsnoop_dump(int fd) { error: ringbuffer_free(ringbuffer); } +#endif diff --git a/gd/btaa/host/activity_attribution.cc b/gd/btaa/host/activity_attribution.cc index a29aaacdb..e9f413440 100644 --- a/gd/btaa/host/activity_attribution.cc +++ b/gd/btaa/host/activity_attribution.cc @@ -36,5 +36,7 @@ void ActivityAttribution::Start() {} void ActivityAttribution::Stop() {} +const ModuleFactory ActivityAttribution::Factory = ModuleFactory([]() { return new ActivityAttribution(); }); + } // namespace activity_attribution } // namespace bluetooth diff --git a/main/Android.bp b/main/Android.bp index 7dc9c858f..56ca73c7b 100644 --- a/main/Android.bp +++ b/main/Android.bp @@ -99,14 +99,10 @@ cc_library_shared { "android.hardware.bluetooth.audio@2.1", "android.hardware.bluetooth@1.0", "android.hardware.bluetooth@1.1", - "android.system.suspend.control-V1-ndk", - "libaaudio", "libbinder_ndk", "libcrypto", "libcutils", - "libdl", "libflatbuffers-cpp", - "libfmq", "libhidlbase", "liblog", "libprocessgroup", @@ -137,6 +133,19 @@ cc_library_shared { "libosi", "libbt-protos-lite", ], + target: { + android: { + shared_libs: [ + "android.system.suspend.control-V1-ndk", + "libaaudio", + "libfmq", + ], + required: [ + "libldacBT_enc", + "libldacBT_abr", + ], + }, + }, // Shared library link options. // References to global symbols and functions should bind to the library // itself. This is to avoid issues with some of the unit/system tests @@ -146,15 +155,14 @@ cc_library_shared { required: [ "bt_did.conf", "bt_stack.conf", - "libldacBT_enc", - "libldacBT_abr", ], cflags: [ "-DBUILDCFG", ], sanitize: { - scs: true, + never: true, }, + host_supported: true, } cc_library_static { -- 2.11.0