Loading system/gd/hci/BUILD.gn +4 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,10 @@ source_set("BluetoothHciSources") { include_dirs = [ "//bt/gd" ] deps = [ "//bt/gd:gd_default_deps" ] deps = [ "//bt:libbt-platform-protos-lite", "//bt/gd:gd_default_deps", ] configs += [ "//bt:target_defaults" ] } system/stack/Android.bp +92 −23 Original line number Diff line number Diff line Loading @@ -690,11 +690,28 @@ cc_test { ], include_dirs: [ "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/vnd/ble", ], generated_headers: [ "BluetoothGeneratedBundlerSchema_h_bfbs", "BluetoothGeneratedDumpsysDataSchema_h", "BluetoothGeneratedPackets_h", ], srcs: crypto_toolbox_srcs + [ ":BluetoothBtaaSources_host", ":BluetoothHalSources_hci_host", ":BluetoothOsSources_host", ":TestMockBta", ":TestMockBtif", ":TestMockDevice", ":TestMockLegacyHciCommands", ":TestMockMainBte", ":TestMockMainShim", ":TestMockStackBtu", ":TestMockStackGap", ":TestMockStackGatt", ":TestMockStackSmp", ":TestStackL2cap", "acl/acl.cc", "acl/ble_acl.cc", Loading Loading @@ -723,39 +740,19 @@ cc_test { "metrics/stack_metrics_logging.cc", "test/btm/stack_btm_test.cc", "test/btm/peer_packet_types_test.cc", "test/common/mock_bta_dm_act.cc", "test/common/mock_bta_sys_conn.cc", "test/common/mock_btif_bqr.cc", "test/common/mock_btif_dm.cc", "test/common/mock_btif_storage.cc", "test/common/mock_btu_hcif.cc", "test/common/mock_gap_gap_ble.cc", "test/common/mock_gatt_connection_manager.cc", "test/common/mock_gatt_gatt_auth.cc", "test/common/mock_gatt_main.cc", "test/common/mock_hci_packet_parser.cc", "test/common/mock_l2cap_l2c_utils.cc", "test/common/mock_main_bte_main.cc", "test/common/mock_main_shim.cc", "test/common/mock_main_shim_acl_api.cc", "test/common/mock_main_shim_l2c_api.cc", "test/common/mock_main_shim_btm_api.cc", "test/common/mock_main_shim_link_policy.cc", "test/common/mock_smp_smp_act.cc", "test/common/mock_smp_smp_api.cc", ], static_libs: [ "libbt-common", "libbt-protos-lite", "libbte", "libbtdevice", "libgmock", "liblog", "libosi", "libbtdevice", ], shared_libs: [ "libprotobuf-cpp-lite", "libcrypto", "libflatbuffers-cpp", "libprotobuf-cpp-lite", ], sanitize: { address: true, Loading Loading @@ -901,9 +898,81 @@ cc_test { "libosi", ], shared_libs: [ "libbinder_ndk", "libcrypto", "libflatbuffers-cpp", "libprotobuf-cpp-lite", ], sanitize: { address: true, all_undefined: true, cfi: true, integer_overflow: true, scs: true, diag: { undefined : true }, }, } cc_test { name: "net_test_stack_gatt", test_suites: ["device-tests"], host_supported: true, defaults: ["fluoride_defaults"], local_include_dirs: [ "include", "test/common", ], include_dirs: [ "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/utils/include", ], generated_headers: [ "BluetoothGeneratedBundlerSchema_h_bfbs", "BluetoothGeneratedDumpsysDataSchema_h", "BluetoothGeneratedPackets_h", ], srcs: [ ":TestMockBta", ":TestMockBtif", ":TestMockHci", ":TestMockLegacyHciCommands", ":TestMockMainShim", ":TestMockStackAcl", ":TestMockStackCryptotoolbox", ":TestMockStackSmp", ":TestStackBtm", ":TestStackL2cap", ":TestStackSdp", "eatt/eatt.cc", "gatt/att_protocol.cc", "gatt/connection_manager.cc", "gatt/gatt_api.cc", "gatt/gatt_attr.cc", "gatt/gatt_auth.cc", "gatt/gatt_cl.cc", "gatt/gatt_db.cc", "gatt/gatt_main.cc", "gatt/gatt_sr.cc", "gatt/gatt_sr_hash.cc", "gatt/gatt_utils.cc", "test/gatt/stack_gatt_test.cc", ], static_libs: [ "libbt-common", "libbt-protos-lite", "libbtdevice", "libgmock", "liblog", "libosi", ], shared_libs: [ "libbinder_ndk", "libcrypto", "libflatbuffers-cpp", "libprotobuf-cpp-lite", ], sanitize: { address: true, Loading system/stack/btm/btm_ble_bgconn.cc +17 −18 Original line number Diff line number Diff line Loading @@ -90,38 +90,37 @@ static void acceptlist_command_complete(tHCI_STATUS status, const char* msg) { } static void acceptlist_add_command_complete(uint8_t* p_data, uint16_t evt_len) { if (evt_len > sizeof(uint8_t)) { uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistAdd); } else { if (evt_len < sizeof(uint8_t)) { LOG_ERROR("Received bogus acceptlist add complete length:%hu", evt_len); return; } uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistAdd); } static void acceptlist_remove_command_complete(uint8_t* p_data, uint16_t evt_len) { if (evt_len > sizeof(uint8_t)) { if (evt_len < sizeof(uint8_t)) { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); return; } uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistRemove); } else { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); } } static void acceptlist_clear_command_complete(uint8_t* p_data, uint16_t evt_len) { if (evt_len > sizeof(uint8_t)) { if (evt_len < sizeof(uint8_t)) { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); return; } uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistClear); } else { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); } } /** This function is to stop auto connection procedure */ Loading system/stack/test/btm/stack_btm_test.cc +9 −8 Original line number Diff line number Diff line Loading @@ -20,33 +20,33 @@ #include <gtest/gtest.h> #include <map> #include "btif/include/btif_hh.h" #include "hci/include/hci_layer.h" #include "hci/include/hci_packet_factory.h" #include "hci/include/packet_fragmenter.h" #include "internal_include/stack_config.h" #include "osi/include/osi.h" #include "stack/btm/btm_int_types.h" #include "stack/include/acl_api.h" #include "stack/include/acl_hci_link_interface.h" #include "stack/include/btm_client_interface.h" #include "types/raw_address.h" #include "stack/l2cap/l2c_int.h" #include "test/mock/mock_hcic_hcicmds.h" #include "types/raw_address.h" namespace mock = test::mock::hcic_hcicmds; extern tBTM_CB btm_cb; bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; } uint8_t appl_trace_level = BT_TRACE_LEVEL_VERBOSE; btif_hh_cb_t btif_hh_cb; tL2C_CB l2cb; const hci_packet_factory_t* hci_packet_factory_get_interface() { return nullptr; } const hci_t* hci_layer_get_interface() { return nullptr; } bt_status_t do_in_main_thread(const base::Location& from_here, base::OnceClosure task) { return BT_STATUS_SUCCESS; } void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {} const std::string kSmpOptions("mock smp options"); Loading @@ -59,6 +59,7 @@ bool get_pts_crosskey_sdp_disable(void) { return false; } const std::string* get_pts_smp_options(void) { return &kSmpOptions; } int get_pts_smp_failure_case(void) { return 123; } config_t* get_all(void) { return nullptr; } const packet_fragmenter_t* packet_fragmenter_get_interface() { return nullptr; } stack_config_t mock_stack_config{ .get_trace_config_enabled = get_trace_config_enabled, Loading @@ -76,7 +77,7 @@ const stack_config_t* stack_config_get_interface(void) { std::map<std::string, int> mock_function_count_map; bool MOCK_bluetooth_shim_is_gd_acl_enabled_; extern bool MOCK_bluetooth_shim_is_gd_acl_enabled_; namespace { Loading system/stack/test/gatt/stack_gatt_test.cc 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright 2021 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 <gtest/gtest.h> #include <cstdint> #include <map> #include <string> #include "common/message_loop_thread.h" std::map<std::string, int> mock_function_count_map; void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {} bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; } class StackGattTest : public ::testing::Test {}; TEST_F(StackGattTest, nop) {} Loading
system/gd/hci/BUILD.gn +4 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,10 @@ source_set("BluetoothHciSources") { include_dirs = [ "//bt/gd" ] deps = [ "//bt/gd:gd_default_deps" ] deps = [ "//bt:libbt-platform-protos-lite", "//bt/gd:gd_default_deps", ] configs += [ "//bt:target_defaults" ] }
system/stack/Android.bp +92 −23 Original line number Diff line number Diff line Loading @@ -690,11 +690,28 @@ cc_test { ], include_dirs: [ "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/vnd/ble", ], generated_headers: [ "BluetoothGeneratedBundlerSchema_h_bfbs", "BluetoothGeneratedDumpsysDataSchema_h", "BluetoothGeneratedPackets_h", ], srcs: crypto_toolbox_srcs + [ ":BluetoothBtaaSources_host", ":BluetoothHalSources_hci_host", ":BluetoothOsSources_host", ":TestMockBta", ":TestMockBtif", ":TestMockDevice", ":TestMockLegacyHciCommands", ":TestMockMainBte", ":TestMockMainShim", ":TestMockStackBtu", ":TestMockStackGap", ":TestMockStackGatt", ":TestMockStackSmp", ":TestStackL2cap", "acl/acl.cc", "acl/ble_acl.cc", Loading Loading @@ -723,39 +740,19 @@ cc_test { "metrics/stack_metrics_logging.cc", "test/btm/stack_btm_test.cc", "test/btm/peer_packet_types_test.cc", "test/common/mock_bta_dm_act.cc", "test/common/mock_bta_sys_conn.cc", "test/common/mock_btif_bqr.cc", "test/common/mock_btif_dm.cc", "test/common/mock_btif_storage.cc", "test/common/mock_btu_hcif.cc", "test/common/mock_gap_gap_ble.cc", "test/common/mock_gatt_connection_manager.cc", "test/common/mock_gatt_gatt_auth.cc", "test/common/mock_gatt_main.cc", "test/common/mock_hci_packet_parser.cc", "test/common/mock_l2cap_l2c_utils.cc", "test/common/mock_main_bte_main.cc", "test/common/mock_main_shim.cc", "test/common/mock_main_shim_acl_api.cc", "test/common/mock_main_shim_l2c_api.cc", "test/common/mock_main_shim_btm_api.cc", "test/common/mock_main_shim_link_policy.cc", "test/common/mock_smp_smp_act.cc", "test/common/mock_smp_smp_api.cc", ], static_libs: [ "libbt-common", "libbt-protos-lite", "libbte", "libbtdevice", "libgmock", "liblog", "libosi", "libbtdevice", ], shared_libs: [ "libprotobuf-cpp-lite", "libcrypto", "libflatbuffers-cpp", "libprotobuf-cpp-lite", ], sanitize: { address: true, Loading Loading @@ -901,9 +898,81 @@ cc_test { "libosi", ], shared_libs: [ "libbinder_ndk", "libcrypto", "libflatbuffers-cpp", "libprotobuf-cpp-lite", ], sanitize: { address: true, all_undefined: true, cfi: true, integer_overflow: true, scs: true, diag: { undefined : true }, }, } cc_test { name: "net_test_stack_gatt", test_suites: ["device-tests"], host_supported: true, defaults: ["fluoride_defaults"], local_include_dirs: [ "include", "test/common", ], include_dirs: [ "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", "packages/modules/Bluetooth/system/utils/include", ], generated_headers: [ "BluetoothGeneratedBundlerSchema_h_bfbs", "BluetoothGeneratedDumpsysDataSchema_h", "BluetoothGeneratedPackets_h", ], srcs: [ ":TestMockBta", ":TestMockBtif", ":TestMockHci", ":TestMockLegacyHciCommands", ":TestMockMainShim", ":TestMockStackAcl", ":TestMockStackCryptotoolbox", ":TestMockStackSmp", ":TestStackBtm", ":TestStackL2cap", ":TestStackSdp", "eatt/eatt.cc", "gatt/att_protocol.cc", "gatt/connection_manager.cc", "gatt/gatt_api.cc", "gatt/gatt_attr.cc", "gatt/gatt_auth.cc", "gatt/gatt_cl.cc", "gatt/gatt_db.cc", "gatt/gatt_main.cc", "gatt/gatt_sr.cc", "gatt/gatt_sr_hash.cc", "gatt/gatt_utils.cc", "test/gatt/stack_gatt_test.cc", ], static_libs: [ "libbt-common", "libbt-protos-lite", "libbtdevice", "libgmock", "liblog", "libosi", ], shared_libs: [ "libbinder_ndk", "libcrypto", "libflatbuffers-cpp", "libprotobuf-cpp-lite", ], sanitize: { address: true, Loading
system/stack/btm/btm_ble_bgconn.cc +17 −18 Original line number Diff line number Diff line Loading @@ -90,38 +90,37 @@ static void acceptlist_command_complete(tHCI_STATUS status, const char* msg) { } static void acceptlist_add_command_complete(uint8_t* p_data, uint16_t evt_len) { if (evt_len > sizeof(uint8_t)) { uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistAdd); } else { if (evt_len < sizeof(uint8_t)) { LOG_ERROR("Received bogus acceptlist add complete length:%hu", evt_len); return; } uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistAdd); } static void acceptlist_remove_command_complete(uint8_t* p_data, uint16_t evt_len) { if (evt_len > sizeof(uint8_t)) { if (evt_len < sizeof(uint8_t)) { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); return; } uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistRemove); } else { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); } } static void acceptlist_clear_command_complete(uint8_t* p_data, uint16_t evt_len) { if (evt_len > sizeof(uint8_t)) { if (evt_len < sizeof(uint8_t)) { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); return; } uint8_t status; STREAM_TO_UINT8(status, p_data); acceptlist_command_complete(static_cast<tHCI_STATUS>(status), kAcceptlistClear); } else { LOG_ERROR("Received bogus acceptlist remove complete length:%hu", evt_len); } } /** This function is to stop auto connection procedure */ Loading
system/stack/test/btm/stack_btm_test.cc +9 −8 Original line number Diff line number Diff line Loading @@ -20,33 +20,33 @@ #include <gtest/gtest.h> #include <map> #include "btif/include/btif_hh.h" #include "hci/include/hci_layer.h" #include "hci/include/hci_packet_factory.h" #include "hci/include/packet_fragmenter.h" #include "internal_include/stack_config.h" #include "osi/include/osi.h" #include "stack/btm/btm_int_types.h" #include "stack/include/acl_api.h" #include "stack/include/acl_hci_link_interface.h" #include "stack/include/btm_client_interface.h" #include "types/raw_address.h" #include "stack/l2cap/l2c_int.h" #include "test/mock/mock_hcic_hcicmds.h" #include "types/raw_address.h" namespace mock = test::mock::hcic_hcicmds; extern tBTM_CB btm_cb; bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; } uint8_t appl_trace_level = BT_TRACE_LEVEL_VERBOSE; btif_hh_cb_t btif_hh_cb; tL2C_CB l2cb; const hci_packet_factory_t* hci_packet_factory_get_interface() { return nullptr; } const hci_t* hci_layer_get_interface() { return nullptr; } bt_status_t do_in_main_thread(const base::Location& from_here, base::OnceClosure task) { return BT_STATUS_SUCCESS; } void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {} const std::string kSmpOptions("mock smp options"); Loading @@ -59,6 +59,7 @@ bool get_pts_crosskey_sdp_disable(void) { return false; } const std::string* get_pts_smp_options(void) { return &kSmpOptions; } int get_pts_smp_failure_case(void) { return 123; } config_t* get_all(void) { return nullptr; } const packet_fragmenter_t* packet_fragmenter_get_interface() { return nullptr; } stack_config_t mock_stack_config{ .get_trace_config_enabled = get_trace_config_enabled, Loading @@ -76,7 +77,7 @@ const stack_config_t* stack_config_get_interface(void) { std::map<std::string, int> mock_function_count_map; bool MOCK_bluetooth_shim_is_gd_acl_enabled_; extern bool MOCK_bluetooth_shim_is_gd_acl_enabled_; namespace { Loading
system/stack/test/gatt/stack_gatt_test.cc 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright 2021 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 <gtest/gtest.h> #include <cstdint> #include <map> #include <string> #include "common/message_loop_thread.h" std::map<std::string, int> mock_function_count_map; void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...) {} bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; } class StackGattTest : public ::testing::Test {}; TEST_F(StackGattTest, nop) {}