RootCanal: Remove AclPacketBuilder and ScoPacketBuilder
Bug: 140386699
Test: run_cert.sh
Change-Id: I262b2fe26614c790879c5e3a8abff5616a064b1d
diff --git a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
index d4974a0..cd38ffe 100644
--- a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
+++ b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.cc
@@ -26,9 +26,8 @@
#include "packet/raw_builder.h"
#include "hci.h"
-#include "packets/hci/acl_packet_view.h"
#include "packets/hci/command_packet_view.h"
-#include "packets/hci/sco_packet_view.h"
+#include "packets/packet_view.h"
using std::vector;
using test_vendor_lib::hci::EventCode;
@@ -234,7 +233,9 @@
}
void DualModeController::HandleAcl(std::shared_ptr<std::vector<uint8_t>> packet) {
- auto acl_packet = packets::AclPacketView::Create(packet);
+ bluetooth::hci::PacketView<bluetooth::hci::kLittleEndian> raw_packet(packet);
+ auto acl_packet = bluetooth::hci::AclPacketView::Create(raw_packet);
+ ASSERT(acl_packet.IsValid());
if (loopback_mode_ == hci::LoopbackMode::LOCAL) {
uint16_t handle = acl_packet.GetHandle();
@@ -253,7 +254,8 @@
}
void DualModeController::HandleSco(std::shared_ptr<std::vector<uint8_t>> packet) {
- auto sco_packet = packets::ScoPacketView::Create(packet);
+ bluetooth::hci::PacketView<bluetooth::hci::kLittleEndian> raw_packet(packet);
+ auto sco_packet = bluetooth::hci::ScoPacketView::Create(raw_packet);
if (loopback_mode_ == hci::LoopbackMode::LOCAL) {
uint16_t handle = sco_packet.GetHandle();
send_sco_(packet);
@@ -314,8 +316,15 @@
void DualModeController::RegisterAclChannel(
const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>& callback) {
- link_layer_controller_.RegisterAclChannel(callback);
- send_acl_ = callback;
+ send_acl_ =
+ [callback](std::shared_ptr<bluetooth::hci::AclPacketBuilder> acl_data) {
+ auto bytes = std::make_shared<std::vector<uint8_t>>();
+ bluetooth::packet::BitInserter bit_inserter(*bytes);
+ bytes->reserve(acl_data->size());
+ acl_data->Serialize(bit_inserter);
+ callback(std::move(bytes));
+ };
+ link_layer_controller_.RegisterAclChannel(send_acl_);
}
void DualModeController::RegisterScoChannel(
diff --git a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
index b2ec70a..bd9c17d 100644
--- a/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
+++ b/vendor_libs/test_vendor_lib/model/controller/dual_mode_controller.h
@@ -435,7 +435,8 @@
void SendCommandCompleteUnknownOpCodeEvent(uint16_t command_opcode) const;
// Callbacks to send packets back to the HCI.
- std::function<void(std::shared_ptr<std::vector<uint8_t>>)> send_acl_;
+ std::function<void(std::shared_ptr<bluetooth::hci::AclPacketBuilder>)>
+ send_acl_;
std::function<void(std::shared_ptr<bluetooth::hci::EventPacketBuilder>)>
send_event_;
std::function<void(std::shared_ptr<std::vector<uint8_t>>)> send_sco_;
diff --git a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc
index b77f2ce..dcec05b 100644
--- a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc
+++ b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.cc
@@ -19,9 +19,7 @@
#include "hci.h"
#include "include/le_advertisement.h"
#include "os/log.h"
-#include "packets/hci/acl_packet_builder.h"
#include "packets/hci/command_packet_view.h"
-#include "packets/hci/sco_packet_builder.h"
#include "packets/raw_builder.h"
#include "packet/raw_builder.h"
@@ -95,7 +93,8 @@
return SendCommandToRemoteByAddress(opcode, args, connections_.GetAddress(handle), use_public_address);
}
-hci::Status LinkLayerController::SendAclToRemote(AclPacketView acl_packet) {
+hci::Status LinkLayerController::SendAclToRemote(
+ bluetooth::hci::AclPacketView acl_packet) {
uint16_t handle = acl_packet.GetHandle();
if (!connections_.HasHandle(handle)) {
return hci::Status::UNKNOWN_CONNECTION;
@@ -129,8 +128,8 @@
uint16_t first_two_bytes =
static_cast<uint16_t>(acl_packet.GetHandle()) +
- (static_cast<uint16_t>(acl_packet.GetPacketBoundaryFlags()) << 12) +
- (static_cast<uint16_t>(acl_packet.GetBroadcastFlags()) << 14);
+ (static_cast<uint16_t>(acl_packet.GetPacketBoundaryFlag()) << 12) +
+ (static_cast<uint16_t>(acl_packet.GetBroadcastFlag()) << 14);
raw_builder_ptr->AddOctets2(first_two_bytes);
raw_builder_ptr->AddOctets2(static_cast<uint16_t>(payload_bytes.size()));
raw_builder_ptr->AddOctets(payload_bytes);
@@ -234,18 +233,26 @@
std::shared_ptr<std::vector<uint8_t>> payload_bytes =
std::make_shared<std::vector<uint8_t>>(payload.begin(), payload.end());
- AclPacketView acl_view = AclPacketView::Create(payload_bytes);
+ bluetooth::hci::PacketView<bluetooth::hci::kLittleEndian> raw_packet(
+ payload_bytes);
+ auto acl_view = bluetooth::hci::AclPacketView::Create(raw_packet);
+ ASSERT(acl_view.IsValid());
+
LOG_INFO("%s: remote handle 0x%x size %d", __func__, acl_view.GetHandle(), static_cast<int>(acl_view.size()));
uint16_t local_handle = connections_.GetHandle(incoming.GetSourceAddress());
LOG_INFO("%s: local handle 0x%x", __func__, local_handle);
- acl::PacketBoundaryFlagsType boundary_flags = acl_view.GetPacketBoundaryFlags();
- acl::BroadcastFlagsType broadcast_flags = acl_view.GetBroadcastFlags();
- std::unique_ptr<RawBuilder> builder = std::make_unique<RawBuilder>();
- std::vector<uint8_t> raw_data(acl_view.GetPayload().begin(),
- acl_view.GetPayload().end());
- builder->AddOctets(raw_data);
- send_acl_(AclPacketBuilder::Create(local_handle, boundary_flags, broadcast_flags, std::move(builder))->ToVector());
+ std::unique_ptr<bluetooth::packet::RawBuilder> raw_builder_ptr =
+ std::make_unique<bluetooth::packet::RawBuilder>();
+ std::vector<uint8_t> payload_data(acl_view.GetPayload().begin(),
+ acl_view.GetPayload().end());
+ raw_builder_ptr->AddOctets(payload_data);
+
+ auto acl_packet = bluetooth::hci::AclPacketBuilder::Create(
+ local_handle, acl_view.GetPacketBoundaryFlag(),
+ acl_view.GetBroadcastFlag(), std::move(raw_builder_ptr));
+
+ send_acl_(std::move(acl_packet));
}
void LinkLayerController::IncomingCommandPacket(
@@ -889,7 +896,8 @@
}
void LinkLayerController::RegisterAclChannel(
- const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>& callback) {
+ const std::function<
+ void(std::shared_ptr<bluetooth::hci::AclPacketBuilder>)>& callback) {
send_acl_ = callback;
}
diff --git a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h
index ffc9044..86797ce 100644
--- a/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h
+++ b/vendor_libs/test_vendor_lib/model/controller/link_layer_controller.h
@@ -24,9 +24,8 @@
#include "include/phy.h"
#include "model/devices/device_properties.h"
#include "model/setup/async_manager.h"
-#include "packets/hci/acl_packet_view.h"
-#include "packets/hci/sco_packet_view.h"
#include "packets/link_layer_packets.h"
+#include "packets/packet_view.h"
#include "security_manager.h"
namespace test_vendor_lib {
@@ -44,8 +43,8 @@
bluetooth::hci::ErrorCode SendCommandToRemoteByHandle(
bluetooth::hci::OpCode opcode, packets::PacketView<true> args,
uint16_t handle);
- hci::Status SendScoToRemote(packets::ScoPacketView sco_packet);
- hci::Status SendAclToRemote(packets::AclPacketView acl_packet);
+ hci::Status SendScoToRemote(bluetooth::hci::ScoPacketView sco_packet);
+ hci::Status SendAclToRemote(bluetooth::hci::AclPacketView acl_packet);
void WriteSimplePairingMode(bool enabled);
void StartSimplePairing(const Address& address);
@@ -108,7 +107,9 @@
const std::function<void(
std::shared_ptr<bluetooth::hci::EventPacketBuilder>)>& send_event_);
- void RegisterAclChannel(const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>& send_acl);
+ void RegisterAclChannel(
+ const std::function<
+ void(std::shared_ptr<bluetooth::hci::AclPacketBuilder>)>& send_acl);
void RegisterScoChannel(const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>& send_sco);
@@ -308,7 +309,8 @@
std::function<void(AsyncTaskId)> cancel_task_;
// Callbacks to send packets back to the HCI.
- std::function<void(std::shared_ptr<std::vector<uint8_t>>)> send_acl_;
+ std::function<void(std::shared_ptr<bluetooth::hci::AclPacketBuilder>)>
+ send_acl_;
std::function<void(std::shared_ptr<bluetooth::hci::EventPacketBuilder>)>
send_event_;
std::function<void(std::shared_ptr<std::vector<uint8_t>>)> send_sco_;
diff --git a/vendor_libs/test_vendor_lib/model/devices/car_kit.cc b/vendor_libs/test_vendor_lib/model/devices/car_kit.cc
index f3fc3e6..65603f1 100644
--- a/vendor_libs/test_vendor_lib/model/devices/car_kit.cc
+++ b/vendor_libs/test_vendor_lib/model/devices/car_kit.cc
@@ -31,7 +31,8 @@
page_scan_delay_ms_ = std::chrono::milliseconds(600);
// Stub in packet handling for now
- link_layer_controller_.RegisterAclChannel([](std::shared_ptr<std::vector<uint8_t>>) {});
+ link_layer_controller_.RegisterAclChannel(
+ [](std::shared_ptr<bluetooth::hci::AclPacketBuilder>) {});
link_layer_controller_.RegisterEventChannel(
[](std::shared_ptr<bluetooth::hci::EventPacketBuilder>) {});
link_layer_controller_.RegisterScoChannel([](std::shared_ptr<std::vector<uint8_t>>) {});
diff --git a/vendor_libs/test_vendor_lib/packets/Android.bp b/vendor_libs/test_vendor_lib/packets/Android.bp
index d25a11f..a769e14 100644
--- a/vendor_libs/test_vendor_lib/packets/Android.bp
+++ b/vendor_libs/test_vendor_lib/packets/Android.bp
@@ -14,13 +14,9 @@
"packet_view.cc",
"raw_builder.cc",
"view.cc",
- "hci/acl_packet_builder.cc",
- "hci/acl_packet_view.cc",
"hci/command_packet_builder.cc",
"hci/command_packet_view.cc",
"hci/hci_packet_builder.cc",
- "hci/sco_packet_builder.cc",
- "hci/sco_packet_view.cc",
],
cflags: [
"-fvisibility=hidden",
@@ -53,7 +49,6 @@
srcs: [
"test/packet_builder_test.cc",
"test/packet_view_test.cc",
- "hci/test/acl_builder_test.cc",
":BluetoothHciClassSources",
],
header_libs: [
diff --git a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_builder.cc b/vendor_libs/test_vendor_lib/packets/hci/acl_packet_builder.cc
deleted file mode 100644
index 3c74ad6..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_builder.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2018 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 "packets/hci/acl_packet_builder.h"
-
-#include "os/log.h"
-
-using std::vector;
-using test_vendor_lib::acl::BroadcastFlagsType;
-using test_vendor_lib::acl::PacketBoundaryFlagsType;
-
-namespace test_vendor_lib {
-namespace packets {
-
-AclPacketBuilder::AclPacketBuilder(uint16_t handle, PacketBoundaryFlagsType packet_boundary_flags,
- BroadcastFlagsType broadcast_flags, std::unique_ptr<BasePacketBuilder> payload)
- : handle_(handle), packet_boundary_flags_(packet_boundary_flags), broadcast_flags_(broadcast_flags),
- payload_(std::move(payload)) {}
-
-std::unique_ptr<AclPacketBuilder> AclPacketBuilder::Create(uint16_t handle,
- PacketBoundaryFlagsType packet_boundary_flags,
- BroadcastFlagsType broadcast_flags,
- std::unique_ptr<BasePacketBuilder> payload) {
- return std::unique_ptr<AclPacketBuilder>(
- new AclPacketBuilder(handle, packet_boundary_flags, broadcast_flags, std::move(payload)));
-}
-
-size_t AclPacketBuilder::size() const {
- return 2 * sizeof(uint16_t) + payload_->size();
-}
-
-void AclPacketBuilder::Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const {
- insert(static_cast<uint16_t>((handle_ & 0xfff) | (static_cast<uint16_t>(packet_boundary_flags_) << 12) |
- (static_cast<uint16_t>(broadcast_flags_) << 14)),
- it);
- uint16_t payload_size = payload_->size();
-
- ASSERT_LOG(static_cast<size_t>(payload_size) == payload_->size(), "Payload too large for an ACL packet: %d",
- static_cast<int>(payload_->size()));
- insert(payload_size, it);
- payload_->Serialize(it);
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_builder.h b/vendor_libs/test_vendor_lib/packets/hci/acl_packet_builder.h
deleted file mode 100644
index 9599130..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_builder.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2018 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 <memory>
-#include <vector>
-
-#include "include/acl.h"
-#include "packets/hci/hci_packet_builder.h"
-#include "packets/packet_builder.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-// ACL data packets are specified in the Bluetooth Core Specification Version
-// 4.2, Volume 2, Part E, Section 5.4.2
-class AclPacketBuilder : public HciPacketBuilder {
- public:
- virtual ~AclPacketBuilder() override = default;
-
- static std::unique_ptr<AclPacketBuilder> Create(uint16_t handle, acl::PacketBoundaryFlagsType packet_boundary_flags,
- acl::BroadcastFlagsType broadcast_flags,
- std::unique_ptr<BasePacketBuilder> payload);
-
- virtual size_t size() const override;
- virtual void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const;
-
- private:
- AclPacketBuilder(uint16_t handle, acl::PacketBoundaryFlagsType packet_boundary_flags,
- acl::BroadcastFlagsType broadcast_flags, std::unique_ptr<BasePacketBuilder> payload);
- AclPacketBuilder() = delete;
- uint16_t handle_;
- acl::PacketBoundaryFlagsType packet_boundary_flags_;
- acl::BroadcastFlagsType broadcast_flags_;
- std::unique_ptr<BasePacketBuilder> payload_;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_view.cc b/vendor_libs/test_vendor_lib/packets/hci/acl_packet_view.cc
deleted file mode 100644
index 4e41a73..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_view.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2018 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 "packets/hci/acl_packet_view.h"
-
-#include "os/log.h"
-
-using std::vector;
-using test_vendor_lib::acl::BroadcastFlagsType;
-using test_vendor_lib::acl::PacketBoundaryFlagsType;
-
-namespace test_vendor_lib {
-namespace packets {
-
-AclPacketView::AclPacketView(std::shared_ptr<std::vector<uint8_t>> packet) : PacketView<true>(packet) {}
-
-AclPacketView::AclPacketView(PacketView<true> packet_view) : PacketView<true>(packet_view) {}
-
-AclPacketView AclPacketView::Create(std::shared_ptr<std::vector<uint8_t>> packet) {
- return AclPacketView(packet);
-}
-
-AclPacketView AclPacketView::Create(PacketView<true> packet_view) {
- return AclPacketView(packet_view);
-}
-
-uint16_t AclPacketView::GetHandle() const {
- return begin().extract<uint16_t>() & 0xfff;
-}
-
-PacketBoundaryFlagsType AclPacketView::GetPacketBoundaryFlags() const {
- return static_cast<PacketBoundaryFlagsType>(((begin() + 1).extract<uint8_t>() & 0x30) >> 4);
-}
-
-BroadcastFlagsType AclPacketView::GetBroadcastFlags() const {
- return static_cast<BroadcastFlagsType>(((begin() + 1).extract<uint8_t>() & 0xc0) >> 6);
-}
-
-PacketView<true> AclPacketView::GetPayload() const {
- uint16_t payload_size = (begin() + sizeof(uint16_t)).extract<uint16_t>();
- ASSERT_LOG(static_cast<uint16_t>(size() - 2 * sizeof(uint16_t)) == payload_size,
- "Malformed ACL packet payload_size %d + 4 != %d", static_cast<int>(payload_size),
- static_cast<int>(size()));
- return SubViewLittleEndian(2 * sizeof(uint16_t), size());
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_view.h b/vendor_libs/test_vendor_lib/packets/hci/acl_packet_view.h
deleted file mode 100644
index 1e69cda..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/acl_packet_view.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2018 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 <memory>
-#include <vector>
-
-#include "include/acl.h"
-#include "packets/packet_view.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-// ACL data packets are specified in the Bluetooth Core Specification Version
-// 4.2, Volume 2, Part E, Section 5.4.2
-class AclPacketView : public PacketView<true> {
- public:
- virtual ~AclPacketView() override = default;
-
- static AclPacketView Create(std::shared_ptr<std::vector<uint8_t>> packet);
- static AclPacketView Create(PacketView<true> packet_view);
-
- uint16_t GetHandle() const;
- acl::PacketBoundaryFlagsType GetPacketBoundaryFlags() const;
- acl::BroadcastFlagsType GetBroadcastFlags() const;
- PacketView<true> GetPayload() const;
-
- private:
- AclPacketView(std::shared_ptr<std::vector<uint8_t>> packet);
- AclPacketView(PacketView<true> packet_view);
- AclPacketView() = delete;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_builder.cc b/vendor_libs/test_vendor_lib/packets/hci/sco_packet_builder.cc
deleted file mode 100644
index ae61124..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_builder.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2018 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 "packets/hci/sco_packet_builder.h"
-
-#include "os/log.h"
-
-using std::vector;
-using test_vendor_lib::sco::PacketStatusFlagsType;
-
-namespace test_vendor_lib {
-namespace packets {
-
-ScoPacketBuilder::ScoPacketBuilder(uint16_t handle, PacketStatusFlagsType packet_status_flags,
- std::unique_ptr<BasePacketBuilder> payload)
- : handle_(handle), packet_status_flags_(packet_status_flags), payload_(std::move(payload)) {}
-
-size_t ScoPacketBuilder::size() const {
- return 2 * sizeof(uint16_t) + payload_->size();
-}
-
-void ScoPacketBuilder::Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const {
- insert(static_cast<uint16_t>((handle_ & 0xfff) | (static_cast<uint16_t>(packet_status_flags_) << 12)), it);
- uint8_t payload_size = payload_->size();
-
- ASSERT_LOG(static_cast<size_t>(payload_size) == payload_->size(), "Payload too large for a SCO packet: %d",
- static_cast<int>(payload_->size()));
- insert(payload_size, it);
- payload_->Serialize(it);
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_builder.h b/vendor_libs/test_vendor_lib/packets/hci/sco_packet_builder.h
deleted file mode 100644
index 94a71f5..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_builder.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2018 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 <memory>
-#include <vector>
-
-#include "include/sco.h"
-#include "packets/hci/hci_packet_builder.h"
-#include "packets/packet_builder.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-// SCO data packets are specified in the Bluetooth Core Specification Version
-// 4.2, Volume 2, Part E, Section 5.4.3
-class ScoPacketBuilder : public HciPacketBuilder {
- public:
- virtual ~ScoPacketBuilder() override = default;
-
- static std::unique_ptr<ScoPacketBuilder> Create(uint16_t handle, sco::PacketStatusFlagsType packet_status_flags,
- std::unique_ptr<BasePacketBuilder> payload);
-
- virtual size_t size() const override;
-
- virtual void Serialize(std::back_insert_iterator<std::vector<uint8_t>> it) const override;
-
- private:
- ScoPacketBuilder(uint16_t handle, sco::PacketStatusFlagsType packet_status_flags,
- std::unique_ptr<BasePacketBuilder> payload);
- ScoPacketBuilder() = delete;
- uint16_t handle_;
- sco::PacketStatusFlagsType packet_status_flags_;
- std::unique_ptr<BasePacketBuilder> payload_;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_view.cc b/vendor_libs/test_vendor_lib/packets/hci/sco_packet_view.cc
deleted file mode 100644
index 415ce05..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_view.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2018 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 "packets/hci/sco_packet_view.h"
-
-#include "os/log.h"
-
-using test_vendor_lib::sco::PacketStatusFlagsType;
-
-namespace test_vendor_lib {
-namespace packets {
-
-ScoPacketView::ScoPacketView(std::shared_ptr<std::vector<uint8_t>> packet) : PacketView<true>(packet) {}
-
-ScoPacketView ScoPacketView::Create(std::shared_ptr<std::vector<uint8_t>> packet) {
- return ScoPacketView(packet);
-}
-
-uint16_t ScoPacketView::GetHandle() const {
- return begin().extract<uint16_t>() & 0xfff;
-}
-
-PacketStatusFlagsType ScoPacketView::GetPacketStatusFlags() const {
- return static_cast<PacketStatusFlagsType>(((begin() + 1).extract<uint8_t>() & 0x30) >> 4);
-}
-
-PacketView<true> ScoPacketView::GetPayload() const {
- uint8_t payload_size = (begin() + sizeof(uint16_t)).extract<uint8_t>();
- ASSERT_LOG(static_cast<uint8_t>(size() - sizeof(uint16_t) - sizeof(uint8_t)) == payload_size,
- "Malformed SCO packet payload_size %d + 4 != %d", static_cast<int>(payload_size),
- static_cast<int>(size()));
- return SubViewLittleEndian(sizeof(uint16_t) + sizeof(uint8_t), size());
-}
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_view.h b/vendor_libs/test_vendor_lib/packets/hci/sco_packet_view.h
deleted file mode 100644
index 3fb24b0..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/sco_packet_view.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2018 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 <memory>
-#include <vector>
-
-#include "include/sco.h"
-#include "packets/packet_view.h"
-
-namespace test_vendor_lib {
-namespace packets {
-
-// SCO data packets are specified in the Bluetooth Core Specification Version
-// 4.2, Volume 2, Part E, Section 5.4.3
-class ScoPacketView : public PacketView<true> {
- public:
- virtual ~ScoPacketView() override = default;
-
- static ScoPacketView Create(std::shared_ptr<std::vector<uint8_t>> packet);
-
- uint16_t GetHandle() const;
- sco::PacketStatusFlagsType GetPacketStatusFlags() const;
- PacketView<true> GetPayload() const;
-
- private:
- ScoPacketView(std::shared_ptr<std::vector<uint8_t>> packet);
- ScoPacketView() = delete;
-};
-
-} // namespace packets
-} // namespace test_vendor_lib
diff --git a/vendor_libs/test_vendor_lib/packets/hci/test/acl_builder_test.cc b/vendor_libs/test_vendor_lib/packets/hci/test/acl_builder_test.cc
deleted file mode 100644
index ad99df1..0000000
--- a/vendor_libs/test_vendor_lib/packets/hci/test/acl_builder_test.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2018 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 "packets/hci/acl_packet_builder.h"
-#include "packets/hci/acl_packet_view.h"
-#include "packets/raw_builder.h"
-
-#include <gtest/gtest.h>
-#include <forward_list>
-#include <memory>
-
-#include "hci/address.h"
-
-using ::bluetooth::hci::Address;
-using std::vector;
-using test_vendor_lib::acl::BroadcastFlagsType;
-using test_vendor_lib::acl::PacketBoundaryFlagsType;
-
-namespace {
-vector<uint8_t> count = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
-};
-
-vector<uint8_t> information_request = {
- 0xfe, 0x2e, 0x0a, 0x00, 0x06, 0x00, 0x01, 0x00, 0x0a, 0x02, 0x02, 0x00, 0x02, 0x00,
-};
-
-} // namespace
-
-namespace test_vendor_lib {
-namespace packets {
-
-class AclBuilderTest : public ::testing::Test {
- public:
- AclBuilderTest() = default;
- ~AclBuilderTest() override = default;
-};
-
-TEST(AclBuilderTest, buildAclCountTest) {
- uint16_t handle = 0x0102;
- PacketBoundaryFlagsType packet_boundary_flags = PacketBoundaryFlagsType::FIRST_AUTOMATICALLY_FLUSHABLE;
- BroadcastFlagsType broadcast_flags = BroadcastFlagsType::ACTIVE_SLAVE_BROADCAST;
-
- std::unique_ptr<RawBuilder> count_payload = std::make_unique<RawBuilder>();
- count_payload->AddOctets(count);
- ASSERT_EQ(count.size(), count_payload->size());
-
- std::unique_ptr<AclPacketBuilder> count_packet =
- AclPacketBuilder::Create(handle, packet_boundary_flags, broadcast_flags, std::move(count_payload));
-
- ASSERT_EQ(count.size() + 4, count_packet->size());
-
- std::shared_ptr<std::vector<uint8_t>> count_packet_bytes = count_packet->ToVector();
- AclPacketView count_packet_view = AclPacketView::Create(count_packet_bytes);
-
- ASSERT_EQ(handle, count_packet_view.GetHandle());
- ASSERT_EQ(packet_boundary_flags, count_packet_view.GetPacketBoundaryFlags());
- ASSERT_EQ(broadcast_flags, count_packet_view.GetBroadcastFlags());
- PacketView<true> count_view = count_packet_view.GetPayload();
-
- ASSERT_EQ(count_view.size(), count.size());
- for (size_t i = 0; i < count_view.size(); i++) {
- ASSERT_EQ(count_view[i], count[i]);
- }
-}
-
-TEST(AclBuilderTest, buildInformationRequest) {
- uint16_t handle = 0x0efe;
- PacketBoundaryFlagsType packet_boundary_flags = PacketBoundaryFlagsType::FIRST_AUTOMATICALLY_FLUSHABLE;
- BroadcastFlagsType broadcast_flags = BroadcastFlagsType::POINT_TO_POINT;
-
- std::vector<uint8_t> payload_bytes(information_request.begin() + 4, information_request.end());
- std::unique_ptr<RawBuilder> payload = std::make_unique<RawBuilder>();
- payload->AddOctets(payload_bytes);
- ASSERT_EQ(payload_bytes.size(), payload->size());
-
- std::unique_ptr<AclPacketBuilder> packet =
- AclPacketBuilder::Create(handle, packet_boundary_flags, broadcast_flags, std::move(payload));
-
- ASSERT_EQ(information_request.size(), packet->size());
-
- std::shared_ptr<std::vector<uint8_t>> packet_bytes = packet->ToVector();
- AclPacketView packet_view = AclPacketView::Create(packet_bytes);
-
- ASSERT_EQ(packet_bytes->size(), information_request.size());
- for (size_t i = 0; i < packet_bytes->size(); i++) {
- ASSERT_EQ((*packet_bytes)[i], information_request[i]);
- }
-
- ASSERT_EQ(handle, packet_view.GetHandle());
- ASSERT_EQ(packet_boundary_flags, packet_view.GetPacketBoundaryFlags());
- ASSERT_EQ(broadcast_flags, packet_view.GetBroadcastFlags());
- PacketView<true> payload_view = packet_view.GetPayload();
-
- ASSERT_EQ(payload_view.size(), payload_bytes.size());
- for (size_t i = 0; i < payload_view.size(); i++) {
- ASSERT_EQ(payload_view[i], payload_bytes[i]);
- }
-
- ASSERT_EQ(packet_view.size(), information_request.size());
- for (size_t i = 0; i < packet_view.size(); i++) {
- ASSERT_EQ(packet_view[i], information_request[i]);
- }
-}
-
-} // namespace packets
-} // namespace test_vendor_lib