diff options
author | Devin Moore <devinmoore@google.com> | 2024-02-22 22:37:58 +0000 |
---|---|---|
committer | Devin Moore <devinmoore@google.com> | 2024-02-22 23:07:27 +0000 |
commit | 392e462fd3fecbb8981a008d0dcd039030efbf33 (patch) | |
tree | 026daf582445f6269a24a7342e16e0a930efea93 | |
parent | d971c58c8c0b373bfe8899bd98424ed821b7c984 (diff) | |
download | av-392e462fd3fecbb8981a008d0dcd039030efbf33.tar.gz |
If the swcodec HAL is declared, then register it with servicemanager
If a HAL service is declared, it must be reachable at run time.
vts_treble_vintf_framework_test verifies this.
Don't base the registration of the HAL service on the SDK API level.
VTS and libvintf can ensure it's registered correctly on devices.
This change does still allow the flagging to disable the AIDL HAL for
debugging purposes, but those devices will not pass VTS like that.
Test: vts_treble_vintf_framework_test
Bug: 279809333
Change-Id: Ia8c6bce0a670fbbcb2a3006c75a3d77a526f826e
-rw-r--r-- | media/module/codecserviceregistrant/CodecServiceRegistrant.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp b/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp index caf252472c..4fbfab17c9 100644 --- a/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp +++ b/media/module/codecserviceregistrant/CodecServiceRegistrant.cpp @@ -819,19 +819,21 @@ extern "C" void RegisterCodecServices() { } bool registered = false; - if (platformVersion >= __ANDROID_API_V__) { - if (!aidlStore) { - aidlStore = ::ndk::SharedRefBase::make<c2_aidl::utils::ComponentStore>( - std::make_shared<H2C2ComponentStore>(nullptr)); - } - const std::string serviceName = - std::string(c2_aidl::IComponentStore::descriptor) + "/software"; - binder_exception_t ex = AServiceManager_addService( - aidlStore->asBinder().get(), serviceName.c_str()); - if (ex == EX_NONE) { - registered = true; - } else { - LOG(ERROR) << "Cannot register software Codec2 AIDL service."; + const std::string aidlServiceName = + std::string(c2_aidl::IComponentStore::descriptor) + "/software"; + if (__builtin_available(android __ANDROID_API_S__, *)) { + if (AServiceManager_isDeclared(aidlServiceName.c_str())) { + if (!aidlStore) { + aidlStore = ::ndk::SharedRefBase::make<c2_aidl::utils::ComponentStore>( + std::make_shared<H2C2ComponentStore>(nullptr)); + } + binder_exception_t ex = AServiceManager_addService( + aidlStore->asBinder().get(), aidlServiceName.c_str()); + if (ex == EX_NONE) { + registered = true; + } else { + LOG(WARNING) << "Cannot register software Codec2 AIDL service. Exception: " << ex; + } } } |