Merge "legacy: Use common mock functions test/net_test_bta"
diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc
index 67b68b6..a08eea3 100644
--- a/system/btif/src/btif_dm.cc
+++ b/system/btif/src/btif_dm.cc
@@ -1155,8 +1155,7 @@
       /* inquiry result */
       bt_bdname_t bdname;
       uint8_t remote_name_len;
-      uint8_t num_uuids = 0, max_num_uuid = 32;
-      uint8_t uuid_list[32 * Uuid::kNumBytes16];
+      tBTA_SERVICE_MASK services = 0;
 
       p_search_data->inq_res.remt_name_not_required =
           check_eir_remote_name(p_search_data, NULL, NULL);
@@ -1170,11 +1169,14 @@
       if (!check_eir_remote_name(p_search_data, bdname.name, &remote_name_len))
         check_cached_remote_name(p_search_data, bdname.name, &remote_name_len);
 
-      /* Check EIR for services */
+      /* Check EIR for remote name and services */
       if (p_search_data->inq_res.p_eir) {
-        BTM_GetEirUuidList(p_search_data->inq_res.p_eir,
-                           p_search_data->inq_res.eir_len, Uuid::kNumBytes16,
-                           &num_uuids, uuid_list, max_num_uuid);
+        BTA_GetEirService(p_search_data->inq_res.p_eir,
+                          p_search_data->inq_res.eir_len, &services);
+        BTIF_TRACE_DEBUG("%s()EIR BTA services = %08X", __func__,
+                         (uint32_t)services);
+        /* TODO:  Get the service list and check to see which uuids we got and
+         * send it back to the client. */
       }
 
       {
@@ -1242,21 +1244,6 @@
                                    &(p_search_data->inq_res.include_rsi));
         num_properties++;
 
-        /* EIR queried services */
-        if (num_uuids > 0) {
-          uint16_t* p_uuid16 = (uint16_t*)uuid_list;
-          std::vector<Uuid> uuid128_list;
-          for (int i = 0; i < num_uuids; ++i) {
-            Uuid uuid = Uuid::From16Bit(p_uuid16[i]);
-            uuid128_list.push_back(uuid);
-          }
-
-          BTIF_STORAGE_FILL_PROPERTY(
-              &properties[num_properties], BT_PROPERTY_UUIDS,
-              num_uuids * Uuid::kNumBytes128, uuid128_list.data());
-          num_properties++;
-        }
-
         status =
             btif_storage_add_remote_device(&bdaddr, num_properties, properties);
         ASSERTC(status == BT_STATUS_SUCCESS,
diff --git a/system/test/mock/mock_main_shim_metrics_api.cc b/system/test/mock/mock_main_shim_metrics_api.cc
index 76c5e3c..1b63839 100644
--- a/system/test/mock/mock_main_shim_metrics_api.cc
+++ b/system/test/mock/mock_main_shim_metrics_api.cc
@@ -35,9 +35,7 @@
 //       for this effort.  This compilation unit may compile as-is, or
 //       may need attention to prune the inclusion set.
 #include "gd/hci/address.h"
-#include "gd/os/metrics.h"
 #include "main/shim/helpers.h"
-#include "main/shim/metrics_api.h"
 #include "types/raw_address.h"
 
 // Mock include file to share data between tests and mock
diff --git a/system/test/mock/mock_main_shim_metrics_api.h b/system/test/mock/mock_main_shim_metrics_api.h
index aba10a8..39f4e7f 100644
--- a/system/test/mock/mock_main_shim_metrics_api.h
+++ b/system/test/mock/mock_main_shim_metrics_api.h
@@ -284,4 +284,4 @@
 }  // namespace mock
 }  // namespace test
 
-// END mockcify generation
\ No newline at end of file
+// END mockcify generation
diff --git a/system/test/mock/mock_stack_btu_hcif.cc b/system/test/mock/mock_stack_btu_hcif.cc
index 4669b71..a319e60 100644
--- a/system/test/mock/mock_stack_btu_hcif.cc
+++ b/system/test/mock/mock_stack_btu_hcif.cc
@@ -19,6 +19,7 @@
  *   Functions generated:9
  */
 
+#include <cstdint>
 #include <map>
 #include <string>
 
@@ -29,24 +30,7 @@
 #include <base/callback.h>
 #include <base/location.h>
 
-#include <cstdint>
-
-#include "btif/include/btif_config.h"
-#include "common/metrics.h"
-#include "device/include/controller.h"
-#include "osi/include/log.h"
-#include "stack/include/acl_hci_link_interface.h"
-#include "stack/include/ble_acl_interface.h"
-#include "stack/include/ble_hci_link_interface.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/btm_iso_api.h"
-#include "stack/include/dev_hci_link_interface.h"
-#include "stack/include/gatt_api.h"
-#include "stack/include/hci_evt_length.h"
-#include "stack/include/inq_hci_link_interface.h"
-#include "stack/include/l2cap_hci_link_interface.h"
-#include "stack/include/sco_hci_link_interface.h"
-#include "stack/include/sec_hci_link_interface.h"
 
 #ifndef UNUSED_ATTR
 #define UNUSED_ATTR
diff --git a/system/test/mock/mock_udrv_ulinux_uipc.cc b/system/test/mock/mock_udrv_ulinux_uipc.cc
index 6e32173..65afa58 100644
--- a/system/test/mock/mock_udrv_ulinux_uipc.cc
+++ b/system/test/mock/mock_udrv_ulinux_uipc.cc
@@ -19,32 +19,13 @@
  *   Functions generated:12
  */
 
