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

Commit 82375c5a authored by Sunny Kapdi's avatar Sunny Kapdi Committed by Alice Kuo
Browse files

BTAudio HAL: Init and check for factory provider

Initialize factory_provider_ and check for its validity
before attempting to unlinkToDeath

Bug: 233961816
Tag: #refactor
Test: atest BluetoothInstrumentationTests
Change-Id: If0a883968a563da3df56aecfb97b2d97f6bbc4e5
Merged-In: If0a883968a563da3df56aecfb97b2d97f6bbc4e5
(cherry picked from commit bb863768)
parent cb803390
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ std::ostream& operator<<(std::ostream& os, const BluetoothAudioCtrlAck& ack) {
BluetoothAudioClientInterface::BluetoothAudioClientInterface(
    IBluetoothTransportInstance* instance)
    : provider_(nullptr),
      provider_factory_(nullptr),
      session_started_(false),
      data_mq_(nullptr),
      transport_(instance) {
@@ -154,9 +155,9 @@ BluetoothAudioSinkClientInterface::BluetoothAudioSinkClientInterface(
}

BluetoothAudioSinkClientInterface::~BluetoothAudioSinkClientInterface() {
  if (provider_ != nullptr) {
    AIBinder_unlinkToDeath(provider_factory_->asBinder().get(),
                           death_recipient_.get(), nullptr);
  if (provider_factory_ != nullptr) {
    AIBinder_unlinkToDeath(provider_factory_->asBinder().get(), death_recipient_.get(),
                           nullptr);
  }
}

@@ -168,9 +169,9 @@ BluetoothAudioSourceClientInterface::BluetoothAudioSourceClientInterface(
}

BluetoothAudioSourceClientInterface::~BluetoothAudioSourceClientInterface() {
  if (provider_ != nullptr) {
    AIBinder_unlinkToDeath(provider_factory_->asBinder().get(),
                           death_recipient_.get(), nullptr);
  if (provider_factory_ != nullptr) {
    AIBinder_unlinkToDeath(provider_factory_->asBinder().get(), death_recipient_.get(),
                           nullptr);
  }
}