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

Commit 07b8f1e2 authored by Antoine SOULIER's avatar Antoine SOULIER
Browse files

hci/hal: Move "Android" dependancies into backend

Bug: 333612868
Test: mmm packages/modules/Bluetooth
Flag: EXEMPT, code move
Change-Id: I16d6c15818d0f085178642352bfd26de1a8bde69
parent 3ba15b62
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ class HciBackendCallbacks {

class HciBackend {
 public:
  static std::shared_ptr<HciBackend> CreateAidl(const char*);
  static std::shared_ptr<HciBackend> CreateAidl();
  static std::shared_ptr<HciBackend> CreateHidl(::bluetooth::os::Handler*);

  virtual ~HciBackend() = default;
+8 −2
Original line number Diff line number Diff line
@@ -122,8 +122,14 @@ class AidlHci : public HciBackend {
  std::shared_ptr<AidlHciCallbacks> hci_callbacks_;
};

std::shared_ptr<HciBackend> HciBackend::CreateAidl(const char* service_name) {
  return std::make_shared<AidlHci>(service_name);
std::shared_ptr<HciBackend> HciBackend::CreateAidl() {
  static constexpr char kBluetoothAidlHalServiceName[] =
      "android.hardware.bluetooth.IBluetoothHci/default";

  if (AServiceManager_isDeclared(kBluetoothAidlHalServiceName))
    return std::make_shared<AidlHci>(kBluetoothAidlHalServiceName);

  return std::shared_ptr<HciBackend>();
}

}  // namespace bluetooth::hal
+4 −9
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
 * limitations under the License.
 */

#include <android/binder_manager.h>
#include <bluetooth/log.h>

#include <future>
@@ -113,9 +112,6 @@ class HciCallbacksImpl : public HciBackendCallbacks {
};

class HciHalImpl : public HciHal {
  static constexpr char kBluetoothAidlHalServiceName[] =
      "android.hardware.bluetooth.IBluetoothHci/default";

 public:
  void registerIncomingPacketCallback(HciHalCallbacks* callback) override {
    callbacks_->SetCallback(callback);
@@ -162,11 +158,10 @@ class HciHalImpl : public HciHal {
    link_clocker_ = GetDependency<LinkClocker>();
    btsnoop_logger_ = GetDependency<SnoopLogger>();

    if (AServiceManager_isDeclared(kBluetoothAidlHalServiceName)) {
      backend_ = HciBackend::CreateAidl(kBluetoothAidlHalServiceName);
    } else {
      backend_ = HciBackend::CreateHidl(GetHandler());
    }
    backend_ = HciBackend::CreateAidl();
    if (!backend_) backend_ = HciBackend::CreateHidl(GetHandler());

    log::assert_that(backend_ != nullptr, "No backend available");

    callbacks_ = std::make_shared<HciCallbacksImpl>(btsnoop_logger_, link_clocker_);