From 9822a8bd790d8384600d81aff8f09bd40becc701 Mon Sep 17 00:00:00 2001
From: Myles Watson <mylesgw@google.com>
Date: Mon, 30 Oct 2023 15:53:02 -0700
Subject: [PATCH] Reland: Use one definition for Octet16

Bug: 301661850
Test: mma -j32
Change-Id: I496d968e4be5ef26f102d153e4fb11cc66b18e94
---
 system/bta/ag/bta_ag_cfg.cc                   |  1 -
 system/bta/dm/bta_dm_main.cc                  |  3 +-
 system/bta/gatt/bta_gatts_int.h               |  1 -
 system/bta/gatt/database.cc                   |  1 +
 system/bta/gatt/database.h                    |  2 +-
 system/bta/has/has_ctp.cc                     |  2 ++
 system/bta/has/has_preset.cc                  |  2 ++
 system/bta/has/has_preset.h                   |  1 -
 system/bta/hd/bta_hd_int.h                    |  1 -
 system/bta/hf_client/bta_hf_client_api.cc     |  1 -
 system/bta/hf_client/bta_hf_client_int.h      |  1 -
 system/bta/hh/bta_hh_int.h                    |  1 -
 system/bta/include/bta_api.h                  |  2 --
 system/bta/include/bta_av_api.h               |  1 -
 system/bta/include/bta_dm_acl.h               |  1 -
 system/bta/include/bta_dm_ci.h                |  2 +-
 system/bta/include/bta_jv_co.h                |  1 -
 system/bta/include/bta_sec_api.h              | 10 +++----
 system/bta/le_audio/devices.h                 |  1 -
 system/bta/sys/bta_sys_main.cc                |  1 -
 system/btif/src/btif_a2dp_sink.cc             |  1 -
 system/btif/src/btif_sock_l2cap.cc            |  1 -
 system/common/address_obfuscator.h            |  6 ++--
 system/device/include/device_iot_config.h     |  1 -
 system/device/src/device_iot_config.cc        |  1 -
 system/device/src/device_iot_config_int.cc    |  1 -
 system/device/src/interop.cc                  |  1 -
 system/gd/crypto_toolbox/crypto_toolbox.h     |  6 ++--
 system/gd/hci/octets.h                        | 29 +++++++++++++++++++
 system/main/shim/acl.h                        |  1 -
 system/main/shim/acl_legacy_interface.h       |  1 -
 system/main/shim/helpers.h                    |  1 -
 .../profile/sdp/common/data_element_reader.h  |  2 +-
 system/stack/acl/peer_packet_types.h          |  1 -
 .../stack/btm/ble_advertiser_hci_interface.h  |  1 -
 system/stack/btm/ble_scanner_hci_interface.h  |  1 -
 system/stack/btm/btm_devctl.cc                |  1 +
 system/stack/include/acl_hci_link_interface.h |  1 -
 system/stack/include/avrc_defs.h              |  1 -
 system/stack/include/ble_acl_interface.h      |  3 +-
 system/stack/include/bt_octets.h              | 14 +++------
 system/stack/include/bt_types.h               |  6 +---
 system/stack/include/sco_hci_link_interface.h |  1 +
 .../stack/test/btm/peer_packet_types_test.cc  |  6 ++--
 system/test/suite/adapter/adapter_unittest.cc |  1 -
 45 files changed, 60 insertions(+), 65 deletions(-)
 create mode 100644 system/gd/hci/octets.h

diff --git a/system/bta/ag/bta_ag_cfg.cc b/system/bta/ag/bta_ag_cfg.cc
index c3319739490..e0c42e95f38 100644
--- a/system/bta/ag/bta_ag_cfg.cc
+++ b/system/bta/ag/bta_ag_cfg.cc
@@ -29,7 +29,6 @@
 #include "device/include/esco_parameters.h"
 #include "osi/include/allocator.h"
 #include "osi/include/compat.h"
-#include "stack/include/bt_types.h"
 
 #ifndef BTA_AG_CIND_INFO
 #define BTA_AG_CIND_INFO                                                       \
