diff options
author | Josh Wu <joshwu@google.com> | 2022-03-28 02:59:45 -0700 |
---|---|---|
committer | Josh Wu <joshwu@google.com> | 2022-04-07 09:02:20 -0700 |
commit | 08255b45d906ffe2da7026ea70f9e57ecca7c09d (patch) | |
tree | f44df681a33038fd8b8aa0f94eae6e2064d82832 | |
parent | 1edd38d6ee7b883e7a5327e1a37dd4a4cb202964 (diff) |
BtAudio: Prevent unlink dead binder
Tag: #stability
Bug: 227029886
Test: manually kill bt process
Change-Id: Ic976a33feb5a3636ab828637faf0ba109f5948ce
-rw-r--r-- | bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp | 8 | ||||
-rw-r--r-- | bluetooth/audio/aidl/default/BluetoothAudioProvider.h | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp b/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp index 0dd814828c..2a88959af5 100644 --- a/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp +++ b/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp @@ -45,6 +45,7 @@ ndk::ScopedAStatus BluetoothAudioProvider::startSession( latency_modes_ = latencyModes; audio_config_ = std::make_unique<AudioConfiguration>(audio_config); stack_iface_ = host_if; + is_binder_died = false; AIBinder_linkToDeath(stack_iface_->asBinder().get(), death_recipient_.get(), this); @@ -59,8 +60,10 @@ ndk::ScopedAStatus BluetoothAudioProvider::endSession() { if (stack_iface_ != nullptr) { BluetoothAudioSessionReport::OnSessionEnded(session_type_); - AIBinder_unlinkToDeath(stack_iface_->asBinder().get(), - death_recipient_.get(), this); + if (!is_binder_died) { + AIBinder_unlinkToDeath(stack_iface_->asBinder().get(), + death_recipient_.get(), this); + } } else { LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_) << " has NO session"; @@ -147,6 +150,7 @@ void BluetoothAudioProvider::binderDiedCallbackAidl(void* ptr) { LOG(ERROR) << __func__ << ": Null AudioProvider HAL died"; return; } + provider->is_binder_died = true; provider->endSession(); } diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProvider.h b/bluetooth/audio/aidl/default/BluetoothAudioProvider.h index a9f830af78..dbfff7d26c 100644 --- a/bluetooth/audio/aidl/default/BluetoothAudioProvider.h +++ b/bluetooth/audio/aidl/default/BluetoothAudioProvider.h @@ -62,6 +62,7 @@ class BluetoothAudioProvider : public BnBluetoothAudioProvider { std::unique_ptr<AudioConfiguration> audio_config_ = nullptr; SessionType session_type_; std::vector<LatencyMode> latency_modes_; + bool is_binder_died = false; }; } // namespace audio |