diff options
author | 2024-02-03 03:56:59 +0900 | |
---|---|---|
committer | 2024-02-06 10:47:17 +0900 | |
commit | 75fc06f26b18631d9d079ffed7c73f68201a43c3 (patch) | |
tree | bbf3542b690b3f76026a1de8155792799e735dba /libs/binder/IServiceManager.cpp | |
parent | 0e8add7c20e83af68429ca7c76cec33b4820a5c0 (diff) |
binder: add openDeclaredPassthroughHal()
It handles dlopen()ing a declared native hal. This can replace
android_load_sphal_library to load declared native instance. The new API
also supports when instances are from APEX.
Bug: 316051788
Test: atest servicemanager_test
Test: atest vts_treble_vintf_vendor_test
Change-Id: I95b752253e0b550d38f0543ff56134d38d838855
Diffstat (limited to 'libs/binder/IServiceManager.cpp')
-rw-r--r-- | libs/binder/IServiceManager.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index fe566fccb2..39573ec54d 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -40,6 +40,11 @@ #include "ServiceManagerHost.h" #endif +#if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) && !defined(__ANDROID_NATIVE_BRIDGE__) +#include <android/apexsupport.h> +#include <vndksupport/linker.h> +#endif + #include "Static.h" namespace android { @@ -259,6 +264,27 @@ bool checkPermission(const String16& permission, pid_t pid, uid_t uid, bool logP } } +void* openDeclaredPassthroughHal(const String16& interface, const String16& instance, int flag) { +#if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) && !defined(__ANDROID_NATIVE_BRIDGE__) + sp<IServiceManager> sm = defaultServiceManager(); + String16 name = interface + String16("/") + instance; + if (!sm->isDeclared(name)) { + return nullptr; + } + String16 libraryName = interface + String16(".") + instance + String16(".so"); + if (auto updatableViaApex = sm->updatableViaApex(name); updatableViaApex.has_value()) { + return AApexSupport_loadLibrary(String8(libraryName).c_str(), + String8(*updatableViaApex).c_str(), flag); + } + return android_load_sphal_library(String8(libraryName).c_str(), flag); +#else + (void)interface; + (void)instance; + (void)flag; + return nullptr; +#endif +} + #endif //__ANDROID_VNDK__ // ---------------------------------------------------------------------- |