diff --git a/system/bta/dm/bta_dm_main.cc b/system/bta/dm/bta_dm_main.cc
index 53ee8cb3813..ac4ceddf930 100644
--- a/system/bta/dm/bta_dm_main.cc
+++ b/system/bta/dm/bta_dm_main.cc
@@ -26,15 +26,14 @@
 
 #include "bt_trace.h"
 #include "bta/dm/bta_dm_disc.h"
-#include "bta/dm/bta_dm_sec_int.h"
 #include "bta/dm/bta_dm_gatt_client.h"
 #include "bta/dm/bta_dm_int.h"
+#include "bta/dm/bta_dm_sec_int.h"
 #include "gd/common/circular_buffer.h"
 #include "gd/common/strings.h"
 #include "main/shim/dumpsys.h"
 #include "stack/btm/btm_int_types.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 
 tBTA_DM_ACL_CB bta_dm_acl_cb;
 tBTA_DM_CB bta_dm_cb;
diff --git a/system/bta/gatt/bta_gatts_int.h b/system/bta/gatt/bta_gatts_int.h
index d7e95a1d1d9..f79bccdcc36 100644
--- a/system/bta/gatt/bta_gatts_int.h
+++ b/system/bta/gatt/bta_gatts_int.h
@@ -30,7 +30,6 @@
 #include "bta/include/bta_gatt_api.h"
 #include "bta/sys/bta_sys.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "stack/include/btm_ble_api_types.h"
 #include "stack/include/gatt_api.h"
 #include "types/bluetooth/uuid.h"
diff --git a/system/bta/gatt/database.cc b/system/bta/gatt/database.cc
index 223ff94b681..8ee75c0ddb6 100644
--- a/system/bta/gatt/database.cc
+++ b/system/bta/gatt/database.cc
@@ -25,6 +25,7 @@
 #include <sstream>
 
 #include "bt_trace.h"
+#include "bt_types.h"
 #include "stack/crypto_toolbox/crypto_toolbox.h"
 #include "stack/include/gattdefs.h"
 #include "types/bluetooth/uuid.h"
diff --git a/system/bta/gatt/database.h b/system/bta/gatt/database.h
index 3e618d23d11..3a87ebc792e 100644
--- a/system/bta/gatt/database.h
+++ b/system/bta/gatt/database.h
@@ -22,7 +22,7 @@
 #include <string>
 #include <vector>
 
