diff --git a/system/btif/Android.bp b/system/btif/Android.bp index dd0eec1ccbe7764424bb5db1ca0e498045b01c64..64be7a1f2070a73797ef9b948f331ddbbd2d96b0 100644 --- a/system/btif/Android.bp +++ b/system/btif/Android.bp @@ -428,7 +428,6 @@ cc_test { include_dirs: btifCommonIncludes, srcs: [ ":TestCommonMockFunctions", - ":TestMockCommon", ":TestMockOsi", "test/btif_rc_test.cc", ], @@ -750,7 +749,6 @@ cc_test { ":TestMockBtaVc", ":TestMockBtcore", ":TestMockBtu", - ":TestMockCommon", ":TestMockFrameworks", ":TestMockHci", ":TestMockMainShim", @@ -764,8 +762,6 @@ cc_test { ], header_libs: ["libbluetooth_headers"], shared_libs: [ - "android.hardware.bluetooth.audio@2.0", - "android.hardware.bluetooth.audio@2.1", "libbase", "libcrypto", "libcutils", @@ -776,7 +772,6 @@ cc_test { "server_configurable_flags", ], static_libs: [ - "android.hardware.bluetooth.a2dp@1.0", "avrcp-target-service", "bluetooth_flags_c_lib", "lib-bt-packets", @@ -787,6 +782,7 @@ cc_test { "libbluetooth_crypto_toolbox", "libbluetooth_gd", "libbt-audio-hal-interface", + "libbt-common", "libbt-platform-protos-lite", "libbt-sbc-decoder", "libbt-sbc-encoder", @@ -800,6 +796,7 @@ cc_test { "libcom.android.sysprop.bluetooth.wrapped", "libevent", "libgmock", + "libprotobuf-cpp-lite", "libstatslog_bt", ], cflags: [ @@ -809,10 +806,13 @@ cc_test { target: { android: { static_libs: [ + "android.hardware.bluetooth.a2dp@1.0", "android.hardware.common-V2-ndk", "android.hardware.common.fmq-V1-ndk", ], shared_libs: [ + "android.hardware.bluetooth.audio@2.0", + "android.hardware.bluetooth.audio@2.1", "libbinder_ndk", "libstatssocket", ], diff --git a/system/stack/Android.bp b/system/stack/Android.bp index 08fc2f14d35cc87c5d8b414327b68aff09c67fc0..ff20723163a1191da6972366bce1578f7f84e594 100644 --- a/system/stack/Android.bp +++ b/system/stack/Android.bp @@ -830,13 +830,13 @@ cc_test { include_dirs: [ "packages/modules/Bluetooth/system", "packages/modules/Bluetooth/system/gd", + "packages/modules/Bluetooth/system/include", "packages/modules/Bluetooth/system/internal_include", ], srcs: [ ":TestCommonMainHandler", ":TestCommonMockFunctions", ":TestMockBtif", - ":TestMockCommon", ":TestMockDevice", ":TestMockMainShim", ":TestMockStackAcl", @@ -871,6 +871,7 @@ cc_test { "libbluetooth_l2cap_pdl", "libbluetooth_smp_pdl", "libbt-btu-main-thread", + "libbt-common", "libbt-platform-protos-lite", "libbt_shim_bridge", "libbt_shim_ffi", @@ -879,8 +880,16 @@ cc_test { "libgmock", "liblog", "libosi", + "libstatslog_bt", ], - header_libs: ["libbluetooth_headers"], + target: { + android: { + shared_libs: [ + "libstatssocket", + ], + }, + }, + // header_libs: ["libbluetooth_headers"], cflags: ["-Wno-unused-parameter"], } diff --git a/system/test/Android.bp b/system/test/Android.bp index b575e49401a293ade93a85d2e9819bb9abcf12fd..062095832455b58383cac96be304bc8ac906121d 100644 --- a/system/test/Android.bp +++ b/system/test/Android.bp @@ -189,13 +189,6 @@ filegroup { ], } -filegroup { - name: "TestMockCommon", - srcs: [ - "mock/mock_common_*.cc", - ], -} - filegroup { name: "TestMockStackA2dp", srcs: [ diff --git a/system/test/mock/mock_android_hardware_audio.cc b/system/test/mock/mock_android_hardware_audio.cc deleted file mode 100644 index 01910deee9b241b71c3686acf7a840892eabca43..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_android_hardware_audio.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 <cstdint> - -#include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioHost.h> - -namespace android { -namespace hardware { -namespace bluetooth { - -namespace a2dp { -namespace V1_0 { -class BluetoothAudioHost : public IBluetoothAudioHost { - ::android::hardware::Return<void> setHALInstrumentation() { return Void(); } - ::android::hardware::Return<bool> linkToDeath( - android::sp<android::hardware::hidl_death_recipient> const&, uint64_t) { - return false; - } - ::android::hardware::Return<void> ping() { return Void(); } - ::android::hardware::Return<void> getDebugInfo( - std::__1::function<void(android::hidl::base::V1_0::DebugInfo const&)>) { - return Void(); - } - ::android::hardware::Return<void> notifySyspropsChanged() { return Void(); } - ::android::hardware::Return<bool> unlinkToDeath( - android::sp<android::hardware::hidl_death_recipient> const&) { - return false; - } -}; - -} // namespace V1_0 -} // namespace a2dp - -namespace audio { - -namespace V2_0 { - -class AudioConfiguration { - AudioConfiguration() {} -}; - -} // namespace V2_0 - -} // namespace audio -} // namespace bluetooth -} // namespace hardware -} // namespace android diff --git a/system/test/mock/mock_common_message_loop_thread.cc b/system/test/mock/mock_common_message_loop_thread.cc deleted file mode 100644 index 7ca4c62cd6c139dca84c20b1869c569aca2dfbde..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_common_message_loop_thread.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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 "common/message_loop_thread.h" - -#include <sys/syscall.h> -#include <unistd.h> -#include <thread> - -#include <base/strings/stringprintf.h> - -namespace bluetooth { - -namespace common { - -static constexpr int kRealTimeFifoSchedulingPriority = 1; - -MessageLoopThread::MessageLoopThread(const std::string& thread_name) - : thread_name_(thread_name), - message_loop_(nullptr), - run_loop_(nullptr), - thread_(nullptr), - thread_id_(-1), - linux_tid_(-1), - weak_ptr_factory_(this), - shutting_down_(false) {} - -MessageLoopThread::~MessageLoopThread() { ShutDown(); } - -void MessageLoopThread::StartUp() { - std::promise<void> start_up_promise; - std::future<void> start_up_future = start_up_promise.get_future(); - { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - if (thread_ != nullptr) { - LOG(WARNING) << __func__ << ": thread " << *this << " is already started"; - - return; - } - thread_ = new std::thread(&MessageLoopThread::RunThread, this, - std::move(start_up_promise)); - } - start_up_future.wait(); -} - -bool MessageLoopThread::DoInThread(const base::Location& from_here, - base::OnceClosure task) { - return DoInThreadDelayed(from_here, std::move(task), base::TimeDelta()); -} - -bool MessageLoopThread::DoInThreadDelayed(const base::Location& from_here, - base::OnceClosure task, - const base::TimeDelta& delay) { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - if (message_loop_ == nullptr) { - LOG(ERROR) << __func__ << ": message loop is null for thread " << *this - << ", from " << from_here.ToString(); - return false; - } - if (!message_loop_->task_runner()->PostDelayedTask(from_here, std::move(task), - delay)) { - LOG(ERROR) << __func__ - << ": failed to post task to message loop for thread " << *this - << ", from " << from_here.ToString(); - return false; - } - return true; -} - -void MessageLoopThread::ShutDown() { - { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - if (thread_ == nullptr) { - LOG(INFO) << __func__ << ": thread " << *this << " is already stopped"; - return; - } - if (message_loop_ == nullptr) { - LOG(INFO) << __func__ << ": message_loop_ is null. Already stopping"; - return; - } - if (shutting_down_) { - LOG(INFO) << __func__ << ": waiting for thread to join"; - return; - } - shutting_down_ = true; - CHECK_NE(thread_id_, base::PlatformThread::CurrentId()) - << __func__ << " should not be called on the thread itself. " - << "Otherwise, deadlock may happen."; - if (!message_loop_->task_runner()->PostTask( - FROM_HERE, run_loop_->QuitWhenIdleClosure())) { - LOG(FATAL) << __func__ - << ": failed to post task to message loop for thread " - << *this; - } - } - thread_->join(); - { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - delete thread_; - thread_ = nullptr; - shutting_down_ = false; - } -} - -base::PlatformThreadId MessageLoopThread::GetThreadId() const { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - return thread_id_; -} - -std::string MessageLoopThread::GetName() const { return thread_name_; } - -std::string MessageLoopThread::ToString() const { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - return base::StringPrintf("%s(%d)", thread_name_.c_str(), thread_id_); -} - -bool MessageLoopThread::IsRunning() const { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - return thread_id_ != -1; -} - -// Non API method, should not be protected by API mutex -void MessageLoopThread::RunThread(MessageLoopThread* thread, - std::promise<void> start_up_promise) { - thread->Run(std::move(start_up_promise)); -} - -// This should only be used in tests. -btbase::AbstractMessageLoop* MessageLoopThread::message_loop() const { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - return message_loop_; -} - -bool MessageLoopThread::EnableRealTimeScheduling() { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - - if (!IsRunning()) { - LOG(ERROR) << __func__ << ": thread " << *this << " is not running"; - return false; - } - - struct sched_param rt_params = {.sched_priority = - kRealTimeFifoSchedulingPriority}; - int rc = sched_setscheduler(linux_tid_, SCHED_FIFO, &rt_params); - if (rc != 0) { - LOG(ERROR) << __func__ << ": unable to set SCHED_FIFO priority " - << kRealTimeFifoSchedulingPriority << " for linux_tid " - << std::to_string(linux_tid_) << ", thread " << *this - << ", error: " << strerror(errno); - return false; - } - return true; -} - -base::WeakPtr<MessageLoopThread> MessageLoopThread::GetWeakPtr() { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - return weak_ptr_factory_.GetWeakPtr(); -} - -void MessageLoopThread::Run(std::promise<void> start_up_promise) { - { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - LOG(INFO) << __func__ << ": message loop starting for thread " - << thread_name_; - base::PlatformThread::SetName(thread_name_); - message_loop_ = new btbase::AbstractMessageLoop(); - run_loop_ = new base::RunLoop(); - thread_id_ = base::PlatformThread::CurrentId(); - linux_tid_ = static_cast<pid_t>(syscall(SYS_gettid)); - start_up_promise.set_value(); - } - - // Blocking until ShutDown() is called - run_loop_->Run(); - - { - std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); - thread_id_ = -1; - linux_tid_ = -1; - delete message_loop_; - message_loop_ = nullptr; - delete run_loop_; - run_loop_ = nullptr; - LOG(INFO) << __func__ << ": message loop finished for thread " - << thread_name_; - } -} - -void MessageLoopThread::Post(base::OnceClosure closure) { - DoInThread(FROM_HERE, std::move(closure)); -} - -} // namespace common - -} // namespace bluetooth diff --git a/system/test/mock/mock_common_metric_id_allocator.cc b/system/test/mock/mock_common_metric_id_allocator.cc deleted file mode 100644 index 5ea9b163dcbadc7b7a7db0cfc6831342ac8d5add..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_common_metric_id_allocator.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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. - */ - -/* - * Generated mock file from original source file - * Functions generated:11 - */ - -#include <base/logging.h> - -#include <string> - -#include "common/metric_id_allocator.h" -#include "test/common/mock_functions.h" -#include "types/raw_address.h" - -namespace { - -const size_t paired_device_cache_capacity{10}; -const std::string paired_device_cache_log_tag("Mock"); -} // namespace - -namespace bluetooth { -namespace common { - -const int MetricIdAllocator::kMinId = 0; - -MetricIdAllocator::MetricIdAllocator() - : paired_device_cache_(paired_device_cache_capacity, - paired_device_cache_log_tag), - temporary_device_cache_(paired_device_cache_capacity, - paired_device_cache_log_tag) { - next_id_ = 0; - initialized_ = true; -} - -class MockMetricIdAllocator : public MetricIdAllocator { - public: - MockMetricIdAllocator() {} -}; - -MockMetricIdAllocator metric_id_allocator; - -MetricIdAllocator& MetricIdAllocator::GetInstance() { - inc_func_call_count(__func__); - return metric_id_allocator; -} -MetricIdAllocator::~MetricIdAllocator() {} -bool MetricIdAllocator::Close() { - inc_func_call_count(__func__); - return false; -} -bool MetricIdAllocator::Init( - const std::unordered_map<RawAddress, int>& paired_device_map, - Callback save_id_callback, Callback forget_device_callback) { - inc_func_call_count(__func__); - return false; -} -bool MetricIdAllocator::IsEmpty() const { - inc_func_call_count(__func__); - return false; -} -bool MetricIdAllocator::IsValidId(const int id) { - inc_func_call_count(__func__); - return false; -} -bool MetricIdAllocator::SaveDevice(const RawAddress& mac_address) { - inc_func_call_count(__func__); - return false; -} -int MetricIdAllocator::AllocateId(const RawAddress& mac_address) { - inc_func_call_count(__func__); - return 0; -} -void MetricIdAllocator::ForgetDevice(const RawAddress& mac_address) { - inc_func_call_count(__func__); -} -void MetricIdAllocator::ForgetDevicePostprocess(const RawAddress& mac_address, - const int id) { - inc_func_call_count(__func__); -} - -} // namespace common -} // namespace bluetooth diff --git a/system/test/mock/mock_common_metrics.cc b/system/test/mock/mock_common_metrics.cc deleted file mode 100644 index d67156e4addf53e580fffa3da7da8f36a9f97785..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_common_metrics.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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. - */ - -/* - * Generated mock file from original source file - * Functions generated:36 - */ - -#include <string> - -#include "common/metrics.h" -#include "test/common/mock_functions.h" -#include "types/raw_address.h" - -namespace bluetooth { -namespace common { - -void A2dpSessionMetrics::Update(const A2dpSessionMetrics& metrics) { - inc_func_call_count(__func__); -} - -struct BluetoothMetricsLogger::impl { - int mock{123}; -}; - -BluetoothMetricsLogger::BluetoothMetricsLogger() {} -void BluetoothMetricsLogger::Build() { inc_func_call_count(__func__); } -void BluetoothMetricsLogger::CutoffSession() { inc_func_call_count(__func__); } -void BluetoothMetricsLogger::LogA2dpSession( - const A2dpSessionMetrics& a2dp_session_metrics) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::LogBluetoothSessionDeviceInfo( - uint32_t device_class, device_type_t device_type) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::LogBluetoothSessionEnd( - disconnect_reason_t disconnect_reason, uint64_t timestamp_ms) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::LogBluetoothSessionStart( - connection_tech_t connection_tech_type, uint64_t timestamp_ms) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::LogHeadsetProfileRfcConnection( - tBTA_SERVICE_ID service_id) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::LogPairEvent(uint32_t disconnect_reason, - uint64_t timestamp_ms, - uint32_t device_class, - device_type_t device_type) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::LogScanEvent(bool start, - const std::string& initator, - scan_tech_t type, uint32_t results, - uint64_t timestamp_ms) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::LogWakeEvent(wake_event_type_t type, - const std::string& requestor, - const std::string& name, - uint64_t timestamp_ms) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::Reset() { inc_func_call_count(__func__); } -void BluetoothMetricsLogger::ResetLog() { inc_func_call_count(__func__); } -void BluetoothMetricsLogger::ResetSession() { inc_func_call_count(__func__); } -void BluetoothMetricsLogger::WriteBase64(int fd) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::WriteBase64String(std::string* serialized) { - inc_func_call_count(__func__); -} -void BluetoothMetricsLogger::WriteString(std::string* serialized) { - inc_func_call_count(__func__); -} -void LogA2dpAudioOverrunEvent(const RawAddress& address, - uint64_t encoding_interval_millis, - int num_dropped_buffers, - int num_dropped_encoded_frames, - int num_dropped_encoded_bytes) { - inc_func_call_count(__func__); -} -void LogA2dpAudioUnderrunEvent(const RawAddress& address, - uint64_t encoding_interval_millis, - int num_missing_pcm_bytes) { - inc_func_call_count(__func__); -} -void LogA2dpPlaybackEvent(const RawAddress& address, int playback_state, - int audio_coding_mode) { - inc_func_call_count(__func__); -} -void LogBluetoothHalCrashReason(const RawAddress& address, uint32_t error_code, - uint32_t vendor_error_code) { - inc_func_call_count(__func__); -} -void LogClassicPairingEvent(const RawAddress& address, uint16_t handle, - uint32_t hci_cmd, uint16_t hci_event, - uint16_t cmd_status, uint16_t reason_code, - int64_t event_value) { - inc_func_call_count(__func__); -} -void LogHciTimeoutEvent(uint32_t hci_cmd) { inc_func_call_count(__func__); } -void LogLinkLayerConnectionEvent(const RawAddress* address, - uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, - uint16_t link_type, uint32_t hci_cmd, - uint16_t hci_event, uint16_t hci_ble_event, - uint16_t cmd_status, uint16_t reason_code) { - inc_func_call_count(__func__); -} -void LogManufacturerInfo(const RawAddress& address, - android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, - const std::string& manufacturer, - const std::string& model, - const std::string& hardware_version, - const std::string& software_version) { - inc_func_call_count(__func__); -} -void LogReadFailedContactCounterResult(const RawAddress& address, - uint16_t handle, uint32_t cmd_status, - int32_t failed_contact_counter) { - inc_func_call_count(__func__); -} -void LogReadRssiResult(const RawAddress& address, uint16_t handle, - uint32_t cmd_status, int8_t rssi) { - inc_func_call_count(__func__); -} -void LogReadTxPowerLevelResult(const RawAddress& address, uint16_t handle, - uint32_t cmd_status, - int32_t transmit_power_level) { - inc_func_call_count(__func__); -} -void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version, - uint16_t manufacturer_name, uint16_t subversion) { - inc_func_call_count(__func__); -} -void LogSdpAttribute(const RawAddress& address, uint16_t protocol_uuid, - uint16_t attribute_id, size_t attribute_size, - const char* attribute_value) { - inc_func_call_count(__func__); -} -void LogSmpPairingEvent(const RawAddress& address, uint8_t smp_cmd, - android::bluetooth::DirectionEnum direction, - uint8_t smp_fail_reason) { - inc_func_call_count(__func__); -} -void LogSocketConnectionState( - const RawAddress& address, int port, int type, - android::bluetooth::SocketConnectionstateEnum connection_state, - int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port, - android::bluetooth::SocketRoleEnum socket_role) { - inc_func_call_count(__func__); -} - -void LogLeAudioConnectionSessionReported( - int32_t group_size, int32_t group_metric_id, - int64_t connection_duration_nanos, - std::vector<int64_t>& device_connecting_offset_nanos, - std::vector<int64_t>& device_connected_offset_nanos, - std::vector<int64_t>& device_connection_duration_nanos, - std::vector<int32_t>& device_connection_status, - std::vector<int32_t>& device_disconnection_status, - std::vector<RawAddress>& device_address, - std::vector<int64_t>& streaming_offset_nanos, - std::vector<int64_t>& streaming_duration_nanos, - std::vector<int32_t>& streaming_context_type) { - inc_func_call_count(__func__); -} - -void LogLeAudioBroadcastSessionReported(int64_t duration_nanos) { - inc_func_call_count(__func__); -} - -} // namespace common -} // namespace bluetooth diff --git a/system/test/mock/mock_common_os_utils.cc b/system/test/mock/mock_common_os_utils.cc deleted file mode 100644 index e9dabf273a98d6d0bfe550c778111b64e944389e..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_common_os_utils.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -/* - * Generated mock file from original source file - * Functions generated:1 - * - * mockcify.pl ver 0.3.0 - */ - -// Mock include file to share data between tests and mock -#include "test/mock/mock_common_os_utils.h" - -#include "test/common/mock_functions.h" - -// Mocked internal structures, if any - -namespace test { -namespace mock { -namespace common_os_utils { - -// Function state capture and return values, if needed -struct is_bluetooth_uid is_bluetooth_uid; - -} // namespace common_os_utils -} // namespace mock -} // namespace test - -// Mocked function return values, if any -namespace test { -namespace mock { -namespace common_os_utils { - -bool is_bluetooth_uid::return_value = false; - -} // namespace common_os_utils -} // namespace mock -} // namespace test - -// Mocked functions, if any -bool is_bluetooth_uid() { - inc_func_call_count(__func__); - return test::mock::common_os_utils::is_bluetooth_uid(); -} -// Mocked functions complete -// END mockcify generation diff --git a/system/test/mock/mock_common_repeating_timer.cc b/system/test/mock/mock_common_repeating_timer.cc deleted file mode 100644 index 5b9db123b89dce14956ace46bff88bd7d3851b74..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_common_repeating_timer.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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. - */ - -/* - * Generated mock file from original source file - * Functions generated:8 - */ - -#include "common/message_loop_thread.h" -#include "common/repeating_timer.h" -#include "test/common/mock_functions.h" - -using namespace bluetooth::common; - -RepeatingTimer::~RepeatingTimer() { inc_func_call_count(__func__); } -bool RepeatingTimer::IsScheduled() const { - inc_func_call_count(__func__); - return false; -} -bool RepeatingTimer::SchedulePeriodic( - const base::WeakPtr<MessageLoopThread>& thread, - const base::Location& from_here, base::Closure task, - base::TimeDelta period) { - inc_func_call_count(__func__); - return false; -} -void RepeatingTimer::Cancel() { - inc_func_call_count(__func__); - expected_time_next_task_us_ = 0; -} -void RepeatingTimer::CancelAndWait() { inc_func_call_count(__func__); } -void RepeatingTimer::CancelClosure(std::promise<void> promise) { - inc_func_call_count(__func__); -} -void RepeatingTimer::CancelHelper(std::promise<void> promise) { - inc_func_call_count(__func__); -} -void RepeatingTimer::RunTask() { inc_func_call_count(__func__); } diff --git a/system/test/mock/mock_common_stop_watch_legacy.cc b/system/test/mock/mock_common_stop_watch_legacy.cc deleted file mode 100644 index e008f8d3b42e0704d3cf0129a7e1887a456c2159..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_common_stop_watch_legacy.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -/* - * Generated mock file from original source file - * Functions generated:4 - */ - -#include <base/logging.h> - -#include <string> -#include <utility> - -#include "common/stop_watch_legacy.h" -#include "test/common/mock_functions.h" - -namespace bluetooth { -namespace common { - -StopWatchLegacy::StopWatchLegacy(std::string text) - : text_(std::move(text)), - timestamp_(std::chrono::system_clock::now()), - start_timestamp_(std::chrono::high_resolution_clock::now()) { - inc_func_call_count(__func__); -} -StopWatchLegacy::~StopWatchLegacy() { inc_func_call_count(__func__); } -void StopWatchLegacy::DumpStopWatchLog() { inc_func_call_count(__func__); } -void StopWatchLegacy::RecordLog(StopWatchLog log) { - inc_func_call_count(__func__); -} - -} // namespace common -} // namespace bluetooth diff --git a/system/test/mock/mock_common_time_util.cc b/system/test/mock/mock_common_time_util.cc deleted file mode 100644 index 282879c740228092634e00cb87cd53692ffba19b..0000000000000000000000000000000000000000 --- a/system/test/mock/mock_common_time_util.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ - -/* - * Generated mock file from original source file - * Functions generated:3 - */ - -#include <sys/time.h> - -#include "common/time_util.h" -#include "test/common/mock_functions.h" - -namespace bluetooth { -namespace common { - -uint64_t time_get_os_boottime_ms() { - inc_func_call_count(__func__); - return 0; -} -uint64_t time_get_os_boottime_us() { - inc_func_call_count(__func__); - return 0; -} -uint64_t time_gettimeofday_us() { - inc_func_call_count(__func__); - return 0; -} -uint64_t time_get_os_monotonic_raw_us() { - inc_func_call_count(__func__); - return 0; -} - -} // namespace common -} // namespace bluetooth diff --git a/system/test/suite/Android.bp b/system/test/suite/Android.bp index 8610185c66ca94467c513ee38cad729bc3329652..594799c34ca786874e48a05654c8e594853eaaab 100644 --- a/system/test/suite/Android.bp +++ b/system/test/suite/Android.bp @@ -39,7 +39,6 @@ cc_defaults { ":BtaDmSources", ":TestCommonMockFunctions", ":TestMockAndroidHardware", - ":TestMockCommon", ":TestMockFrameworks", ":TestMockHci", ":TestMockUdrv", @@ -76,6 +75,7 @@ cc_defaults { "libbt-audio-hal-interface", "libbt-bta", "libbt-bta-core", + "libbt-common", "libbt-hci", "libbt-sbc-decoder", "libbt-sbc-encoder", @@ -118,10 +118,6 @@ cc_test { "gatt/gatt_unittest.cc", ], static_libs: [ - "android.hardware.bluetooth@1.0", - "android.hardware.bluetooth@1.1", - "android.hardware.common-V2-ndk", - "android.hardware.common.fmq-V1-ndk", "libbluetooth_crypto_toolbox", "libbluetooth_gd", "libbt-btu-main-thread", @@ -129,9 +125,21 @@ cc_test { "libbt_shim_bridge", "libchrome", "libevent", + "libprotobuf-cpp-lite", ], shared_libs: [ "server_configurable_flags", ], + target: { + android: { + static_libs: [ + "android.hardware.bluetooth@1.0", + "android.hardware.bluetooth@1.1", + "android.hardware.common-V2-ndk", + "android.hardware.common.fmq-V1-ndk", + ], + }, + host: {}, + }, cflags: ["-Wno-unused-parameter"], }