+#include <cstdint>
 #include <map>
 #include <string>
 
 extern std::map<std::string, int> mock_function_count_map;
 
-#include <errno.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
-#include <sys/select.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/un.h>
-#include <unistd.h>
-#include <mutex>
-#include <set>
-#include "audio_a2dp_hw/include/audio_a2dp_hw.h"
-#include "bt_utils.h"
-#include "osi/include/osi.h"
-#include "osi/include/socket_utils/sockets.h"
-#include "uipc.h"
+#include "udrv/include/uipc.h"
 
 #ifndef UNUSED_ATTR
 #define UNUSED_ATTR
diff --git a/system/test/mock/mock_utils_bt.h b/system/test/mock/mock_utils_bt.h
index 82a2d04..88a7c32 100644
--- a/system/test/mock/mock_utils_bt.h
+++ b/system/test/mock/mock_utils_bt.h
@@ -34,21 +34,8 @@
 //       still applies, but crafting proper inclusion is out of scope
 //       for this effort.  This compilation unit may compile as-is, or
 //       may need attention to prune from (or add to ) the inclusion set.
-#include <errno.h>
-#include <processgroup/sched_policy.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/resource.h>
-#include <unistd.h>
 
-#include <mutex>
-
-#include "bt_utils.h"
-#include "btcore/include/module.h"
-#include "osi/include/compat.h"
-#include "osi/include/log.h"
-#include "osi/include/properties.h"
+#include "utils/include/bt_utils.h"
 
 // Mocked compile conditionals, if any
 
diff --git a/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc b/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
index 8df6186..7b833c9 100644
--- a/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
+++ b/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
@@ -204,6 +204,7 @@
   SET_SUPPORTED(REMOTE_NAME_REQUEST, RemoteNameRequest);
   SET_SUPPORTED(LE_SET_EVENT_MASK, LeSetEventMask);
   SET_SUPPORTED(LE_READ_BUFFER_SIZE_V1, LeReadBufferSize);
+  SET_SUPPORTED(LE_READ_BUFFER_SIZE_V2, LeReadBufferSizeV2);
   SET_SUPPORTED(LE_READ_LOCAL_SUPPORTED_FEATURES, LeReadLocalSupportedFeatures);
   SET_SUPPORTED(LE_SET_RANDOM_ADDRESS, LeSetRandomAddress);
   SET_SUPPORTED(LE_SET_ADVERTISING_PARAMETERS, LeSetAdvertisingParameters);
@@ -1590,6 +1591,23 @@
   send_event_(std::move(packet));
 }
 
+void DualModeController::LeReadBufferSizeV2(CommandView command) {
+  auto command_view = gd_hci::LeReadBufferSizeV2View::Create(command);
+  ASSERT(command_view.IsValid());
+
+  bluetooth::hci::LeBufferSize le_buffer_size;
+  le_buffer_size.le_data_packet_length_ = properties_.GetLeDataPacketLength();
+  le_buffer_size.total_num_le_packets_ = properties_.GetTotalNumLeDataPackets();
+  bluetooth::hci::LeBufferSize iso_buffer_size;
+  iso_buffer_size.le_data_packet_length_ = properties_.GetIsoDataPacketLength();
+  iso_buffer_size.total_num_le_packets_ =
+      properties_.GetTotalNumIsoDataPackets();
+
+  auto packet = bluetooth::hci::LeReadBufferSizeV2CompleteBuilder::Create(
+      kNumCommandPackets, ErrorCode::SUCCESS, le_buffer_size, iso_buffer_size);
+  send_event_(std::move(packet));
+}
+
 void DualModeController::LeSetAddressResolutionEnable(CommandView command) {
     // NOP
     auto payload =
diff --git a/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h b/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
index c446c61..5135b76 100644
--- a/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
+++ b/system/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
@@ -531,6 +531,9 @@
   // 7.8.77
   void LeSetPrivacyMode(CommandView args);
 
+  // 7.8.93 (moved to 7.8.2)
+  void LeReadBufferSizeV2(CommandView args);
+
   // 7.8.96 - 7.8.110
   void LeReadIsoTxSync(CommandView packet_view);
   void LeSetCigParameters(CommandView packet_view);
diff --git a/system/vendor_libs/test_vendor_lib/model/devices/device_properties.h b/system/vendor_libs/test_vendor_lib/model/devices/device_properties.h
index 8e33bdb..956a7f0 100644
--- a/system/vendor_libs/test_vendor_lib/model/devices/device_properties.h
+++ b/system/vendor_libs/test_vendor_lib/model/devices/device_properties.h
@@ -327,6 +327,14 @@
     return num_le_data_packets_;
   }
 
+  uint16_t GetIsoDataPacketLength() const {
+    return iso_data_packet_length_;
+  }
+
+  uint8_t GetTotalNumIsoDataPackets() const {
+    return num_iso_data_packets_;
+  }
+
   // Specification Version 4.2, Volume 2, Part E, Section 7.8.3
   uint64_t GetLeSupportedFeatures() const {
     return le_supported_features_;
@@ -417,6 +425,10 @@
   uint8_t le_advertisement_type_{};
   std::vector<uint8_t> le_advertisement_;
   std::vector<uint8_t> le_scan_response_;
+
+  // ISO
+  uint16_t iso_data_packet_length_{1021};
+  uint8_t num_iso_data_packets_{12};
 };
 
 }  // namespace test_vendor_lib