OSDN Git Service

Introduce bta/test mocks and fakes
authorChris Manton <cmanton@google.com>
Mon, 8 Feb 2021 04:26:22 +0000 (20:26 -0800)
committerChris Manton <cmanton@google.com>
Tue, 16 Feb 2021 16:27:18 +0000 (08:27 -0800)
Towards testable code

Bug: 176960731
Tag: #refactor
Test: gd/cert/run

Change-Id: I0527f4daf7d03d12a05975fa9fd01a06bd2105e5

32 files changed:
bta/Android.bp
bta/test/bta_dm_test.cc [new file with mode: 0644]
bta/test/common/fake_osi.cc [new file with mode: 0644]
bta/test/common/fake_osi.h [new file with mode: 0644]
bta/test/common/mock_btif_co_bta_dm_co.cc [new file with mode: 0644]
bta/test/common/mock_btif_co_bta_hh_co.cc [new file with mode: 0644]
bta/test/common/mock_btif_debug_conn.cc [new file with mode: 0644]
bta/test/common/mock_btif_dm.cc [new file with mode: 0644]
bta/test/common/mock_btif_stack_manager.cc [new file with mode: 0644]
bta/test/common/mock_btif_storage.cc [new file with mode: 0644]
bta/test/common/mock_device_controller.cc [new file with mode: 0644]
bta/test/common/mock_device_interop.cc [new file with mode: 0644]
bta/test/common/mock_main_shim_acl.cc [new file with mode: 0644]
bta/test/common/mock_main_shim_btm_api.cc [new file with mode: 0644]
bta/test/common/mock_shim.cc [new file with mode: 0644]
bta/test/common/mock_stack_acl.cc [new file with mode: 0644]
bta/test/common/mock_stack_btm.cc [new file with mode: 0644]
bta/test/common/mock_stack_btm_ble.cc [new file with mode: 0644]
bta/test/common/mock_stack_btm_dev.cc [new file with mode: 0644]
bta/test/common/mock_stack_btm_pm.cc [new file with mode: 0644]
bta/test/common/mock_stack_btm_sco.cc [new file with mode: 0644]
bta/test/common/mock_stack_btm_sec.cc [new file with mode: 0644]
bta/test/common/mock_stack_crypto_toolbox_aes_cmac.cc [new file with mode: 0644]
bta/test/common/mock_stack_gap_ble.cc [new file with mode: 0644]
bta/test/common/mock_stack_gatt.cc [new file with mode: 0644]
bta/test/common/mock_stack_gatt_attr.cc [new file with mode: 0644]
bta/test/common/mock_stack_gatt_connection_manager.cc [new file with mode: 0644]
bta/test/common/mock_stack_hidh.cc [new file with mode: 0644]
bta/test/common/mock_stack_l2cap.cc [new file with mode: 0644]
bta/test/common/mock_stack_l2cap_ble.cc [new file with mode: 0644]
bta/test/common/mock_stack_sdp.cc [new file with mode: 0644]
bta/test/common/mock_stack_srvc_dis.cc [new file with mode: 0644]

index 2d52862..f18e0cc 100644 (file)
@@ -153,6 +153,80 @@ cc_test {
     ],
 }
 
