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

Commit 44bc06e1 authored by Cheney Ni's avatar Cheney Ni
Browse files

bthal: Do not allow to initialize more than once

Because the Bluetooth HAL service can serve one client at a time, but is
stuck by double attempting, here we check if there is a transport layer,
and reject the second request.

Bug: 169472630
Test: VTS
Tag: #stability
Change-Id: I5046eaa0bcc9b7f16713b3940af4a73e56ea3630
parent f6cfcc36
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -281,6 +281,15 @@ Return<void> BluetoothHci::initialize_impl(
    ALOGE("cb == nullptr! -> Unable to call initializationComplete(ERR)");
    return Void();
  }
  if (hci_handle_ != nullptr) {
    ALOGE("hci_handle != nullptr! -> Double attempt to initialize the HAL");
    auto hidl_status =
        cb->initializationComplete(V1_0::Status::INITIALIZATION_ERROR);
    if (!hidl_status.isOk()) {
      ALOGE("VendorInterface -> Unable to call initializationComplete(ERR)");
    }
    return Void();
  }

  death_recipient_->setHasDied(false);
  cb->linkToDeath(death_recipient_, 0);