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

Commit 88171772 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "HCI: Add a timer for finding the Bluetooth service" am: 3716aac6

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1948093

Change-Id: I2fe240b30abacd120d99abda77b37938265b98bc
parents 727302f7 3716aac6
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "common/strings.h"
#include "hal/hci_hal.h"
#include "hal/snoop_logger.h"
#include "os/alarm.h"
#include "os/log.h"

using ::android::hardware::hidl_vec;
@@ -37,6 +38,7 @@ using ::android::hardware::bluetooth::V1_1::IBluetoothHci;
using ::android::hardware::bluetooth::V1_1::IBluetoothHciCallbacks;
using HidlStatus = ::android::hardware::bluetooth::V1_0::Status;
using IBluetoothHci_1_0 = ::android::hardware::bluetooth::V1_0::IBluetoothHci;
using bluetooth::common::BindOnce;

namespace bluetooth {
namespace hal {
@@ -205,6 +207,13 @@ class HciHalHidl : public HciHal {
    }
    btsnoop_logger_ = GetDependency<SnoopLogger>();

    auto get_service_alarm = new os::Alarm(GetHandler());
    get_service_alarm->Schedule(
        BindOnce([] {
          LOG_ALWAYS_FATAL("Unable to get a Bluetooth service after 500ms, start the HAL before starting Bluetooth");
        }),
        std::chrono::milliseconds(500));

    bt_hci_1_1_ = IBluetoothHci::getService();

    if (bt_hci_1_1_ != nullptr) {
@@ -213,6 +222,9 @@ class HciHalHidl : public HciHal {
      bt_hci_ = IBluetoothHci_1_0::getService();
    }

    get_service_alarm->Cancel();
    delete get_service_alarm;

    ASSERT(bt_hci_ != nullptr);
    auto death_link = bt_hci_->linkToDeath(hci_death_recipient_, 0);
    ASSERT_LOG(death_link.isOk(), "Unable to set the death recipient for the Bluetooth HAL");