Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5277d21a authored by Zach Johnson's avatar Zach Johnson
Browse files

CommandPacket -> Command

drop the packet, it's simpler.

CommandPacket is already a packet, and the generated Rust packets will
have Packet appended in some cases, which would lead to
CommandPacketPacket, which is not great.

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost SimpleHalTest
Change-Id: I5ad00f7c0f0d2dda83b3e1213145f0bd87c799e0
parent cbbb8b64
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ void FuzzHciHal::injectArbitrary(FuzzedDataProvider& fdp) {
}

void FuzzHciHal::sendHciCommand(HciPacket packet) {
  hci::CommandPacketView command = hci::CommandPacketView::FromBytes(packet);
  hci::CommandView command = hci::CommandView::FromBytes(packet);
  if (!command.IsValid()) {
    return;
  }
+1 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    callbacks->OnReadRemoteVersionInformationComplete(version, manufacturer_name, sub_version);
  }

  void enqueue_command(std::unique_ptr<CommandPacketBuilder> command_packet) {
  void enqueue_command(std::unique_ptr<CommandBuilder> command_packet) {
    hci_layer_->EnqueueCommand(
        std::move(command_packet),
        handler_->BindOnce(&LeAddressManager::OnCommandComplete, common::Unretained(le_address_manager_)));
+68 −66

File changed.

Preview size limit exceeded, changes collapsed.

+14 −11
Original line number Diff line number Diff line
@@ -57,21 +57,24 @@ PacketView<kLittleEndian> GetPacketView(std::unique_ptr<packet::BasePacketBuilde

class TestHciLayer : public HciLayer {
 public:
  void EnqueueCommand(std::unique_ptr<CommandPacketBuilder> command,
  void EnqueueCommand(
      std::unique_ptr<CommandBuilder> command,
      common::ContextualOnceCallback<void(CommandCompleteView)> on_complete) override {
    GetHandler()->Post(common::BindOnce(&TestHciLayer::HandleCommand, common::Unretained(this), std::move(command),
                                        std::move(on_complete)));
  }

  void EnqueueCommand(std::unique_ptr<CommandPacketBuilder> command,
  void EnqueueCommand(
      std::unique_ptr<CommandBuilder> command,
      common::ContextualOnceCallback<void(CommandStatusView)> on_status) override {
    EXPECT_TRUE(false) << "Controller properties should not generate Command Status";
  }

  void HandleCommand(std::unique_ptr<CommandPacketBuilder> command_builder,
  void HandleCommand(
      std::unique_ptr<CommandBuilder> command_builder,
      common::ContextualOnceCallback<void(CommandCompleteView)> on_complete) {
    auto packet_view = GetPacketView(std::move(command_builder));
    CommandPacketView command = CommandPacketView::Create(packet_view);
    CommandView command = CommandView::Create(packet_view);
    ASSERT_TRUE(command.IsValid());

    uint8_t num_packets = 1;
@@ -227,7 +230,7 @@ class TestHciLayer : public HciLayer {
    number_of_completed_packets_callback_.Invoke(event);
  }

  CommandPacketView GetCommand(OpCode op_code) {
  CommandView GetCommand(OpCode op_code) {
    std::unique_lock<std::mutex> lock(mutex_);
    std::chrono::milliseconds time = std::chrono::milliseconds(3000);

@@ -239,9 +242,9 @@ class TestHciLayer : public HciLayer {
    }
    EXPECT_TRUE(command_queue_.size() > 0);
    if (command_queue_.empty()) {
      return CommandPacketView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>()));
      return CommandView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>()));
    }
    CommandPacketView command = command_queue_.front();
    CommandView command = command_queue_.front();
    EXPECT_EQ(command.GetOpCode(), op_code);
    command_queue_.pop();
    return command;
@@ -260,7 +263,7 @@ class TestHciLayer : public HciLayer {

 private:
  common::ContextualCallback<void(EventPacketView)> number_of_completed_packets_callback_;
  std::queue<CommandPacketView> command_queue_;
  std::queue<CommandView> command_queue_;
  mutable std::mutex mutex_;
  std::condition_variable not_empty_;
};
+2 −2
Original line number Diff line number Diff line
@@ -114,8 +114,8 @@ class AclManagerFacadeService : public AclManagerFacade::Service, public Connect
      ::grpc::ServerContext* context,
      const ConnectionCommandMsg* request,
      ::google::protobuf::Empty* response) override {
    auto command_view = ConnectionManagementCommandView::Create(
        AclCommandView::Create(CommandPacketView::Create(PacketView<kLittleEndian>(
    auto command_view =
        ConnectionManagementCommandView::Create(AclCommandView::Create(CommandView::Create(PacketView<kLittleEndian>(
            std::make_shared<std::vector<uint8_t>>(request->packet().begin(), request->packet().end())))));
    if (!command_view.IsValid()) {
      return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Invalid command packet");
Loading