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

Commit bc1d590f authored by Myles Watson's avatar Myles Watson Committed by Andre Eisenbach
Browse files

test_vendor: Remove unused libbt-vendor files

Bug: 36810308
Test: builds
Change-Id: I50b4a3efaac622959dbf25c0f854d455057e6f3e
parent f5dbb89e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -47,12 +47,10 @@ cc_test_host {
        "src/bt_address.cc",
        "src/command_packet.cc",
        "src/event_packet.cc",
        "src/hci_transport.cc",
        "src/packet.cc",
        "src/packet_stream.cc",
        "test/async_manager_unittest.cc",
        "test/bt_address_unittest.cc",
        "test/hci_transport_unittest.cc",
        "test/packet_stream_unittest.cc",
    ],
    local_include_dirs: [
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#include "base/time/time.h"
#include "bt_address.h"
#include "command_packet.h"
#include "hci_transport.h"
#include "event_packet.h"
#include "test_channel_transport.h"

namespace test_vendor_lib {
+0 −82
Original line number Diff line number Diff line
//
// Copyright 2015 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 <functional>
#include <list>
#include <memory>

#include "base/files/scoped_file.h"
#include "command_packet.h"
#include "event_packet.h"
#include "packet.h"
#include "packet_stream.h"

namespace test_vendor_lib {

// Manages communication channel between HCI and the controller by providing the
// socket mechanisms for sending HCI [commands|events] [to|from] the controller.
class HciTransport {
 public:
  HciTransport();

  virtual ~HciTransport() = default;

  void CloseHciFd();

  void CloseVendorFd();

  int GetHciFd() const;

  int GetVendorFd() const;

  // Creates the underlying socketpair to be used as a communication channel
  // between the HCI and the vendor library/controller. Returns false if an
  // error occurs.
  bool SetUp();

  // Sets the callback that is run when command packets are received.
  void RegisterCommandHandler(
      const std::function<void(std::unique_ptr<CommandPacket>)>& callback);

  // Blocks while it tries to writes the event to the vendor file descriptor.
  void SendEvent(std::unique_ptr<EventPacket> event);

  // Called when there is a command to read on |fd|.
  void OnCommandReady(int fd);

 private:
  // Callback executed in ReceiveReadyCommand() to pass the incoming command
  // over to the handler for further processing.
  std::function<void(std::unique_ptr<CommandPacket>)> command_handler_;

  // For performing packet-based IO.
  PacketStream packet_stream_;

  // The two ends of the socketpair. |hci_fd_| is handed back to the HCI in
  // bt_vendor.cc and |vendor_fd_| is used by |packet_stream_| to receive/send
  // data from/to the HCI. Both file descriptors are owned and managed by the
  // transport object, although |hci_fd_| can be closed by the HCI in
  // TestVendorOp().
  std::unique_ptr<base::ScopedFD> hci_fd_;
  std::unique_ptr<base::ScopedFD> vendor_fd_;

  HciTransport(const HciTransport& cmdPckt) = delete;
  HciTransport& operator=(const HciTransport& cmdPckt) = delete;
};

}  // namespace test_vendor_lib
+0 −86
Original line number Diff line number Diff line
//
// Copyright 2015 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 "async_manager.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "dual_mode_controller.h"
#include "event_packet.h"
#include "hci/include/bt_vendor_lib.h"
#include "hci_transport.h"
#include "test_channel_transport.h"

#include <memory>

namespace test_vendor_lib {

// Contains the three core objects that make up the test vendor library: the
// HciTransport for communication, the HciHandler for processing commands, and
// the Controller for actual command implementations. The VendorManager shall
// be used in bt_vendor.cc to provide access to the test controller by setting
// up a message loop (on another thread) that the HCI will talk to and
// controller methods will execute on.
class VendorManager {
 public:
  VendorManager();

  ~VendorManager() = default;

  void CleanUp();

  // Initializes the controller and sets up the test channel to wait for
  // connections.
  bool Initialize();

  void CloseHciFd();

  int GetHciFd() const;

  const bt_vendor_callbacks_t& GetVendorCallbacks() const;

  // Stores a copy of the vendor specific configuration callbacks passed into
  // the vendor library from the HCI in TestVendorInit().
  void SetVendorCallbacks(const bt_vendor_callbacks_t& callbacks);

 private:
  // Set up a test channel on _port_
  void SetUpTestChannel(int port);

  // Creates the HCI's communication channel and overrides IO callbacks to
  // receive and send packets.
  HciTransport transport_;

  // The controller object that provides implementations of Bluetooth commands.
  DualModeController controller_;

  // The two test channel objects that perform functions corresponding to the
  // HciTransport and HciHandler.
  TestChannelTransport test_channel_transport_;

  // Configuration callbacks provided by the HCI for use in TestVendorOp().
  bt_vendor_callbacks_t vendor_callbacks_;

  // The object that manages asynchronous tasks such as watching a file
  // descriptor or doing something in the future
  AsyncManager async_manager_;

  VendorManager(const VendorManager& cmdPckt) = delete;
  VendorManager& operator=(const VendorManager& cmdPckt) = delete;
};

}  // namespace test_vendor_lib
+0 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include "base/json/json_reader.h"
#include "base/values.h"
#include "event_packet.h"
#include "hci_transport.h"

#include "osi/include/log.h"
#include "osi/include/osi.h"
Loading