+cc_test {
+    name: "bt_host_test_bta",
+    defaults: ["fluoride_bta_defaults"],
+    test_suites: ["device-tests"],
+    host_supported: true,
+    include_dirs: [
+        "system/bt",
+    ],
+    srcs: [
+        "dm/bta_dm_act.cc",
+        "dm/bta_dm_cfg.cc",
+        "dm/bta_dm_ci.cc",
+        "dm/bta_dm_main.cc",
+        "dm/bta_dm_pm.cc",
+        "gatt/bta_gattc_act.cc",
+        "gatt/bta_gattc_api.cc",
+        "gatt/bta_gattc_cache.cc",
+        "gatt/bta_gattc_main.cc",
+        "gatt/bta_gattc_queue.cc",
+        "gatt/bta_gattc_utils.cc",
+        "gatt/database.cc",
+        "gatt/database_builder.cc",
+        "hh/bta_hh_act.cc",
+        "hh/bta_hh_cfg.cc",
+        "hh/bta_hh_le.cc",
+        "hh/bta_hh_main.cc",
+        "hh/bta_hh_utils.cc",
+        "sys/bta_sys_conn.cc",
+        "sys/bta_sys_main.cc",
+        "test/bta_dm_test.cc",
+        "test/common/fake_osi.cc",
+        "test/common/mock_btif_co_bta_dm_co.cc",
+        "test/common/mock_btif_co_bta_hh_co.cc",
+        "test/common/mock_btif_debug_conn.cc",
+        "test/common/mock_btif_dm.cc",
+        "test/common/mock_btif_stack_manager.cc",
+        "test/common/mock_btif_storage.cc",
+        "test/common/mock_device_controller.cc",
+        "test/common/mock_device_interop.cc",
+        "test/common/mock_main_shim_acl.cc",
+        "test/common/mock_main_shim_btm_api.cc",
+        "test/common/mock_shim.cc",
+        "test/common/mock_stack_acl.cc",
+        "test/common/mock_stack_btm.cc",
+        "test/common/mock_stack_btm_ble.cc",
+        "test/common/mock_stack_btm_dev.cc",
+        "test/common/mock_stack_btm_pm.cc",
+        "test/common/mock_stack_btm_sco.cc",
+        "test/common/mock_stack_btm_sec.cc",
+        "test/common/mock_stack_crypto_toolbox_aes_cmac.cc",
+        "test/common/mock_stack_gap_ble.cc",
+        "test/common/mock_stack_gatt.cc",
+        "test/common/mock_stack_gatt_attr.cc",
+        "test/common/mock_stack_gatt_connection_manager.cc",
+        "test/common/mock_stack_hidh.cc",
+        "test/common/mock_stack_l2cap.cc",
+        "test/common/mock_stack_l2cap_ble.cc",
+        "test/common/mock_stack_sdp.cc",
+        "test/common/mock_stack_srvc_dis.cc",
+    ],
+    shared_libs: [
+        "libcrypto",
+        "liblog",
+        "libprotobuf-cpp-lite",
+    ],
+    static_libs: [
+        "libbluetooth-types",
+        "libbt-common",
+        "libbt-protos-lite",
+        "libbtcore",
+        "libgmock",
+    ],
+}
+
 // bta hf client add record tests for target
 // ========================================================
 cc_test {
diff --git a/bta/test/bta_dm_test.cc b/bta/test/bta_dm_test.cc
new file mode 100644 (file)
index 0000000..321ee28
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 <base/bind.h>
+#include <base/location.h>
+#include <gtest/gtest.h>
+
+#include "bta/dm/bta_dm_int.h"
+#include "bta/hf_client/bta_hf_client_int.h"
+#include "bta/include/bta_hf_client_api.h"
+#include "common/message_loop_thread.h"
+
+std::map<std::string, int> mock_function_count_map;
+
+bt_status_t do_in_main_thread_delayed(const base::Location& from_here,
+                                      base::OnceClosure task,
+                                      const base::TimeDelta& delay) {
+  return BT_STATUS_SUCCESS;
+}
+
+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, ...) {}
+
+namespace base {
+class MessageLoop;
+}  // namespace base
+bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }
+
+namespace {
+constexpr uint8_t kUnusedTimer = BTA_ID_MAX;
+}  // namespace
+
+class BtaDmTest : public testing::Test {
+ protected:
+  void SetUp() override {
+    mock_function_count_map.clear();
+
+    bta_dm_init_cb();
+
+    for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
+      for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
+        bta_dm_cb.pm_timer[i].srvc_id[j] = kUnusedTimer;
+      }
+    }
+  }
+  void TearDown() override { bta_dm_deinit_cb(); }
+};
+
+TEST_F(BtaDmTest, nop) {
+  bool status = true;
+  ASSERT_EQ(true, status);
+}
diff --git a/bta/test/common/fake_osi.cc b/bta/test/common/fake_osi.cc
new file mode 100644 (file)
index 0000000..b6842ef
--- /dev/null
@@ -0,0 +1,645 @@
+/*
+ * 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
+ */
+
+#include <list>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "osi/src/compat.cc"  // For strlcpy
+
+#include "osi/include/alarm.h"
+#include "osi/include/allocator.h"
+#include "osi/include/array.h"
+#include "osi/include/buffer.h"
+#include "osi/include/config.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/future.h"
+#include "osi/include/hash_map_utils.h"
+#include "osi/include/list.h"
+#include "osi/include/log.h"
+#include "osi/include/osi.h"
+#include "osi/include/reactor.h"
+#include "osi/include/ringbuffer.h"
+#include "osi/include/semaphore.h"
+#include "osi/include/socket.h"
+#include "osi/include/thread.h"
+#include "osi/include/wakelock.h"
+#include "test/common/fake_osi.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+std::list<entry_t>::iterator section_t::Find(const std::string& key) {
+  mock_function_count_map[__func__]++;
+  return std::find_if(
+      entries.begin(), entries.end(),
+      [&key](const entry_t& entry) { return entry.key == key; });
+}
+std::list<section_t>::iterator config_t::Find(const std::string& section) {
+  mock_function_count_map[__func__]++;
+  return std::find_if(
+      sections.begin(), sections.end(),
+      [&section](const section_t& sec) { return sec.name == section; });
+}
+
+bool checksum_save(const std::string& checksum, const std::string& filename) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool config_get_bool(const config_t& config, const std::string& section,
+                     const std::string& key, bool def_value) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool config_has_key(const config_t& config, const std::string& section,
+                    const std::string& key) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool config_has_section(const config_t& config, const std::string& section) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool config_remove_key(config_t* config, const std::string& section,
+                       const std::string& key) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool config_remove_section(config_t* config, const std::string& section) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool config_save(const config_t& config, const std::string& filename) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool config_t::Has(const std::string& key) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool section_t::Has(const std::string& key) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+const std::string* config_get_string(const config_t& config,
+                                     const std::string& section,
+                                     const std::string& key,
+                                     const std::string* def_value) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+int config_get_int(const config_t& config, const std::string& section,
+                   const std::string& key, int def_value) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+std::string checksum_read(const char* filename) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+std::unique_ptr<config_t> config_new(const char* filename) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+std::unique_ptr<config_t> config_new_clone(const config_t& src) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+std::unique_ptr<config_t> config_new_empty(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint64_t config_get_uint64(const config_t& config, const std::string& section,
+                           const std::string& key, uint64_t def_value) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void config_set_bool(config_t* config, const std::string& section,
+                     const std::string& key, bool value) {
+  mock_function_count_map[__func__]++;
+}
+void config_set_int(config_t* config, const std::string& section,
+                    const std::string& key, int value) {
+  mock_function_count_map[__func__]++;
+}
+void config_set_string(config_t* config, const std::string& section,
+                       const std::string& key, const std::string& value) {
+  mock_function_count_map[__func__]++;
+}
+void config_set_uint64(config_t* config, const std::string& section,
+                       const std::string& key, uint64_t value) {
+  mock_function_count_map[__func__]++;
+}
+void section_t::Set(std::string key, std::string value) {
+  mock_function_count_map[__func__]++;
+}
+
+bool array_append_ptr(array_t* array, void* data) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool array_append_value(array_t* array, uint32_t value) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+size_t array_length(const array_t* array) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void array_free(array_t* array) { mock_function_count_map[__func__]++; }
+void* array_at(const array_t* array, size_t index) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* array_ptr(const array_t* array) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+
+size_t allocation_tracker_expect_no_allocations(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t allocation_tracker_resize_for_canary(size_t size) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void allocation_tracker_reset(void) { mock_function_count_map[__func__]++; }
+void allocation_tracker_uninit(void) { mock_function_count_map[__func__]++; }
+void osi_allocator_debug_dump(int fd) { mock_function_count_map[__func__]++; }
+void* allocation_tracker_notify_alloc(uint8_t allocator_id, void* ptr,
+                                      size_t requested_size) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* allocation_tracker_notify_free(UNUSED_ATTR uint8_t allocator_id,
+                                     void* ptr) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+
+bool reactor_change_registration(reactor_object_t* object,
+                                 void (*read_ready)(void* context),
+                                 void (*write_ready)(void* context)) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+reactor_object_t* reactor_register(reactor_t* reactor, int fd, void* context,
+                                   void (*read_ready)(void* context),
+                                   void (*write_ready)(void* context)) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+reactor_status_t reactor_run_once(reactor_t* reactor) {
+  mock_function_count_map[__func__]++;
+  return REACTOR_STATUS_DONE;
+}
+reactor_status_t reactor_start(reactor_t* reactor) {
+  mock_function_count_map[__func__]++;
+  return REACTOR_STATUS_DONE;
+}
+reactor_t* reactor_new(void) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void reactor_free(reactor_t* reactor) { mock_function_count_map[__func__]++; }
+void reactor_stop(reactor_t* reactor) { mock_function_count_map[__func__]++; }
+void reactor_unregister(reactor_object_t* obj) {
+  mock_function_count_map[__func__]++;
+}
+
+future_t* future_new(void) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+future_t* future_new_immediate(void* value) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void future_ready(future_t* future, void* value) {
+  mock_function_count_map[__func__]++;
+}
+void mutex_global_lock(void) { mock_function_count_map[__func__]++; }
+void mutex_global_unlock(void) { mock_function_count_map[__func__]++; }
+void* future_await(future_t* future) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+
+bool thread_is_self(const thread_t* thread) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool thread_post(thread_t* thread, thread_fn func, void* context) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool thread_set_priority(thread_t* thread, int priority) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool thread_set_rt_priority(thread_t* thread, int priority) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+const char* thread_name(const thread_t* thread) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+reactor_t* thread_get_reactor(const thread_t* thread) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+thread_t* thread_new(const char* name) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+thread_t* thread_new_sized(const char* name, size_t work_queue_capacity) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void thread_free(thread_t* thread) { mock_function_count_map[__func__]++; }
+void thread_join(thread_t* thread) { mock_function_count_map[__func__]++; }
+void thread_stop(thread_t* thread) { mock_function_count_map[__func__]++; }
+
+char* osi_strdup(const char* str) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+char* osi_strndup(const char* str, size_t len) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void osi_free(void* ptr) { mock_function_count_map[__func__]++; }
+void osi_free_and_reset(void** p_ptr) { mock_function_count_map[__func__]++; }
+void* osi_calloc(size_t size) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* osi_malloc(size_t size) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+
+bool fixed_queue_is_empty(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool fixed_queue_try_enqueue(fixed_queue_t* queue, void* data) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+fixed_queue_t* fixed_queue_new(size_t capacity) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+int fixed_queue_get_dequeue_fd(const fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+int fixed_queue_get_enqueue_fd(const fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+list_t* fixed_queue_get_list(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+size_t fixed_queue_capacity(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t fixed_queue_length(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void fixed_queue_enqueue(fixed_queue_t* queue, void* data) {
+  mock_function_count_map[__func__]++;
+}
+void fixed_queue_flush(fixed_queue_t* queue, fixed_queue_free_cb free_cb) {
+  mock_function_count_map[__func__]++;
+}
+void fixed_queue_free(fixed_queue_t* queue, fixed_queue_free_cb free_cb) {
+  mock_function_count_map[__func__]++;
+}
+void fixed_queue_register_dequeue(fixed_queue_t* queue, reactor_t* reactor,
+                                  fixed_queue_cb ready_cb, void* context) {
+  mock_function_count_map[__func__]++;
+}
+void fixed_queue_unregister_dequeue(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+}
+void* fixed_queue_dequeue(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* fixed_queue_try_dequeue(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* fixed_queue_try_peek_first(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* fixed_queue_try_peek_last(fixed_queue_t* queue) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* fixed_queue_try_remove_from_queue(fixed_queue_t* queue, void* data) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+
+alarm_t* alarm_new(const char* name) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+alarm_t* alarm_new_periodic(const char* name) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+bool alarm_is_scheduled(const alarm_t* alarm) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+uint64_t alarm_get_remaining_ms(const alarm_t* alarm) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void alarm_cancel(alarm_t* alarm) { mock_function_count_map[__func__]++; }
+void alarm_cleanup(void) { mock_function_count_map[__func__]++; }
+void alarm_debug_dump(int fd) { mock_function_count_map[__func__]++; }
+void alarm_free(alarm_t* alarm) { mock_function_count_map[__func__]++; }
+void alarm_set(alarm_t* alarm, uint64_t interval_ms, alarm_callback_t cb,
+               void* data) {
+  mock_function_count_map[__func__]++;
+}
+
+struct fake_osi_alarm_set_on_mloop fake_osi_alarm_set_on_mloop_;
+void alarm_set_on_mloop(alarm_t* alarm, uint64_t interval_ms,
+                        alarm_callback_t cb, void* data) {
+  mock_function_count_map[__func__]++;
+  fake_osi_alarm_set_on_mloop_.interval_ms = interval_ms;
+  fake_osi_alarm_set_on_mloop_.cb = cb;
+  fake_osi_alarm_set_on_mloop_.data = data;
+}
+
+int osi_rand(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+
+buffer_t* buffer_new_ref(const buffer_t* buf) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+buffer_t* buffer_new_slice(const buffer_t* buf, size_t slice_size) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+size_t buffer_length(const buffer_t* buf) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void buffer_free(buffer_t* buffer) { mock_function_count_map[__func__]++; }
+void* buffer_ptr(const buffer_t* buf) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+
+bool socket_listen(const socket_t* socket, port_t port) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+socket_t* socket_accept(const socket_t* socket) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+socket_t* socket_new(void) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+socket_t* socket_new_from_fd(int fd) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+ssize_t socket_bytes_available(const socket_t* socket) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+ssize_t socket_read(const socket_t* socket, void* buf, size_t count) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+ssize_t socket_write(const socket_t* socket, const void* buf, size_t count) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+ssize_t socket_write_and_transfer_fd(const socket_t* socket, const void* buf,
+                                     size_t count, int fd) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void socket_free(socket_t* socket) { mock_function_count_map[__func__]++; }
+void socket_register(socket_t* socket, reactor_t* reactor, void* context,
+                     socket_cb read_cb, socket_cb write_cb) {
+  mock_function_count_map[__func__]++;
+}
+void socket_unregister(socket_t* socket) {
+  mock_function_count_map[__func__]++;
+}
+
+bool list_append(list_t* list, void* data) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool list_contains(const list_t* list, const void* data) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool list_insert_after(list_t* list, list_node_t* prev_node, void* data) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool list_is_empty(const list_t* list) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool list_prepend(list_t* list, void* data) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool list_remove(list_t* list, void* data) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+list_node_t* list_back_node(const list_t* list) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+list_node_t* list_begin(const list_t* list) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+list_node_t* list_end(UNUSED_ATTR const list_t* list) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+list_node_t* list_foreach(const list_t* list, list_iter_cb callback,
+                          void* context) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+list_node_t* list_next(const list_node_t* node) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+list_t* list_new(list_free_cb callback) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+list_t* list_new_internal(list_free_cb callback,
+                          const allocator_t* zeroed_allocator) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+size_t list_length(const list_t* list) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void list_clear(list_t* list) { mock_function_count_map[__func__]++; }
+void list_free(list_t* list) { mock_function_count_map[__func__]++; }
+void* list_back(const list_t* list) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* list_front(const list_t* list) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void* list_node(const list_node_t* node) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+
+int osi_socket_local_client(const char* name, int namespaceId, int type) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+int osi_socket_local_client_connect(int fd, const char* name, int namespaceId,
+                                    int type UNUSED_ATTR) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+int osi_socket_local_server_bind(int s, const char* name, int namespaceId) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+int osi_socket_make_sockaddr_un(const char* name, int namespaceId,
+                                struct sockaddr_un* p_addr, socklen_t* alen) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+
+size_t ringbuffer_available(const ringbuffer_t* rb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t ringbuffer_delete(ringbuffer_t* rb, size_t length) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t ringbuffer_insert(ringbuffer_t* rb, const uint8_t* p, size_t length) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t ringbuffer_peek(const ringbuffer_t* rb, off_t offset, uint8_t* p,
+                       size_t length) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t ringbuffer_pop(ringbuffer_t* rb, uint8_t* p, size_t length) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t ringbuffer_size(const ringbuffer_t* rb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void ringbuffer_free(ringbuffer_t* rb) { mock_function_count_map[__func__]++; }
+
+bool osi_property_get_bool(const char* key, bool default_value) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+int osi_property_get(const char* key, char* value, const char* default_value) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+int osi_property_set(const char* key, const char* value) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+int32_t osi_property_get_int32(const char* key, int32_t default_value) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+
+bool semaphore_try_wait(semaphore_t* semaphore) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+int semaphore_get_fd(const semaphore_t* semaphore) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+semaphore_t* semaphore_new(unsigned int value) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void semaphore_free(semaphore_t* semaphore) {
+  mock_function_count_map[__func__]++;
+}
+void semaphore_post(semaphore_t* semaphore) {
+  mock_function_count_map[__func__]++;
+}
+void semaphore_wait(semaphore_t* semaphore) {
+  mock_function_count_map[__func__]++;
+}
+
+bool wakelock_acquire(void) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool wakelock_release(void) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+void wakelock_cleanup(void) { mock_function_count_map[__func__]++; }
+void wakelock_debug_dump(int fd) { mock_function_count_map[__func__]++; }
+void wakelock_set_os_callouts(bt_os_callouts_t* callouts) {
+  mock_function_count_map[__func__]++;
+}
+void wakelock_set_paths(const char* lock_path, const char* unlock_path) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/fake_osi.h b/bta/test/common/fake_osi.h
new file mode 100644 (file)
index 0000000..9056d58
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <cstdint>
+#include "osi/include/alarm.h"
+
+struct fake_osi_alarm_set_on_mloop {
+  uint64_t interval_ms{0};
+  alarm_callback_t cb{};
+  void* data{nullptr};
+};
diff --git a/bta/test/common/mock_btif_co_bta_dm_co.cc b/bta/test/common/mock_btif_co_bta_dm_co.cc
new file mode 100644 (file)
index 0000000..e244296
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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
+ */
+
+#include <cstdint>
+
+#include "bta/include/bta_api.h"
+#include "bta/sys/bta_sys.h"
+#include "internal_include/bte_appl.h"
+#include "osi/include/osi.h"  // UNUSED_ATTR
+#include "stack/include/btm_api_types.h"
+
+tBTE_APPL_CFG bte_appl_cfg = {
+    BTA_LE_AUTH_REQ_SC_MITM_BOND,  // Authentication requirements
+    BTM_IO_CAP_UNKNOWN, BTM_BLE_INITIATOR_KEY_SIZE, BTM_BLE_RESPONDER_KEY_SIZE,
+    BTM_BLE_MAX_KEY_SIZE};
+
+bool bta_dm_co_get_compress_memory(UNUSED_ATTR tBTA_SYS_ID id,
+                                   UNUSED_ATTR uint8_t** memory_p,
+                                   UNUSED_ATTR uint32_t* memory_size) {
+  return true;
+}
diff --git a/bta/test/common/mock_btif_co_bta_hh_co.cc b/bta/test/common/mock_btif_co_bta_hh_co.cc
new file mode 100644 (file)
index 0000000..8378255
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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:12
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "bta/include/bta_hh_api.h"
+#include "bta/include/bta_hh_co.h"
+#include "btif/include/btif_hh.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+int bta_hh_co_write(int fd, uint8_t* rpt, uint16_t len) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTA_HH_RPT_CACHE_ENTRY* bta_hh_le_co_cache_load(const RawAddress& remote_bda,
+                                                 uint8_t* p_num_rpt,
+                                                 UNUSED_ATTR uint8_t app_id) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void bta_hh_co_close(uint8_t dev_handle, uint8_t app_id) {
+  mock_function_count_map[__func__]++;
+}
+void bta_hh_co_data(uint8_t dev_handle, uint8_t* p_rpt, uint16_t len,
+                    tBTA_HH_PROTO_MODE mode, uint8_t sub_class,
+                    uint8_t ctry_code, UNUSED_ATTR const RawAddress& peer_addr,
+                    uint8_t app_id) {
+  mock_function_count_map[__func__]++;
+}
+void bta_hh_co_destroy(int fd) { mock_function_count_map[__func__]++; }
+void bta_hh_co_get_rpt_rsp(uint8_t dev_handle, uint8_t status, uint8_t* p_rpt,
+                           uint16_t len) {
+  mock_function_count_map[__func__]++;
+}
+void bta_hh_co_open(uint8_t dev_handle, uint8_t sub_class,
+                    tBTA_HH_ATTR_MASK attr_mask, uint8_t app_id) {
+  mock_function_count_map[__func__]++;
+}
+void bta_hh_co_send_hid_info(btif_hh_device_t* p_dev, const char* dev_name,
+                             uint16_t vendor_id, uint16_t product_id,
+                             uint16_t version, uint8_t ctry_code, int dscp_len,
+                             uint8_t* p_dscp) {
+  mock_function_count_map[__func__]++;
+}
+void bta_hh_co_set_rpt_rsp(uint8_t dev_handle, uint8_t status) {
+  mock_function_count_map[__func__]++;
+}
+void bta_hh_le_co_reset_rpt_cache(const RawAddress& remote_bda,
+                                  UNUSED_ATTR uint8_t app_id) {
+  mock_function_count_map[__func__]++;
+}
+void bta_hh_le_co_rpt_info(const RawAddress& remote_bda,
+                           tBTA_HH_RPT_CACHE_ENTRY* p_entry,
+                           UNUSED_ATTR uint8_t app_id) {
+  mock_function_count_map[__func__]++;
+}
+void uhid_set_non_blocking(int fd) { mock_function_count_map[__func__]++; }
diff --git a/bta/test/common/mock_btif_debug_conn.cc b/bta/test/common/mock_btif_debug_conn.cc
new file mode 100644 (file)
index 0000000..d262760
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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:2
+ */
+
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "btif/include/btif_debug_conn.h"
+#include "stack/include/gatt_api.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+void btif_debug_conn_dump(int fd) { mock_function_count_map[__func__]++; }
+void btif_debug_conn_state(const RawAddress& bda,
+                           const btif_debug_conn_state_t state,
+                           const tGATT_DISCONN_REASON disconnect_reason) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_btif_dm.cc b/bta/test/common/mock_btif_dm.cc
new file mode 100644 (file)
index 0000000..e6d2587
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * 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:51
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "bta/include/bta_api.h"
+#include "include/hardware/bluetooth.h"
+#include "internal_include/bte_appl.h"
+#include "types/raw_address.h"
+
+struct uid_set_t;
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool btif_dm_pairing_is_busy() {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool check_cod_hid(const RawAddress* remote_bdaddr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool check_sdp_bl(const RawAddress* remote_bdaddr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bt_status_t btif_dm_get_adapter_property(bt_property_t* prop) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id,
+                                            bool b_enable) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+uint16_t btif_dm_get_connection_state(const RawAddress* bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void BTIF_dm_disable() { mock_function_count_map[__func__]++; }
+void BTIF_dm_enable() { mock_function_count_map[__func__]++; }
+void BTIF_dm_on_hw_error() { mock_function_count_map[__func__]++; }
+void BTIF_dm_report_inquiry_status_change(uint8_t status) {
+  mock_function_count_map[__func__]++;
+}
+void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data) {
+  mock_function_count_map[__func__]++;
+}
+void btif_ble_receiver_test(uint8_t rx_freq) {
+  mock_function_count_map[__func__]++;
+}
+void btif_ble_test_end() { mock_function_count_map[__func__]++; }
+void btif_ble_transmitter_test(uint8_t tx_freq, uint8_t test_data_len,
+                               uint8_t packet_payload) {
+  mock_function_count_map[__func__]++;
+}
+void btif_debug_bond_event_dump(int fd) { mock_function_count_map[__func__]++; }
+void btif_dm_ble_sec_req_evt(tBTA_DM_BLE_SEC_REQ* p_ble_req, bool is_consent) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_cancel_bond(const RawAddress bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_cancel_discovery(void) { mock_function_count_map[__func__]++; }
+void btif_dm_cleanup(void) { mock_function_count_map[__func__]++; }
+void btif_dm_create_bond(const RawAddress bd_addr, int transport) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_create_bond_out_of_band(const RawAddress bd_addr, int transport,
+                                     const bt_out_of_band_data_t oob_data) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_enable_service(tBTA_SERVICE_ID service_id, bool enable) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask,
+                                Octet16* p_er,
+                                tBTA_BLE_LOCAL_ID_KEYS* p_id_keys) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_get_remote_services(RawAddress remote_addr, const int transport) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_hh_open_failed(RawAddress* bdaddr) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_init(uid_set_t* set) { mock_function_count_map[__func__]++; }
+void btif_dm_load_ble_local_keys(void) { mock_function_count_map[__func__]++; }
+void btif_dm_on_disable() { mock_function_count_map[__func__]++; }
+void btif_dm_pin_reply(const RawAddress bd_addr, uint8_t accept,
+                       uint8_t pin_len, bt_pin_code_t pin_code) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_proc_io_req(tBTM_AUTH_REQ* p_auth_req, bool is_orig) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_proc_io_rsp(UNUSED_ATTR const RawAddress& bd_addr,
+                         tBTM_IO_CAP io_cap, UNUSED_ATTR tBTM_OOB_DATA oob_data,
+                         tBTM_AUTH_REQ auth_req) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_read_energy_info() { mock_function_count_map[__func__]++; }
+void btif_dm_remove_ble_bonding_keys(void) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_remove_bond(const RawAddress bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_save_ble_bonding_keys(RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_set_oob_for_io_req(tBTM_OOB_DATA* p_has_oob_data) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_set_oob_for_le_io_req(const RawAddress& bd_addr,
+                                   tBTM_OOB_DATA* p_has_oob_data,
+                                   tBTM_LE_AUTH_REQ* p_auth_req) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_ssp_reply(const RawAddress bd_addr, bt_ssp_variant_t variant,
+                       uint8_t accept) {
+  mock_function_count_map[__func__]++;
+}
+void btif_dm_start_discovery(void) { mock_function_count_map[__func__]++; }
+void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr,
+                                          BD_NAME bd_name,
+                                          tBT_DEVICE_TYPE dev_type) {
+  mock_function_count_map[__func__]++;
+}
+
+bool btif_dm_get_smp_config(tBTE_APPL_CFG* p_cfg) {
+  mock_function_count_map[__func__]++;
+  return true;
+}
+
+bool btif_dm_proc_rmt_oob(const RawAddress& bd_addr, Octet16* p_c,
+                          Octet16* p_r) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+
+void btif_dm_proc_loc_oob(bool valid, const Octet16& c, const Octet16& r) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_btif_stack_manager.cc b/bta/test/common/mock_btif_stack_manager.cc
new file mode 100644 (file)
index 0000000..bc07077
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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
+ */
+
+#include "osi/include/future.h"
+
+static future_t* hack_future;
+
+future_t* stack_manager_get_hack_future() { return hack_future; }
diff --git a/bta/test/common/mock_btif_storage.cc b/bta/test/common/mock_btif_storage.cc
new file mode 100644 (file)
index 0000000..8c09ad9
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * 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:44
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "bta/include/bta_hearing_aid_api.h"
+#include "stack/include/bt_types.h"
+#include "types/ble_address_with_type.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+Octet16 btif_storage_get_gatt_cl_db_hash(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  Octet16 octet;
+  return octet;
+}
+bool btif_has_ble_keys(const std::string& bdstr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btif_storage_get_hearing_aid_prop(
+    const RawAddress& address, uint8_t* capabilities, uint64_t* hi_sync_id,
+    uint16_t* render_delay, uint16_t* preparation_delay, uint16_t* codecs) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btif_storage_get_stored_remote_name(const RawAddress& bd_addr,
+                                         char* name) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btif_storage_is_restricted_device(const RawAddress* remote_bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bt_status_t btif_storage_add_ble_bonding_key(RawAddress* remote_bd_addr,
+                                             const uint8_t* key,
+                                             uint8_t key_type,
+                                             uint8_t key_length) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_add_ble_local_key(const Octet16& key,
+                                           uint8_t key_type) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_add_bonded_device(RawAddress* remote_bd_addr,
+                                           LinkKey link_key, uint8_t key_type,
+                                           uint8_t pin_length) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_add_hid_device_info(
+    RawAddress* remote_bd_addr, uint16_t attr_mask, uint8_t sub_class,
+    uint8_t app_id, uint16_t vendor_id, uint16_t product_id, uint16_t version,
+    uint8_t ctry_code, uint16_t ssr_max_latency, uint16_t ssr_min_tout,
+    uint16_t dl_len, uint8_t* dsc_list) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_add_remote_device(const RawAddress* remote_bd_addr,
+                                           uint32_t num_properties,
+                                           bt_property_t* properties) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_get_adapter_property(bt_property_t* property) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_get_ble_bonding_key(const RawAddress& remote_bd_addr,
+                                             uint8_t key_type,
+                                             uint8_t* key_value,
+                                             int key_length) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_get_ble_local_key(uint8_t key_type,
+                                           Octet16* key_value) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_get_remote_addr_type(const RawAddress* remote_bd_addr,
+                                              tBLE_ADDR_TYPE* addr_type) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_get_remote_device_property(
+    const RawAddress* remote_bd_addr, bt_property_t* property) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_load_bonded_devices(void) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_load_bonded_hid_info(void) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_load_hidd(void) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_remove_ble_bonding_keys(
+    const RawAddress* remote_bd_addr) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_remove_ble_local_keys(void) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_remove_bonded_device(
+    const RawAddress* remote_bd_addr) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_remove_hid_info(const RawAddress& remote_bd_addr) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_remove_hidd(RawAddress* remote_bd_addr) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_set_adapter_property(bt_property_t* property) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_set_hidd(const RawAddress& remote_bd_addr) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_set_remote_addr_type(const RawAddress* remote_bd_addr,
+                                              tBLE_ADDR_TYPE addr_type) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+bt_status_t btif_storage_set_remote_device_property(
+    const RawAddress* remote_bd_addr, bt_property_t* property) {
+  mock_function_count_map[__func__]++;
+  return BT_STATUS_SUCCESS;
+}
+void btif_storage_add_hearing_aid(const HearingDevice& dev_info) {
+  mock_function_count_map[__func__]++;
+}
+int btif_storage_get_num_bonded_devices(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+size_t btif_split_uuids_string(const char* str, bluetooth::Uuid* p_uuid,
+                               size_t max_uuids) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t btif_storage_get_gatt_cl_supp_feat(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t btif_storage_get_local_io_caps() {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t btif_storage_get_local_io_caps_ble() {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void btif_storage_load_bonded_hearing_aids() {
+  mock_function_count_map[__func__]++;
+}
+void btif_storage_remove_gatt_cl_db_hash(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void btif_storage_remove_gatt_cl_supp_feat(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void btif_storage_remove_hearing_aid(const RawAddress& address) {
+  mock_function_count_map[__func__]++;
+}
+void btif_storage_set_gatt_cl_db_hash(const RawAddress& bd_addr, Octet16 hash) {
+  mock_function_count_map[__func__]++;
+}
+void btif_storage_set_gatt_cl_supp_feat(const RawAddress& bd_addr,
+                                        uint8_t feat) {
+  mock_function_count_map[__func__]++;
+}
+void btif_storage_set_hearing_aid_acceptlist(const RawAddress& address,
+                                             bool add_to_acceptlist) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_device_controller.cc b/bta/test/common/mock_device_controller.cc
new file mode 100644 (file)
index 0000000..7b0cbbc
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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 <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "device/include/controller.h"
+#include "hci/include/hci_layer.h"
+#include "hci/include/hci_packet_factory.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+const controller_t* controller_get_interface() {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+const controller_t* controller_get_test_interface(
+    const hci_t* hci_interface,
+    const hci_packet_factory_t* packet_factory_interface,
+    const hci_packet_parser_t* packet_parser_interface) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
diff --git a/bta/test/common/mock_device_interop.cc b/bta/test/common/mock_device_interop.cc
new file mode 100644 (file)
index 0000000..7afb53a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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:6
+ */
+
+#include <cstddef>
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "device/include/interop.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool interop_match_addr(const interop_feature_t feature,
+                        const RawAddress* addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool interop_match_name(const interop_feature_t feature, const char* name) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+void interop_database_add(uint16_t feature, const RawAddress* addr,
+                          size_t length) {
+  mock_function_count_map[__func__]++;
+}
+void interop_database_clear() { mock_function_count_map[__func__]++; }
diff --git a/bta/test/common/mock_main_shim_acl.cc b/bta/test/common/mock_main_shim_acl.cc
new file mode 100644 (file)
index 0000000..96b175d
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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:7
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "main/shim/acl_api.h"
+#include "types/ble_address_with_type.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+void bluetooth::shim::ACL_CreateClassicConnection(
+    const RawAddress& raw_address) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::ACL_CancelLeConnection(
+    const tBLE_BD_ADDR& legacy_address_with_type) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::ACL_ConfigureLePrivacy(bool is_le_privacy_enabled) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::ACL_CreateLeConnection(
+    const tBLE_BD_ADDR& legacy_address_with_type) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::ACL_Disconnect(uint16_t handle, bool is_classic,
+                                     tHCI_STATUS reason) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::ACL_Shutdown() { mock_function_count_map[__func__]++; }
+void bluetooth::shim::ACL_WriteData(uint16_t handle, const BT_HDR* p_buf) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_main_shim_btm_api.cc b/bta/test/common/mock_main_shim_btm_api.cc
new file mode 100644 (file)
index 0000000..e48b6e0
--- /dev/null
@@ -0,0 +1,439 @@
+/*
+ * 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:85
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include <base/bind.h>
+#include <base/callback.h>
+#include "main/shim/btm_api.h"
+#include "stack/include/btm_ble_api_types.h"
+#include "types/bt_transport.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+Octet16 octet16;
+
+bool bluetooth::shim::BTM_BleDataSignature(const RawAddress& bd_addr,
+                                           uint8_t* p_text, uint16_t len,
+                                           BLE_SIGNATURE signature) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_BleLocalPrivacyEnabled(void) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_BleSecurityProcedureIsRunning(
+    const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_BleVerifySignature(const RawAddress& bd_addr,
+                                             uint8_t* p_orig, uint16_t len,
+                                             uint32_t counter,
+                                             uint8_t* p_comp) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_GetLeSecurityState(const RawAddress& bd_addr,
+                                             uint8_t* p_le_dev_sec_flags,
+                                             uint8_t* p_le_key_size) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_HasEirService(const uint32_t* p_eir_uuid,
+                                        uint16_t uuid16) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_ReadConnectedTransportAddress(
+    RawAddress* remote_bda, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_ReadRemoteConnectionAddr(
+    const RawAddress& pseudo_addr, RawAddress& conn_addr,
+    tBLE_ADDR_TYPE* p_addr_type) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_SecAddDevice(const RawAddress& bd_addr,
+                                       DEV_CLASS dev_class, BD_NAME bd_name,
+                                       uint8_t* features, LinkKey* link_key,
+                                       uint8_t key_type, uint8_t pin_length) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_SecAddRmtNameNotifyCallback(
+    tBTM_RMT_NAME_CALLBACK* p_callback) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_SecDeleteDevice(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback(
+    tBTM_RMT_NAME_CALLBACK* p_callback) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_SecRegister(const tBTM_APPL_INFO* bta_callbacks) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool bluetooth::shim::BTM_UseLeLink(const RawAddress& raw_address) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+char* bluetooth::shim::BTM_SecReadDevName(const RawAddress& address) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+const Octet16& bluetooth::shim::BTM_GetDeviceEncRoot() {
+  mock_function_count_map[__func__]++;
+  return octet16;
+}
+const Octet16& bluetooth::shim::BTM_GetDeviceDHK() {
+  mock_function_count_map[__func__]++;
+  return octet16;
+}
+const Octet16& bluetooth::shim::BTM_GetDeviceIDRoot() {
+  mock_function_count_map[__func__]++;
+  return octet16;
+}
+tBTM_EIR_SEARCH_RESULT bluetooth::shim::BTM_HasInquiryEirService(
+    tBTM_INQ_RESULTS* p_results, uint16_t uuid16) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbFirst(void) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbNext(tBTM_INQ_INFO* p_cur) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbRead(const RawAddress& p_bda) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec,
+                                            tBTM_INQ_RESULTS_CB* p_results_cb,
+                                            tBTM_CMPL_CB* p_cmpl_cb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_CancelRemoteDeviceName(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_ClearInqDb(const RawAddress* p_bda) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_ReadRemoteDeviceName(
+    const RawAddress& raw_address, tBTM_CMPL_CB* callback,
+    tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_SecBond(const RawAddress& bd_addr,
+                                         tBLE_ADDR_TYPE addr_type,
+                                         tBT_TRANSPORT transport,
+                                         int device_type) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_SecBondCancel(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_SetConnectability(uint16_t page_mode,
+                                                   uint16_t window,
+                                                   uint16_t interval) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_SetDeviceClass(DEV_CLASS dev_class) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_SetDiscoverability(uint16_t discoverable_mode,
+                                                    uint16_t window,
+                                                    uint16_t interval) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_SetEncryption(const RawAddress& bd_addr,
+                                               tBT_TRANSPORT transport,
+                                               tBTM_SEC_CALLBACK* p_callback,
+                                               void* p_ref_data,
+                                               tBTM_BLE_SEC_ACT sec_act) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_SetInquiryMode(uint8_t inquiry_mode) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb,
+                                              tBTM_CMPL_CB* p_cmpl_cb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::BTM_WriteEIR(BT_HDR* p_buff) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS bluetooth::shim::btm_sec_mx_access_request(
+    const RawAddress& bd_addr, bool is_originator,
+    uint16_t security_requirement, tBTM_SEC_CALLBACK* p_callback,
+    void* p_ref_data) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint16_t bluetooth::shim::BTM_GetHCIConnHandle(const RawAddress& remote_bda,
+                                               tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint16_t bluetooth::shim::BTM_IsInquiryActive(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t bluetooth::shim::BTM_BleGetSupportedKeySize(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t bluetooth::shim::BTM_BleMaxMultiAdvInstanceCount() {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t bluetooth::shim::BTM_GetEirSupportedServices(uint32_t* p_eir_uuid,
+                                                     uint8_t** p,
+                                                     uint8_t max_num_uuid16,
+                                                     uint8_t* p_num_uuid16) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t bluetooth::shim::BTM_GetEirUuidList(uint8_t* p_eir, size_t eir_len,
+                                            uint8_t uuid_size,
+                                            uint8_t* p_num_uuid,
+                                            uint8_t* p_uuid_list,
+                                            uint8_t max_num_uuid) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void bluetooth::shim::BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleAdvFilterParamSetup(
+    int action, tBTM_BLE_PF_FILT_INDEX filt_index,
+    std::unique_ptr<btgatt_filt_param_setup_t> p_filt_params,
+    tBTM_BLE_PF_PARAM_CB cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleEnableDisableFilterFeature(
+    uint8_t enable, tBTM_BLE_PF_STATUS_CBACK p_stat_cback) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleLoadLocalKeys(uint8_t key_type,
+                                           tBTM_BLE_LOCAL_KEYS* p_key) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleOobDataReply(const RawAddress& bd_addr,
+                                          uint8_t res, uint8_t len,
+                                          uint8_t* p_data) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleReadPhy(
+    const RawAddress& bd_addr,
+    base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleReceiverTest(uint8_t rx_freq,
+                                          tBTM_CMPL_CB* p_cmd_cmpl_cback) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleSecureConnectionOobDataReply(
+    const RawAddress& bd_addr, uint8_t* p_c, uint8_t* p_r) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleSetConnScanParams(uint32_t scan_interval,
+                                               uint32_t scan_window) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys,
+                                    uint8_t rx_phys, uint16_t phy_options) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleSetPrefConnParams(const RawAddress& bd_addr,
+                                               uint16_t min_conn_int,
+                                               uint16_t max_conn_int,
+                                               uint16_t peripheral_latency,
+                                               uint16_t supervision_tout) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleTestEnd(tBTM_CMPL_CB* p_cmd_cmpl_cback) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleTransmitterTest(uint8_t tx_freq,
+                                             uint8_t test_data_len,
+                                             uint8_t packet_payload,
+                                             tBTM_CMPL_CB* p_cmd_cmpl_cback) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_CancelInquiry(void) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_ConfirmReqReply(tBTM_STATUS res,
+                                          const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_EnableInterlacedInquiryScan() {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_EnableInterlacedPageScan() {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
+                                            tBTM_BLE_PF_FILT_INDEX filt_index,
+                                            tBLE_BD_ADDR addr,
+                                            tBTM_BLE_PF_CFG_CBACK cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index,
+                                      tBTM_BLE_PF_CFG_CBACK cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,
+                                           tBTM_BLE_PF_FILT_INDEX filt_index,
+                                           std::vector<uint8_t> name,
+                                           tBTM_BLE_PF_CFG_CBACK cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_manu_data(
+    tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_INDEX filt_index,
+    uint16_t company_id, uint16_t company_id_mask, std::vector<uint8_t> data,
+    std::vector<uint8_t> data_mask, tBTM_BLE_PF_CFG_CBACK cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_set(tBTM_BLE_PF_FILT_INDEX filt_index,
+                                    std::vector<ApcfCommand> commands,
+                                    tBTM_BLE_PF_CFG_CBACK cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,
+                                          tBTM_BLE_PF_FILT_INDEX filt_index) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_srvc_data_pattern(
+    tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_INDEX filt_index,
+    std::vector<uint8_t> data, std::vector<uint8_t> data_mask,
+    tBTM_BLE_PF_CFG_CBACK cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
+                                            tBTM_BLE_PF_FILT_INDEX filt_index,
+                                            tBTM_BLE_PF_COND_TYPE filter_type,
+                                            const bluetooth::Uuid& uuid,
+                                            tBTM_BLE_PF_LOGIC_TYPE cond_logic,
+                                            const bluetooth::Uuid& uuid_mask,
+                                            tBTM_BLE_PF_CFG_CBACK cb) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res,
+                                       uint8_t pin_len, uint8_t* p_pin) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_ReadConnectionAddr(const RawAddress& remote_bda,
+                                             RawAddress& local_conn_addr,
+                                             tBLE_ADDR_TYPE* p_addr_type) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_ReadDevInfo(const RawAddress& remote_bda,
+                                      tBT_DEVICE_TYPE* p_dev_type,
+                                      tBLE_ADDR_TYPE* p_addr_type) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_RemoteOobDataReply(tBTM_STATUS res,
+                                             const RawAddress& bd_addr,
+                                             const Octet16& c,
+                                             const Octet16& r) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_RemoveEirService(uint32_t* p_eir_uuid,
+                                           uint16_t uuid16) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_SecAddBleDevice(const RawAddress& bd_addr,
+                                          tBT_DEVICE_TYPE dev_type,
+                                          tBLE_ADDR_TYPE addr_type) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_SecAddBleKey(const RawAddress& bd_addr,
+                                       tBTM_LE_KEY_VALUE* p_le_key,
+                                       tBTM_LE_KEY_TYPE key_type) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_SecClearSecurityFlags(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::BTM_SecurityGrant(const RawAddress& bd_addr,
+                                        uint8_t res) {
+  mock_function_count_map[__func__]++;
+}
+void bluetooth::shim::SendRemoteNameRequest(const RawAddress& raw_address) {
+  mock_function_count_map[__func__]++;
+}
+void btm_api_process_extended_inquiry_result(RawAddress raw_address,
+                                             uint8_t page_scan_rep_mode,
+                                             DEV_CLASS device_class,
+                                             uint16_t clock_offset, int8_t rssi,
+                                             const uint8_t* eir_data,
+                                             size_t eir_len) {
+  mock_function_count_map[__func__]++;
+}
+void btm_api_process_inquiry_result(const RawAddress& raw_address,
+                                    uint8_t page_scan_rep_mode,
+                                    DEV_CLASS device_class,
+                                    uint16_t clock_offset) {
+  mock_function_count_map[__func__]++;
+}
+void btm_api_process_inquiry_result_with_rssi(RawAddress raw_address,
+                                              uint8_t page_scan_rep_mode,
+                                              DEV_CLASS device_class,
+                                              uint16_t clock_offset,
+                                              int8_t rssi) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_shim.cc b/bta/test/common/mock_shim.cc
new file mode 100644 (file)
index 0000000..828da52
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#define LOG_TAG "bt_shim"
+
+#include "gd/common/init_flags.h"
+#include "main/shim/shim.h"
+
+future_t* IdleModuleStartUp() { return kReturnImmediate; }
+
+future_t* ShimModuleStartUp() { return kReturnImmediate; }
+
+future_t* GeneralShutDown() { return kReturnImmediate; }
+
+bool bluetooth::shim::is_gd_advertising_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_scanning_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_security_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_acl_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_link_policy_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_hci_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_controller_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_l2cap_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_shim_enabled() {
+  return bluetooth::common::init_flags::gd_core_is_enabled();
+}
+
+bool bluetooth::shim::is_any_gd_enabled() { return false; }
+
+bool bluetooth::shim::is_gd_stack_started_up() { return false; }
diff --git a/bta/test/common/mock_stack_acl.cc b/bta/test/common/mock_stack_acl.cc
new file mode 100644 (file)
index 0000000..9da255a
--- /dev/null
@@ -0,0 +1,452 @@
+/*
+ * 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:127
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/acl/acl.h"
+#include "stack/include/acl_api.h"
+#include "stack/include/hci_error_code.h"
+#include "types/bt_transport.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool IsEprAvailable(const tACL_CONN& p_acl) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool ACL_SupportTransparentSynchronousData(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsAclConnectionUp(const RawAddress& remote_bda,
+                           tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsAclConnectionUpAndHandleValid(const RawAddress& remote_bda,
+                                         tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsAclConnectionUpFromHandle(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsBleConnection(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsPhy2mSupported(const RawAddress& remote_bda,
+                          tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_ReadRemoteConnectionAddr(const RawAddress& pseudo_addr,
+                                  RawAddress& conn_addr,
+                                  tBLE_ADDR_TYPE* p_addr_type) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_ReadRemoteVersion(const RawAddress& addr, uint8_t* lmp_version,
+                           uint16_t* manufacturer, uint16_t* lmp_sub_version) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_create_le_connection(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_create_le_connection_with_id(uint8_t id, const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_is_role_switch_allowed() {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_is_switch_role_idle(const RawAddress& bd_addr,
+                             tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_peer_supports_ble_2m_phy(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_peer_supports_ble_coded_phy(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_peer_supports_ble_connection_parameters_request(
+    const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_peer_supports_ble_packet_extension(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_peer_supports_sniff_subrating(const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_refresh_remote_address(const RawAddress& identity_address,
+                                tBLE_ADDR_TYPE identity_address_type,
+                                const RawAddress& bda, tBLE_ADDR_TYPE rra_type,
+                                const RawAddress& rpa) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool acl_set_peer_le_features_from_handle(uint16_t hci_handle,
+                                          const uint8_t* p) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool sco_peer_supports_esco_2m_phy(const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool sco_peer_supports_esco_3m_phy(const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+const RawAddress acl_address_from_handle(uint16_t handle) {
+  mock_function_count_map[__func__]++;
+  return RawAddress::kEmpty;
+}
+void acl_send_data_packet_br_edr([[maybe_unused]] const RawAddress& bd_addr,
+                                 BT_HDR* p_buf) {
+  mock_function_count_map[__func__]++;
+}
+void acl_create_classic_connection(const RawAddress& bd_addr,
+                                   bool there_are_high_priority_channels,
+                                   bool is_bonding) {
+  mock_function_count_map[__func__]++;
+}
+tACL_CONN* acl_get_connection_from_address(const RawAddress& bd_addr,
+                                           tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tACL_CONN* acl_get_connection_from_handle(uint16_t handle) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_STATUS BTM_GetLinkSuperTout(const RawAddress& remote_bda,
+                                 uint16_t* p_timeout) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, uint8_t* p_role) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_ReadFailedContactCounter(const RawAddress& remote_bda,
+                                         tBTM_CMPL_CB* p_cb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_ReadRSSI(const RawAddress& remote_bda, tBTM_CMPL_CB* p_cb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_ReadTxPower(const RawAddress& remote_bda,
+                            tBT_TRANSPORT transport, tBTM_CMPL_CB* p_cb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda,
+                                 uint16_t timeout) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_SwitchRoleToCentral(const RawAddress& remote_bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS btm_remove_acl(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda,
+                              tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint16_t BTM_GetMaxPacketSize(const RawAddress& addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint16_t mock_stack_acl_num_links = 0;
+uint16_t BTM_GetNumAclLinks(void) {
+  mock_function_count_map[__func__]++;
+  return mock_stack_acl_num_links;
+}
+uint16_t acl_get_supported_packet_types() {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint16_t btm_get_acl_disc_reason_code(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t BTM_GetPeerSCA(const RawAddress& remote_bda, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t BTM_SetTraceLevel(uint8_t new_level) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t acl_link_role_from_handle(uint16_t handle) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t btm_handle_to_acl_index(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void ACL_RegisterClient(struct acl_client_callback_s* callbacks) {
+  mock_function_count_map[__func__]++;
+}
+void ACL_UnregisterClient(struct acl_client_callback_s* callbacks) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_ReadConnectionAddr(const RawAddress& remote_bda,
+                            RawAddress& local_conn_addr,
+                            tBLE_ADDR_TYPE* p_addr_type) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_RequestPeerSCA(const RawAddress& remote_bda, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_acl_after_controller_started(const controller_t* controller) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_block_role_switch_for(const RawAddress& peer_addr) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_block_sniff_mode_for(const RawAddress& peer_addr) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_default_block_role_switch() { mock_function_count_map[__func__]++; }
+void BTM_default_unblock_role_switch() { mock_function_count_map[__func__]++; }
+void BTM_unblock_role_switch_for(const RawAddress& peer_addr) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_unblock_sniff_mode_for(const RawAddress& peer_addr) {
+  mock_function_count_map[__func__]++;
+}
+void acl_accept_connection_request(const RawAddress& bd_addr, uint8_t role) {
+  mock_function_count_map[__func__]++;
+}
+void acl_disconnect_after_role_switch(uint16_t conn_handle,
+                                      tHCI_STATUS reason) {
+  mock_function_count_map[__func__]++;
+}
+void acl_disconnect_from_handle(uint16_t handle, tHCI_STATUS reason) {
+  mock_function_count_map[__func__]++;
+}
+void acl_link_segments_xmitted(BT_HDR* p_msg) {
+  mock_function_count_map[__func__]++;
+}
+void acl_packets_completed(uint16_t handle, uint16_t credits) {
+  mock_function_count_map[__func__]++;
+}
+void acl_process_extended_features(uint16_t handle, uint8_t current_page_number,
+                                   uint8_t max_page_number, uint64_t features) {
+  mock_function_count_map[__func__]++;
+}
+void acl_process_num_completed_pkts(uint8_t* p, uint8_t evt_len) {
+  mock_function_count_map[__func__]++;
+}
+void acl_rcv_acl_data(BT_HDR* p_msg) { mock_function_count_map[__func__]++; }
+void acl_reject_connection_request(const RawAddress& bd_addr, uint8_t reason) {
+  mock_function_count_map[__func__]++;
+}
+void acl_send_data_packet_ble(const RawAddress& bd_addr, BT_HDR* p_buf) {
+  mock_function_count_map[__func__]++;
+}
+void acl_set_disconnect_reason(tHCI_STATUS acl_disc_reason) {
+  mock_function_count_map[__func__]++;
+}
+void acl_write_automatic_flush_timeout(const RawAddress& bd_addr,
+                                       uint16_t flush_timeout_in_ticks) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p, uint16_t* p_pkt_type) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_connected(const RawAddress& bda, uint16_t handle,
+                       tHCI_STATUS status, uint8_t enc_mode) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_connection_request(const RawAddress& bda, uint8_t* dc) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_created(const RawAddress& bda, uint16_t hci_handle,
+                     uint8_t link_role, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_device_down(void) { mock_function_count_map[__func__]++; }
+void btm_acl_disconnected(tHCI_STATUS status, uint16_t handle,
+                          tHCI_REASON reason) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
+                            uint8_t encr_enable) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_notif_conn_collision(const RawAddress& bda) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_paging(BT_HDR* p, const RawAddress& bda) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_process_sca_cmpl_pkt(uint8_t len, uint8_t* data) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_removed(uint16_t handle) { mock_function_count_map[__func__]++; }
+void btm_acl_reset_paging(void) { mock_function_count_map[__func__]++; }
+void btm_acl_resubmit_page(void) { mock_function_count_map[__func__]++; }
+void btm_acl_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr,
+                          uint8_t new_role) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_set_paging(bool value) { mock_function_count_map[__func__]++; }
+void btm_acl_update_conn_addr(uint16_t handle, const RawAddress& address) {
+  mock_function_count_map[__func__]++;
+}
+void btm_acl_update_inquiry_status(uint8_t status) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_refresh_local_resolvable_private_addr(
+    const RawAddress& pseudo_addr, const RawAddress& local_rpa) {
+  mock_function_count_map[__func__]++;
+}
+void btm_cont_rswitch_from_handle(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+}
+void btm_establish_continue_from_address(const RawAddress& bda,
+                                         tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+}
+void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
+                                     uint8_t num_read_pages) {
+  mock_function_count_map[__func__]++;
+}
+void btm_process_remote_version_complete(uint8_t status, uint16_t handle,
+                                         uint8_t lmp_version,
+                                         uint16_t manufacturer,
+                                         uint16_t lmp_subversion) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_automatic_flush_timeout_complete(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_failed_contact_counter_complete(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_failed_contact_counter_timeout(UNUSED_ATTR void* data) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_link_quality_complete(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_link_quality_timeout(UNUSED_ATTR void* data) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_ext_features(uint16_t handle, uint8_t page_number) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_ext_features_complete(uint16_t handle, uint8_t page_num,
+                                           uint8_t max_page,
+                                           uint8_t* features) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_ext_features_complete_raw(uint8_t* p, uint8_t evt_len) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_ext_features_failed(uint8_t status, uint16_t handle) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_features_complete(uint16_t handle, uint8_t* features) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_features_complete_raw(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_version_complete(tHCI_STATUS status, uint16_t handle,
+                                      uint8_t lmp_version,
+                                      uint16_t manufacturer,
+                                      uint16_t lmp_subversion) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_remote_version_complete_raw(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_rssi_complete(uint8_t* p) { mock_function_count_map[__func__]++; }
+void btm_read_rssi_timeout(UNUSED_ATTR void* data) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_tx_power_complete(uint8_t* p, bool is_ble) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_tx_power_timeout(UNUSED_ATTR void* data) {
+  mock_function_count_map[__func__]++;
+}
+void btm_rejectlist_role_change_device(const RawAddress& bd_addr,
+                                       uint8_t hci_status) {
+  mock_function_count_map[__func__]++;
+}
+void btm_set_link_policy(tACL_CONN* conn, tLINK_POLICY policy) {
+  mock_function_count_map[__func__]++;
+}
+void btm_set_packet_types_from_address(const RawAddress& bd_addr,
+                                       tBT_TRANSPORT transport,
+                                       uint16_t pkt_types) {
+  mock_function_count_map[__func__]++;
+}
+void hci_btm_set_link_supervision_timeout(tACL_CONN& link, uint16_t timeout) {
+  mock_function_count_map[__func__]++;
+}
+void on_acl_br_edr_connected(const RawAddress& bda, uint16_t handle,
+                             uint8_t enc_mode) {
+  mock_function_count_map[__func__]++;
+}
+void on_acl_br_edr_failed(const RawAddress& bda, tHCI_STATUS status) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_btm.cc b/bta/test/common/mock_stack_btm.cc
new file mode 100644 (file)
index 0000000..3f8d1ca
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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
+ */
+
+#include "stack/include/btm_ble_api_types.h"
+#include "stack/include/btm_client_interface.h"
+#include "types/raw_address.h"
+
+bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16) {
+  return false;
+}
+tBTM_INQ_INFO* BTM_InqDbFirst(void) { return nullptr; }
+tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur) { return nullptr; }
+tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda) { return nullptr; }
+tBTM_STATUS BTM_CancelRemoteDeviceName(void) { return BTM_SUCCESS; }
+tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda) { return BTM_SUCCESS; }
+tBTM_STATUS BTM_ReadLocalDeviceNameFromController(
+    tBTM_CMPL_CB* p_rln_cmpl_cback) {
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda,
+                                     tBTM_CMPL_CB* p_cb,
+                                     tBT_TRANSPORT transport) {
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_SetConnectability(uint16_t page_mode) { return BTM_SUCCESS; }
+tBTM_STATUS BTM_SetDeviceClass(DEV_CLASS dev_class) { return BTM_SUCCESS; }
+tBTM_STATUS BTM_SetLocalDeviceName(char* p_name) { return BTM_SUCCESS; }
+tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb,
+                             tBTM_CMPL_CB* p_cmpl_cb) {
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff) { return BTM_SUCCESS; }
+tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode) { return BTM_SUCCESS; }
+tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback) {
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
+                           tBTM_INQ_RESULTS_CB* p_results_cb,
+                           tBTM_CMPL_CB* p_cmpl_cb) {
+  return BTM_SUCCESS;
+}
+uint16_t BTM_IsInquiryActive(void) { return 0; }
+uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p,
+                                    uint8_t max_num_uuid16,
+                                    uint8_t* p_num_uuid16) {
+  return 0;
+}
+void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) {}
+void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK* p_vsc_cback) {}
+void BTM_CancelInquiry(void) {}
+void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16) {}
+void BTM_WritePageTimeout(uint16_t timeout) {}
+bool BTM_BleConfigPrivacy(bool enable) { return false; }
+bool BTM_IsDeviceUp() { return false; }
+bool BTM_is_sniff_allowed_for(const RawAddress& peer_addr) { return false; }
+void btm_ble_adv_init() {}
+tBTM_STATUS BTM_ReadLocalDeviceName(char** p_name) { return BTM_SUCCESS; }
+uint8_t BTM_GetAcceptlistSize() { return 0; }
+
+struct btm_client_interface_s btm_client_interface = {};
+
+struct btm_client_interface_s& get_btm_client_interface() {
+  return btm_client_interface;
+}
diff --git a/bta/test/common/mock_stack_btm_ble.cc b/bta/test/common/mock_stack_btm_ble.cc
new file mode 100644 (file)
index 0000000..d23849c
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * 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:50
+ */
+
+#include <base/bind.h>
+#include <base/callback.h>
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/btm/btm_ble_int_types.h"
+#include "stack/btm/btm_int_types.h"
+#include "stack/btm/security_device_record.h"
+#include "stack/include/bt_types.h"
+#include "stack/include/btm_api_types.h"
+#include "stack/include/btm_ble_api_types.h"
+#include "stack/include/l2cdefs.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+void btm_ble_reset_id(void) { mock_function_count_map[__func__]++; }
+bool BTM_BleDataSignature(const RawAddress& bd_addr, uint8_t* p_text,
+                          uint16_t len, BLE_SIGNATURE signature) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_BleVerifySignature(const RawAddress& bd_addr, uint8_t* p_orig,
+                            uint16_t len, uint32_t counter, uint8_t* p_comp) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_ReadConnectedTransportAddress(RawAddress* remote_bda,
+                                       tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_UseLeLink(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btm_ble_get_acl_remote_addr(uint16_t hci_handle, RawAddress& conn_addr,
+                                 tBLE_ADDR_TYPE* p_addr_type) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btm_ble_get_enc_key_type(const RawAddress& bd_addr, uint8_t* p_key_types) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btm_get_local_div(const RawAddress& bd_addr, uint16_t* p_div) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+namespace {
+Octet16 octet16;
+}
+
+const Octet16& BTM_GetDeviceDHK() {
+  mock_function_count_map[__func__]++;
+  return octet16;
+}
+const Octet16& BTM_GetDeviceEncRoot() {
+  mock_function_count_map[__func__]++;
+  return octet16;
+}
+const Octet16& BTM_GetDeviceIDRoot() {
+  mock_function_count_map[__func__]++;
+  return octet16;
+}
+tBTM_SEC_ACTION btm_ble_determine_security_act(bool is_originator,
+                                               const RawAddress& bdaddr,
+                                               uint16_t security_required) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_SetBleDataLength(const RawAddress& bd_addr,
+                                 uint16_t tx_pdu_length) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_ble_set_encryption(const RawAddress& bd_addr,
+                                   tBTM_BLE_SEC_ACT sec_act,
+                                   uint8_t link_role) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_ble_start_encrypt(const RawAddress& bda, bool use_stk,
+                                  Octet16* p_stk) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tL2CAP_LE_RESULT_CODE btm_ble_start_sec_check(const RawAddress& bd_addr,
+                                              uint16_t psm, bool is_originator,
+                                              tBTM_SEC_CALLBACK* p_callback,
+                                              void* p_ref_data) {
+  mock_function_count_map[__func__]++;
+  return L2CAP_LE_RESULT_CONN_OK;
+}
+uint8_t btm_ble_br_keys_req(tBTM_SEC_DEV_REC* p_dev_rec,
+                            tBTM_LE_IO_REQ* p_data) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC* p_dev_rec,
+                                    tBTM_LE_IO_REQ* p_data) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr,
+                           tSMP_EVT_DATA* p_data) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void BTM_BleConfirmReply(const RawAddress& bd_addr, uint8_t res) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleLoadLocalKeys(uint8_t key_type, tBTM_BLE_LOCAL_KEYS* p_key) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleOobDataReply(const RawAddress& bd_addr, uint8_t res, uint8_t len,
+                         uint8_t* p_data) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BlePasskeyReply(const RawAddress& bd_addr, uint8_t res,
+                         uint32_t passkey) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleReadPhy(
+    const RawAddress& bd_addr,
+    base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleReceiverTest(uint8_t rx_freq, tBTM_CMPL_CB* p_cmd_cmpl_cback) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleSecureConnectionOobDataReply(const RawAddress& bd_addr,
+                                         uint8_t* p_c, uint8_t* p_r) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys,
+                   uint16_t phy_options) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleSetPrefConnParams(const RawAddress& bd_addr, uint16_t min_conn_int,
+                              uint16_t max_conn_int,
+                              uint16_t peripheral_latency,
+                              uint16_t supervision_tout) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleTestEnd(tBTM_CMPL_CB* p_cmd_cmpl_cback) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_BleTransmitterTest(uint8_t tx_freq, uint8_t test_data_len,
+                            uint8_t packet_payload,
+                            tBTM_CMPL_CB* p_cmd_cmpl_cback) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_ReadDevInfo(const RawAddress& remote_bda, tBT_DEVICE_TYPE* p_dev_type,
+                     tBLE_ADDR_TYPE* p_addr_type) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_SecAddBleDevice(const RawAddress& bd_addr, tBT_DEVICE_TYPE dev_type,
+                         tBLE_ADDR_TYPE addr_type) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,
+                      tBTM_LE_KEY_TYPE key_type) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_SecurityGrant(const RawAddress& bd_addr, uint8_t res) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_connected(const RawAddress& bda, uint16_t handle, uint8_t enc_mode,
+                       uint8_t role, tBLE_ADDR_TYPE addr_type,
+                       bool addr_matched) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_connected_from_address_with_type(
+    const tBLE_BD_ADDR& address_with_type, uint16_t handle, uint8_t enc_mode,
+    uint8_t role, bool addr_matched) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_increment_sign_ctr(const RawAddress& bd_addr, bool is_local) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_link_encrypted(const RawAddress& bd_addr, uint8_t encr_enable) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_link_sec_check(const RawAddress& bd_addr,
+                            tBTM_LE_AUTH_REQ auth_req,
+                            tBTM_BLE_SEC_REQ_ACT* p_sec_req_act) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_ltk_request(uint16_t handle, uint8_t rand[8], uint16_t ediv) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_ltk_request_reply(const RawAddress& bda, bool use_stk,
+                               const Octet16& stk) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_rand_enc_complete(uint8_t* p, uint16_t op_code,
+                               tBTM_RAND_ENC_CB* p_enc_cplt_cback) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_set_random_address(const RawAddress& random_bda) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_test_command_complete(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_ble_update_sec_key_size(const RawAddress& bd_addr,
+                                 uint8_t enc_key_size) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_save_le_key(const RawAddress& bd_addr, tBTM_LE_KEY_TYPE key_type,
+                         tBTM_LE_KEY_VALUE* p_keys, bool pass_to_application) {
+  mock_function_count_map[__func__]++;
+}
+void doNothing(uint8_t* data, uint16_t len) {
+  mock_function_count_map[__func__]++;
+}
+void read_phy_cb(
+    base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb,
+    uint8_t* data, uint16_t len) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_btm_dev.cc b/bta/test/common/mock_stack_btm_dev.cc
new file mode 100644 (file)
index 0000000..692fcfd
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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:12
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/btm/security_device_record.h"
+#include "stack/include/bt_types.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
+                      BD_NAME bd_name, uint8_t* features, LinkKey* p_link_key,
+                      uint8_t key_type, uint8_t pin_length) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec) {
+  mock_function_count_map[__func__]++;
+}
+char* BTM_SecReadDevName(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+void BTM_SecClearSecurityFlags(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_btm_pm.cc b/bta/test/common/mock_stack_btm_pm.cc
new file mode 100644 (file)
index 0000000..62a9f4f
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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:17
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/include/btm_api_types.h"
+#include "stack/include/btm_status.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool BTM_ReadPowerMode(const RawAddress& remote_bda, tBTM_PM_MODE* p_mode) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_SetLinkPolicyActiveMode(const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id,
+                           tBTM_PM_STATUS_CBACK* p_cb) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
+                             const tBTM_PM_PWR_MD* p_mode) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda, uint16_t max_lat,
+                             uint16_t min_rmt_to, uint16_t min_loc_to) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+void BTM_PM_OnConnected(uint16_t handle, const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_PM_OnDisconnected(uint16_t handle) {
+  mock_function_count_map[__func__]++;
+}
+void btm_pm_on_mode_change(tHCI_STATUS status, uint16_t handle,
+                           tHCI_MODE current_mode, uint16_t interval) {
+  mock_function_count_map[__func__]++;
+}
+void btm_pm_on_sniff_subrating(tHCI_STATUS status, uint16_t handle,
+                               uint16_t maximum_transmit_latency,
+                               uint16_t maximum_receive_latency,
+                               uint16_t minimum_remote_timeout,
+                               uint16_t minimum_local_timeout) {
+  mock_function_count_map[__func__]++;
+}
+void btm_pm_proc_cmd_status(tHCI_STATUS status) {
+  mock_function_count_map[__func__]++;
+}
+void btm_pm_proc_mode_change(tHCI_STATUS hci_status, uint16_t hci_handle,
+                             tHCI_MODE hci_mode, uint16_t interval) {
+  mock_function_count_map[__func__]++;
+}
+void btm_pm_proc_ssr_evt(uint8_t* p, UNUSED_ATTR uint16_t evt_len) {
+  mock_function_count_map[__func__]++;
+}
+void btm_pm_reset(void) { mock_function_count_map[__func__]++; }
+void process_ssr_event(tHCI_STATUS status, uint16_t handle,
+                       UNUSED_ATTR uint16_t max_tx_lat, uint16_t max_rx_lat) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_btm_sco.cc b/bta/test/common/mock_stack_btm_sco.cc
new file mode 100644 (file)
index 0000000..47cef70
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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:23
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/include/btm_api_types.h"
+#include "stack/include/btm_status.h"
+#include "stack/include/hci_error_code.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool BTM_IsScoActiveByBdaddr(const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btm_is_sco_active(uint16_t handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btm_sco_removed(uint16_t hci_handle, tHCI_REASON reason) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_STATUS BTM_ChangeEScoLinkParms(uint16_t sco_inx,
+                                    tBTM_CHG_ESCO_PARAMS* p_parms) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,
+                          uint16_t pkt_types, uint16_t* p_sco_inx,
+                          tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx,
+                               tBTM_ESCO_CBACK* p_esco_cback) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t BTM_GetNumScoLinks(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status,
+                     enh_esco_params_t* p_parms) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_RemoveSco(const RawAddress& bda) {
+  mock_function_count_map[__func__]++;
+}
+void btm_esco_proc_conn_chg(uint8_t status, uint16_t handle,
+                            uint8_t tx_interval, uint8_t retrans_window,
+                            uint16_t rx_pkt_len, uint16_t tx_pkt_len) {
+  mock_function_count_map[__func__]++;
+}
+void btm_route_sco_data(BT_HDR* p_msg) { mock_function_count_map[__func__]++; }
+void btm_sco_acl_removed(const RawAddress* bda) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sco_chk_pend_rolechange(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sco_chk_pend_unpark(tHCI_STATUS hci_status, uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class,
+                      uint8_t link_type) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sco_connected(tHCI_STATUS hci_status, const RawAddress& bda,
+                       uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sco_disc_chk_pend_for_modechange(uint16_t hci_handle) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sco_on_disconnected(uint16_t hci_handle, tHCI_REASON reason) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_btm_sec.cc b/bta/test/common/mock_stack_btm_sec.cc
new file mode 100644 (file)
index 0000000..4c68bfc
--- /dev/null
@@ -0,0 +1,282 @@
+/*
+ * 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:66
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/btm/security_device_record.h"
+#include "stack/include/btm_status.h"
+#include "stack/include/hci_error_code.h"
+#include "stack/include/security_client_callbacks.h"
+#include "types/bt_transport.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool BTM_BothEndsSupportSecureConnections(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_GetSecurityFlags(const RawAddress& bd_addr, uint8_t* p_sec_flags) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_GetSecurityFlagsByTransport(const RawAddress& bd_addr,
+                                     uint8_t* p_sec_flags,
+                                     tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsAuthenticated(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsEncrypted(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsLinkKeyAuthed(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_IsLinkKeyKnown(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_PeerSupportsSecureConnections(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_SecDeleteRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_SecIsSecurityPending(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
+                          uint8_t service_id, uint16_t sec_level, uint16_t psm,
+                          uint32_t mx_proto_id, uint32_t mx_chan_id) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool btm_sec_is_a_bonded_dev(const RawAddress& bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool is_sec_state_equal(void* data, void* context) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool is_state_getting_name(void* data, void* context) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+const uint8_t* btm_get_dev_class(const RawAddress& bda) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tBTM_SEC_DEV_REC* btm_sec_find_dev_by_sec_state(uint8_t state) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_SEC_SERV_REC* btm_sec_find_first_serv(bool is_originator, uint16_t psm) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
+                        tBT_TRANSPORT transport, int device_type,
+                        uint8_t pin_len, uint8_t* p_pin) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_SecBondCancel(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
+                              tBT_TRANSPORT transport,
+                              tBTM_SEC_CALLBACK* p_callback, void* p_ref_data,
+                              tBTM_BLE_SEC_ACT sec_act) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
+                                      tBT_TRANSPORT transport, uint8_t pin_len,
+                                      uint8_t* p_pin) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_sec_disconnect(uint16_t handle, tHCI_STATUS reason) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_sec_l2cap_access_req(const RawAddress& bd_addr, uint16_t psm,
+                                     bool is_originator,
+                                     tBTM_SEC_CALLBACK* p_callback,
+                                     void* p_ref_data) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_sec_l2cap_access_req_by_requirement(
+    const RawAddress& bd_addr, uint16_t security_required, bool is_originator,
+    tBTM_SEC_CALLBACK* p_callback, void* p_ref_data) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
+                                      bool is_originator,
+                                      uint16_t security_required,
+                                      tBTM_SEC_CALLBACK* p_callback,
+                                      void* p_ref_data) {
+  mock_function_count_map[__func__]++;
+  return BTM_SUCCESS;
+}
+uint16_t BTM_GetClockOffset(const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t BTM_SecClrService(uint8_t service_id) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t BTM_SecClrServiceByPsm(uint16_t psm) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void BTM_ConfirmReqReply(tBTM_STATUS res, const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res, uint8_t pin_len,
+                      uint8_t* p_pin) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_PasskeyReqReply(tBTM_STATUS res, const RawAddress& bd_addr,
+                         uint32_t passkey) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_ReadLocalOobData(void) { mock_function_count_map[__func__]++; }
+void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr,
+                            const Octet16& c, const Octet16& r) {
+  mock_function_count_map[__func__]++;
+}
+void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len) {
+  mock_function_count_map[__func__]++;
+}
+void NotifyBondingCanceled(tBTM_STATUS btm_status) {
+  mock_function_count_map[__func__]++;
+}
+void btm_create_conn_cancel_complete(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_inq_stop_on_ssp(void) {}
+void btm_io_capabilities_req(const RawAddress& p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_io_capabilities_rsp(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_proc_sp_req_evt(tBTM_SP_EVT event, uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_read_local_oob_complete(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_rem_oob_req(uint8_t* p) { mock_function_count_map[__func__]++; }
+void btm_sec_abort_access_req(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_check_pending_reqs(void) { mock_function_count_map[__func__]++; }
+void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_conn_req(const RawAddress& bda, uint8_t* dc) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_connected(const RawAddress& bda, uint16_t handle,
+                       tHCI_STATUS status, uint8_t enc_mode) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec,
+                                 tBTM_STATUS btm_status, bool is_le_transport) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_dev_reset(void) { mock_function_count_map[__func__]++; }
+void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status,
+                            uint8_t encr_enable) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_link_key_notification(const RawAddress& p_bda,
+                                   const Octet16& link_key, uint8_t key_type) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_link_key_request(uint8_t* p_event) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_pin_code_request(uint8_t* p_event) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_rmt_host_support_feat_evt(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr,
+                                       uint8_t* p_bd_name, tHCI_STATUS status) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_set_peer_sec_caps(uint16_t hci_handle, bool ssp_supported,
+                               bool sc_supported,
+                               bool hci_role_switch_supported) {
+  mock_function_count_map[__func__]++;
+}
+void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset) {
+  mock_function_count_map[__func__]++;
+}
+void btm_simple_pair_complete(uint8_t* p) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_crypto_toolbox_aes_cmac.cc b/bta/test/common/mock_stack_crypto_toolbox_aes_cmac.cc
new file mode 100644 (file)
index 0000000..1388333
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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
+ */
+
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/crypto_toolbox/aes.h"
+#include "stack/crypto_toolbox/crypto_toolbox.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+namespace crypto_toolbox {
+Octet16 aes_cmac(const Octet16& key, const uint8_t* input, uint16_t length) {
+  mock_function_count_map[__func__]++;
+  Octet16 octet16;
+  return octet16;
+}
+}  // namespace crypto_toolbox
diff --git a/bta/test/common/mock_stack_gap_ble.cc b/bta/test/common/mock_stack_gap_ble.cc
new file mode 100644 (file)
index 0000000..999c293
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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:6
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/include/gap_api.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool GAP_BleCancelReadPeerDevName(const RawAddress& peer_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GAP_BleReadPeerDevName(const RawAddress& peer_bda,
+                            tGAP_BLE_CMPL_CBACK* p_cback) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GAP_BleReadPeerPrefConnParams(const RawAddress& peer_bda) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+void GAP_BleAttrDBUpdate(uint16_t attr_uuid, tGAP_BLE_ATTR_VALUE* p_value) {
+  mock_function_count_map[__func__]++;
+}
+void gap_attr_db_init(void) { mock_function_count_map[__func__]++; }
diff --git a/bta/test/common/mock_stack_gatt.cc b/bta/test/common/mock_stack_gatt.cc
new file mode 100644 (file)
index 0000000..6ae3c8e
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * 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:27
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+#include "stack/gatt/gatt_int.h"
+#include "stack/include/gatt_api.h"
+#include "types/bluetooth/uuid.h"
+#include "types/bt_transport.h"
+#include "types/raw_address.h"
+
+using namespace bluetooth;
+
+extern std::map<std::string, int> mock_function_count_map;
+tGATT_HDL_LIST_ELEM elem;  // gatt_add_an_item_to_list
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool GATTS_DeleteService(tGATT_IF gatt_if, Uuid* p_svc_uuid,
+                         uint16_t svc_inst) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GATTS_NVRegister(tGATT_APPL_INFO* p_cb_info) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GATT_CancelConnect(tGATT_IF gatt_if, const RawAddress& bd_addr,
+                        bool is_direct) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct,
+                  tBT_TRANSPORT transport, bool opportunistic) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct,
+                  tBT_TRANSPORT transport, bool opportunistic,
+                  uint8_t initiating_phys) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GATT_GetConnIdIfConnected(tGATT_IF gatt_if, const RawAddress& bd_addr,
+                               uint16_t* p_conn_id, tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool GATT_GetConnectionInfor(uint16_t conn_id, tGATT_IF* p_gatt_if,
+                             RawAddress& bd_addr, tBT_TRANSPORT* p_transport) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool is_active_service(const Uuid& app_uuid128, Uuid* p_svc_uuid,
+                       uint16_t start_handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+tGATT_HDL_LIST_ELEM& gatt_add_an_item_to_list(uint16_t s_handle) {
+  mock_function_count_map[__func__]++;
+  return elem;
+}
+tGATT_IF GATT_Register(const Uuid& app_uuid128, tGATT_CBACK* p_cb_info,
+                       bool eatt_support) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tGATT_STATUS GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTC_Discover(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
+                            uint16_t start_handle, uint16_t end_handle) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTC_Discover(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
+                            uint16_t start_handle, uint16_t end_handle,
+                            const Uuid& uuid) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTC_ExecuteWrite(uint16_t conn_id, bool is_execute) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTC_Read(uint16_t conn_id, tGATT_READ_TYPE type,
+                        tGATT_READ_PARAM* p_read) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTC_SendHandleValueConfirm(uint16_t conn_id, uint16_t cid) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTC_Write(uint16_t conn_id, tGATT_WRITE_TYPE type,
+                         tGATT_VALUE* p_write) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTS_AddService(tGATT_IF gatt_if, btgatt_db_element_t* service,
+                              int count) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle,
+                                         uint16_t val_len, uint8_t* p_val) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTS_HandleValueNotification(uint16_t conn_id,
+                                           uint16_t attr_handle,
+                                           uint16_t val_len, uint8_t* p_val) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATTS_SendRsp(uint16_t conn_id, uint32_t trans_id,
+                           tGATT_STATUS status, tGATTS_RSP* p_msg) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS GATT_Disconnect(uint16_t conn_id) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+void GATTS_AddHandleRange(tGATTS_HNDL_RANGE* p_hndl_range) {
+  mock_function_count_map[__func__]++;
+}
+void GATTS_StopService(uint16_t service_handle) {
+  mock_function_count_map[__func__]++;
+}
+void GATT_Deregister(tGATT_IF gatt_if) { mock_function_count_map[__func__]++; }
+void GATT_SetIdleTimeout(const RawAddress& bd_addr, uint16_t idle_tout,
+                         tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+}
+void GATT_StartIf(tGATT_IF gatt_if) { mock_function_count_map[__func__]++; }
diff --git a/bta/test/common/mock_stack_gatt_attr.cc b/bta/test/common/mock_stack_gatt_attr.cc
new file mode 100644 (file)
index 0000000..8198b1c
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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:14
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/gatt/gatt_int.h"
+#include "types/bt_transport.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+uint16_t gatt_profile_find_conn_id_by_bd_addr(const RawAddress& remote_bda) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+bool gatt_profile_get_eatt_support(
+    const RawAddress& remote_bda,
+    base::OnceCallback<void(const RawAddress&, bool)> cb) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool gatt_sr_is_cl_change_aware(tGATT_TCB& tcb) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+tGATT_PROFILE_CLCB* gatt_profile_clcb_alloc(uint16_t conn_id,
+                                            const RawAddress& bda,
+                                            tBT_TRANSPORT tranport) {
+  mock_function_count_map[__func__]++;
+  return nullptr;
+}
+tGATT_STATUS proc_read_req(uint16_t conn_id, tGATTS_REQ_TYPE,
+                           tGATT_READ_REQ* p_data, tGATTS_RSP* p_rsp) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS proc_write_req(uint16_t conn_id, tGATTS_REQ_TYPE,
+                            tGATT_WRITE_REQ* p_data) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+tGATT_STATUS read_attr_value(uint16_t conn_id, uint16_t handle,
+                             tGATT_VALUE* p_value, bool is_long) {
+  mock_function_count_map[__func__]++;
+  return GATT_SUCCESS;
+}
+void GATT_ConfigServiceChangeCCC(const RawAddress& remote_bda, bool enable,
+                                 tBT_TRANSPORT transport) {
+  mock_function_count_map[__func__]++;
+}
+void gatt_profile_clcb_dealloc(tGATT_PROFILE_CLCB* p_clcb) {
+  mock_function_count_map[__func__]++;
+}
+void gatt_profile_db_init(void) { mock_function_count_map[__func__]++; }
+void gatt_sr_init_cl_status(tGATT_TCB& tcb) {
+  mock_function_count_map[__func__]++;
+}
+void gatt_sr_update_cl_status(tGATT_TCB& tcb, bool chg_aware) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_gatt_connection_manager.cc b/bta/test/common/mock_stack_gatt_connection_manager.cc
new file mode 100644 (file)
index 0000000..1c4887c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/gatt/connection_manager.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+namespace connection_manager {
+
+void reset(bool after_reset) { mock_function_count_map[__func__]++; }
+
+}  // namespace connection_manager
diff --git a/bta/test/common/mock_stack_hidh.cc b/bta/test/common/mock_stack_hidh.cc
new file mode 100644 (file)
index 0000000..6d0c07b
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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 <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/include/hiddefs.h"
+#include "stack/include/hidh_api.h"
+#include "stack/include/sdp_api.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+tHID_STATUS HID_HostAddDev(const RawAddress& addr, uint16_t attr_mask,
+                           uint8_t* handle) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tHID_STATUS HID_HostCloseDev(uint8_t dev_handle) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tHID_STATUS HID_HostDeregister(void) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tHID_STATUS HID_HostGetSDPRecord(const RawAddress& addr,
+                                 tSDP_DISCOVERY_DB* p_db, uint32_t db_len,
+                                 tHID_HOST_SDP_CALLBACK* sdp_cback) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tHID_STATUS HID_HostOpenDev(uint8_t dev_handle) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tHID_STATUS HID_HostRegister(tHID_HOST_DEV_CALLBACK* dev_cback) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tHID_STATUS HID_HostRemoveDev(uint8_t dev_handle) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tHID_STATUS HID_HostWriteDev(uint8_t dev_handle, uint8_t t_type, uint8_t param,
+                             uint16_t data, uint8_t report_id, BT_HDR* pbuf) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t HID_HostSetTraceLevel(uint8_t new_level) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void HID_HostInit(void) { mock_function_count_map[__func__]++; }
+void hidh_get_str_attr(tSDP_DISC_REC* p_rec, uint16_t attr_id, uint16_t max_len,
+                       char* str) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_l2cap.cc b/bta/test/common/mock_stack_l2cap.cc
new file mode 100644 (file)
index 0000000..bc21b66
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * 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
+ */
+
+#include <cstdint>
+#include <string>
+
+#include "btm_sec.h"
+#include "main/shim/l2c_api.h"
+#include "main/shim/shim.h"
+#include "osi/include/log.h"
+#include "stack/include/l2c_api.h"
+#include "stack/l2cap/l2c_int.h"
+
+tBT_TRANSPORT l2c_get_transport_from_fixed_cid(uint16_t fixed_cid) {
+  if (fixed_cid >= L2CAP_ATT_CID && fixed_cid <= L2CAP_SMP_CID)
+    return BT_TRANSPORT_LE;
+  return BT_TRANSPORT_BR_EDR;
+}
+
+uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
+                        bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
+                        uint16_t my_mtu, uint16_t required_remote_mtu,
+                        uint16_t sec_level) {
+  auto ret = L2CA_Register(psm, p_cb_info, enable_snoop, p_ertm_info, my_mtu,
+                           required_remote_mtu, sec_level);
+  BTM_SetSecurityLevel(false, "", 0, sec_level, psm, 0, 0);
+  return ret;
+}
+
+uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
+                       bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
+                       uint16_t my_mtu, uint16_t required_remote_mtu,
+                       uint16_t sec_level) {
+  return 0;
+}
+
+void L2CA_Deregister(uint16_t psm) {}
+
+uint16_t L2CA_AllocateLePSM(void) { return 0; }
+
+void L2CA_FreeLePSM(uint16_t psm) {}
+
+uint16_t L2CA_ConnectReq2(uint16_t psm, const RawAddress& p_bd_addr,
+                          uint16_t sec_level) {
+  return 0;
+}
+
+uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& p_bd_addr) {
+  return 0;
+}
+
+uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
+                            uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) {
+  return 0;
+}
+
+void L2CA_DeregisterLECoc(uint16_t psm) {}
+
+uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr,
+                              tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) {
+  return 0;
+}
+
+bool L2CA_GetPeerLECocConfig(uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) {
+  return false;
+}
+
+bool L2CA_ConnectCreditBasedRsp(const RawAddress& p_bd_addr, uint8_t id,
+                                std::vector<uint16_t>& accepted_lcids,
+                                uint16_t result, tL2CAP_LE_CFG_INFO* p_cfg) {
+  return false;
+}
+
+std::vector<uint16_t> L2CA_ConnectCreditBasedReq(uint16_t psm,
+                                                 const RawAddress& p_bd_addr,
+                                                 tL2CAP_LE_CFG_INFO* p_cfg) {
+  return std::vector<uint16_t>();
+}
+
+bool L2CA_ReconfigCreditBasedConnsReq(const RawAddress& bda,
+                                      std::vector<uint16_t>& lcids,
+                                      tL2CAP_LE_CFG_INFO* p_cfg) {
+  return false;
+}
+
+bool L2CA_DisconnectReq(uint16_t cid) { return false; }
+
+bool L2CA_DisconnectLECocReq(uint16_t cid) { return false; }
+
+bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { return false; }
+
+bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout,
+                                 tBT_TRANSPORT transport) {
+  return false;
+}
+uint8_t L2CA_SetTraceLevel(uint8_t new_level) { return 0; }
+
+bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) {
+  return false;
+}
+
+bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) {
+  return false;
+}
+
+bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat,
+                          uint8_t* p_chnl_mask) {
+  return false;
+}
+
+bool L2CA_RegisterFixedChannel(uint16_t fixed_cid,
+                               tL2CAP_FIXED_CHNL_REG* p_freg) {
+  return false;
+}
+
+bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
+  return false;
+}
+
+uint16_t L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& rem_bda,
+                                BT_HDR* p_buf) {
+  return 0;
+}
+
+bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
+  return false;
+}
+
+bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) {
+  return false;
+}
+
+uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) { return 0; }
+
+uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) { return 0; }
+
+bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) { return false; }
+
+uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) { return 0; }
+
+bool L2CA_IsLinkEstablished(const RawAddress& bd_addr,
+                            tBT_TRANSPORT transport) {
+  return false;
+}
diff --git a/bta/test/common/mock_stack_l2cap_ble.cc b/bta/test/common/mock_stack_l2cap_ble.cc
new file mode 100644 (file)
index 0000000..1b8f16e
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * 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:22
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/l2cap/l2c_int.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool L2CA_EnableUpdateBleConnParams(const RawAddress& rem_bda, bool enable) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool L2CA_UpdateBleConnParams(const RawAddress& rem_bda, uint16_t min_int,
+                              uint16_t max_int, uint16_t latency,
+                              uint16_t timeout, uint16_t min_ce_len,
+                              uint16_t max_ce_len) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool l2cble_conn_comp(uint16_t handle, uint8_t role, const RawAddress& bda,
+                      tBLE_ADDR_TYPE type, uint16_t conn_interval,
+                      uint16_t conn_latency, uint16_t conn_timeout) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool l2cble_conn_comp_from_address_with_type(
+    uint16_t handle, uint8_t role, const tBLE_BD_ADDR& address_with_type,
+    uint16_t conn_interval, uint16_t conn_latency, uint16_t conn_timeout) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool l2cble_create_conn(tL2C_LCB* p_lcb) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+hci_role_t L2CA_GetBleConnRole(const RawAddress& bd_addr) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tL2CAP_LE_RESULT_CODE l2ble_sec_access_req(const RawAddress& bd_addr,
+                                           uint16_t psm, bool is_originator,
+                                           tL2CAP_SEC_CBACK* p_callback,
+                                           void* p_ref_data) {
+  mock_function_count_map[__func__]++;
+  return L2CAP_LE_RESULT_CONN_OK;
+}
+void L2CA_AdjustConnectionIntervals(uint16_t* min_interval,
+                                    uint16_t* max_interval,
+                                    uint16_t floor_interval) {
+  mock_function_count_map[__func__]++;
+}
+void l2c_ble_link_adjust_allocation(void) {
+  mock_function_count_map[__func__]++;
+}
+void l2c_link_processs_ble_num_bufs(uint16_t num_lm_ble_bufs) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_credit_based_conn_req(tL2C_CCB* p_ccb) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_credit_based_conn_res(tL2C_CCB* p_ccb, uint16_t result) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_notify_le_connection(const RawAddress& bda) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_process_conn_update_evt(uint16_t handle, uint8_t status,
+                                    uint16_t interval, uint16_t latency,
+                                    uint16_t timeout) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_process_data_length_change_event(uint16_t handle,
+                                             uint16_t tx_data_len,
+                                             uint16_t rx_data_len) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_process_rc_param_request_evt(uint16_t handle, uint16_t int_min,
+                                         uint16_t int_max, uint16_t latency,
+                                         uint16_t timeout) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_sec_comp(const RawAddress* bda, tBT_TRANSPORT transport,
+                     void* p_ref_data, uint8_t status) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_send_flow_control_credit(tL2C_CCB* p_ccb, uint16_t credit_value) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_send_peer_disc_req(tL2C_CCB* p_ccb) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_update_data_length(tL2C_LCB* p_lcb) {
+  mock_function_count_map[__func__]++;
+}
+void l2cble_use_preferred_conn_params(const RawAddress& bda) {
+  mock_function_count_map[__func__]++;
+}
diff --git a/bta/test/common/mock_stack_sdp.cc b/bta/test/common/mock_stack_sdp.cc
new file mode 100644 (file)
index 0000000..ef39c63
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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
+ */
+
+#include <string.h>
+
+#include "bt_target.h"
+
+#include "sdp_api.h"
+
+#include "osi/include/osi.h"
+
+using bluetooth::Uuid;
+
+bool SDP_InitDiscoveryDb(tSDP_DISCOVERY_DB* p_db, uint32_t len,
+                         uint16_t num_uuid, const Uuid* p_uuid_list,
+                         uint16_t num_attr, uint16_t* p_attr_list) {
+  return false;
+}
+
+bool SDP_CancelServiceSearch(tSDP_DISCOVERY_DB* p_db) { return false; }
+
+bool SDP_ServiceSearchRequest(const RawAddress& p_bd_addr,
+                              tSDP_DISCOVERY_DB* p_db,
+                              tSDP_DISC_CMPL_CB* p_cb) {
+  return false;
+}
+
+bool SDP_ServiceSearchAttributeRequest(const RawAddress& p_bd_addr,
+                                       tSDP_DISCOVERY_DB* p_db,
+                                       tSDP_DISC_CMPL_CB* p_cb) {
+  return false;
+}
+bool SDP_ServiceSearchAttributeRequest2(const RawAddress& p_bd_addr,
+                                        tSDP_DISCOVERY_DB* p_db,
+                                        tSDP_DISC_CMPL_CB2* p_cb2,
+                                        void* user_data) {
+  return false;
+}
+
+tSDP_DISC_ATTR* SDP_FindAttributeInRec(tSDP_DISC_REC* p_rec, uint16_t attr_id) {
+  return (NULL);
+}
+
+bool SDP_FindServiceUUIDInRec(tSDP_DISC_REC* p_rec, Uuid* p_uuid) {
+  return false;
+}
+
+bool SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC* p_rec, Uuid* p_uuid) {
+  return false;
+}
+
+tSDP_DISC_REC* SDP_FindServiceInDb(tSDP_DISCOVERY_DB* p_db,
+                                   uint16_t service_uuid,
+                                   tSDP_DISC_REC* p_start_rec) {
+  return (NULL);
+}
+
+tSDP_DISC_REC* SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB* p_db,
+                                          tSDP_DISC_REC* p_start_rec) {
+  return (NULL);
+}
+
+tSDP_DISC_REC* SDP_FindServiceUUIDInDb(tSDP_DISCOVERY_DB* p_db,
+                                       const Uuid& uuid,
+                                       tSDP_DISC_REC* p_start_rec) {
+  return (NULL);
+}
+
+bool SDP_FindProtocolListElemInRec(tSDP_DISC_REC* p_rec, uint16_t layer_uuid,
+                                   tSDP_PROTOCOL_ELEM* p_elem) {
+  return (false);
+}
+
+bool SDP_FindProfileVersionInRec(tSDP_DISC_REC* p_rec, uint16_t profile_uuid,
+                                 uint16_t* p_version) {
+  return (false);
+}
+
+uint16_t SDP_DiDiscover(const RawAddress& remote_device,
+                        tSDP_DISCOVERY_DB* p_db, uint32_t len,
+                        tSDP_DISC_CMPL_CB* p_cb) {
+  return 0;
+}
+
+uint8_t SDP_GetNumDiRecords(tSDP_DISCOVERY_DB* p_db) { return 0; }
+
+uint16_t SDP_GetDiRecord(uint8_t get_record_index,
+                         tSDP_DI_GET_RECORD* p_device_info,
+                         tSDP_DISCOVERY_DB* p_db) {
+  return 0;
+}
+uint16_t SDP_SetLocalDiRecord(tSDP_DI_RECORD* p_device_info,
+                              uint32_t* p_handle) {
+  return 0;
+}
+uint8_t SDP_SetTraceLevel(uint8_t new_level) { return 0; }
diff --git a/bta/test/common/mock_stack_srvc_dis.cc b/bta/test/common/mock_stack_srvc_dis.cc
new file mode 100644 (file)
index 0000000..1885802
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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:10
+ */
+
+#include <cstdint>
+#include <map>
+#include <string>
+
+extern std::map<std::string, int> mock_function_count_map;
+
+#include "stack/include/srvc_api.h"
+#include "stack/srvc/srvc_eng_int.h"
+#include "types/raw_address.h"
+
+#ifndef UNUSED_ATTR
+#define UNUSED_ATTR
+#endif
+
+bool DIS_ReadDISInfo(const RawAddress& peer_bda, tDIS_READ_CBACK* p_cback,
+                     tDIS_ATTR_MASK mask) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool dis_gatt_c_read_dis_req(uint16_t conn_id) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+bool dis_valid_handle_range(uint16_t handle) {
+  mock_function_count_map[__func__]++;
+  return false;
+}
+tDIS_STATUS DIS_SrInit(tDIS_ATTR_MASK dis_attr_mask) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR* p_info) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t dis_read_attr_value(UNUSED_ATTR uint8_t clcb_idx, uint16_t handle,
+                            tGATT_VALUE* p_value, bool is_long,
+                            tGATT_STATUS* p_status) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+uint8_t dis_write_attr_value(UNUSED_ATTR tGATT_WRITE_REQ* p_data,
+                             tGATT_STATUS* p_status) {
+  mock_function_count_map[__func__]++;
+  return 0;
+}
+void dis_c_cmpl_cback(tSRVC_CLCB* p_clcb, tGATTC_OPTYPE op, tGATT_STATUS status,
+                      tGATT_CL_COMPLETE* p_data) {
+  mock_function_count_map[__func__]++;
+}