From 75fc06f26b18631d9d079ffed7c73f68201a43c3 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Sat, 3 Feb 2024 03:56:59 +0900 Subject: 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 --- libs/ui/Gralloc5.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'libs/ui/Gralloc5.cpp') diff --git a/libs/ui/Gralloc5.cpp b/libs/ui/Gralloc5.cpp index c3b2d3d808..123bef4a4f 100644 --- a/libs/ui/Gralloc5.cpp +++ b/libs/ui/Gralloc5.cpp @@ -83,10 +83,18 @@ static void *loadIMapperLibrary() { return nullptr; } - std::string lib_name = "mapper." + mapperSuffix + ".so"; - void *so = android_load_sphal_library(lib_name.c_str(), RTLD_LOCAL | RTLD_NOW); + void* so = nullptr; + // TODO(b/322384429) switch this to __ANDROID_API_V__ when V is finalized + // TODO(b/302113279) use __ANDROID_VENDOR_API__ for vendor variant + if (__builtin_available(android __ANDROID_API_FUTURE__, *)) { + so = AServiceManager_openDeclaredPassthroughHal("mapper", mapperSuffix.c_str(), + RTLD_LOCAL | RTLD_NOW); + } else { + std::string lib_name = "mapper." + mapperSuffix + ".so"; + so = android_load_sphal_library(lib_name.c_str(), RTLD_LOCAL | RTLD_NOW); + } if (!so) { - ALOGE("Failed to load %s", lib_name.c_str()); + ALOGE("Failed to load mapper.%s.so", mapperSuffix.c_str()); } return so; }(); -- cgit v1.2.3-59-g8ed1b