Skip to content

Commit

Permalink
Off Target developement of Fluoride stack
Browse files Browse the repository at this point in the history
Off Target developement of Fluoride stack

Change-Id: Ia102dc62947d42336427ef5dadba242e14313123
  • Loading branch information
Subramanian Srinivasan authored and Vaishali Gupta committed Nov 8, 2019
1 parent 238e265 commit 5c0e0e8
Show file tree
Hide file tree
Showing 39 changed files with 745 additions and 321 deletions.
16 changes: 2 additions & 14 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@
group("bluetooth") {
deps = [
"//main:bluetooth",
"//service:bluetoothtbd",
"//service:offtarget_test",
]
}

group("bluetooth_tests") {
testonly = true

deps = [
"//test/suite:net_test_bluetooth",
"//btcore:net_test_btcore",
"//hci:net_test_hci",
"//osi:net_test_osi",
"//device:net_test_device",
]
}
}
23 changes: 22 additions & 1 deletion bta/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ static_library("bta") {
"gatt/bta_gatts_api.cc",
"gatt/bta_gatts_main.cc",
"gatt/bta_gatts_utils.cc",
"gatt/database_builder.cc",
"gatt/database.cc",
"hf_client/bta_hf_client_act.cc",
"hf_client/bta_hf_client_api.cc",
"hf_client/bta_hf_client_at.cc",
Expand Down Expand Up @@ -85,6 +87,7 @@ static_library("bta") {
"sys/bta_sys_conn.cc",
"sys/bta_sys_main.cc",
"sys/utl.cc",
"hearing_aid/hearing_aid.cc",
]

include_dirs = [
Expand All @@ -94,6 +97,10 @@ static_library("bta") {
"hd",
"include",
"sys",
"av",
"ag",
"gatt",
"//bta",
"//",
"//btcore/include",
"//hci/include",
Expand All @@ -103,10 +110,24 @@ static_library("bta") {
"//udrv/include",
"//utils/include",
"//vnd/include",
"//internal_include",
"//device/include",
"//linux_include",
"//third_party/bluetooth_ext/system_bt_ext/bta/include",
"//third_party/bluetooth_ext/system_bt_ext",
"//stock_bt_include",
"//third_party/bluetooth_ext/vhal/include",
"//third_party/system/core/include",
"//third_party/libchrome/base",
"//third_party/bluetooth_ext/system_bt_ext/btif/include",
]

deps = [
"//third_party/libchrome:base"
"//third_party/libchrome:base",
"//third_party/bluetooth_ext/system_bt_ext:system_bt_ext_device",
]

defines = [
"UNUSED(param)",
]
}
12 changes: 11 additions & 1 deletion bta/gatt/bta_gattc_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ using gatt::IncludedService;
using gatt::Service;
using gatt::StoredAttribute;

#if (OFF_TARGET_TEST_ENABLED == TRUE)
constexpr static std::pair<uint16_t, uint16_t> EXPLORE_END =
std::make_pair(0xFFFF, 0xFFFF);
#endif

static void bta_gattc_cache_write(const RawAddress& server_bda,
const std::vector<StoredAttribute>& attr);
static tGATT_STATUS bta_gattc_sdp_service_disc(uint16_t conn_id,
Expand Down Expand Up @@ -200,7 +205,12 @@ void bta_gattc_start_disc_char_dscp(uint16_t conn_id,

std::pair<uint16_t, uint16_t> range =
p_srvc_cb->pending_discovery.NextDescriptorRangeToExplore();
if (range == DatabaseBuilder::EXPLORE_END) {
#if (OFF_TARGET_TEST_ENABLED == FALSE)
if (range == DatabaseBuilder::EXPLORE_END)
#else
if (range == EXPLORE_END)
#endif
{
goto descriptor_discovery_done;
}

Expand Down
3 changes: 2 additions & 1 deletion btcore/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ cc_library_static {
name: "libbtcore_qti",
defaults: ["fluoride_defaults_qti"],
local_include_dirs: ["include"],
include_dirs: ["vendor/qcom/opensource/commonsys/system/bt"],
include_dirs: ["vendor/qcom/opensource/commonsys/system/bt",
"vendor/qcom/opensource/commonsys/system/bt/stack/include"],
srcs: [
"src/device_class.cc",
"src/hal_util.cc",
Expand Down
34 changes: 3 additions & 31 deletions btcore/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,17 @@ static_library("btcore") {
"src/hal_util.cc",
"src/module.cc",
"src/property.cc",
"src/uuid.cc",
"src/osi_module.cc",
]

include_dirs = [
"include",
"//internal_include",
"//stack/include",
"//",
]

deps = [
"//third_party/libchrome:base",
]
}

executable("net_test_btcore") {
testonly = true
sources = [
"test/device_class_test.cc",
"test/property_test.cc",
"test/uuid_test.cc",
"//osi/test/AllocationTestHarness.cc",
]

include_dirs = [
"include",
"//",
]

deps = [
"//btcore",
"//osi",
"//types",
"//third_party/googletest:gtest_main",
"//third_party/libchrome:base",
]

libs = [
"-lpthread",
"-lrt",
"-ldl",
]
}
}
15 changes: 14 additions & 1 deletion btcore/src/hal_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "bt_target.h"

#define LOG_TAG "hal_util"

Expand All @@ -29,16 +30,28 @@

using base::StringPrintf;

#define BLUETOOTH_LIBRARY_NAME "libbluetoothQti.so"
#if (OFF_TARGET_TEST_ENABLED == FALSE)
#define BLUETOOTH_LIBRARY_NAME "libbluetoothQti.so"
#else
#define BLUETOOTH_LIBRARY_NAME "./libbluetooth.so"
#endif //OFF_TARGET_TEST_ENABLED

int hal_util_load_bt_library(const bt_interface_t** interface) {
const char* sym = BLUETOOTH_INTERFACE_STRING;
bt_interface_t* itf = nullptr;

// Always try to load the default Bluetooth stack on GN builds.
#if (OFF_TARGET_TEST_ENABLED == FALSE)
void* handle = dlopen(BLUETOOTH_LIBRARY_NAME, RTLD_NOW);
#else
void* handle = dlopen(BLUETOOTH_LIBRARY_NAME, RTLD_LAZY);
LOG(INFO) << __func__ << " loading HAL path=" << BLUETOOTH_LIBRARY_NAME;
#endif //OFF_TARGET_TEST_ENABLED
if (!handle) {
LOG(ERROR) << __func__ << ": failed to load bluetooth library";
#if (OFF_TARGET_TEST_ENABLED == TRUE)
LOG(ERROR) << __func__ << "dlerror:"<<dlerror();
#endif //OFF_TARGET_TEST_ENABLED
goto error;
}

Expand Down
19 changes: 18 additions & 1 deletion btif/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static_library("btif") {
"src/btif_uid.cc",
"src/btif_util.cc",
"src/stack_manager.cc",
"src/btif_bqr.cc",
]

# BTIF callouts
Expand All @@ -76,9 +77,12 @@ static_library("btif") {
include_dirs = [
"include",
"//",
"co",
"//common",
"//audio_a2dp_hw/include",
"//bta/include",
"//bta/sys",
"//bta/ag",
"//btcore/include",
"//device/include",
"//embdrv/sbc/encoder/include",
Expand All @@ -92,9 +96,22 @@ static_library("btif") {
"//udrv/include",
"//utils/include",
"//vnd/include",
"//internal_include",
"//stack/l2cap",
"//linux_include",
"//third_party/bluetooth_ext/vhal/include",
"//third_party/bluetooth_ext/vhal/include/hardware",
"//third_party/bluetooth_ext/system_bt_ext/btif/include",
"//third_party/bluetooth_ext/system_bt_ext/bta/include",
"//third_party/system/core/include",
"//third_party/bluetooth_ext/system_bt_ext",
"//third_party/libchrome/base",
]

deps = [
"//third_party/libchrome:base"
"//third_party/libchrome:base",
"//third_party/bluetooth_ext/system_bt_ext:system_bt_ext_btif",
"//common:common",
"//osi:osi",
]
}
4 changes: 4 additions & 0 deletions btif/co/bta_hh_co.cc
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ void bta_hh_co_set_rpt_rsp(uint8_t dev_handle, uint8_t status) {
return;
}

#if (OFF_TARGET_TEST_ENABLED == FALSE)
memset(&ev, 0, sizeof(ev));
ev.type = UHID_SET_REPORT_REPLY;
/* get the report id from queue_start pointer */
Expand All @@ -733,6 +734,7 @@ void bta_hh_co_set_rpt_rsp(uint8_t dev_handle, uint8_t status) {
ev.u.set_report_reply.id);
ev.u.set_report_reply.err = status;
uhid_write(p_dev->fd, &ev);
#endif //OFF_TARGET_TEST_ENABLED
}

/*******************************************************************************
Expand Down Expand Up @@ -775,6 +777,7 @@ void bta_hh_co_get_rpt_rsp(uint8_t dev_handle, uint8_t status, uint8_t* p_rpt,
return;
}

#if (OFF_TARGET_TEST_ENABLED == FALSE)
memset(&ev, 0, sizeof(ev));
ev.type = UHID_GET_REPORT_REPLY;
ev.u.get_report_reply.err = status;
Expand All @@ -791,6 +794,7 @@ void bta_hh_co_get_rpt_rsp(uint8_t dev_handle, uint8_t status, uint8_t* p_rpt,
memcpy(ev.u.get_report_reply.data, p_rpt + BT_HID_RPT_OFFSET, len);
}
uhid_write(p_dev->fd, &ev);
#endif
}

#if (BTA_HH_LE_INCLUDED == TRUE)
Expand Down
19 changes: 14 additions & 5 deletions btif/include/btif_hh.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@
#include <stdint.h>
#include "bta_hh_api.h"
#include "btu.h"
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 18, 00))
#include "osi/include/fixed_queue.h"
#endif // (LINUX_VERSION_CODE > KERNEL_VERSION(3,18,00))
#if (OFF_TARGET_TEST_ENABLED == FALSE)
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 18, 00))
#include "osi/include/fixed_queue.h"
#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,18,00))
#else
#include "osi/include/fixed_queue.h"
#endif // OFF_TARGET_TEST_ENABLED

/*******************************************************************************
* Constants & Macros
Expand Down Expand Up @@ -72,10 +76,15 @@ typedef struct {
pthread_t hh_poll_thread_id;
uint8_t hh_keep_polling;
alarm_t* vup_timer;
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 18, 00))
#if (OFF_TARGET_TEST_ENABLED == FALSE)
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 18, 00))
fixed_queue_t* set_rpt_id_queue;
fixed_queue_t* get_rpt_id_queue;
#endif // (LINUX_VERSION_CODE > KERNEL_VERSION(3,18,00))
#else
fixed_queue_t* set_rpt_id_queue;
fixed_queue_t* get_rpt_id_queue;
#endif // (LINUX_VERSION_CODE > KERNEL_VERSION(3,18,00))
#endif //OFF_TARGET_TEST_ENABLED
bool local_vup; // Indicated locally initiated VUP
uint8_t last_output_rpt_data[UHID_DATA_MAX];
} btif_hh_device_t;
Expand Down
8 changes: 8 additions & 0 deletions btif/src/btif_a2dp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@
#include "osi/include/log.h"
#include "btif_a2dp_audio_interface.h"
#include "btif_hf.h"

#if (OFF_TARGET_TEST_ENABLED == FALSE)
#include "audio_hal_interface/a2dp_encoding.h"
#endif
#include "btif_bat.h"

#if (OFF_TARGET_TEST_ENABLED == TRUE)
#include "service/a2dp_hal_sim/audio_a2dp_hal_stub.h"
using ::bluetooth::audio::a2dp::SessionType;
#endif

#define BTIF_A2DP_START_BLOCK_SCO_CONNECTED 0x0D

extern bool btif_a2dp_audio_if_init;
Expand Down
11 changes: 11 additions & 0 deletions btif/src/btif_a2dp_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#define LOG_TAG "bt_btif_a2dp_source"
#define ATRACE_TAG ATRACE_TAG_AUDIO

#include "bt_target.h"

#include <base/logging.h>
#ifndef OS_GENERIC
#include <cutils/trace.h>
Expand All @@ -33,7 +35,16 @@
#include <algorithm>

#include "audio_a2dp_hw/include/audio_a2dp_hw.h"
#if (OFF_TARGET_TEST_ENABLED == FALSE)
#include "audio_hal_interface/a2dp_encoding.h"
#endif

#if (OFF_TARGET_TEST_ENABLED == TRUE)
#include "service/a2dp_hal_sim/audio_a2dp_hal.h"
#include "service/a2dp_hal_sim/audio_a2dp_hal_stub.h"
using ::bluetooth::audio::a2dp::SessionType;
#endif

#include "bt_common.h"
#include "bta_av_ci.h"
#include "btif_a2dp.h"
Expand Down
6 changes: 6 additions & 0 deletions btif/src/btif_av.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@
#include "btif_bat.h"
#include "bta/av/bta_av_int.h"
#include "device/include/device_iot_config.h"
#if (OFF_TARGET_TEST_ENABLED == FALSE)
#include "audio_hal_interface/a2dp_encoding.h"
#endif
#include "controller.h"
#if (OFF_TARGET_TEST_ENABLED == TRUE)
#include "log/log.h"
#include "service/a2dp_hal_sim/audio_a2dp_hal_stub.h"
#endif

extern bool isDevUiReq;
bool isBitRateChange = false;
Expand Down
3 changes: 3 additions & 0 deletions btif/src/btif_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,12 @@ static void read_or_set_metrics_salt() {
}
if (!AddressObfuscator::IsSaltValid(metrics_salt)) {
LOG(INFO) << __func__ << ": Metrics salt is not invalid, creating new one";
#if (OFF_TARGET_TEST_ENABLED == FALSE)
//TODO need to resolve below dependency
if (RAND_bytes(metrics_salt.data(), metrics_salt.size()) != 1) {
LOG(FATAL) << __func__ << "Failed to generate salt for metrics";
}
#endif
if (!btif_config_set_bin(BT_CONFIG_METRICS_SECTION,
BT_CONFIG_METRICS_SALT_256BIT, metrics_salt.data(),
metrics_salt.size())) {
Expand Down
Loading

0 comments on commit 5c0e0e8

Please sign in to comment.