-#include "stack/include/bt_types.h" /* for Octet16 */
+#include "stack/include/bt_octets.h"
 #include "types/bluetooth/uuid.h"
 
 namespace gatt {
diff --git a/system/bta/has/has_ctp.cc b/system/bta/has/has_ctp.cc
index 147a3cfb65f..a2beffea84e 100644
--- a/system/bta/has/has_ctp.cc
+++ b/system/bta/has/has_ctp.cc
@@ -16,7 +16,9 @@
  */
 
 #include "has_ctp.h"
+
 #include "os/log.h"
+#include "stack/include/bt_types.h"
 
 namespace le_audio {
 namespace has {
diff --git a/system/bta/has/has_preset.cc b/system/bta/has/has_preset.cc
index b54831150f5..ab8c97b8840 100644
--- a/system/bta/has/has_preset.cc
+++ b/system/bta/has/has_preset.cc
@@ -17,6 +17,8 @@
 
 #include "has_preset.h"
 
+#include "stack/include/bt_types.h"
+
 namespace le_audio {
 namespace has {
 
diff --git a/system/bta/has/has_preset.h b/system/bta/has/has_preset.h
index 978077e6b40..3ba5a728165 100644
--- a/system/bta/has/has_preset.h
+++ b/system/bta/has/has_preset.h
@@ -22,7 +22,6 @@
 #include <optional>
 #include <string>
 
-#include "bt_types.h"
 #include "hardware/bt_has.h"
 
 namespace le_audio {
diff --git a/system/bta/hd/bta_hd_int.h b/system/bta/hd/bta_hd_int.h
index ae0ead6d014..f3907f65677 100644
--- a/system/bta/hd/bta_hd_int.h
+++ b/system/bta/hd/bta_hd_int.h
@@ -31,7 +31,6 @@
 #include "bta/include/bta_hd_api.h"
 #include "bta/sys/bta_sys.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "stack/include/hiddefs.h"
 #include "types/raw_address.h"
 
diff --git a/system/bta/hf_client/bta_hf_client_api.cc b/system/bta/hf_client/bta_hf_client_api.cc
index 46d942284d7..1ed76f07278 100644
--- a/system/bta/hf_client/bta_hf_client_api.cc
+++ b/system/bta/hf_client/bta_hf_client_api.cc
@@ -38,7 +38,6 @@
 #include "osi/include/allocator.h"
 #include "osi/include/compat.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 /*****************************************************************************
diff --git a/system/bta/hf_client/bta_hf_client_int.h b/system/bta/hf_client/bta_hf_client_int.h
index 21b8d29da45..b5e3a37f0ad 100644
--- a/system/bta/hf_client/bta_hf_client_int.h
+++ b/system/bta/hf_client/bta_hf_client_int.h
@@ -25,7 +25,6 @@
 #include "bta/sys/bta_sys.h"
 #include "osi/include/alarm.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 /*****************************************************************************
diff --git a/system/bta/hh/bta_hh_int.h b/system/bta/hh/bta_hh_int.h
index 078903ad33f..de9f3cf2157 100644
--- a/system/bta/hh/bta_hh_int.h
+++ b/system/bta/hh/bta_hh_int.h
@@ -32,7 +32,6 @@
 #include "bta/include/bta_hh_api.h"
 #include "bta/sys/bta_sys.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 /* state machine events, these events are handled by the state machine */
diff --git a/system/bta/include/bta_api.h b/system/bta/include/bta_api.h
index 0c4d243fcbe..90d5e03b719 100644
--- a/system/bta/include/bta_api.h
+++ b/system/bta/include/bta_api.h
@@ -35,8 +35,6 @@
 #include "bta_api_data_types.h"
 #include "osi/include/log.h"
 #include "stack/include/bt_name.h"
-#include "stack/include/bt_octets.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/hci_error_code.h"
diff --git a/system/bta/include/bta_av_api.h b/system/bta/include/bta_av_api.h
index 5d59842204b..df133e6c787 100644
--- a/system/bta/include/bta_av_api.h
+++ b/system/bta/include/bta_av_api.h
@@ -31,7 +31,6 @@
 #include "bta/include/bta_api.h"
 #include "stack/include/avrc_defs.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 /*****************************************************************************
diff --git a/system/bta/include/bta_dm_acl.h b/system/bta/include/bta_dm_acl.h
index ec724851452..44cf3cf73ba 100644
--- a/system/bta/include/bta_dm_acl.h
+++ b/system/bta/include/bta_dm_acl.h
@@ -18,7 +18,6 @@
 
 #include <cstdint>
 
-#include "stack/include/bt_types.h"
 #include "stack/include/hci_error_code.h"
 #include "types/bt_transport.h"
 #include "types/hci_role.h"
diff --git a/system/bta/include/bta_dm_ci.h b/system/bta/include/bta_dm_ci.h
index 2109e414396..3989eb061ef 100644
--- a/system/bta/include/bta_dm_ci.h
+++ b/system/bta/include/bta_dm_ci.h
@@ -26,7 +26,7 @@
 
 #include <cstdint>
 
-#include "stack/include/bt_types.h"
+#include "stack/include/bt_octets.h"
 #include "types/raw_address.h"
 
 /*****************************************************************************
diff --git a/system/bta/include/bta_jv_co.h b/system/bta/include/bta_jv_co.h
index 35562dd0a0f..e170f2fb968 100644
--- a/system/bta/include/bta_jv_co.h
+++ b/system/bta/include/bta_jv_co.h
@@ -27,7 +27,6 @@
 #include <cstdint>
 
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 
 /*****************************************************************************
  *  Function Declarations
diff --git a/system/bta/include/bta_sec_api.h b/system/bta/include/bta_sec_api.h
index 3b9625b4c6c..958ecfd5fbe 100644
--- a/system/bta/include/bta_sec_api.h
+++ b/system/bta/include/bta_sec_api.h
@@ -18,25 +18,23 @@
 
 #pragma once
 
-#include <base/strings/stringprintf.h>
 #include <base/functional/callback.h>
+#include <base/strings/stringprintf.h>
 
 #include <cstdint>
 #include <vector>
 
 #include "bt_target.h"  // Must be first to define build configuration
+#include "bta_api_data_types.h"
+#include "stack/include/bt_name.h"
 #include "stack/include/bt_octets.h"
-#include "stack/include/bt_types.h"
-#include "stack/include/btm_sec_api_types.h"
 #include "stack/include/btm_ble_sec_api_types.h"
-#include "stack/include/bt_name.h"
+#include "stack/include/btm_sec_api_types.h"
 #include "stack/include/hci_error_code.h"
 #include "types/ble_address_with_type.h"
 #include "types/bt_transport.h"
 #include "types/raw_address.h"
 
-#include "bta_api_data_types.h"
-
 /* Security Setting Mask */
 #define BTA_SEC_AUTHENTICATE \
   (BTM_SEC_IN_AUTHENTICATE | \
diff --git a/system/bta/le_audio/devices.h b/system/bta/le_audio/devices.h
index 49bd52805b5..922204482cd 100644
--- a/system/bta/le_audio/devices.h
+++ b/system/bta/le_audio/devices.h
@@ -31,7 +31,6 @@
 #endif
 
 #include "audio_hal_client/audio_hal_client.h"
-#include "bt_types.h"
 #include "bta_groups.h"
 #include "btm_iso_api_types.h"
 #include "gatt_api.h"
diff --git a/system/bta/sys/bta_sys_main.cc b/system/bta/sys/bta_sys_main.cc
index 5dcfd45cbc4..614deb3a4c5 100644
--- a/system/bta/sys/bta_sys_main.cc
+++ b/system/bta/sys/bta_sys_main.cc
@@ -37,7 +37,6 @@
 #include "osi/include/allocator.h"
 #include "osi/include/log.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "stack/include/main_thread.h"
 
 void BTIF_dm_on_hw_error();
diff --git a/system/btif/src/btif_a2dp_sink.cc b/system/btif/src/btif_a2dp_sink.cc
index fe2bca06bab..be2098788ec 100644
--- a/system/btif/src/btif_a2dp_sink.cc
+++ b/system/btif/src/btif_a2dp_sink.cc
@@ -40,7 +40,6 @@
 #include "osi/include/log.h"
 #include "osi/include/osi.h"  // UNUSED_ATTR
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 using bluetooth::common::MessageLoopThread;
diff --git a/system/btif/src/btif_sock_l2cap.cc b/system/btif/src/btif_sock_l2cap.cc
index afb0ef52fb4..545345172a8 100644
--- a/system/btif/src/btif_sock_l2cap.cc
+++ b/system/btif/src/btif_sock_l2cap.cc
@@ -37,7 +37,6 @@
 #include "osi/include/osi.h"
 #include "stack/btm/security_device_record.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 struct packet {
diff --git a/system/common/address_obfuscator.h b/system/common/address_obfuscator.h
index b8e7dc27f95..9118b07af86 100644
--- a/system/common/address_obfuscator.h
+++ b/system/common/address_obfuscator.h
@@ -18,10 +18,10 @@
 
 #pragma once
 
-#include <array>
 #include <mutex>
 #include <string>
 
+#include "gd/hci/octets.h"
 #include "raw_address.h"
 
 namespace bluetooth {
@@ -29,8 +29,8 @@ namespace common {
 
 class AddressObfuscator {
  public:
-  static constexpr unsigned int kOctet32Length = 32;
-  using Octet32 = std::array<uint8_t, kOctet32Length>;
+  static constexpr unsigned int kOctet32Length = hci::kOctet32Length;
+  using Octet32 = hci::Octet32;
   static AddressObfuscator* GetInstance() {
     static auto instance = new AddressObfuscator();
     return instance;
diff --git a/system/device/include/device_iot_config.h b/system/device/include/device_iot_config.h
index df2f94c31a5..060b0bdd0d8 100644
--- a/system/device/include/device_iot_config.h
+++ b/system/device/include/device_iot_config.h
@@ -23,7 +23,6 @@
 #include <stddef.h>
 
 #include "bt_target.h"
-#include "bt_types.h"
 #include "device_iot_conf_defs.h"
 #include "raw_address.h"
 
diff --git a/system/device/src/device_iot_config.cc b/system/device/src/device_iot_config.cc
index 1f6060460a8..ff0a759d303 100644
--- a/system/device/src/device_iot_config.cc
+++ b/system/device/src/device_iot_config.cc
@@ -29,7 +29,6 @@
 #include <mutex>
 #include <string>
 
-#include "bt_types.h"
 #include "btcore/include/module.h"
 #include "btif/include/btif_api.h"
 #include "btif/include/btif_util.h"
diff --git a/system/device/src/device_iot_config_int.cc b/system/device/src/device_iot_config_int.cc
index 9ec0f8d986e..c99b269d5ee 100644
--- a/system/device/src/device_iot_config_int.cc
+++ b/system/device/src/device_iot_config_int.cc
@@ -30,7 +30,6 @@
 #include <mutex>
 #include <string>
 
-#include "bt_types.h"
 #include "btcore/include/module.h"
 #include "btif/include/btif_api.h"
 #include "btif/include/btif_util.h"
diff --git a/system/device/src/interop.cc b/system/device/src/interop.cc
index bf1bc15c894..ad01073cbe0 100644
--- a/system/device/src/interop.cc
+++ b/system/device/src/interop.cc
@@ -37,7 +37,6 @@
 #include <string>
 #include <utility>
 
-#include "bt_types.h"
 #include "btcore/include/module.h"
 #include "btif/include/btif_storage.h"
 #include "check.h"
diff --git a/system/gd/crypto_toolbox/crypto_toolbox.h b/system/gd/crypto_toolbox/crypto_toolbox.h
index aa15d6ead84..799183d4e7c 100644
--- a/system/gd/crypto_toolbox/crypto_toolbox.h
+++ b/system/gd/crypto_toolbox/crypto_toolbox.h
@@ -21,11 +21,13 @@
 #include <cstdint>
 #include <cstring>
 
+#include "hci/octets.h"
+
 namespace bluetooth {
 namespace crypto_toolbox {
 
-constexpr int OCTET16_LEN = 16;
-using Octet16 = std::array<uint8_t, OCTET16_LEN>;
+constexpr int OCTET16_LEN = hci::kOctet16Length;
+using Octet16 = hci::Octet16;
 
 Octet16 c1(
     const Octet16& k,
diff --git a/system/gd/hci/octets.h b/system/gd/hci/octets.h
new file mode 100644
index 00000000000..0eba1561c0d
--- /dev/null
+++ b/system/gd/hci/octets.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2023 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 <array>
+#include <cstdint>
+
+namespace bluetooth::hci {
+
+constexpr int kOctet16Length = 16;
+using Octet16 = std::array<uint8_t, kOctet16Length>;
+
+constexpr int kOctet32Length = 32;
+using Octet32 = std::array<uint8_t, kOctet32Length>;
+}  // namespace bluetooth::hci
diff --git a/system/main/shim/acl.h b/system/main/shim/acl.h
index 5c08312e7af..eadb465bd67 100644
--- a/system/main/shim/acl.h
+++ b/system/main/shim/acl.h
@@ -29,7 +29,6 @@
 #include "main/shim/acl_legacy_interface.h"
 #include "main/shim/link_connection_interface.h"
 #include "main/shim/link_policy_interface.h"
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 using LeRandCallback = base::OnceCallback<void(uint64_t)>;
diff --git a/system/main/shim/acl_legacy_interface.h b/system/main/shim/acl_legacy_interface.h
index b4aaae8bb5f..5a3ac0716e8 100644
--- a/system/main/shim/acl_legacy_interface.h
+++ b/system/main/shim/acl_legacy_interface.h
@@ -19,7 +19,6 @@
 #include <cstdint>
 
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "stack/include/hci_error_code.h"
 #include "stack/include/hci_mode.h"
 #include "stack/include/hcidefs.h"
diff --git a/system/main/shim/helpers.h b/system/main/shim/helpers.h
index 7d023291eb7..bd1dd93204e 100644
--- a/system/main/shim/helpers.h
+++ b/system/main/shim/helpers.h
@@ -20,7 +20,6 @@
 #include "hci/address_with_type.h"
 #include "osi/include/allocator.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "stack/include/hci_error_code.h"
 #include "stack/include/hci_mode.h"
 #include "stack/include/hcidefs.h"
diff --git a/system/profile/sdp/common/data_element_reader.h b/system/profile/sdp/common/data_element_reader.h
index 13346bd8838..5b4d770a268 100644
--- a/system/profile/sdp/common/data_element_reader.h
+++ b/system/profile/sdp/common/data_element_reader.h
@@ -22,7 +22,7 @@
 #include "bluetooth/uuid.h"
 #include "packet.h"
 #include "sdp_common.h"
-#include "stack/include/bt_types.h"
+#include "stack/include/bt_octets.h"
 
 namespace bluetooth {
 namespace sdp {
diff --git a/system/stack/acl/peer_packet_types.h b/system/stack/acl/peer_packet_types.h
index 952cf63dda5..78aa9466866 100644
--- a/system/stack/acl/peer_packet_types.h
+++ b/system/stack/acl/peer_packet_types.h
@@ -16,7 +16,6 @@
 
 #pragma once
 
-#include "stack/include/bt_types.h"
 #include "stack/include/hcidefs.h"
 
 #define BD_FEATURES_LEN 8
diff --git a/system/stack/btm/ble_advertiser_hci_interface.h b/system/stack/btm/ble_advertiser_hci_interface.h
index 0b95cf9a6c8..b946f39cad6 100644
--- a/system/stack/btm/ble_advertiser_hci_interface.h
+++ b/system/stack/btm/ble_advertiser_hci_interface.h
@@ -23,7 +23,6 @@
 
 #include <vector>
 
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 /* This class is an abstraction of HCI commands used for managing
diff --git a/system/stack/btm/ble_scanner_hci_interface.h b/system/stack/btm/ble_scanner_hci_interface.h
index 31080016a40..7a2e19910d1 100644
--- a/system/stack/btm/ble_scanner_hci_interface.h
+++ b/system/stack/btm/ble_scanner_hci_interface.h
@@ -22,7 +22,6 @@
 
 #include <vector>
 
-#include "stack/include/bt_types.h"
 #include "types/raw_address.h"
 
 class BleScannerHciInterface {
diff --git a/system/stack/btm/btm_devctl.cc b/system/stack/btm/btm_devctl.cc
index 842599d91c2..5c293480039 100644
--- a/system/stack/btm/btm_devctl.cc
+++ b/system/stack/btm/btm_devctl.cc
@@ -23,6 +23,7 @@
  *
  ******************************************************************************/
 
+#include "acl_api_types.h"
 #define LOG_TAG "devctl"
 
 #include <base/logging.h>
diff --git a/system/stack/include/acl_hci_link_interface.h b/system/stack/include/acl_hci_link_interface.h
index 8566c96d93b..e6a1ce1386b 100644
--- a/system/stack/include/acl_hci_link_interface.h
+++ b/system/stack/include/acl_hci_link_interface.h
@@ -20,7 +20,6 @@
 #include <cstdint>
 
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 #include "stack/include/hci_error_code.h"
 #include "stack/include/hci_mode.h"
 #include "stack/include/hcidefs.h"
diff --git a/system/stack/include/avrc_defs.h b/system/stack/include/avrc_defs.h
index 864eef01d55..ca9fd7ea5e9 100644
--- a/system/stack/include/avrc_defs.h
+++ b/system/stack/include/avrc_defs.h
@@ -27,7 +27,6 @@
 #include <cstdint>
 
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_types.h"
 
 /*****************************************************************************
  *  constants
diff --git a/system/stack/include/ble_acl_interface.h b/system/stack/include/ble_acl_interface.h
index 128dfbffbcc..244e13b1268 100644
--- a/system/stack/include/ble_acl_interface.h
+++ b/system/stack/include/ble_acl_interface.h
@@ -18,8 +18,9 @@
 
 #include <cstdint>
 
-#include "stack/include/bt_types.h"
 #include "stack/include/hci_error_code.h"
+#include "types/ble_address_with_type.h"
+#include "types/hci_role.h"
 #include "types/raw_address.h"
 
 void acl_ble_enhanced_connection_complete(
diff --git a/system/stack/include/bt_octets.h b/system/stack/include/bt_octets.h
index 36c9e07ab8a..3a90164e1d7 100644
--- a/system/stack/include/bt_octets.h
+++ b/system/stack/include/bt_octets.h
@@ -16,17 +16,13 @@
 
 #pragma once
 
-/* Some C files include this header file */
-#ifdef __cplusplus
-
-#include <array>
 #include <cstdint>
 
-constexpr int OCTET16_LEN = 16;
-typedef std::array<uint8_t, OCTET16_LEN> Octet16;
+#include "gd/hci/octets.h"
 
-constexpr int LINK_KEY_LEN = OCTET16_LEN;
-typedef Octet16 LinkKey; /* Link Key */
+using Octet16 = bluetooth::hci::Octet16;
+using LinkKey = bluetooth::hci::Octet16; /* Link Key */
+static constexpr int OCTET16_LEN = bluetooth::hci::kOctet16Length;
 
 /* Sample LTK from BT Spec 5.1 | Vol 6, Part C 1
  * 0x4C68384139F574D836BCF34E9DFB01BF */
@@ -34,8 +30,6 @@ constexpr Octet16 SAMPLE_LTK = {0xbf, 0x01, 0xfb, 0x9d, 0x4e, 0xf3, 0xbc, 0x36,
                                 0xd8, 0x74, 0xf5, 0x39, 0x41, 0x38, 0x68, 0x4c};
 inline bool is_sample_ltk(const Octet16& ltk) { return ltk == SAMPLE_LTK; }
 
-#endif
-
 #define BT_OCTET8_LEN 8
 typedef uint8_t BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 16 */
 
diff --git a/system/stack/include/bt_types.h b/system/stack/include/bt_types.h
index e4f0f12ad42..1831b83dd80 100644
--- a/system/stack/include/bt_types.h
+++ b/system/stack/include/bt_types.h
@@ -20,17 +20,13 @@
 #define BT_TYPES_H
 
 #include <stdbool.h>
-#include <stdint.h>
-#ifdef __cplusplus
-#include <string>
-#endif  // __cplusplus
 
 #include "stack/include/bt_dev_class.h"
 #include "stack/include/bt_device_type.h"
 #include "stack/include/bt_hdr.h"
-#include "stack/include/bt_octets.h"
 #ifdef __cplusplus
 #include "include/hardware/bluetooth.h"
+#include "stack/include/bt_octets.h"
 #include "types/bluetooth/uuid.h"
 #include "types/raw_address.h"
 #endif  // __cplusplus
diff --git a/system/stack/include/sco_hci_link_interface.h b/system/stack/include/sco_hci_link_interface.h
index cd9d8f9e6b4..34dc174113d 100644
--- a/system/stack/include/sco_hci_link_interface.h
+++ b/system/stack/include/sco_hci_link_interface.h
@@ -19,6 +19,7 @@
 
 #include <cstdint>
 
+#include "stack/include/bt_dev_class.h"
 #include "stack/include/hci_error_code.h"
 #include "types/class_of_device.h"
 #include "types/raw_address.h"
diff --git a/system/stack/test/btm/peer_packet_types_test.cc b/system/stack/test/btm/peer_packet_types_test.cc
index 4b8485398e8..aeae23770c5 100644
--- a/system/stack/test/btm/peer_packet_types_test.cc
+++ b/system/stack/test/btm/peer_packet_types_test.cc
@@ -16,12 +16,10 @@
  *
  */
 
+#include "stack/acl/peer_packet_types.h"
+
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
-#include <map>
-
-#include "stack/acl/peer_packet_types.h"
-#include "stack/include/bt_types.h"
 
 namespace {
 
diff --git a/system/test/suite/adapter/adapter_unittest.cc b/system/test/suite/adapter/adapter_unittest.cc
index fe30df33529..dc8771da3c0 100644
--- a/system/test/suite/adapter/adapter_unittest.cc
+++ b/system/test/suite/adapter/adapter_unittest.cc
@@ -18,7 +18,6 @@
 
 #include "adapter/bluetooth_test.h"
 #include "btcore/include/property.h"
-#include "stack/include/bt_types.h"
 #include "types/bt_transport.h"
 #include "types/raw_address.h"
 
-- 
GitLab