From 1f7c37f373068c41ba77413fc6dc4eb8bac28f0b Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Sun, 23 Feb 2020 03:02:43 +0900 Subject: Use {llndk,vndksp}.libraries.txt from VNDK APEX /system/etc/{llndk,vndksp}.libraries.txt files will be deprecated. These files can be read from VNDK APEX. Bug: 145184886 Test: build / boot Merged-In: Ic6f46033bd525325562e04ef9e8bcb8ebb5b5d41 Change-Id: Ic6f46033bd525325562e04ef9e8bcb8ebb5b5d41 (cherry picked from commit 78396804770bf3c3a1143f823a466cc0c6849104) --- libs/graphicsenv/GraphicsEnv.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'libs/graphicsenv/GraphicsEnv.cpp') diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp index befabee66d..4809c1f0d8 100644 --- a/libs/graphicsenv/GraphicsEnv.cpp +++ b/libs/graphicsenv/GraphicsEnv.cpp @@ -61,26 +61,25 @@ enum NativeLibrary { VNDKSP = 1, }; -static constexpr const char* kNativeLibrariesSystemConfigPath[] = {"/etc/llndk.libraries.txt", - "/etc/vndksp.libraries.txt"}; +static constexpr const char* kNativeLibrariesSystemConfigPath[] = + {"/apex/com.android.vndk.v{}/etc/llndk.libraries.{}.txt", + "/apex/com.android.vndk.v{}/etc/vndksp.libraries.{}.txt"}; static std::string vndkVersionStr() { #ifdef __BIONIC__ - std::string version = android::base::GetProperty("ro.vndk.version", ""); - if (version != "" && version != "current") { - return "." + version; - } + return android::base::GetProperty("ro.vndk.version", ""); #endif return ""; } static void insertVndkVersionStr(std::string* fileName) { LOG_ALWAYS_FATAL_IF(!fileName, "fileName should never be nullptr"); - size_t insertPos = fileName->find_last_of("."); - if (insertPos == std::string::npos) { - insertPos = fileName->length(); + std::string version = vndkVersionStr(); + size_t pos = fileName->find("{}"); + while (pos != std::string::npos) { + fileName->replace(pos, 2, version); + pos = fileName->find("{}", pos + version.size()); } - fileName->insert(insertPos, vndkVersionStr()); } static bool readConfig(const std::string& configFile, std::vector* soNames) { @@ -103,11 +102,7 @@ static bool readConfig(const std::string& configFile, std::vector* } static const std::string getSystemNativeLibraries(NativeLibrary type) { - static const char* androidRootEnv = getenv("ANDROID_ROOT"); - static const std::string rootDir = androidRootEnv != nullptr ? androidRootEnv : "/system"; - - std::string nativeLibrariesSystemConfig = rootDir + kNativeLibrariesSystemConfigPath[type]; - + std::string nativeLibrariesSystemConfig = kNativeLibrariesSystemConfigPath[type]; insertVndkVersionStr(&nativeLibrariesSystemConfig); std::vector soNames; -- cgit v1.2.3-59-g8ed1b