Loading system/gd/hal/hci_hal_android_hidl.cc +17 −25 Original line number Original line Diff line number Diff line Loading @@ -315,8 +315,8 @@ class HciHalHidl : public HciHal { if (aidl_callbacks_) { if (aidl_callbacks_) { aidl_callbacks_->SetCallback(callback); aidl_callbacks_->SetCallback(callback); } } if (callbacks_) { if (hidl_callbacks_) { callbacks_->SetCallback(callback); hidl_callbacks_->SetCallback(callback); } } } } Loading @@ -324,8 +324,8 @@ class HciHalHidl : public HciHal { if (aidl_callbacks_) { if (aidl_callbacks_) { aidl_callbacks_->ResetCallback(); aidl_callbacks_->ResetCallback(); } } if (callbacks_) { if (hidl_callbacks_) { callbacks_->ResetCallback(); hidl_callbacks_->ResetCallback(); } } } } Loading Loading @@ -405,18 +405,22 @@ class HciHalHidl : public HciHal { aidl_callbacks_->GetInitPromise()->get_future().wait(); aidl_callbacks_->GetInitPromise()->get_future().wait(); } else { } else { start_hidl(); start_hidl(); callbacks_->GetInitPromise()->get_future().wait(); hidl_callbacks_->GetInitPromise()->get_future().wait(); } } } } void start_aidl() { void start_aidl() { common::StopWatch stop_watch(__func__); common::StopWatch stop_watch(__func__); ::ndk::SpAIBinder binder(AServiceManager_getService(kBluetoothAidlHalServiceName)); ::ndk::SpAIBinder binder(AServiceManager_waitForService(kBluetoothAidlHalServiceName)); aidl_hci_ = IBluetoothHci::fromBinder(binder); aidl_hci_ = IBluetoothHci::fromBinder(binder); if (aidl_hci_ != nullptr) { if (aidl_hci_ != nullptr) { LOG_INFO("Using the AIDL interface"); LOG_INFO("Using the AIDL interface"); aidl_death_recipient_ = ::ndk::ScopedAIBinder_DeathRecipient( aidl_death_recipient_ = AIBinder_DeathRecipient_new(HciHalHidl::hci_binder_died_static)); ::ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new([](void* cookie) { LOG_ERROR("Bluetooth HAL service died!"); common::StopWatch::DumpStopWatchLog(); abort(); })); auto death_link = auto death_link = AIBinder_linkToDeath(aidl_hci_->asBinder().get(), aidl_death_recipient_.get(), this); AIBinder_linkToDeath(aidl_hci_->asBinder().get(), aidl_death_recipient_.get(), this); Loading @@ -426,7 +430,6 @@ class HciHalHidl : public HciHal { aidl_callbacks_ = ::ndk::SharedRefBase::make<AidlHciCallbacks>(btaa_logger_, btsnoop_logger_); aidl_callbacks_ = ::ndk::SharedRefBase::make<AidlHciCallbacks>(btaa_logger_, btsnoop_logger_); aidl_hci_->initialize(aidl_callbacks_); aidl_hci_->initialize(aidl_callbacks_); return; } } } } Loading Loading @@ -465,12 +468,12 @@ class HciHalHidl : public HciHal { ASSERT(bt_hci_ != nullptr); ASSERT(bt_hci_ != nullptr); auto death_link = bt_hci_->linkToDeath(hci_death_recipient_, 0); 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"); ASSERT_LOG(death_link.isOk(), "Unable to set the death recipient for the Bluetooth HAL"); callbacks_ = new InternalHciCallbacks(btaa_logger_, btsnoop_logger_); hidl_callbacks_ = new InternalHciCallbacks(btaa_logger_, btsnoop_logger_); if (bt_hci_1_1_ != nullptr) { if (bt_hci_1_1_ != nullptr) { bt_hci_1_1_->initialize_1_1(callbacks_); bt_hci_1_1_->initialize_1_1(hidl_callbacks_); } else { } else { bt_hci_->initialize(callbacks_); bt_hci_->initialize(hidl_callbacks_); } } } } Loading @@ -488,17 +491,6 @@ class HciHalHidl : public HciHal { } } private: private: static void hci_binder_died_static(void* cookie) { auto hal_ptr = static_cast<HciHalHidl*>(cookie); hal_ptr->hci_binder_died(); } void hci_binder_died() { LOG_ERROR("Bluetooth HAL service died!"); common::StopWatch::DumpStopWatchLog(); abort(); } void stop_hidl() { void stop_hidl() { ASSERT(bt_hci_ != nullptr); ASSERT(bt_hci_ != nullptr); auto death_unlink = bt_hci_->unlinkToDeath(hci_death_recipient_); auto death_unlink = bt_hci_->unlinkToDeath(hci_death_recipient_); Loading @@ -511,7 +503,7 @@ class HciHalHidl : public HciHal { } } bt_hci_ = nullptr; bt_hci_ = nullptr; bt_hci_1_1_ = nullptr; bt_hci_1_1_ = nullptr; callbacks_->ResetCallback(); hidl_callbacks_->ResetCallback(); } } void stop_aidl() { void stop_aidl() { Loading @@ -528,7 +520,7 @@ class HciHalHidl : public HciHal { aidl_hci_ = nullptr; aidl_hci_ = nullptr; aidl_callbacks_->ResetCallback(); aidl_callbacks_->ResetCallback(); } } android::sp<InternalHciCallbacks> callbacks_; android::sp<InternalHciCallbacks> hidl_callbacks_; android::sp<IBluetoothHci_1_0> bt_hci_; android::sp<IBluetoothHci_1_0> bt_hci_; android::sp<IBluetoothHci_1_1> bt_hci_1_1_; android::sp<IBluetoothHci_1_1> bt_hci_1_1_; std::shared_ptr<IBluetoothHci> aidl_hci_; std::shared_ptr<IBluetoothHci> aidl_hci_; Loading Loading
system/gd/hal/hci_hal_android_hidl.cc +17 −25 Original line number Original line Diff line number Diff line Loading @@ -315,8 +315,8 @@ class HciHalHidl : public HciHal { if (aidl_callbacks_) { if (aidl_callbacks_) { aidl_callbacks_->SetCallback(callback); aidl_callbacks_->SetCallback(callback); } } if (callbacks_) { if (hidl_callbacks_) { callbacks_->SetCallback(callback); hidl_callbacks_->SetCallback(callback); } } } } Loading @@ -324,8 +324,8 @@ class HciHalHidl : public HciHal { if (aidl_callbacks_) { if (aidl_callbacks_) { aidl_callbacks_->ResetCallback(); aidl_callbacks_->ResetCallback(); } } if (callbacks_) { if (hidl_callbacks_) { callbacks_->ResetCallback(); hidl_callbacks_->ResetCallback(); } } } } Loading Loading @@ -405,18 +405,22 @@ class HciHalHidl : public HciHal { aidl_callbacks_->GetInitPromise()->get_future().wait(); aidl_callbacks_->GetInitPromise()->get_future().wait(); } else { } else { start_hidl(); start_hidl(); callbacks_->GetInitPromise()->get_future().wait(); hidl_callbacks_->GetInitPromise()->get_future().wait(); } } } } void start_aidl() { void start_aidl() { common::StopWatch stop_watch(__func__); common::StopWatch stop_watch(__func__); ::ndk::SpAIBinder binder(AServiceManager_getService(kBluetoothAidlHalServiceName)); ::ndk::SpAIBinder binder(AServiceManager_waitForService(kBluetoothAidlHalServiceName)); aidl_hci_ = IBluetoothHci::fromBinder(binder); aidl_hci_ = IBluetoothHci::fromBinder(binder); if (aidl_hci_ != nullptr) { if (aidl_hci_ != nullptr) { LOG_INFO("Using the AIDL interface"); LOG_INFO("Using the AIDL interface"); aidl_death_recipient_ = ::ndk::ScopedAIBinder_DeathRecipient( aidl_death_recipient_ = AIBinder_DeathRecipient_new(HciHalHidl::hci_binder_died_static)); ::ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new([](void* cookie) { LOG_ERROR("Bluetooth HAL service died!"); common::StopWatch::DumpStopWatchLog(); abort(); })); auto death_link = auto death_link = AIBinder_linkToDeath(aidl_hci_->asBinder().get(), aidl_death_recipient_.get(), this); AIBinder_linkToDeath(aidl_hci_->asBinder().get(), aidl_death_recipient_.get(), this); Loading @@ -426,7 +430,6 @@ class HciHalHidl : public HciHal { aidl_callbacks_ = ::ndk::SharedRefBase::make<AidlHciCallbacks>(btaa_logger_, btsnoop_logger_); aidl_callbacks_ = ::ndk::SharedRefBase::make<AidlHciCallbacks>(btaa_logger_, btsnoop_logger_); aidl_hci_->initialize(aidl_callbacks_); aidl_hci_->initialize(aidl_callbacks_); return; } } } } Loading Loading @@ -465,12 +468,12 @@ class HciHalHidl : public HciHal { ASSERT(bt_hci_ != nullptr); ASSERT(bt_hci_ != nullptr); auto death_link = bt_hci_->linkToDeath(hci_death_recipient_, 0); 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"); ASSERT_LOG(death_link.isOk(), "Unable to set the death recipient for the Bluetooth HAL"); callbacks_ = new InternalHciCallbacks(btaa_logger_, btsnoop_logger_); hidl_callbacks_ = new InternalHciCallbacks(btaa_logger_, btsnoop_logger_); if (bt_hci_1_1_ != nullptr) { if (bt_hci_1_1_ != nullptr) { bt_hci_1_1_->initialize_1_1(callbacks_); bt_hci_1_1_->initialize_1_1(hidl_callbacks_); } else { } else { bt_hci_->initialize(callbacks_); bt_hci_->initialize(hidl_callbacks_); } } } } Loading @@ -488,17 +491,6 @@ class HciHalHidl : public HciHal { } } private: private: static void hci_binder_died_static(void* cookie) { auto hal_ptr = static_cast<HciHalHidl*>(cookie); hal_ptr->hci_binder_died(); } void hci_binder_died() { LOG_ERROR("Bluetooth HAL service died!"); common::StopWatch::DumpStopWatchLog(); abort(); } void stop_hidl() { void stop_hidl() { ASSERT(bt_hci_ != nullptr); ASSERT(bt_hci_ != nullptr); auto death_unlink = bt_hci_->unlinkToDeath(hci_death_recipient_); auto death_unlink = bt_hci_->unlinkToDeath(hci_death_recipient_); Loading @@ -511,7 +503,7 @@ class HciHalHidl : public HciHal { } } bt_hci_ = nullptr; bt_hci_ = nullptr; bt_hci_1_1_ = nullptr; bt_hci_1_1_ = nullptr; callbacks_->ResetCallback(); hidl_callbacks_->ResetCallback(); } } void stop_aidl() { void stop_aidl() { Loading @@ -528,7 +520,7 @@ class HciHalHidl : public HciHal { aidl_hci_ = nullptr; aidl_hci_ = nullptr; aidl_callbacks_->ResetCallback(); aidl_callbacks_->ResetCallback(); } } android::sp<InternalHciCallbacks> callbacks_; android::sp<InternalHciCallbacks> hidl_callbacks_; android::sp<IBluetoothHci_1_0> bt_hci_; android::sp<IBluetoothHci_1_0> bt_hci_; android::sp<IBluetoothHci_1_1> bt_hci_1_1_; android::sp<IBluetoothHci_1_1> bt_hci_1_1_; std::shared_ptr<IBluetoothHci> aidl_hci_; std::shared_ptr<IBluetoothHci> aidl_hci_; Loading